babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633
  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. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. 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>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. 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;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. 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;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. 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;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Copy the current vector to an array
  2133. * @returns a new array with 2 elements: the Vector2 coordinates.
  2134. */
  2135. asArray(): number[];
  2136. /**
  2137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2138. * @param source defines the source Vector2
  2139. * @returns the current updated Vector2
  2140. */
  2141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2142. /**
  2143. * Sets the Vector2 coordinates with the given floats
  2144. * @param x defines the first coordinate
  2145. * @param y defines the second coordinate
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFromFloats(x: number, y: number): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. set(x: number, y: number): Vector2;
  2156. /**
  2157. * Add another vector with the current one
  2158. * @param otherVector defines the other vector
  2159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2160. */
  2161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2162. /**
  2163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @param result defines the target vector
  2166. * @returns the unmodified current Vector2
  2167. */
  2168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2169. /**
  2170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. addVector3(otherVector: Vector3): Vector2;
  2181. /**
  2182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2183. * @param otherVector defines the other vector
  2184. * @returns a new Vector2
  2185. */
  2186. subtract(otherVector: Vector2): Vector2;
  2187. /**
  2188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2189. * @param otherVector defines the other vector
  2190. * @param result defines the target vector
  2191. * @returns the unmodified current Vector2
  2192. */
  2193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2194. /**
  2195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Multiplies in place the current Vector2 coordinates by the given ones
  2202. * @param otherVector defines the other vector
  2203. * @returns the current updated Vector2
  2204. */
  2205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @returns a new Vector2
  2210. */
  2211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2214. * @param otherVector defines the other vector
  2215. * @param result defines the target vector
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2221. * @param x defines the first coordinate
  2222. * @param y defines the second coordinate
  2223. * @returns a new Vector2
  2224. */
  2225. multiplyByFloats(x: number, y: number): Vector2;
  2226. /**
  2227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @returns a new Vector2
  2230. */
  2231. divide(otherVector: Vector2): Vector2;
  2232. /**
  2233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @param result defines the target vector
  2236. * @returns the unmodified current Vector2
  2237. */
  2238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2239. /**
  2240. * Divides the current Vector2 coordinates by the given ones
  2241. * @param otherVector defines the other vector
  2242. * @returns the current updated Vector2
  2243. */
  2244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 with current Vector2 negated coordinates
  2247. * @returns a new Vector2
  2248. */
  2249. negate(): Vector2;
  2250. /**
  2251. * Negate this vector in place
  2252. * @returns this
  2253. */
  2254. negateInPlace(): Vector2;
  2255. /**
  2256. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2257. * @param result defines the Vector3 object where to store the result
  2258. * @returns the current Vector2
  2259. */
  2260. negateToRef(result: Vector2): Vector2;
  2261. /**
  2262. * Multiply the Vector2 coordinates by scale
  2263. * @param scale defines the scaling factor
  2264. * @returns the current updated Vector2
  2265. */
  2266. scaleInPlace(scale: number): Vector2;
  2267. /**
  2268. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2269. * @param scale defines the scaling factor
  2270. * @returns a new Vector2
  2271. */
  2272. scale(scale: number): Vector2;
  2273. /**
  2274. * Scale the current Vector2 values by a factor to a given Vector2
  2275. * @param scale defines the scale factor
  2276. * @param result defines the Vector2 object where to store the result
  2277. * @returns the unmodified current Vector2
  2278. */
  2279. scaleToRef(scale: number, result: Vector2): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Gets a boolean if two vectors are equals
  2289. * @param otherVector defines the other vector
  2290. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2291. */
  2292. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2293. /**
  2294. * Gets a boolean if two vectors are equals (using an epsilon value)
  2295. * @param otherVector defines the other vector
  2296. * @param epsilon defines the minimal distance to consider equality
  2297. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2298. */
  2299. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2300. /**
  2301. * Gets a new Vector2 from current Vector2 floored values
  2302. * @returns a new Vector2
  2303. */
  2304. floor(): Vector2;
  2305. /**
  2306. * Gets a new Vector2 from current Vector2 floored values
  2307. * @returns a new Vector2
  2308. */
  2309. fract(): Vector2;
  2310. /**
  2311. * Gets the length of the vector
  2312. * @returns the vector length (float)
  2313. */
  2314. length(): number;
  2315. /**
  2316. * Gets the vector squared length
  2317. * @returns the vector squared length (float)
  2318. */
  2319. lengthSquared(): number;
  2320. /**
  2321. * Normalize the vector
  2322. * @returns the current updated Vector2
  2323. */
  2324. normalize(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 copied from the Vector2
  2327. * @returns a new Vector2
  2328. */
  2329. clone(): Vector2;
  2330. /**
  2331. * Gets a new Vector2(0, 0)
  2332. * @returns a new Vector2
  2333. */
  2334. static Zero(): Vector2;
  2335. /**
  2336. * Gets a new Vector2(1, 1)
  2337. * @returns a new Vector2
  2338. */
  2339. static One(): Vector2;
  2340. /**
  2341. * Gets a new Vector2 set from the given index element of the given array
  2342. * @param array defines the data source
  2343. * @param offset defines the offset in the data source
  2344. * @returns a new Vector2
  2345. */
  2346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2347. /**
  2348. * Sets "result" from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @param result defines the target vector
  2352. */
  2353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2354. /**
  2355. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2356. * @param value1 defines 1st point of control
  2357. * @param value2 defines 2nd point of control
  2358. * @param value3 defines 3rd point of control
  2359. * @param value4 defines 4th point of control
  2360. * @param amount defines the interpolation factor
  2361. * @returns a new Vector2
  2362. */
  2363. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2364. /**
  2365. * 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".
  2366. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2367. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2368. * @param value defines the value to clamp
  2369. * @param min defines the lower limit
  2370. * @param max defines the upper limit
  2371. * @returns a new Vector2
  2372. */
  2373. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2376. * @param value1 defines the 1st control point
  2377. * @param tangent1 defines the outgoing tangent
  2378. * @param value2 defines the 2nd control point
  2379. * @param tangent2 defines the incoming tangent
  2380. * @param amount defines the interpolation factor
  2381. * @returns a new Vector2
  2382. */
  2383. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2384. /**
  2385. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2386. * @param start defines the start vector
  2387. * @param end defines the end vector
  2388. * @param amount defines the interpolation factor
  2389. * @returns a new Vector2
  2390. */
  2391. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2392. /**
  2393. * Gets the dot product of the vector "left" and the vector "right"
  2394. * @param left defines first vector
  2395. * @param right defines second vector
  2396. * @returns the dot product (float)
  2397. */
  2398. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2399. /**
  2400. * Returns a new Vector2 equal to the normalized given vector
  2401. * @param vector defines the vector to normalize
  2402. * @returns a new Vector2
  2403. */
  2404. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2405. /**
  2406. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2407. * @param left defines 1st vector
  2408. * @param right defines 2nd vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2421. * @param vector defines the vector to transform
  2422. * @param transformation defines the matrix to apply
  2423. * @returns a new Vector2
  2424. */
  2425. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2426. /**
  2427. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @param result defines the target vector
  2431. */
  2432. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2433. /**
  2434. * Determines if a given vector is included in a triangle
  2435. * @param p defines the vector to test
  2436. * @param p0 defines 1st triangle point
  2437. * @param p1 defines 2nd triangle point
  2438. * @param p2 defines 3rd triangle point
  2439. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2440. */
  2441. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2442. /**
  2443. * Gets the distance between the vectors "value1" and "value2"
  2444. * @param value1 defines first vector
  2445. * @param value2 defines second vector
  2446. * @returns the distance between vectors
  2447. */
  2448. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2449. /**
  2450. * Returns the squared distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the squared distance between vectors
  2454. */
  2455. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns a new Vector2
  2461. */
  2462. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2463. /**
  2464. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2465. * @param p defines the middle point
  2466. * @param segA defines one point of the segment
  2467. * @param segB defines the other point of the segment
  2468. * @returns the shortest distance
  2469. */
  2470. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2471. }
  2472. /**
  2473. * Class used to store (x,y,z) vector representation
  2474. * A Vector3 is the main object used in 3D geometry
  2475. * It can represent etiher the coordinates of a point the space, either a direction
  2476. * Reminder: js uses a left handed forward facing system
  2477. */
  2478. export class Vector3 {
  2479. private static _UpReadOnly;
  2480. private static _ZeroReadOnly;
  2481. /** @hidden */
  2482. _x: number;
  2483. /** @hidden */
  2484. _y: number;
  2485. /** @hidden */
  2486. _z: number;
  2487. /** @hidden */
  2488. _isDirty: boolean;
  2489. /** Gets or sets the x coordinate */
  2490. get x(): number;
  2491. set x(value: number);
  2492. /** Gets or sets the y coordinate */
  2493. get y(): number;
  2494. set y(value: number);
  2495. /** Gets or sets the z coordinate */
  2496. get z(): number;
  2497. set z(value: number);
  2498. /**
  2499. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2500. * @param x defines the first coordinates (on X axis)
  2501. * @param y defines the second coordinates (on Y axis)
  2502. * @param z defines the third coordinates (on Z axis)
  2503. */
  2504. constructor(x?: number, y?: number, z?: number);
  2505. /**
  2506. * Creates a string representation of the Vector3
  2507. * @returns a string with the Vector3 coordinates.
  2508. */
  2509. toString(): string;
  2510. /**
  2511. * Gets the class name
  2512. * @returns the string "Vector3"
  2513. */
  2514. getClassName(): string;
  2515. /**
  2516. * Creates the Vector3 hash code
  2517. * @returns a number which tends to be unique between Vector3 instances
  2518. */
  2519. getHashCode(): number;
  2520. /**
  2521. * Creates an array containing three elements : the coordinates of the Vector3
  2522. * @returns a new array of numbers
  2523. */
  2524. asArray(): number[];
  2525. /**
  2526. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2527. * @param array defines the destination array
  2528. * @param index defines the offset in the destination array
  2529. * @returns the current Vector3
  2530. */
  2531. toArray(array: FloatArray, index?: number): Vector3;
  2532. /**
  2533. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2534. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2535. */
  2536. toQuaternion(): Quaternion;
  2537. /**
  2538. * Adds the given vector to the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Adds the given coordinates to the current Vector3
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2553. * @param otherVector defines the second operand
  2554. * @returns the resulting Vector3
  2555. */
  2556. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2559. * @param otherVector defines the second operand
  2560. * @param result defines the Vector3 object where to store the result
  2561. * @returns the current Vector3
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2564. /**
  2565. * Subtract the given vector from the current Vector3
  2566. * @param otherVector defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the resulting Vector3
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2578. * @param otherVector defines the second operand
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2583. /**
  2584. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2585. * @param x defines the x coordinate of the operand
  2586. * @param y defines the y coordinate of the operand
  2587. * @param z defines the z coordinate of the operand
  2588. * @returns the resulting Vector3
  2589. */
  2590. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2591. /**
  2592. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2593. * @param x defines the x coordinate of the operand
  2594. * @param y defines the y coordinate of the operand
  2595. * @param z defines the z coordinate of the operand
  2596. * @param result defines the Vector3 object where to store the result
  2597. * @returns the current Vector3
  2598. */
  2599. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2600. /**
  2601. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2602. * @returns a new Vector3
  2603. */
  2604. negate(): Vector3;
  2605. /**
  2606. * Negate this vector in place
  2607. * @returns this
  2608. */
  2609. negateInPlace(): Vector3;
  2610. /**
  2611. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. negateToRef(result: Vector3): Vector3;
  2616. /**
  2617. * Multiplies the Vector3 coordinates by the float "scale"
  2618. * @param scale defines the multiplier factor
  2619. * @returns the current updated Vector3
  2620. */
  2621. scaleInPlace(scale: number): Vector3;
  2622. /**
  2623. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2624. * @param scale defines the multiplier factor
  2625. * @returns a new Vector3
  2626. */
  2627. scale(scale: number): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2630. * @param scale defines the multiplier factor
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. scaleToRef(scale: number, result: Vector3): Vector3;
  2635. /**
  2636. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2637. * @param scale defines the scale factor
  2638. * @param result defines the Vector3 object where to store the result
  2639. * @returns the unmodified current Vector3
  2640. */
  2641. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2642. /**
  2643. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2644. * @param origin defines the origin of the projection ray
  2645. * @param plane defines the plane to project to
  2646. * @returns the projected vector3
  2647. */
  2648. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2649. /**
  2650. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2651. * @param origin defines the origin of the projection ray
  2652. * @param plane defines the plane to project to
  2653. * @param result defines the Vector3 where to store the result
  2654. */
  2655. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2656. /**
  2657. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2658. * @param otherVector defines the second operand
  2659. * @returns true if both vectors are equals
  2660. */
  2661. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2662. /**
  2663. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2664. * @param otherVector defines the second operand
  2665. * @param epsilon defines the minimal distance to define values as equals
  2666. * @returns true if both vectors are distant less than epsilon
  2667. */
  2668. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2669. /**
  2670. * Returns true if the current Vector3 coordinates equals the given floats
  2671. * @param x defines the x coordinate of the operand
  2672. * @param y defines the y coordinate of the operand
  2673. * @param z defines the z coordinate of the operand
  2674. * @returns true if both vectors are equals
  2675. */
  2676. equalsToFloats(x: number, y: number, z: number): boolean;
  2677. /**
  2678. * Multiplies the current Vector3 coordinates by the given ones
  2679. * @param otherVector defines the second operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2683. /**
  2684. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2685. * @param otherVector defines the second operand
  2686. * @returns the new Vector3
  2687. */
  2688. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2689. /**
  2690. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2691. * @param otherVector defines the second operand
  2692. * @param result defines the Vector3 object where to store the result
  2693. * @returns the current Vector3
  2694. */
  2695. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2696. /**
  2697. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2698. * @param x defines the x coordinate of the operand
  2699. * @param y defines the y coordinate of the operand
  2700. * @param z defines the z coordinate of the operand
  2701. * @returns the new Vector3
  2702. */
  2703. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2706. * @param otherVector defines the second operand
  2707. * @returns the new Vector3
  2708. */
  2709. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2712. * @param otherVector defines the second operand
  2713. * @param result defines the Vector3 object where to store the result
  2714. * @returns the current Vector3
  2715. */
  2716. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2717. /**
  2718. * Divides the current Vector3 coordinates by the given ones.
  2719. * @param otherVector defines the second operand
  2720. * @returns the current updated Vector3
  2721. */
  2722. divideInPlace(otherVector: Vector3): Vector3;
  2723. /**
  2724. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2729. /**
  2730. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2731. * @param other defines the second operand
  2732. * @returns the current updated Vector3
  2733. */
  2734. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2735. /**
  2736. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2737. * @param x defines the x coordinate of the operand
  2738. * @param y defines the y coordinate of the operand
  2739. * @param z defines the z coordinate of the operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2745. * @param x defines the x coordinate of the operand
  2746. * @param y defines the y coordinate of the operand
  2747. * @param z defines the z coordinate of the operand
  2748. * @returns the current updated Vector3
  2749. */
  2750. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2751. /**
  2752. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2753. * Check if is non uniform within a certain amount of decimal places to account for this
  2754. * @param epsilon the amount the values can differ
  2755. * @returns if the the vector is non uniform to a certain number of decimal places
  2756. */
  2757. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2758. /**
  2759. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2760. */
  2761. get isNonUniform(): boolean;
  2762. /**
  2763. * Gets a new Vector3 from current Vector3 floored values
  2764. * @returns a new Vector3
  2765. */
  2766. floor(): Vector3;
  2767. /**
  2768. * Gets a new Vector3 from current Vector3 floored values
  2769. * @returns a new Vector3
  2770. */
  2771. fract(): Vector3;
  2772. /**
  2773. * Gets the length of the Vector3
  2774. * @returns the length of the Vector3
  2775. */
  2776. length(): number;
  2777. /**
  2778. * Gets the squared length of the Vector3
  2779. * @returns squared length of the Vector3
  2780. */
  2781. lengthSquared(): number;
  2782. /**
  2783. * Normalize the current Vector3.
  2784. * Please note that this is an in place operation.
  2785. * @returns the current updated Vector3
  2786. */
  2787. normalize(): Vector3;
  2788. /**
  2789. * Reorders the x y z properties of the vector in place
  2790. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2791. * @returns the current updated vector
  2792. */
  2793. reorderInPlace(order: string): this;
  2794. /**
  2795. * Rotates the vector around 0,0,0 by a quaternion
  2796. * @param quaternion the rotation quaternion
  2797. * @param result vector to store the result
  2798. * @returns the resulting vector
  2799. */
  2800. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2801. /**
  2802. * Rotates a vector around a given point
  2803. * @param quaternion the rotation quaternion
  2804. * @param point the point to rotate around
  2805. * @param result vector to store the result
  2806. * @returns the resulting vector
  2807. */
  2808. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2809. /**
  2810. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2811. * The cross product is then orthogonal to both current and "other"
  2812. * @param other defines the right operand
  2813. * @returns the cross product
  2814. */
  2815. cross(other: Vector3): Vector3;
  2816. /**
  2817. * Normalize the current Vector3 with the given input length.
  2818. * Please note that this is an in place operation.
  2819. * @param len the length of the vector
  2820. * @returns the current updated Vector3
  2821. */
  2822. normalizeFromLength(len: number): Vector3;
  2823. /**
  2824. * Normalize the current Vector3 to a new vector
  2825. * @returns the new Vector3
  2826. */
  2827. normalizeToNew(): Vector3;
  2828. /**
  2829. * Normalize the current Vector3 to the reference
  2830. * @param reference define the Vector3 to update
  2831. * @returns the updated Vector3
  2832. */
  2833. normalizeToRef(reference: Vector3): Vector3;
  2834. /**
  2835. * Creates a new Vector3 copied from the current Vector3
  2836. * @returns the new Vector3
  2837. */
  2838. clone(): Vector3;
  2839. /**
  2840. * Copies the given vector coordinates to the current Vector3 ones
  2841. * @param source defines the source Vector3
  2842. * @returns the current updated Vector3
  2843. */
  2844. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2845. /**
  2846. * Copies the given floats to the current Vector3 coordinates
  2847. * @param x defines the x coordinate of the operand
  2848. * @param y defines the y coordinate of the operand
  2849. * @param z defines the z coordinate of the operand
  2850. * @returns the current updated Vector3
  2851. */
  2852. copyFromFloats(x: number, y: number, z: number): Vector3;
  2853. /**
  2854. * Copies the given floats to the current Vector3 coordinates
  2855. * @param x defines the x coordinate of the operand
  2856. * @param y defines the y coordinate of the operand
  2857. * @param z defines the z coordinate of the operand
  2858. * @returns the current updated Vector3
  2859. */
  2860. set(x: number, y: number, z: number): Vector3;
  2861. /**
  2862. * Copies the given float to the current Vector3 coordinates
  2863. * @param v defines the x, y and z coordinates of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. setAll(v: number): Vector3;
  2867. /**
  2868. * Get the clip factor between two vectors
  2869. * @param vector0 defines the first operand
  2870. * @param vector1 defines the second operand
  2871. * @param axis defines the axis to use
  2872. * @param size defines the size along the axis
  2873. * @returns the clip factor
  2874. */
  2875. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2876. /**
  2877. * Get angle between two vectors
  2878. * @param vector0 angle between vector0 and vector1
  2879. * @param vector1 angle between vector0 and vector1
  2880. * @param normal direction of the normal
  2881. * @return the angle between vector0 and vector1
  2882. */
  2883. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2884. /**
  2885. * Returns a new Vector3 set from the index "offset" of the given array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @returns the new Vector3
  2889. */
  2890. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @returns the new Vector3
  2896. * @deprecated Please use FromArray instead.
  2897. */
  2898. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2901. * @param array defines the source array
  2902. * @param offset defines the offset in the source array
  2903. * @param result defines the Vector3 where to store the result
  2904. */
  2905. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2906. /**
  2907. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2908. * @param array defines the source array
  2909. * @param offset defines the offset in the source array
  2910. * @param result defines the Vector3 where to store the result
  2911. * @deprecated Please use FromArrayToRef instead.
  2912. */
  2913. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2914. /**
  2915. * Sets the given vector "result" with the given floats.
  2916. * @param x defines the x coordinate of the source
  2917. * @param y defines the y coordinate of the source
  2918. * @param z defines the z coordinate of the source
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2922. /**
  2923. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2924. * @returns a new empty Vector3
  2925. */
  2926. static Zero(): Vector3;
  2927. /**
  2928. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2929. * @returns a new unit Vector3
  2930. */
  2931. static One(): Vector3;
  2932. /**
  2933. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2934. * @returns a new up Vector3
  2935. */
  2936. static Up(): Vector3;
  2937. /**
  2938. * Gets a up Vector3 that must not be updated
  2939. */
  2940. static get UpReadOnly(): DeepImmutable<Vector3>;
  2941. /**
  2942. * Gets a zero Vector3 that must not be updated
  2943. */
  2944. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2945. /**
  2946. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2947. * @returns a new down Vector3
  2948. */
  2949. static Down(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2952. * @param rightHandedSystem is the scene right-handed (negative z)
  2953. * @returns a new forward Vector3
  2954. */
  2955. static Forward(rightHandedSystem?: boolean): Vector3;
  2956. /**
  2957. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2958. * @param rightHandedSystem is the scene right-handed (negative-z)
  2959. * @returns a new forward Vector3
  2960. */
  2961. static Backward(rightHandedSystem?: boolean): Vector3;
  2962. /**
  2963. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2964. * @returns a new right Vector3
  2965. */
  2966. static Right(): Vector3;
  2967. /**
  2968. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2969. * @returns a new left Vector3
  2970. */
  2971. static Left(): Vector3;
  2972. /**
  2973. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2974. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2975. * @param vector defines the Vector3 to transform
  2976. * @param transformation defines the transformation matrix
  2977. * @returns the transformed Vector3
  2978. */
  2979. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2980. /**
  2981. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2982. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2983. * @param vector defines the Vector3 to transform
  2984. * @param transformation defines the transformation matrix
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2990. * This method computes tranformed coordinates only, not transformed direction vectors
  2991. * @param x define the x coordinate of the source vector
  2992. * @param y define the y coordinate of the source vector
  2993. * @param z define the z coordinate of the source vector
  2994. * @param transformation defines the transformation matrix
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3000. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3001. * @param vector defines the Vector3 to transform
  3002. * @param transformation defines the transformation matrix
  3003. * @returns the new Vector3
  3004. */
  3005. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3006. /**
  3007. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3008. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3009. * @param vector defines the Vector3 to transform
  3010. * @param transformation defines the transformation matrix
  3011. * @param result defines the Vector3 where to store the result
  3012. */
  3013. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3014. /**
  3015. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3016. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3017. * @param x define the x coordinate of the source vector
  3018. * @param y define the y coordinate of the source vector
  3019. * @param z define the z coordinate of the source vector
  3020. * @param transformation defines the transformation matrix
  3021. * @param result defines the Vector3 where to store the result
  3022. */
  3023. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3024. /**
  3025. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3026. * @param value1 defines the first control point
  3027. * @param value2 defines the second control point
  3028. * @param value3 defines the third control point
  3029. * @param value4 defines the fourth control point
  3030. * @param amount defines the amount on the spline to use
  3031. * @returns the new Vector3
  3032. */
  3033. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3034. /**
  3035. * 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"
  3036. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3037. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3038. * @param value defines the current value
  3039. * @param min defines the lower range value
  3040. * @param max defines the upper range value
  3041. * @returns the new Vector3
  3042. */
  3043. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * 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"
  3046. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3047. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3048. * @param value defines the current value
  3049. * @param min defines the lower range value
  3050. * @param max defines the upper range value
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3054. /**
  3055. * Checks if a given vector is inside a specific range
  3056. * @param v defines the vector to test
  3057. * @param min defines the minimum range
  3058. * @param max defines the maximum range
  3059. */
  3060. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3061. /**
  3062. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3063. * @param value1 defines the first control point
  3064. * @param tangent1 defines the first tangent vector
  3065. * @param value2 defines the second control point
  3066. * @param tangent2 defines the second tangent vector
  3067. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3068. * @returns the new Vector3
  3069. */
  3070. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3071. /**
  3072. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3073. * @param start defines the start value
  3074. * @param end defines the end value
  3075. * @param amount max defines amount between both (between 0 and 1)
  3076. * @returns the new Vector3
  3077. */
  3078. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3079. /**
  3080. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3081. * @param start defines the start value
  3082. * @param end defines the end value
  3083. * @param amount max defines amount between both (between 0 and 1)
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3087. /**
  3088. * Returns the dot product (float) between the vectors "left" and "right"
  3089. * @param left defines the left operand
  3090. * @param right defines the right operand
  3091. * @returns the dot product
  3092. */
  3093. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3094. /**
  3095. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3096. * The cross product is then orthogonal to both "left" and "right"
  3097. * @param left defines the left operand
  3098. * @param right defines the right operand
  3099. * @returns the cross product
  3100. */
  3101. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3102. /**
  3103. * Sets the given vector "result" with the cross product of "left" and "right"
  3104. * The cross product is then orthogonal to both "left" and "right"
  3105. * @param left defines the left operand
  3106. * @param right defines the right operand
  3107. * @param result defines the Vector3 where to store the result
  3108. */
  3109. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3110. /**
  3111. * Returns a new Vector3 as the normalization of the given vector
  3112. * @param vector defines the Vector3 to normalize
  3113. * @returns the new Vector3
  3114. */
  3115. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the normalization of the given first vector
  3118. * @param vector defines the Vector3 to normalize
  3119. * @param result defines the Vector3 where to store the result
  3120. */
  3121. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3122. /**
  3123. * Project a Vector3 onto screen space
  3124. * @param vector defines the Vector3 to project
  3125. * @param world defines the world matrix to use
  3126. * @param transform defines the transform (view x projection) matrix to use
  3127. * @param viewport defines the screen viewport to use
  3128. * @returns the new Vector3
  3129. */
  3130. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3131. /** @hidden */
  3132. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3133. /**
  3134. * Unproject from screen space to object space
  3135. * @param source defines the screen space Vector3 to use
  3136. * @param viewportWidth defines the current width of the viewport
  3137. * @param viewportHeight defines the current height of the viewport
  3138. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3139. * @param transform defines the transform (view x projection) matrix to use
  3140. * @returns the new Vector3
  3141. */
  3142. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param source defines the screen space Vector3 to use
  3146. * @param viewportWidth defines the current width of the viewport
  3147. * @param viewportHeight defines the current height of the viewport
  3148. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3149. * @param view defines the view matrix to use
  3150. * @param projection defines the projection matrix to use
  3151. * @returns the new Vector3
  3152. */
  3153. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3154. /**
  3155. * Unproject from screen space to object space
  3156. * @param source defines the screen space Vector3 to use
  3157. * @param viewportWidth defines the current width of the viewport
  3158. * @param viewportHeight defines the current height of the viewport
  3159. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3160. * @param view defines the view matrix to use
  3161. * @param projection defines the projection matrix to use
  3162. * @param result defines the Vector3 where to store the result
  3163. */
  3164. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3165. /**
  3166. * Unproject from screen space to object space
  3167. * @param sourceX defines the screen space x coordinate to use
  3168. * @param sourceY defines the screen space y coordinate to use
  3169. * @param sourceZ defines the screen space z coordinate to use
  3170. * @param viewportWidth defines the current width of the viewport
  3171. * @param viewportHeight defines the current height of the viewport
  3172. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3173. * @param view defines the view matrix to use
  3174. * @param projection defines the projection matrix to use
  3175. * @param result defines the Vector3 where to store the result
  3176. */
  3177. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3178. /**
  3179. * Gets the minimal coordinate values between two Vector3
  3180. * @param left defines the first operand
  3181. * @param right defines the second operand
  3182. * @returns the new Vector3
  3183. */
  3184. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3185. /**
  3186. * Gets the maximal coordinate values between two Vector3
  3187. * @param left defines the first operand
  3188. * @param right defines the second operand
  3189. * @returns the new Vector3
  3190. */
  3191. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3192. /**
  3193. * Returns the distance between the vectors "value1" and "value2"
  3194. * @param value1 defines the first operand
  3195. * @param value2 defines the second operand
  3196. * @returns the distance
  3197. */
  3198. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3199. /**
  3200. * Returns the squared distance between the vectors "value1" and "value2"
  3201. * @param value1 defines the first operand
  3202. * @param value2 defines the second operand
  3203. * @returns the squared distance
  3204. */
  3205. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3206. /**
  3207. * Returns a new Vector3 located at the center between "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the new Vector3
  3211. */
  3212. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3213. /**
  3214. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3215. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3216. * to something in order to rotate it from its local system to the given target system
  3217. * Note: axis1, axis2 and axis3 are normalized during this operation
  3218. * @param axis1 defines the first axis
  3219. * @param axis2 defines the second axis
  3220. * @param axis3 defines the third axis
  3221. * @returns a new Vector3
  3222. */
  3223. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3224. /**
  3225. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3226. * @param axis1 defines the first axis
  3227. * @param axis2 defines the second axis
  3228. * @param axis3 defines the third axis
  3229. * @param ref defines the Vector3 where to store the result
  3230. */
  3231. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3232. }
  3233. /**
  3234. * Vector4 class created for EulerAngle class conversion to Quaternion
  3235. */
  3236. export class Vector4 {
  3237. /** x value of the vector */
  3238. x: number;
  3239. /** y value of the vector */
  3240. y: number;
  3241. /** z value of the vector */
  3242. z: number;
  3243. /** w value of the vector */
  3244. w: number;
  3245. /**
  3246. * Creates a Vector4 object from the given floats.
  3247. * @param x x value of the vector
  3248. * @param y y value of the vector
  3249. * @param z z value of the vector
  3250. * @param w w value of the vector
  3251. */
  3252. constructor(
  3253. /** x value of the vector */
  3254. x: number,
  3255. /** y value of the vector */
  3256. y: number,
  3257. /** z value of the vector */
  3258. z: number,
  3259. /** w value of the vector */
  3260. w: number);
  3261. /**
  3262. * Returns the string with the Vector4 coordinates.
  3263. * @returns a string containing all the vector values
  3264. */
  3265. toString(): string;
  3266. /**
  3267. * Returns the string "Vector4".
  3268. * @returns "Vector4"
  3269. */
  3270. getClassName(): string;
  3271. /**
  3272. * Returns the Vector4 hash code.
  3273. * @returns a unique hash code
  3274. */
  3275. getHashCode(): number;
  3276. /**
  3277. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3278. * @returns the resulting array
  3279. */
  3280. asArray(): number[];
  3281. /**
  3282. * Populates the given array from the given index with the Vector4 coordinates.
  3283. * @param array array to populate
  3284. * @param index index of the array to start at (default: 0)
  3285. * @returns the Vector4.
  3286. */
  3287. toArray(array: FloatArray, index?: number): Vector4;
  3288. /**
  3289. * Adds the given vector to the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the updated Vector4.
  3292. */
  3293. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3296. * @param otherVector the vector to add
  3297. * @returns the resulting vector
  3298. */
  3299. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3302. * @param otherVector the vector to add
  3303. * @param result the vector to store the result
  3304. * @returns the current Vector4.
  3305. */
  3306. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3307. /**
  3308. * Subtract in place the given vector from the current Vector4.
  3309. * @param otherVector the vector to subtract
  3310. * @returns the updated Vector4.
  3311. */
  3312. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3315. * @param otherVector the vector to add
  3316. * @returns the new vector with the result
  3317. */
  3318. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3321. * @param otherVector the vector to subtract
  3322. * @param result the vector to store the result
  3323. * @returns the current Vector4.
  3324. */
  3325. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3326. /**
  3327. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3328. */
  3329. /**
  3330. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3331. * @param x value to subtract
  3332. * @param y value to subtract
  3333. * @param z value to subtract
  3334. * @param w value to subtract
  3335. * @returns new vector containing the result
  3336. */
  3337. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3338. /**
  3339. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3340. * @param x value to subtract
  3341. * @param y value to subtract
  3342. * @param z value to subtract
  3343. * @param w value to subtract
  3344. * @param result the vector to store the result in
  3345. * @returns the current Vector4.
  3346. */
  3347. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3348. /**
  3349. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3350. * @returns a new vector with the negated values
  3351. */
  3352. negate(): Vector4;
  3353. /**
  3354. * Negate this vector in place
  3355. * @returns this
  3356. */
  3357. negateInPlace(): Vector4;
  3358. /**
  3359. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3360. * @param result defines the Vector3 object where to store the result
  3361. * @returns the current Vector4
  3362. */
  3363. negateToRef(result: Vector4): Vector4;
  3364. /**
  3365. * Multiplies the current Vector4 coordinates by scale (float).
  3366. * @param scale the number to scale with
  3367. * @returns the updated Vector4.
  3368. */
  3369. scaleInPlace(scale: number): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3372. * @param scale the number to scale with
  3373. * @returns a new vector with the result
  3374. */
  3375. scale(scale: number): Vector4;
  3376. /**
  3377. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3378. * @param scale the number to scale with
  3379. * @param result a vector to store the result in
  3380. * @returns the current Vector4.
  3381. */
  3382. scaleToRef(scale: number, result: Vector4): Vector4;
  3383. /**
  3384. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3385. * @param scale defines the scale factor
  3386. * @param result defines the Vector4 object where to store the result
  3387. * @returns the unmodified current Vector4
  3388. */
  3389. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3390. /**
  3391. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3392. * @param otherVector the vector to compare against
  3393. * @returns true if they are equal
  3394. */
  3395. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3396. /**
  3397. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3398. * @param otherVector vector to compare against
  3399. * @param epsilon (Default: very small number)
  3400. * @returns true if they are equal
  3401. */
  3402. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3403. /**
  3404. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3405. * @param x x value to compare against
  3406. * @param y y value to compare against
  3407. * @param z z value to compare against
  3408. * @param w w value to compare against
  3409. * @returns true if equal
  3410. */
  3411. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3412. /**
  3413. * Multiplies in place the current Vector4 by the given one.
  3414. * @param otherVector vector to multiple with
  3415. * @returns the updated Vector4.
  3416. */
  3417. multiplyInPlace(otherVector: Vector4): Vector4;
  3418. /**
  3419. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3420. * @param otherVector vector to multiple with
  3421. * @returns resulting new vector
  3422. */
  3423. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3426. * @param otherVector vector to multiple with
  3427. * @param result vector to store the result
  3428. * @returns the current Vector4.
  3429. */
  3430. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3431. /**
  3432. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3433. * @param x x value multiply with
  3434. * @param y y value multiply with
  3435. * @param z z value multiply with
  3436. * @param w w value multiply with
  3437. * @returns resulting new vector
  3438. */
  3439. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3440. /**
  3441. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3442. * @param otherVector vector to devide with
  3443. * @returns resulting new vector
  3444. */
  3445. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3448. * @param otherVector vector to devide with
  3449. * @param result vector to store the result
  3450. * @returns the current Vector4.
  3451. */
  3452. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3453. /**
  3454. * Divides the current Vector3 coordinates by the given ones.
  3455. * @param otherVector vector to devide with
  3456. * @returns the updated Vector3.
  3457. */
  3458. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3459. /**
  3460. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3461. * @param other defines the second operand
  3462. * @returns the current updated Vector4
  3463. */
  3464. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3465. /**
  3466. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3467. * @param other defines the second operand
  3468. * @returns the current updated Vector4
  3469. */
  3470. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3471. /**
  3472. * Gets a new Vector4 from current Vector4 floored values
  3473. * @returns a new Vector4
  3474. */
  3475. floor(): Vector4;
  3476. /**
  3477. * Gets a new Vector4 from current Vector3 floored values
  3478. * @returns a new Vector4
  3479. */
  3480. fract(): Vector4;
  3481. /**
  3482. * Returns the Vector4 length (float).
  3483. * @returns the length
  3484. */
  3485. length(): number;
  3486. /**
  3487. * Returns the Vector4 squared length (float).
  3488. * @returns the length squared
  3489. */
  3490. lengthSquared(): number;
  3491. /**
  3492. * Normalizes in place the Vector4.
  3493. * @returns the updated Vector4.
  3494. */
  3495. normalize(): Vector4;
  3496. /**
  3497. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3498. * @returns this converted to a new vector3
  3499. */
  3500. toVector3(): Vector3;
  3501. /**
  3502. * Returns a new Vector4 copied from the current one.
  3503. * @returns the new cloned vector
  3504. */
  3505. clone(): Vector4;
  3506. /**
  3507. * Updates the current Vector4 with the given one coordinates.
  3508. * @param source the source vector to copy from
  3509. * @returns the updated Vector4.
  3510. */
  3511. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3512. /**
  3513. * Updates the current Vector4 coordinates with the given floats.
  3514. * @param x float to copy from
  3515. * @param y float to copy from
  3516. * @param z float to copy from
  3517. * @param w float to copy from
  3518. * @returns the updated Vector4.
  3519. */
  3520. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3521. /**
  3522. * Updates the current Vector4 coordinates with the given floats.
  3523. * @param x float to set from
  3524. * @param y float to set from
  3525. * @param z float to set from
  3526. * @param w float to set from
  3527. * @returns the updated Vector4.
  3528. */
  3529. set(x: number, y: number, z: number, w: number): Vector4;
  3530. /**
  3531. * Copies the given float to the current Vector3 coordinates
  3532. * @param v defines the x, y, z and w coordinates of the operand
  3533. * @returns the current updated Vector3
  3534. */
  3535. setAll(v: number): Vector4;
  3536. /**
  3537. * Returns a new Vector4 set from the starting index of the given array.
  3538. * @param array the array to pull values from
  3539. * @param offset the offset into the array to start at
  3540. * @returns the new vector
  3541. */
  3542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3543. /**
  3544. * Updates the given vector "result" from the starting index of the given array.
  3545. * @param array the array to pull values from
  3546. * @param offset the offset into the array to start at
  3547. * @param result the vector to store the result in
  3548. */
  3549. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3550. /**
  3551. * Updates the given vector "result" from the starting index of the given Float32Array.
  3552. * @param array the array to pull values from
  3553. * @param offset the offset into the array to start at
  3554. * @param result the vector to store the result in
  3555. */
  3556. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3557. /**
  3558. * Updates the given vector "result" coordinates from the given floats.
  3559. * @param x float to set from
  3560. * @param y float to set from
  3561. * @param z float to set from
  3562. * @param w float to set from
  3563. * @param result the vector to the floats in
  3564. */
  3565. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3566. /**
  3567. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3568. * @returns the new vector
  3569. */
  3570. static Zero(): Vector4;
  3571. /**
  3572. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3573. * @returns the new vector
  3574. */
  3575. static One(): Vector4;
  3576. /**
  3577. * Returns a new normalized Vector4 from the given one.
  3578. * @param vector the vector to normalize
  3579. * @returns the vector
  3580. */
  3581. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3582. /**
  3583. * Updates the given vector "result" from the normalization of the given one.
  3584. * @param vector the vector to normalize
  3585. * @param result the vector to store the result in
  3586. */
  3587. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3588. /**
  3589. * Returns a vector with the minimum values from the left and right vectors
  3590. * @param left left vector to minimize
  3591. * @param right right vector to minimize
  3592. * @returns a new vector with the minimum of the left and right vector values
  3593. */
  3594. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3595. /**
  3596. * Returns a vector with the maximum values from the left and right vectors
  3597. * @param left left vector to maximize
  3598. * @param right right vector to maximize
  3599. * @returns a new vector with the maximum of the left and right vector values
  3600. */
  3601. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3602. /**
  3603. * Returns the distance (float) between the vectors "value1" and "value2".
  3604. * @param value1 value to calulate the distance between
  3605. * @param value2 value to calulate the distance between
  3606. * @return the distance between the two vectors
  3607. */
  3608. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3609. /**
  3610. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3611. * @param value1 value to calulate the distance between
  3612. * @param value2 value to calulate the distance between
  3613. * @return the distance between the two vectors squared
  3614. */
  3615. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3616. /**
  3617. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3618. * @param value1 value to calulate the center between
  3619. * @param value2 value to calulate the center between
  3620. * @return the center between the two vectors
  3621. */
  3622. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3625. * This methods computes transformed normalized direction vectors only.
  3626. * @param vector the vector to transform
  3627. * @param transformation the transformation matrix to apply
  3628. * @returns the new vector
  3629. */
  3630. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3631. /**
  3632. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3633. * This methods computes transformed normalized direction vectors only.
  3634. * @param vector the vector to transform
  3635. * @param transformation the transformation matrix to apply
  3636. * @param result the vector to store the result in
  3637. */
  3638. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3639. /**
  3640. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3641. * This methods computes transformed normalized direction vectors only.
  3642. * @param x value to transform
  3643. * @param y value to transform
  3644. * @param z value to transform
  3645. * @param w value to transform
  3646. * @param transformation the transformation matrix to apply
  3647. * @param result the vector to store the results in
  3648. */
  3649. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3650. /**
  3651. * Creates a new Vector4 from a Vector3
  3652. * @param source defines the source data
  3653. * @param w defines the 4th component (default is 0)
  3654. * @returns a new Vector4
  3655. */
  3656. static FromVector3(source: Vector3, w?: number): Vector4;
  3657. }
  3658. /**
  3659. * Class used to store quaternion data
  3660. * @see https://en.wikipedia.org/wiki/Quaternion
  3661. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3662. */
  3663. export class Quaternion {
  3664. /** @hidden */
  3665. _x: number;
  3666. /** @hidden */
  3667. _y: number;
  3668. /** @hidden */
  3669. _z: number;
  3670. /** @hidden */
  3671. _w: number;
  3672. /** @hidden */
  3673. _isDirty: boolean;
  3674. /** Gets or sets the x coordinate */
  3675. get x(): number;
  3676. set x(value: number);
  3677. /** Gets or sets the y coordinate */
  3678. get y(): number;
  3679. set y(value: number);
  3680. /** Gets or sets the z coordinate */
  3681. get z(): number;
  3682. set z(value: number);
  3683. /** Gets or sets the w coordinate */
  3684. get w(): number;
  3685. set w(value: number);
  3686. /**
  3687. * Creates a new Quaternion from the given floats
  3688. * @param x defines the first component (0 by default)
  3689. * @param y defines the second component (0 by default)
  3690. * @param z defines the third component (0 by default)
  3691. * @param w defines the fourth component (1.0 by default)
  3692. */
  3693. constructor(x?: number, y?: number, z?: number, w?: number);
  3694. /**
  3695. * Gets a string representation for the current quaternion
  3696. * @returns a string with the Quaternion coordinates
  3697. */
  3698. toString(): string;
  3699. /**
  3700. * Gets the class name of the quaternion
  3701. * @returns the string "Quaternion"
  3702. */
  3703. getClassName(): string;
  3704. /**
  3705. * Gets a hash code for this quaternion
  3706. * @returns the quaternion hash code
  3707. */
  3708. getHashCode(): number;
  3709. /**
  3710. * Copy the quaternion to an array
  3711. * @returns a new array populated with 4 elements from the quaternion coordinates
  3712. */
  3713. asArray(): number[];
  3714. /**
  3715. * Check if two quaternions are equals
  3716. * @param otherQuaternion defines the second operand
  3717. * @return true if the current quaternion and the given one coordinates are strictly equals
  3718. */
  3719. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3720. /**
  3721. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3722. * @param otherQuaternion defines the other quaternion
  3723. * @param epsilon defines the minimal distance to consider equality
  3724. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3725. */
  3726. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3727. /**
  3728. * Clone the current quaternion
  3729. * @returns a new quaternion copied from the current one
  3730. */
  3731. clone(): Quaternion;
  3732. /**
  3733. * Copy a quaternion to the current one
  3734. * @param other defines the other quaternion
  3735. * @returns the updated current quaternion
  3736. */
  3737. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the given float coordinates
  3740. * @param x defines the x coordinate
  3741. * @param y defines the y coordinate
  3742. * @param z defines the z coordinate
  3743. * @param w defines the w coordinate
  3744. * @returns the updated current quaternion
  3745. */
  3746. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3747. /**
  3748. * Updates the current quaternion from the given float coordinates
  3749. * @param x defines the x coordinate
  3750. * @param y defines the y coordinate
  3751. * @param z defines the z coordinate
  3752. * @param w defines the w coordinate
  3753. * @returns the updated current quaternion
  3754. */
  3755. set(x: number, y: number, z: number, w: number): Quaternion;
  3756. /**
  3757. * Adds two quaternions
  3758. * @param other defines the second operand
  3759. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3760. */
  3761. add(other: DeepImmutable<Quaternion>): Quaternion;
  3762. /**
  3763. * Add a quaternion to the current one
  3764. * @param other defines the quaternion to add
  3765. * @returns the current quaternion
  3766. */
  3767. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3768. /**
  3769. * Subtract two quaternions
  3770. * @param other defines the second operand
  3771. * @returns a new quaternion as the subtraction result of the given one from the current one
  3772. */
  3773. subtract(other: Quaternion): Quaternion;
  3774. /**
  3775. * Multiplies the current quaternion by a scale factor
  3776. * @param value defines the scale factor
  3777. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3778. */
  3779. scale(value: number): Quaternion;
  3780. /**
  3781. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3782. * @param scale defines the scale factor
  3783. * @param result defines the Quaternion object where to store the result
  3784. * @returns the unmodified current quaternion
  3785. */
  3786. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3787. /**
  3788. * Multiplies in place the current quaternion by a scale factor
  3789. * @param value defines the scale factor
  3790. * @returns the current modified quaternion
  3791. */
  3792. scaleInPlace(value: number): Quaternion;
  3793. /**
  3794. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3795. * @param scale defines the scale factor
  3796. * @param result defines the Quaternion object where to store the result
  3797. * @returns the unmodified current quaternion
  3798. */
  3799. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies two quaternions
  3802. * @param q1 defines the second operand
  3803. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3804. */
  3805. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3806. /**
  3807. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3808. * @param q1 defines the second operand
  3809. * @param result defines the target quaternion
  3810. * @returns the current quaternion
  3811. */
  3812. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3813. /**
  3814. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3815. * @param q1 defines the second operand
  3816. * @returns the currentupdated quaternion
  3817. */
  3818. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3819. /**
  3820. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3821. * @param ref defines the target quaternion
  3822. * @returns the current quaternion
  3823. */
  3824. conjugateToRef(ref: Quaternion): Quaternion;
  3825. /**
  3826. * Conjugates in place (1-q) the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. conjugateInPlace(): Quaternion;
  3830. /**
  3831. * Conjugates in place (1-q) the current quaternion
  3832. * @returns a new quaternion
  3833. */
  3834. conjugate(): Quaternion;
  3835. /**
  3836. * Gets length of current quaternion
  3837. * @returns the quaternion length (float)
  3838. */
  3839. length(): number;
  3840. /**
  3841. * Normalize in place the current quaternion
  3842. * @returns the current updated quaternion
  3843. */
  3844. normalize(): Quaternion;
  3845. /**
  3846. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3847. * @param order is a reserved parameter and is ignore for now
  3848. * @returns a new Vector3 containing the Euler angles
  3849. */
  3850. toEulerAngles(order?: string): Vector3;
  3851. /**
  3852. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3853. * @param result defines the vector which will be filled with the Euler angles
  3854. * @param order is a reserved parameter and is ignore for now
  3855. * @returns the current unchanged quaternion
  3856. */
  3857. toEulerAnglesToRef(result: Vector3): Quaternion;
  3858. /**
  3859. * Updates the given rotation matrix with the current quaternion values
  3860. * @param result defines the target matrix
  3861. * @returns the current unchanged quaternion
  3862. */
  3863. toRotationMatrix(result: Matrix): Quaternion;
  3864. /**
  3865. * Updates the current quaternion from the given rotation matrix values
  3866. * @param matrix defines the source matrix
  3867. * @returns the current updated quaternion
  3868. */
  3869. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3870. /**
  3871. * Creates a new quaternion from a rotation matrix
  3872. * @param matrix defines the source matrix
  3873. * @returns a new quaternion created from the given rotation matrix values
  3874. */
  3875. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3876. /**
  3877. * Updates the given quaternion with the given rotation matrix values
  3878. * @param matrix defines the source matrix
  3879. * @param result defines the target quaternion
  3880. */
  3881. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3882. /**
  3883. * Returns the dot product (float) between the quaternions "left" and "right"
  3884. * @param left defines the left operand
  3885. * @param right defines the right operand
  3886. * @returns the dot product
  3887. */
  3888. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3889. /**
  3890. * Checks if the two quaternions are close to each other
  3891. * @param quat0 defines the first quaternion to check
  3892. * @param quat1 defines the second quaternion to check
  3893. * @returns true if the two quaternions are close to each other
  3894. */
  3895. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3896. /**
  3897. * Creates an empty quaternion
  3898. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3899. */
  3900. static Zero(): Quaternion;
  3901. /**
  3902. * Inverse a given quaternion
  3903. * @param q defines the source quaternion
  3904. * @returns a new quaternion as the inverted current quaternion
  3905. */
  3906. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3907. /**
  3908. * Inverse a given quaternion
  3909. * @param q defines the source quaternion
  3910. * @param result the quaternion the result will be stored in
  3911. * @returns the result quaternion
  3912. */
  3913. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3914. /**
  3915. * Creates an identity quaternion
  3916. * @returns the identity quaternion
  3917. */
  3918. static Identity(): Quaternion;
  3919. /**
  3920. * Gets a boolean indicating if the given quaternion is identity
  3921. * @param quaternion defines the quaternion to check
  3922. * @returns true if the quaternion is identity
  3923. */
  3924. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3925. /**
  3926. * Creates a quaternion from a rotation around an axis
  3927. * @param axis defines the axis to use
  3928. * @param angle defines the angle to use
  3929. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3930. */
  3931. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3932. /**
  3933. * Creates a rotation around an axis and stores it into the given quaternion
  3934. * @param axis defines the axis to use
  3935. * @param angle defines the angle to use
  3936. * @param result defines the target quaternion
  3937. * @returns the target quaternion
  3938. */
  3939. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Creates a new quaternion from data stored into an array
  3942. * @param array defines the data source
  3943. * @param offset defines the offset in the source array where the data starts
  3944. * @returns a new quaternion
  3945. */
  3946. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3947. /**
  3948. * Updates the given quaternion "result" from the starting index of the given array.
  3949. * @param array the array to pull values from
  3950. * @param offset the offset into the array to start at
  3951. * @param result the quaternion to store the result in
  3952. */
  3953. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3954. /**
  3955. * Create a quaternion from Euler rotation angles
  3956. * @param x Pitch
  3957. * @param y Yaw
  3958. * @param z Roll
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation angles
  3964. * @param x Pitch
  3965. * @param y Yaw
  3966. * @param z Roll
  3967. * @param result the quaternion to store the result
  3968. * @returns the updated quaternion
  3969. */
  3970. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3971. /**
  3972. * Create a quaternion from Euler rotation vector
  3973. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3974. * @returns the new Quaternion
  3975. */
  3976. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3977. /**
  3978. * Updates a quaternion from Euler rotation vector
  3979. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3980. * @param result the quaternion to store the result
  3981. * @returns the updated quaternion
  3982. */
  3983. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3984. /**
  3985. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3986. * @param yaw defines the rotation around Y axis
  3987. * @param pitch defines the rotation around X axis
  3988. * @param roll defines the rotation around Z axis
  3989. * @returns the new quaternion
  3990. */
  3991. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3992. /**
  3993. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3994. * @param yaw defines the rotation around Y axis
  3995. * @param pitch defines the rotation around X axis
  3996. * @param roll defines the rotation around Z axis
  3997. * @param result defines the target quaternion
  3998. */
  3999. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4000. /**
  4001. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4002. * @param alpha defines the rotation around first axis
  4003. * @param beta defines the rotation around second axis
  4004. * @param gamma defines the rotation around third axis
  4005. * @returns the new quaternion
  4006. */
  4007. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4008. /**
  4009. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4010. * @param alpha defines the rotation around first axis
  4011. * @param beta defines the rotation around second axis
  4012. * @param gamma defines the rotation around third axis
  4013. * @param result defines the target quaternion
  4014. */
  4015. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4016. /**
  4017. * 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)
  4018. * @param axis1 defines the first axis
  4019. * @param axis2 defines the second axis
  4020. * @param axis3 defines the third axis
  4021. * @returns the new quaternion
  4022. */
  4023. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4024. /**
  4025. * 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
  4026. * @param axis1 defines the first axis
  4027. * @param axis2 defines the second axis
  4028. * @param axis3 defines the third axis
  4029. * @param ref defines the target quaternion
  4030. */
  4031. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4032. /**
  4033. * Interpolates between two quaternions
  4034. * @param left defines first quaternion
  4035. * @param right defines second quaternion
  4036. * @param amount defines the gradient to use
  4037. * @returns the new interpolated quaternion
  4038. */
  4039. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4040. /**
  4041. * Interpolates between two quaternions and stores it into a target quaternion
  4042. * @param left defines first quaternion
  4043. * @param right defines second quaternion
  4044. * @param amount defines the gradient to use
  4045. * @param result defines the target quaternion
  4046. */
  4047. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4048. /**
  4049. * Interpolate between two quaternions using Hermite interpolation
  4050. * @param value1 defines first quaternion
  4051. * @param tangent1 defines the incoming tangent
  4052. * @param value2 defines second quaternion
  4053. * @param tangent2 defines the outgoing tangent
  4054. * @param amount defines the target quaternion
  4055. * @returns the new interpolated quaternion
  4056. */
  4057. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4058. }
  4059. /**
  4060. * Class used to store matrix data (4x4)
  4061. */
  4062. export class Matrix {
  4063. /**
  4064. * Gets the precision of matrix computations
  4065. */
  4066. static get Use64Bits(): boolean;
  4067. private static _updateFlagSeed;
  4068. private static _identityReadOnly;
  4069. private _isIdentity;
  4070. private _isIdentityDirty;
  4071. private _isIdentity3x2;
  4072. private _isIdentity3x2Dirty;
  4073. /**
  4074. * Gets the update flag of the matrix which is an unique number for the matrix.
  4075. * It will be incremented every time the matrix data change.
  4076. * You can use it to speed the comparison between two versions of the same matrix.
  4077. */
  4078. updateFlag: number;
  4079. private readonly _m;
  4080. /**
  4081. * Gets the internal data of the matrix
  4082. */
  4083. get m(): DeepImmutable<Float32Array | Array<number>>;
  4084. /** @hidden */
  4085. _markAsUpdated(): void;
  4086. /** @hidden */
  4087. private _updateIdentityStatus;
  4088. /**
  4089. * Creates an empty matrix (filled with zeros)
  4090. */
  4091. constructor();
  4092. /**
  4093. * Check if the current matrix is identity
  4094. * @returns true is the matrix is the identity matrix
  4095. */
  4096. isIdentity(): boolean;
  4097. /**
  4098. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4099. * @returns true is the matrix is the identity matrix
  4100. */
  4101. isIdentityAs3x2(): boolean;
  4102. /**
  4103. * Gets the determinant of the matrix
  4104. * @returns the matrix determinant
  4105. */
  4106. determinant(): number;
  4107. /**
  4108. * Returns the matrix as a Float32Array or Array<number>
  4109. * @returns the matrix underlying array
  4110. */
  4111. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4112. /**
  4113. * Returns the matrix as a Float32Array or Array<number>
  4114. * @returns the matrix underlying array.
  4115. */
  4116. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4117. /**
  4118. * Inverts the current matrix in place
  4119. * @returns the current inverted matrix
  4120. */
  4121. invert(): Matrix;
  4122. /**
  4123. * Sets all the matrix elements to zero
  4124. * @returns the current matrix
  4125. */
  4126. reset(): Matrix;
  4127. /**
  4128. * Adds the current matrix with a second one
  4129. * @param other defines the matrix to add
  4130. * @returns a new matrix as the addition of the current matrix and the given one
  4131. */
  4132. add(other: DeepImmutable<Matrix>): Matrix;
  4133. /**
  4134. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4135. * @param other defines the matrix to add
  4136. * @param result defines the target matrix
  4137. * @returns the current matrix
  4138. */
  4139. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4140. /**
  4141. * Adds in place the given matrix to the current matrix
  4142. * @param other defines the second operand
  4143. * @returns the current updated matrix
  4144. */
  4145. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4146. /**
  4147. * Sets the given matrix to the current inverted Matrix
  4148. * @param other defines the target matrix
  4149. * @returns the unmodified current matrix
  4150. */
  4151. invertToRef(other: Matrix): Matrix;
  4152. /**
  4153. * add a value at the specified position in the current Matrix
  4154. * @param index the index of the value within the matrix. between 0 and 15.
  4155. * @param value the value to be added
  4156. * @returns the current updated matrix
  4157. */
  4158. addAtIndex(index: number, value: number): Matrix;
  4159. /**
  4160. * mutiply the specified position in the current Matrix by a value
  4161. * @param index the index of the value within the matrix. between 0 and 15.
  4162. * @param value the value to be added
  4163. * @returns the current updated matrix
  4164. */
  4165. multiplyAtIndex(index: number, value: number): Matrix;
  4166. /**
  4167. * Inserts the translation vector (using 3 floats) in the current matrix
  4168. * @param x defines the 1st component of the translation
  4169. * @param y defines the 2nd component of the translation
  4170. * @param z defines the 3rd component of the translation
  4171. * @returns the current updated matrix
  4172. */
  4173. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4174. /**
  4175. * Adds the translation vector (using 3 floats) in the current matrix
  4176. * @param x defines the 1st component of the translation
  4177. * @param y defines the 2nd component of the translation
  4178. * @param z defines the 3rd component of the translation
  4179. * @returns the current updated matrix
  4180. */
  4181. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4182. /**
  4183. * Inserts the translation vector in the current matrix
  4184. * @param vector3 defines the translation to insert
  4185. * @returns the current updated matrix
  4186. */
  4187. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4188. /**
  4189. * Gets the translation value of the current matrix
  4190. * @returns a new Vector3 as the extracted translation from the matrix
  4191. */
  4192. getTranslation(): Vector3;
  4193. /**
  4194. * Fill a Vector3 with the extracted translation from the matrix
  4195. * @param result defines the Vector3 where to store the translation
  4196. * @returns the current matrix
  4197. */
  4198. getTranslationToRef(result: Vector3): Matrix;
  4199. /**
  4200. * Remove rotation and scaling part from the matrix
  4201. * @returns the updated matrix
  4202. */
  4203. removeRotationAndScaling(): Matrix;
  4204. /**
  4205. * Multiply two matrices
  4206. * @param other defines the second operand
  4207. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4208. */
  4209. multiply(other: DeepImmutable<Matrix>): Matrix;
  4210. /**
  4211. * Copy the current matrix from the given one
  4212. * @param other defines the source matrix
  4213. * @returns the current updated matrix
  4214. */
  4215. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4216. /**
  4217. * Populates the given array from the starting index with the current matrix values
  4218. * @param array defines the target array
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4223. /**
  4224. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4225. * @param other defines the second operand
  4226. * @param result defines the matrix where to store the multiplication
  4227. * @returns the current matrix
  4228. */
  4229. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4230. /**
  4231. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4232. * @param other defines the second operand
  4233. * @param result defines the array where to store the multiplication
  4234. * @param offset defines the offset in the target array where to start storing values
  4235. * @returns the current matrix
  4236. */
  4237. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4238. /**
  4239. * Check equality between this matrix and a second one
  4240. * @param value defines the second matrix to compare
  4241. * @returns true is the current matrix and the given one values are strictly equal
  4242. */
  4243. equals(value: DeepImmutable<Matrix>): boolean;
  4244. /**
  4245. * Clone the current matrix
  4246. * @returns a new matrix from the current matrix
  4247. */
  4248. clone(): Matrix;
  4249. /**
  4250. * Returns the name of the current matrix class
  4251. * @returns the string "Matrix"
  4252. */
  4253. getClassName(): string;
  4254. /**
  4255. * Gets the hash code of the current matrix
  4256. * @returns the hash code
  4257. */
  4258. getHashCode(): number;
  4259. /**
  4260. * Decomposes the current Matrix into a translation, rotation and scaling components
  4261. * @param scale defines the scale vector3 given as a reference to update
  4262. * @param rotation defines the rotation quaternion given as a reference to update
  4263. * @param translation defines the translation vector3 given as a reference to update
  4264. * @returns true if operation was successful
  4265. */
  4266. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4267. /**
  4268. * Gets specific row of the matrix
  4269. * @param index defines the number of the row to get
  4270. * @returns the index-th row of the current matrix as a new Vector4
  4271. */
  4272. getRow(index: number): Nullable<Vector4>;
  4273. /**
  4274. * Sets the index-th row of the current matrix to the vector4 values
  4275. * @param index defines the number of the row to set
  4276. * @param row defines the target vector4
  4277. * @returns the updated current matrix
  4278. */
  4279. setRow(index: number, row: Vector4): Matrix;
  4280. /**
  4281. * Compute the transpose of the matrix
  4282. * @returns the new transposed matrix
  4283. */
  4284. transpose(): Matrix;
  4285. /**
  4286. * Compute the transpose of the matrix and store it in a given matrix
  4287. * @param result defines the target matrix
  4288. * @returns the current matrix
  4289. */
  4290. transposeToRef(result: Matrix): Matrix;
  4291. /**
  4292. * Sets the index-th row of the current matrix with the given 4 x float values
  4293. * @param index defines the row index
  4294. * @param x defines the x component to set
  4295. * @param y defines the y component to set
  4296. * @param z defines the z component to set
  4297. * @param w defines the w component to set
  4298. * @returns the updated current matrix
  4299. */
  4300. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4301. /**
  4302. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4303. * @param scale defines the scale factor
  4304. * @returns a new matrix
  4305. */
  4306. scale(scale: number): Matrix;
  4307. /**
  4308. * Scale the current matrix values by a factor to a given result matrix
  4309. * @param scale defines the scale factor
  4310. * @param result defines the matrix to store the result
  4311. * @returns the current matrix
  4312. */
  4313. scaleToRef(scale: number, result: Matrix): Matrix;
  4314. /**
  4315. * Scale the current matrix values by a factor and add the result to a given matrix
  4316. * @param scale defines the scale factor
  4317. * @param result defines the Matrix to store the result
  4318. * @returns the current matrix
  4319. */
  4320. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4321. /**
  4322. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4323. * @param ref matrix to store the result
  4324. */
  4325. toNormalMatrix(ref: Matrix): void;
  4326. /**
  4327. * Gets only rotation part of the current matrix
  4328. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4329. */
  4330. getRotationMatrix(): Matrix;
  4331. /**
  4332. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4333. * @param result defines the target matrix to store data to
  4334. * @returns the current matrix
  4335. */
  4336. getRotationMatrixToRef(result: Matrix): Matrix;
  4337. /**
  4338. * Toggles model matrix from being right handed to left handed in place and vice versa
  4339. */
  4340. toggleModelMatrixHandInPlace(): void;
  4341. /**
  4342. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4343. */
  4344. toggleProjectionMatrixHandInPlace(): void;
  4345. /**
  4346. * Creates a matrix from an array
  4347. * @param array defines the source array
  4348. * @param offset defines an offset in the source array
  4349. * @returns a new Matrix set from the starting index of the given array
  4350. */
  4351. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4352. /**
  4353. * Copy the content of an array into a given matrix
  4354. * @param array defines the source array
  4355. * @param offset defines an offset in the source array
  4356. * @param result defines the target matrix
  4357. */
  4358. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4359. /**
  4360. * Stores an array into a matrix after having multiplied each component by a given factor
  4361. * @param array defines the source array
  4362. * @param offset defines the offset in the source array
  4363. * @param scale defines the scaling factor
  4364. * @param result defines the target matrix
  4365. */
  4366. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4367. /**
  4368. * Gets an identity matrix that must not be updated
  4369. */
  4370. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4371. /**
  4372. * Stores a list of values (16) inside a given matrix
  4373. * @param initialM11 defines 1st value of 1st row
  4374. * @param initialM12 defines 2nd value of 1st row
  4375. * @param initialM13 defines 3rd value of 1st row
  4376. * @param initialM14 defines 4th value of 1st row
  4377. * @param initialM21 defines 1st value of 2nd row
  4378. * @param initialM22 defines 2nd value of 2nd row
  4379. * @param initialM23 defines 3rd value of 2nd row
  4380. * @param initialM24 defines 4th value of 2nd row
  4381. * @param initialM31 defines 1st value of 3rd row
  4382. * @param initialM32 defines 2nd value of 3rd row
  4383. * @param initialM33 defines 3rd value of 3rd row
  4384. * @param initialM34 defines 4th value of 3rd row
  4385. * @param initialM41 defines 1st value of 4th row
  4386. * @param initialM42 defines 2nd value of 4th row
  4387. * @param initialM43 defines 3rd value of 4th row
  4388. * @param initialM44 defines 4th value of 4th row
  4389. * @param result defines the target matrix
  4390. */
  4391. 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;
  4392. /**
  4393. * Creates new matrix from a list of values (16)
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @returns the new matrix
  4411. */
  4412. 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;
  4413. /**
  4414. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4415. * @param scale defines the scale vector3
  4416. * @param rotation defines the rotation quaternion
  4417. * @param translation defines the translation vector3
  4418. * @returns a new matrix
  4419. */
  4420. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4421. /**
  4422. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4423. * @param scale defines the scale vector3
  4424. * @param rotation defines the rotation quaternion
  4425. * @param translation defines the translation vector3
  4426. * @param result defines the target matrix
  4427. */
  4428. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a new identity matrix
  4431. * @returns a new identity matrix
  4432. */
  4433. static Identity(): Matrix;
  4434. /**
  4435. * Creates a new identity matrix and stores the result in a given matrix
  4436. * @param result defines the target matrix
  4437. */
  4438. static IdentityToRef(result: Matrix): void;
  4439. /**
  4440. * Creates a new zero matrix
  4441. * @returns a new zero matrix
  4442. */
  4443. static Zero(): Matrix;
  4444. /**
  4445. * Creates a new rotation matrix for "angle" radians around the X axis
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationX(angle: number): Matrix;
  4450. /**
  4451. * Creates a new matrix as the invert of a given matrix
  4452. * @param source defines the source matrix
  4453. * @returns the new matrix
  4454. */
  4455. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4456. /**
  4457. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4458. * @param angle defines the angle (in radians) to use
  4459. * @param result defines the target matrix
  4460. */
  4461. static RotationXToRef(angle: number, result: Matrix): void;
  4462. /**
  4463. * Creates a new rotation matrix for "angle" radians around the Y axis
  4464. * @param angle defines the angle (in radians) to use
  4465. * @return the new matrix
  4466. */
  4467. static RotationY(angle: number): Matrix;
  4468. /**
  4469. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4470. * @param angle defines the angle (in radians) to use
  4471. * @param result defines the target matrix
  4472. */
  4473. static RotationYToRef(angle: number, result: Matrix): void;
  4474. /**
  4475. * Creates a new rotation matrix for "angle" radians around the Z axis
  4476. * @param angle defines the angle (in radians) to use
  4477. * @return the new matrix
  4478. */
  4479. static RotationZ(angle: number): Matrix;
  4480. /**
  4481. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4482. * @param angle defines the angle (in radians) to use
  4483. * @param result defines the target matrix
  4484. */
  4485. static RotationZToRef(angle: number, result: Matrix): void;
  4486. /**
  4487. * Creates a new rotation matrix for "angle" radians around the given axis
  4488. * @param axis defines the axis to use
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4495. * @param axis defines the axis to use
  4496. * @param angle defines the angle (in radians) to use
  4497. * @param result defines the target matrix
  4498. */
  4499. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4500. /**
  4501. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4502. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4503. * @param from defines the vector to align
  4504. * @param to defines the vector to align to
  4505. * @param result defines the target matrix
  4506. */
  4507. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4508. /**
  4509. * Creates a rotation matrix
  4510. * @param yaw defines the yaw angle in radians (Y axis)
  4511. * @param pitch defines the pitch angle in radians (X axis)
  4512. * @param roll defines the roll angle in radians (Z axis)
  4513. * @returns the new rotation matrix
  4514. */
  4515. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4516. /**
  4517. * Creates a rotation matrix and stores it in a given matrix
  4518. * @param yaw defines the yaw angle in radians (Y axis)
  4519. * @param pitch defines the pitch angle in radians (X axis)
  4520. * @param roll defines the roll angle in radians (Z axis)
  4521. * @param result defines the target matrix
  4522. */
  4523. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4524. /**
  4525. * Creates a scaling matrix
  4526. * @param x defines the scale factor on X axis
  4527. * @param y defines the scale factor on Y axis
  4528. * @param z defines the scale factor on Z axis
  4529. * @returns the new matrix
  4530. */
  4531. static Scaling(x: number, y: number, z: number): Matrix;
  4532. /**
  4533. * Creates a scaling matrix and stores it in a given matrix
  4534. * @param x defines the scale factor on X axis
  4535. * @param y defines the scale factor on Y axis
  4536. * @param z defines the scale factor on Z axis
  4537. * @param result defines the target matrix
  4538. */
  4539. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4540. /**
  4541. * Creates a translation matrix
  4542. * @param x defines the translation on X axis
  4543. * @param y defines the translation on Y axis
  4544. * @param z defines the translationon Z axis
  4545. * @returns the new matrix
  4546. */
  4547. static Translation(x: number, y: number, z: number): Matrix;
  4548. /**
  4549. * Creates a translation matrix and stores it in a given matrix
  4550. * @param x defines the translation on X axis
  4551. * @param y defines the translation on Y axis
  4552. * @param z defines the translationon Z axis
  4553. * @param result defines the target matrix
  4554. */
  4555. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4556. /**
  4557. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4558. * @param startValue defines the start value
  4559. * @param endValue defines the end value
  4560. * @param gradient defines the gradient factor
  4561. * @returns the new matrix
  4562. */
  4563. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4564. /**
  4565. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4566. * @param startValue defines the start value
  4567. * @param endValue defines the end value
  4568. * @param gradient defines the gradient factor
  4569. * @param result defines the Matrix object where to store data
  4570. */
  4571. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4572. /**
  4573. * Builds a new matrix whose values are computed by:
  4574. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4575. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4576. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4577. * @param startValue defines the first matrix
  4578. * @param endValue defines the second matrix
  4579. * @param gradient defines the gradient between the two matrices
  4580. * @returns the new matrix
  4581. */
  4582. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4583. /**
  4584. * Update a matrix to values which are computed by:
  4585. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4586. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4587. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4588. * @param startValue defines the first matrix
  4589. * @param endValue defines the second matrix
  4590. * @param gradient defines the gradient between the two matrices
  4591. * @param result defines the target matrix
  4592. */
  4593. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4594. /**
  4595. * 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"
  4596. * This function works in left handed mode
  4597. * @param eye defines the final position of the entity
  4598. * @param target defines where the entity should look at
  4599. * @param up defines the up vector for the entity
  4600. * @returns the new matrix
  4601. */
  4602. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4603. /**
  4604. * 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".
  4605. * This function works in left handed mode
  4606. * @param eye defines the final position of the entity
  4607. * @param target defines where the entity should look at
  4608. * @param up defines the up vector for the entity
  4609. * @param result defines the target matrix
  4610. */
  4611. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4612. /**
  4613. * 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"
  4614. * This function works in right handed mode
  4615. * @param eye defines the final position of the entity
  4616. * @param target defines where the entity should look at
  4617. * @param up defines the up vector for the entity
  4618. * @returns the new matrix
  4619. */
  4620. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4621. /**
  4622. * 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".
  4623. * This function works in right handed mode
  4624. * @param eye defines the final position of the entity
  4625. * @param target defines where the entity should look at
  4626. * @param up defines the up vector for the entity
  4627. * @param result defines the target matrix
  4628. */
  4629. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4630. /**
  4631. * Create a left-handed orthographic projection matrix
  4632. * @param width defines the viewport width
  4633. * @param height defines the viewport height
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed orthographic projection matrix
  4637. */
  4638. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Store a left-handed orthographic projection to a given matrix
  4641. * @param width defines the viewport width
  4642. * @param height defines the viewport height
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. */
  4647. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4648. /**
  4649. * Create a left-handed orthographic projection matrix
  4650. * @param left defines the viewport left coordinate
  4651. * @param right defines the viewport right coordinate
  4652. * @param bottom defines the viewport bottom coordinate
  4653. * @param top defines the viewport top coordinate
  4654. * @param znear defines the near clip plane
  4655. * @param zfar defines the far clip plane
  4656. * @returns a new matrix as a left-handed orthographic projection matrix
  4657. */
  4658. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4659. /**
  4660. * Stores a left-handed orthographic projection into a given matrix
  4661. * @param left defines the viewport left coordinate
  4662. * @param right defines the viewport right coordinate
  4663. * @param bottom defines the viewport bottom coordinate
  4664. * @param top defines the viewport top coordinate
  4665. * @param znear defines the near clip plane
  4666. * @param zfar defines the far clip plane
  4667. * @param result defines the target matrix
  4668. */
  4669. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4670. /**
  4671. * Creates a right-handed orthographic projection matrix
  4672. * @param left defines the viewport left coordinate
  4673. * @param right defines the viewport right coordinate
  4674. * @param bottom defines the viewport bottom coordinate
  4675. * @param top defines the viewport top coordinate
  4676. * @param znear defines the near clip plane
  4677. * @param zfar defines the far clip plane
  4678. * @returns a new matrix as a right-handed orthographic projection matrix
  4679. */
  4680. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4681. /**
  4682. * Stores a right-handed orthographic projection into a given matrix
  4683. * @param left defines the viewport left coordinate
  4684. * @param right defines the viewport right coordinate
  4685. * @param bottom defines the viewport bottom coordinate
  4686. * @param top defines the viewport top coordinate
  4687. * @param znear defines the near clip plane
  4688. * @param zfar defines the far clip plane
  4689. * @param result defines the target matrix
  4690. */
  4691. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4692. /**
  4693. * Creates a left-handed perspective projection matrix
  4694. * @param width defines the viewport width
  4695. * @param height defines the viewport height
  4696. * @param znear defines the near clip plane
  4697. * @param zfar defines the far clip plane
  4698. * @returns a new matrix as a left-handed perspective projection matrix
  4699. */
  4700. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4701. /**
  4702. * Creates a left-handed perspective projection matrix
  4703. * @param fov defines the horizontal field of view
  4704. * @param aspect defines the aspect ratio
  4705. * @param znear defines the near clip plane
  4706. * @param zfar defines the far clip plane
  4707. * @returns a new matrix as a left-handed perspective projection matrix
  4708. */
  4709. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4710. /**
  4711. * Stores a left-handed perspective projection into a given matrix
  4712. * @param fov defines the horizontal field of view
  4713. * @param aspect defines the aspect ratio
  4714. * @param znear defines the near clip plane
  4715. * @param zfar defines the far clip plane
  4716. * @param result defines the target matrix
  4717. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4718. */
  4719. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4720. /**
  4721. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4722. * @param fov defines the horizontal field of view
  4723. * @param aspect defines the aspect ratio
  4724. * @param znear defines the near clip plane
  4725. * @param zfar not used as infinity is used as far clip
  4726. * @param result defines the target matrix
  4727. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4728. */
  4729. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4730. /**
  4731. * Creates a right-handed perspective projection matrix
  4732. * @param fov defines the horizontal field of view
  4733. * @param aspect defines the aspect ratio
  4734. * @param znear defines the near clip plane
  4735. * @param zfar defines the far clip plane
  4736. * @returns a new matrix as a right-handed perspective projection matrix
  4737. */
  4738. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4739. /**
  4740. * Stores a right-handed perspective projection into a given matrix
  4741. * @param fov defines the horizontal field of view
  4742. * @param aspect defines the aspect ratio
  4743. * @param znear defines the near clip plane
  4744. * @param zfar defines the far clip plane
  4745. * @param result defines the target matrix
  4746. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4747. */
  4748. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4749. /**
  4750. * Stores a right-handed perspective projection into a given matrix
  4751. * @param fov defines the horizontal field of view
  4752. * @param aspect defines the aspect ratio
  4753. * @param znear defines the near clip plane
  4754. * @param zfar not used as infinity is used as far clip
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a perspective projection for WebVR info a given matrix
  4761. * @param fov defines the field of view
  4762. * @param znear defines the near clip plane
  4763. * @param zfar defines the far clip plane
  4764. * @param result defines the target matrix
  4765. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4766. */
  4767. static PerspectiveFovWebVRToRef(fov: {
  4768. upDegrees: number;
  4769. downDegrees: number;
  4770. leftDegrees: number;
  4771. rightDegrees: number;
  4772. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4773. /**
  4774. * Computes a complete transformation matrix
  4775. * @param viewport defines the viewport to use
  4776. * @param world defines the world matrix
  4777. * @param view defines the view matrix
  4778. * @param projection defines the projection matrix
  4779. * @param zmin defines the near clip plane
  4780. * @param zmax defines the far clip plane
  4781. * @returns the transformation matrix
  4782. */
  4783. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4784. /**
  4785. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4786. * @param matrix defines the matrix to use
  4787. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4788. */
  4789. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4790. /**
  4791. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4792. * @param matrix defines the matrix to use
  4793. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4794. */
  4795. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4796. /**
  4797. * Compute the transpose of a given matrix
  4798. * @param matrix defines the matrix to transpose
  4799. * @returns the new matrix
  4800. */
  4801. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4802. /**
  4803. * Compute the transpose of a matrix and store it in a target matrix
  4804. * @param matrix defines the matrix to transpose
  4805. * @param result defines the target matrix
  4806. */
  4807. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4808. /**
  4809. * Computes a reflection matrix from a plane
  4810. * @param plane defines the reflection plane
  4811. * @returns a new matrix
  4812. */
  4813. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4814. /**
  4815. * Computes a reflection matrix from a plane
  4816. * @param plane defines the reflection plane
  4817. * @param result defines the target matrix
  4818. */
  4819. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4820. /**
  4821. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4822. * @param xaxis defines the value of the 1st axis
  4823. * @param yaxis defines the value of the 2nd axis
  4824. * @param zaxis defines the value of the 3rd axis
  4825. * @param result defines the target matrix
  4826. */
  4827. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4828. /**
  4829. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4830. * @param quat defines the quaternion to use
  4831. * @param result defines the target matrix
  4832. */
  4833. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4834. }
  4835. /**
  4836. * @hidden
  4837. */
  4838. export class TmpVectors {
  4839. static Vector2: Vector2[];
  4840. static Vector3: Vector3[];
  4841. static Vector4: Vector4[];
  4842. static Quaternion: Quaternion[];
  4843. static Matrix: Matrix[];
  4844. }
  4845. }
  4846. declare module "babylonjs/Maths/math.path" {
  4847. import { DeepImmutable, Nullable } from "babylonjs/types";
  4848. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4849. /**
  4850. * Defines potential orientation for back face culling
  4851. */
  4852. export enum Orientation {
  4853. /**
  4854. * Clockwise
  4855. */
  4856. CW = 0,
  4857. /** Counter clockwise */
  4858. CCW = 1
  4859. }
  4860. /** Class used to represent a Bezier curve */
  4861. export class BezierCurve {
  4862. /**
  4863. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4864. * @param t defines the time
  4865. * @param x1 defines the left coordinate on X axis
  4866. * @param y1 defines the left coordinate on Y axis
  4867. * @param x2 defines the right coordinate on X axis
  4868. * @param y2 defines the right coordinate on Y axis
  4869. * @returns the interpolated value
  4870. */
  4871. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4872. }
  4873. /**
  4874. * Defines angle representation
  4875. */
  4876. export class Angle {
  4877. private _radians;
  4878. /**
  4879. * Creates an Angle object of "radians" radians (float).
  4880. * @param radians the angle in radians
  4881. */
  4882. constructor(radians: number);
  4883. /**
  4884. * Get value in degrees
  4885. * @returns the Angle value in degrees (float)
  4886. */
  4887. degrees(): number;
  4888. /**
  4889. * Get value in radians
  4890. * @returns the Angle value in radians (float)
  4891. */
  4892. radians(): number;
  4893. /**
  4894. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4895. * @param a defines first point as the origin
  4896. * @param b defines point
  4897. * @returns a new Angle
  4898. */
  4899. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4900. /**
  4901. * Gets a new Angle object from the given float in radians
  4902. * @param radians defines the angle value in radians
  4903. * @returns a new Angle
  4904. */
  4905. static FromRadians(radians: number): Angle;
  4906. /**
  4907. * Gets a new Angle object from the given float in degrees
  4908. * @param degrees defines the angle value in degrees
  4909. * @returns a new Angle
  4910. */
  4911. static FromDegrees(degrees: number): Angle;
  4912. }
  4913. /**
  4914. * This represents an arc in a 2d space.
  4915. */
  4916. export class Arc2 {
  4917. /** Defines the start point of the arc */
  4918. startPoint: Vector2;
  4919. /** Defines the mid point of the arc */
  4920. midPoint: Vector2;
  4921. /** Defines the end point of the arc */
  4922. endPoint: Vector2;
  4923. /**
  4924. * Defines the center point of the arc.
  4925. */
  4926. centerPoint: Vector2;
  4927. /**
  4928. * Defines the radius of the arc.
  4929. */
  4930. radius: number;
  4931. /**
  4932. * Defines the angle of the arc (from mid point to end point).
  4933. */
  4934. angle: Angle;
  4935. /**
  4936. * Defines the start angle of the arc (from start point to middle point).
  4937. */
  4938. startAngle: Angle;
  4939. /**
  4940. * Defines the orientation of the arc (clock wise/counter clock wise).
  4941. */
  4942. orientation: Orientation;
  4943. /**
  4944. * Creates an Arc object from the three given points : start, middle and end.
  4945. * @param startPoint Defines the start point of the arc
  4946. * @param midPoint Defines the midlle point of the arc
  4947. * @param endPoint Defines the end point of the arc
  4948. */
  4949. constructor(
  4950. /** Defines the start point of the arc */
  4951. startPoint: Vector2,
  4952. /** Defines the mid point of the arc */
  4953. midPoint: Vector2,
  4954. /** Defines the end point of the arc */
  4955. endPoint: Vector2);
  4956. }
  4957. /**
  4958. * Represents a 2D path made up of multiple 2D points
  4959. */
  4960. export class Path2 {
  4961. private _points;
  4962. private _length;
  4963. /**
  4964. * If the path start and end point are the same
  4965. */
  4966. closed: boolean;
  4967. /**
  4968. * Creates a Path2 object from the starting 2D coordinates x and y.
  4969. * @param x the starting points x value
  4970. * @param y the starting points y value
  4971. */
  4972. constructor(x: number, y: number);
  4973. /**
  4974. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4975. * @param x the added points x value
  4976. * @param y the added points y value
  4977. * @returns the updated Path2.
  4978. */
  4979. addLineTo(x: number, y: number): Path2;
  4980. /**
  4981. * 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.
  4982. * @param midX middle point x value
  4983. * @param midY middle point y value
  4984. * @param endX end point x value
  4985. * @param endY end point y value
  4986. * @param numberOfSegments (default: 36)
  4987. * @returns the updated Path2.
  4988. */
  4989. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4990. /**
  4991. * Closes the Path2.
  4992. * @returns the Path2.
  4993. */
  4994. close(): Path2;
  4995. /**
  4996. * Gets the sum of the distance between each sequential point in the path
  4997. * @returns the Path2 total length (float).
  4998. */
  4999. length(): number;
  5000. /**
  5001. * Gets the points which construct the path
  5002. * @returns the Path2 internal array of points.
  5003. */
  5004. getPoints(): Vector2[];
  5005. /**
  5006. * Retreives the point at the distance aways from the starting point
  5007. * @param normalizedLengthPosition the length along the path to retreive the point from
  5008. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5009. */
  5010. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5011. /**
  5012. * Creates a new path starting from an x and y position
  5013. * @param x starting x value
  5014. * @param y starting y value
  5015. * @returns a new Path2 starting at the coordinates (x, y).
  5016. */
  5017. static StartingAt(x: number, y: number): Path2;
  5018. }
  5019. /**
  5020. * Represents a 3D path made up of multiple 3D points
  5021. */
  5022. export class Path3D {
  5023. /**
  5024. * an array of Vector3, the curve axis of the Path3D
  5025. */
  5026. path: Vector3[];
  5027. private _curve;
  5028. private _distances;
  5029. private _tangents;
  5030. private _normals;
  5031. private _binormals;
  5032. private _raw;
  5033. private _alignTangentsWithPath;
  5034. private readonly _pointAtData;
  5035. /**
  5036. * new Path3D(path, normal, raw)
  5037. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5038. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5039. * @param path an array of Vector3, the curve axis of the Path3D
  5040. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5041. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5042. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5043. */
  5044. constructor(
  5045. /**
  5046. * an array of Vector3, the curve axis of the Path3D
  5047. */
  5048. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5049. /**
  5050. * Returns the Path3D array of successive Vector3 designing its curve.
  5051. * @returns the Path3D array of successive Vector3 designing its curve.
  5052. */
  5053. getCurve(): Vector3[];
  5054. /**
  5055. * Returns the Path3D array of successive Vector3 designing its curve.
  5056. * @returns the Path3D array of successive Vector3 designing its curve.
  5057. */
  5058. getPoints(): Vector3[];
  5059. /**
  5060. * @returns the computed length (float) of the path.
  5061. */
  5062. length(): number;
  5063. /**
  5064. * Returns an array populated with tangent vectors on each Path3D curve point.
  5065. * @returns an array populated with tangent vectors on each Path3D curve point.
  5066. */
  5067. getTangents(): Vector3[];
  5068. /**
  5069. * Returns an array populated with normal vectors on each Path3D curve point.
  5070. * @returns an array populated with normal vectors on each Path3D curve point.
  5071. */
  5072. getNormals(): Vector3[];
  5073. /**
  5074. * Returns an array populated with binormal vectors on each Path3D curve point.
  5075. * @returns an array populated with binormal vectors on each Path3D curve point.
  5076. */
  5077. getBinormals(): Vector3[];
  5078. /**
  5079. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5080. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5081. */
  5082. getDistances(): number[];
  5083. /**
  5084. * Returns an interpolated point along this path
  5085. * @param position the position of the point along this path, from 0.0 to 1.0
  5086. * @returns a new Vector3 as the point
  5087. */
  5088. getPointAt(position: number): Vector3;
  5089. /**
  5090. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5091. * @param position the position of the point along this path, from 0.0 to 1.0
  5092. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5093. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5094. */
  5095. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5096. /**
  5097. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5098. * @param position the position of the point along this path, from 0.0 to 1.0
  5099. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5100. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5101. */
  5102. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5103. /**
  5104. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5105. * @param position the position of the point along this path, from 0.0 to 1.0
  5106. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5107. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5108. */
  5109. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5110. /**
  5111. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5114. */
  5115. getDistanceAt(position: number): number;
  5116. /**
  5117. * Returns the array index of the previous point of an interpolated point along this path
  5118. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5119. * @returns the array index
  5120. */
  5121. getPreviousPointIndexAt(position: number): number;
  5122. /**
  5123. * 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)
  5124. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5125. * @returns the sub position
  5126. */
  5127. getSubPositionAt(position: number): number;
  5128. /**
  5129. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5130. * @param target the vector of which to get the closest position to
  5131. * @returns the position of the closest virtual point on this path to the target vector
  5132. */
  5133. getClosestPositionTo(target: Vector3): number;
  5134. /**
  5135. * Returns a sub path (slice) of this path
  5136. * @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
  5137. * @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
  5138. * @returns a sub path (slice) of this path
  5139. */
  5140. slice(start?: number, end?: number): Path3D;
  5141. /**
  5142. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5143. * @param path path which all values are copied into the curves points
  5144. * @param firstNormal which should be projected onto the curve
  5145. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5146. * @returns the same object updated.
  5147. */
  5148. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5149. private _compute;
  5150. private _getFirstNonNullVector;
  5151. private _getLastNonNullVector;
  5152. private _normalVector;
  5153. /**
  5154. * Updates the point at data for an interpolated point along this curve
  5155. * @param position the position of the point along this curve, from 0.0 to 1.0
  5156. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5157. * @returns the (updated) point at data
  5158. */
  5159. private _updatePointAtData;
  5160. /**
  5161. * Updates the point at data from the specified parameters
  5162. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5163. * @param point the interpolated point
  5164. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5165. */
  5166. private _setPointAtData;
  5167. /**
  5168. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5169. */
  5170. private _updateInterpolationMatrix;
  5171. }
  5172. /**
  5173. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5174. * A Curve3 is designed from a series of successive Vector3.
  5175. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5176. */
  5177. export class Curve3 {
  5178. private _points;
  5179. private _length;
  5180. /**
  5181. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5182. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5183. * @param v1 (Vector3) the control point
  5184. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5185. * @param nbPoints (integer) the wanted number of points in the curve
  5186. * @returns the created Curve3
  5187. */
  5188. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5189. /**
  5190. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5191. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5192. * @param v1 (Vector3) the first control point
  5193. * @param v2 (Vector3) the second control point
  5194. * @param v3 (Vector3) the end point of the Cubic Bezier
  5195. * @param nbPoints (integer) the wanted number of points in the curve
  5196. * @returns the created Curve3
  5197. */
  5198. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5199. /**
  5200. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5201. * @param p1 (Vector3) the origin point of the Hermite Spline
  5202. * @param t1 (Vector3) the tangent vector at the origin point
  5203. * @param p2 (Vector3) the end point of the Hermite Spline
  5204. * @param t2 (Vector3) the tangent vector at the end point
  5205. * @param nbPoints (integer) the wanted number of points in the curve
  5206. * @returns the created Curve3
  5207. */
  5208. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5209. /**
  5210. * Returns a Curve3 object along a CatmullRom Spline curve :
  5211. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5212. * @param nbPoints (integer) the wanted number of points between each curve control points
  5213. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5214. * @returns the created Curve3
  5215. */
  5216. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5217. /**
  5218. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5219. * A Curve3 is designed from a series of successive Vector3.
  5220. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5221. * @param points points which make up the curve
  5222. */
  5223. constructor(points: Vector3[]);
  5224. /**
  5225. * @returns the Curve3 stored array of successive Vector3
  5226. */
  5227. getPoints(): Vector3[];
  5228. /**
  5229. * @returns the computed length (float) of the curve.
  5230. */
  5231. length(): number;
  5232. /**
  5233. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5234. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5235. * curveA and curveB keep unchanged.
  5236. * @param curve the curve to continue from this curve
  5237. * @returns the newly constructed curve
  5238. */
  5239. continue(curve: DeepImmutable<Curve3>): Curve3;
  5240. private _computeLength;
  5241. }
  5242. }
  5243. declare module "babylonjs/Animations/easing" {
  5244. /**
  5245. * This represents the main contract an easing function should follow.
  5246. * Easing functions are used throughout the animation system.
  5247. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export interface IEasingFunction {
  5250. /**
  5251. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5252. * of the easing function.
  5253. * The link below provides some of the most common examples of easing functions.
  5254. * @see https://easings.net/
  5255. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5256. * @returns the corresponding value on the curve defined by the easing function
  5257. */
  5258. ease(gradient: number): number;
  5259. }
  5260. /**
  5261. * Base class used for every default easing function.
  5262. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5263. */
  5264. export class EasingFunction implements IEasingFunction {
  5265. /**
  5266. * Interpolation follows the mathematical formula associated with the easing function.
  5267. */
  5268. static readonly EASINGMODE_EASEIN: number;
  5269. /**
  5270. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5271. */
  5272. static readonly EASINGMODE_EASEOUT: number;
  5273. /**
  5274. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5275. */
  5276. static readonly EASINGMODE_EASEINOUT: number;
  5277. private _easingMode;
  5278. /**
  5279. * Sets the easing mode of the current function.
  5280. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5281. */
  5282. setEasingMode(easingMode: number): void;
  5283. /**
  5284. * Gets the current easing mode.
  5285. * @returns the easing mode
  5286. */
  5287. getEasingMode(): number;
  5288. /**
  5289. * @hidden
  5290. */
  5291. easeInCore(gradient: number): number;
  5292. /**
  5293. * Given an input gradient between 0 and 1, this returns the corresponding value
  5294. * of the easing function.
  5295. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5296. * @returns the corresponding value on the curve defined by the easing function
  5297. */
  5298. ease(gradient: number): number;
  5299. }
  5300. /**
  5301. * Easing function with a circle shape (see link below).
  5302. * @see https://easings.net/#easeInCirc
  5303. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5304. */
  5305. export class CircleEase extends EasingFunction implements IEasingFunction {
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a ease back shape (see link below).
  5311. * @see https://easings.net/#easeInBack
  5312. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class BackEase extends EasingFunction implements IEasingFunction {
  5315. /** Defines the amplitude of the function */
  5316. amplitude: number;
  5317. /**
  5318. * Instantiates a back ease easing
  5319. * @see https://easings.net/#easeInBack
  5320. * @param amplitude Defines the amplitude of the function
  5321. */
  5322. constructor(
  5323. /** Defines the amplitude of the function */
  5324. amplitude?: number);
  5325. /** @hidden */
  5326. easeInCore(gradient: number): number;
  5327. }
  5328. /**
  5329. * Easing function with a bouncing shape (see link below).
  5330. * @see https://easings.net/#easeInBounce
  5331. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5332. */
  5333. export class BounceEase extends EasingFunction implements IEasingFunction {
  5334. /** Defines the number of bounces */
  5335. bounces: number;
  5336. /** Defines the amplitude of the bounce */
  5337. bounciness: number;
  5338. /**
  5339. * Instantiates a bounce easing
  5340. * @see https://easings.net/#easeInBounce
  5341. * @param bounces Defines the number of bounces
  5342. * @param bounciness Defines the amplitude of the bounce
  5343. */
  5344. constructor(
  5345. /** Defines the number of bounces */
  5346. bounces?: number,
  5347. /** Defines the amplitude of the bounce */
  5348. bounciness?: number);
  5349. /** @hidden */
  5350. easeInCore(gradient: number): number;
  5351. }
  5352. /**
  5353. * Easing function with a power of 3 shape (see link below).
  5354. * @see https://easings.net/#easeInCubic
  5355. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5356. */
  5357. export class CubicEase extends EasingFunction implements IEasingFunction {
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with an elastic shape (see link below).
  5363. * @see https://easings.net/#easeInElastic
  5364. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the number of oscillations*/
  5368. oscillations: number;
  5369. /** Defines the amplitude of the oscillations*/
  5370. springiness: number;
  5371. /**
  5372. * Instantiates an elastic easing function
  5373. * @see https://easings.net/#easeInElastic
  5374. * @param oscillations Defines the number of oscillations
  5375. * @param springiness Defines the amplitude of the oscillations
  5376. */
  5377. constructor(
  5378. /** Defines the number of oscillations*/
  5379. oscillations?: number,
  5380. /** Defines the amplitude of the oscillations*/
  5381. springiness?: number);
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with an exponential shape (see link below).
  5387. * @see https://easings.net/#easeInExpo
  5388. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the exponent of the function */
  5392. exponent: number;
  5393. /**
  5394. * Instantiates an exponential easing function
  5395. * @see https://easings.net/#easeInExpo
  5396. * @param exponent Defines the exponent of the function
  5397. */
  5398. constructor(
  5399. /** Defines the exponent of the function */
  5400. exponent?: number);
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with a power shape (see link below).
  5406. * @see https://easings.net/#easeInQuad
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class PowerEase extends EasingFunction implements IEasingFunction {
  5410. /** Defines the power of the function */
  5411. power: number;
  5412. /**
  5413. * Instantiates an power base easing function
  5414. * @see https://easings.net/#easeInQuad
  5415. * @param power Defines the power of the function
  5416. */
  5417. constructor(
  5418. /** Defines the power of the function */
  5419. power?: number);
  5420. /** @hidden */
  5421. easeInCore(gradient: number): number;
  5422. }
  5423. /**
  5424. * Easing function with a power of 2 shape (see link below).
  5425. * @see https://easings.net/#easeInQuad
  5426. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5427. */
  5428. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5429. /** @hidden */
  5430. easeInCore(gradient: number): number;
  5431. }
  5432. /**
  5433. * Easing function with a power of 4 shape (see link below).
  5434. * @see https://easings.net/#easeInQuart
  5435. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5436. */
  5437. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5438. /** @hidden */
  5439. easeInCore(gradient: number): number;
  5440. }
  5441. /**
  5442. * Easing function with a power of 5 shape (see link below).
  5443. * @see https://easings.net/#easeInQuint
  5444. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5445. */
  5446. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. /**
  5451. * Easing function with a sin shape (see link below).
  5452. * @see https://easings.net/#easeInSine
  5453. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5454. */
  5455. export class SineEase extends EasingFunction implements IEasingFunction {
  5456. /** @hidden */
  5457. easeInCore(gradient: number): number;
  5458. }
  5459. /**
  5460. * Easing function with a bezier shape (see link below).
  5461. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5462. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5463. */
  5464. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1: number;
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1: number;
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2: number;
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2: number;
  5473. /**
  5474. * Instantiates a bezier function
  5475. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5476. * @param x1 Defines the x component of the start tangent in the bezier curve
  5477. * @param y1 Defines the y component of the start tangent in the bezier curve
  5478. * @param x2 Defines the x component of the end tangent in the bezier curve
  5479. * @param y2 Defines the y component of the end tangent in the bezier curve
  5480. */
  5481. constructor(
  5482. /** Defines the x component of the start tangent in the bezier curve */
  5483. x1?: number,
  5484. /** Defines the y component of the start tangent in the bezier curve */
  5485. y1?: number,
  5486. /** Defines the x component of the end tangent in the bezier curve */
  5487. x2?: number,
  5488. /** Defines the y component of the end tangent in the bezier curve */
  5489. y2?: number);
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. }
  5494. declare module "babylonjs/Maths/math.color" {
  5495. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5496. /**
  5497. * Class used to hold a RBG color
  5498. */
  5499. export class Color3 {
  5500. /**
  5501. * Defines the red component (between 0 and 1, default is 0)
  5502. */
  5503. r: number;
  5504. /**
  5505. * Defines the green component (between 0 and 1, default is 0)
  5506. */
  5507. g: number;
  5508. /**
  5509. * Defines the blue component (between 0 and 1, default is 0)
  5510. */
  5511. b: number;
  5512. /**
  5513. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5514. * @param r defines the red component (between 0 and 1, default is 0)
  5515. * @param g defines the green component (between 0 and 1, default is 0)
  5516. * @param b defines the blue component (between 0 and 1, default is 0)
  5517. */
  5518. constructor(
  5519. /**
  5520. * Defines the red component (between 0 and 1, default is 0)
  5521. */
  5522. r?: number,
  5523. /**
  5524. * Defines the green component (between 0 and 1, default is 0)
  5525. */
  5526. g?: number,
  5527. /**
  5528. * Defines the blue component (between 0 and 1, default is 0)
  5529. */
  5530. b?: number);
  5531. /**
  5532. * Creates a string with the Color3 current values
  5533. * @returns the string representation of the Color3 object
  5534. */
  5535. toString(): string;
  5536. /**
  5537. * Returns the string "Color3"
  5538. * @returns "Color3"
  5539. */
  5540. getClassName(): string;
  5541. /**
  5542. * Compute the Color3 hash code
  5543. * @returns an unique number that can be used to hash Color3 objects
  5544. */
  5545. getHashCode(): number;
  5546. /**
  5547. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5548. * @param array defines the array where to store the r,g,b components
  5549. * @param index defines an optional index in the target array to define where to start storing values
  5550. * @returns the current Color3 object
  5551. */
  5552. toArray(array: FloatArray, index?: number): Color3;
  5553. /**
  5554. * Returns a new Color4 object from the current Color3 and the given alpha
  5555. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5556. * @returns a new Color4 object
  5557. */
  5558. toColor4(alpha?: number): Color4;
  5559. /**
  5560. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5561. * @returns the new array
  5562. */
  5563. asArray(): number[];
  5564. /**
  5565. * Returns the luminance value
  5566. * @returns a float value
  5567. */
  5568. toLuminance(): number;
  5569. /**
  5570. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5571. * @param otherColor defines the second operand
  5572. * @returns the new Color3 object
  5573. */
  5574. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5575. /**
  5576. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5577. * @param otherColor defines the second operand
  5578. * @param result defines the Color3 object where to store the result
  5579. * @returns the current Color3
  5580. */
  5581. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5582. /**
  5583. * Determines equality between Color3 objects
  5584. * @param otherColor defines the second operand
  5585. * @returns true if the rgb values are equal to the given ones
  5586. */
  5587. equals(otherColor: DeepImmutable<Color3>): boolean;
  5588. /**
  5589. * Determines equality between the current Color3 object and a set of r,b,g values
  5590. * @param r defines the red component to check
  5591. * @param g defines the green component to check
  5592. * @param b defines the blue component to check
  5593. * @returns true if the rgb values are equal to the given ones
  5594. */
  5595. equalsFloats(r: number, g: number, b: number): boolean;
  5596. /**
  5597. * Multiplies in place each rgb value by scale
  5598. * @param scale defines the scaling factor
  5599. * @returns the updated Color3
  5600. */
  5601. scale(scale: number): Color3;
  5602. /**
  5603. * Multiplies the rgb values by scale and stores the result into "result"
  5604. * @param scale defines the scaling factor
  5605. * @param result defines the Color3 object where to store the result
  5606. * @returns the unmodified current Color3
  5607. */
  5608. scaleToRef(scale: number, result: Color3): Color3;
  5609. /**
  5610. * Scale the current Color3 values by a factor and add the result to a given Color3
  5611. * @param scale defines the scale factor
  5612. * @param result defines color to store the result into
  5613. * @returns the unmodified current Color3
  5614. */
  5615. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5616. /**
  5617. * Clamps the rgb values by the min and max values and stores the result into "result"
  5618. * @param min defines minimum clamping value (default is 0)
  5619. * @param max defines maximum clamping value (default is 1)
  5620. * @param result defines color to store the result into
  5621. * @returns the original Color3
  5622. */
  5623. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5624. /**
  5625. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5626. * @param otherColor defines the second operand
  5627. * @returns the new Color3
  5628. */
  5629. add(otherColor: DeepImmutable<Color3>): Color3;
  5630. /**
  5631. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5632. * @param otherColor defines the second operand
  5633. * @param result defines Color3 object to store the result into
  5634. * @returns the unmodified current Color3
  5635. */
  5636. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5637. /**
  5638. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5639. * @param otherColor defines the second operand
  5640. * @returns the new Color3
  5641. */
  5642. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5643. /**
  5644. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5645. * @param otherColor defines the second operand
  5646. * @param result defines Color3 object to store the result into
  5647. * @returns the unmodified current Color3
  5648. */
  5649. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5650. /**
  5651. * Copy the current object
  5652. * @returns a new Color3 copied the current one
  5653. */
  5654. clone(): Color3;
  5655. /**
  5656. * Copies the rgb values from the source in the current Color3
  5657. * @param source defines the source Color3 object
  5658. * @returns the updated Color3 object
  5659. */
  5660. copyFrom(source: DeepImmutable<Color3>): Color3;
  5661. /**
  5662. * Updates the Color3 rgb values from the given floats
  5663. * @param r defines the red component to read from
  5664. * @param g defines the green component to read from
  5665. * @param b defines the blue component to read from
  5666. * @returns the current Color3 object
  5667. */
  5668. copyFromFloats(r: number, g: number, b: number): Color3;
  5669. /**
  5670. * Updates the Color3 rgb values from the given floats
  5671. * @param r defines the red component to read from
  5672. * @param g defines the green component to read from
  5673. * @param b defines the blue component to read from
  5674. * @returns the current Color3 object
  5675. */
  5676. set(r: number, g: number, b: number): Color3;
  5677. /**
  5678. * Compute the Color3 hexadecimal code as a string
  5679. * @returns a string containing the hexadecimal representation of the Color3 object
  5680. */
  5681. toHexString(): string;
  5682. /**
  5683. * Computes a new Color3 converted from the current one to linear space
  5684. * @returns a new Color3 object
  5685. */
  5686. toLinearSpace(): Color3;
  5687. /**
  5688. * Converts current color in rgb space to HSV values
  5689. * @returns a new color3 representing the HSV values
  5690. */
  5691. toHSV(): Color3;
  5692. /**
  5693. * Converts current color in rgb space to HSV values
  5694. * @param result defines the Color3 where to store the HSV values
  5695. */
  5696. toHSVToRef(result: Color3): void;
  5697. /**
  5698. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the linear space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5703. /**
  5704. * Computes a new Color3 converted from the current one to gamma space
  5705. * @returns a new Color3 object
  5706. */
  5707. toGammaSpace(): Color3;
  5708. /**
  5709. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5710. * @param convertedColor defines the Color3 object where to store the gamma space version
  5711. * @returns the unmodified Color3
  5712. */
  5713. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5714. private static _BlackReadOnly;
  5715. /**
  5716. * Convert Hue, saturation and value to a Color3 (RGB)
  5717. * @param hue defines the hue
  5718. * @param saturation defines the saturation
  5719. * @param value defines the value
  5720. * @param result defines the Color3 where to store the RGB values
  5721. */
  5722. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5723. /**
  5724. * Creates a new Color3 from the string containing valid hexadecimal values
  5725. * @param hex defines a string containing valid hexadecimal values
  5726. * @returns a new Color3 object
  5727. */
  5728. static FromHexString(hex: string): Color3;
  5729. /**
  5730. * Creates a new Color3 from the starting index of the given array
  5731. * @param array defines the source array
  5732. * @param offset defines an offset in the source array
  5733. * @returns a new Color3 object
  5734. */
  5735. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5736. /**
  5737. * Creates a new Color3 from integer values (< 256)
  5738. * @param r defines the red component to read from (value between 0 and 255)
  5739. * @param g defines the green component to read from (value between 0 and 255)
  5740. * @param b defines the blue component to read from (value between 0 and 255)
  5741. * @returns a new Color3 object
  5742. */
  5743. static FromInts(r: number, g: number, b: number): Color3;
  5744. /**
  5745. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5746. * @param start defines the start Color3 value
  5747. * @param end defines the end Color3 value
  5748. * @param amount defines the gradient value between start and end
  5749. * @returns a new Color3 object
  5750. */
  5751. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5752. /**
  5753. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5754. * @param left defines the start value
  5755. * @param right defines the end value
  5756. * @param amount defines the gradient factor
  5757. * @param result defines the Color3 object where to store the result
  5758. */
  5759. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5760. /**
  5761. * Returns a Color3 value containing a red color
  5762. * @returns a new Color3 object
  5763. */
  5764. static Red(): Color3;
  5765. /**
  5766. * Returns a Color3 value containing a green color
  5767. * @returns a new Color3 object
  5768. */
  5769. static Green(): Color3;
  5770. /**
  5771. * Returns a Color3 value containing a blue color
  5772. * @returns a new Color3 object
  5773. */
  5774. static Blue(): Color3;
  5775. /**
  5776. * Returns a Color3 value containing a black color
  5777. * @returns a new Color3 object
  5778. */
  5779. static Black(): Color3;
  5780. /**
  5781. * Gets a Color3 value containing a black color that must not be updated
  5782. */
  5783. static get BlackReadOnly(): DeepImmutable<Color3>;
  5784. /**
  5785. * Returns a Color3 value containing a white color
  5786. * @returns a new Color3 object
  5787. */
  5788. static White(): Color3;
  5789. /**
  5790. * Returns a Color3 value containing a purple color
  5791. * @returns a new Color3 object
  5792. */
  5793. static Purple(): Color3;
  5794. /**
  5795. * Returns a Color3 value containing a magenta color
  5796. * @returns a new Color3 object
  5797. */
  5798. static Magenta(): Color3;
  5799. /**
  5800. * Returns a Color3 value containing a yellow color
  5801. * @returns a new Color3 object
  5802. */
  5803. static Yellow(): Color3;
  5804. /**
  5805. * Returns a Color3 value containing a gray color
  5806. * @returns a new Color3 object
  5807. */
  5808. static Gray(): Color3;
  5809. /**
  5810. * Returns a Color3 value containing a teal color
  5811. * @returns a new Color3 object
  5812. */
  5813. static Teal(): Color3;
  5814. /**
  5815. * Returns a Color3 value containing a random color
  5816. * @returns a new Color3 object
  5817. */
  5818. static Random(): Color3;
  5819. }
  5820. /**
  5821. * Class used to hold a RBGA color
  5822. */
  5823. export class Color4 {
  5824. /**
  5825. * Defines the red component (between 0 and 1, default is 0)
  5826. */
  5827. r: number;
  5828. /**
  5829. * Defines the green component (between 0 and 1, default is 0)
  5830. */
  5831. g: number;
  5832. /**
  5833. * Defines the blue component (between 0 and 1, default is 0)
  5834. */
  5835. b: number;
  5836. /**
  5837. * Defines the alpha component (between 0 and 1, default is 1)
  5838. */
  5839. a: number;
  5840. /**
  5841. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5842. * @param r defines the red component (between 0 and 1, default is 0)
  5843. * @param g defines the green component (between 0 and 1, default is 0)
  5844. * @param b defines the blue component (between 0 and 1, default is 0)
  5845. * @param a defines the alpha component (between 0 and 1, default is 1)
  5846. */
  5847. constructor(
  5848. /**
  5849. * Defines the red component (between 0 and 1, default is 0)
  5850. */
  5851. r?: number,
  5852. /**
  5853. * Defines the green component (between 0 and 1, default is 0)
  5854. */
  5855. g?: number,
  5856. /**
  5857. * Defines the blue component (between 0 and 1, default is 0)
  5858. */
  5859. b?: number,
  5860. /**
  5861. * Defines the alpha component (between 0 and 1, default is 1)
  5862. */
  5863. a?: number);
  5864. /**
  5865. * Adds in place the given Color4 values to the current Color4 object
  5866. * @param right defines the second operand
  5867. * @returns the current updated Color4 object
  5868. */
  5869. addInPlace(right: DeepImmutable<Color4>): Color4;
  5870. /**
  5871. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5872. * @returns the new array
  5873. */
  5874. asArray(): number[];
  5875. /**
  5876. * Stores from the starting index in the given array the Color4 successive values
  5877. * @param array defines the array where to store the r,g,b components
  5878. * @param index defines an optional index in the target array to define where to start storing values
  5879. * @returns the current Color4 object
  5880. */
  5881. toArray(array: number[], index?: number): Color4;
  5882. /**
  5883. * Determines equality between Color4 objects
  5884. * @param otherColor defines the second operand
  5885. * @returns true if the rgba values are equal to the given ones
  5886. */
  5887. equals(otherColor: DeepImmutable<Color4>): boolean;
  5888. /**
  5889. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5890. * @param right defines the second operand
  5891. * @returns a new Color4 object
  5892. */
  5893. add(right: DeepImmutable<Color4>): Color4;
  5894. /**
  5895. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5896. * @param right defines the second operand
  5897. * @returns a new Color4 object
  5898. */
  5899. subtract(right: DeepImmutable<Color4>): Color4;
  5900. /**
  5901. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5902. * @param right defines the second operand
  5903. * @param result defines the Color4 object where to store the result
  5904. * @returns the current Color4 object
  5905. */
  5906. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5907. /**
  5908. * Creates a new Color4 with the current Color4 values multiplied by scale
  5909. * @param scale defines the scaling factor to apply
  5910. * @returns a new Color4 object
  5911. */
  5912. scale(scale: number): Color4;
  5913. /**
  5914. * Multiplies the current Color4 values by scale and stores the result in "result"
  5915. * @param scale defines the scaling factor to apply
  5916. * @param result defines the Color4 object where to store the result
  5917. * @returns the current unmodified Color4
  5918. */
  5919. scaleToRef(scale: number, result: Color4): Color4;
  5920. /**
  5921. * Scale the current Color4 values by a factor and add the result to a given Color4
  5922. * @param scale defines the scale factor
  5923. * @param result defines the Color4 object where to store the result
  5924. * @returns the unmodified current Color4
  5925. */
  5926. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5927. /**
  5928. * Clamps the rgb values by the min and max values and stores the result into "result"
  5929. * @param min defines minimum clamping value (default is 0)
  5930. * @param max defines maximum clamping value (default is 1)
  5931. * @param result defines color to store the result into.
  5932. * @returns the cuurent Color4
  5933. */
  5934. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5935. /**
  5936. * Multipy an Color4 value by another and return a new Color4 object
  5937. * @param color defines the Color4 value to multiply by
  5938. * @returns a new Color4 object
  5939. */
  5940. multiply(color: Color4): Color4;
  5941. /**
  5942. * Multipy a Color4 value by another and push the result in a reference value
  5943. * @param color defines the Color4 value to multiply by
  5944. * @param result defines the Color4 to fill the result in
  5945. * @returns the result Color4
  5946. */
  5947. multiplyToRef(color: Color4, result: Color4): Color4;
  5948. /**
  5949. * Creates a string with the Color4 current values
  5950. * @returns the string representation of the Color4 object
  5951. */
  5952. toString(): string;
  5953. /**
  5954. * Returns the string "Color4"
  5955. * @returns "Color4"
  5956. */
  5957. getClassName(): string;
  5958. /**
  5959. * Compute the Color4 hash code
  5960. * @returns an unique number that can be used to hash Color4 objects
  5961. */
  5962. getHashCode(): number;
  5963. /**
  5964. * Creates a new Color4 copied from the current one
  5965. * @returns a new Color4 object
  5966. */
  5967. clone(): Color4;
  5968. /**
  5969. * Copies the given Color4 values into the current one
  5970. * @param source defines the source Color4 object
  5971. * @returns the current updated Color4 object
  5972. */
  5973. copyFrom(source: Color4): Color4;
  5974. /**
  5975. * Copies the given float values into the current one
  5976. * @param r defines the red component to read from
  5977. * @param g defines the green component to read from
  5978. * @param b defines the blue component to read from
  5979. * @param a defines the alpha component to read from
  5980. * @returns the current updated Color4 object
  5981. */
  5982. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Copies the given float values into the current one
  5985. * @param r defines the red component to read from
  5986. * @param g defines the green component to read from
  5987. * @param b defines the blue component to read from
  5988. * @param a defines the alpha component to read from
  5989. * @returns the current updated Color4 object
  5990. */
  5991. set(r: number, g: number, b: number, a: number): Color4;
  5992. /**
  5993. * Compute the Color4 hexadecimal code as a string
  5994. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5995. * @returns a string containing the hexadecimal representation of the Color4 object
  5996. */
  5997. toHexString(returnAsColor3?: boolean): string;
  5998. /**
  5999. * Computes a new Color4 converted from the current one to linear space
  6000. * @returns a new Color4 object
  6001. */
  6002. toLinearSpace(): Color4;
  6003. /**
  6004. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6005. * @param convertedColor defines the Color4 object where to store the linear space version
  6006. * @returns the unmodified Color4
  6007. */
  6008. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6009. /**
  6010. * Computes a new Color4 converted from the current one to gamma space
  6011. * @returns a new Color4 object
  6012. */
  6013. toGammaSpace(): Color4;
  6014. /**
  6015. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6016. * @param convertedColor defines the Color4 object where to store the gamma space version
  6017. * @returns the unmodified Color4
  6018. */
  6019. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6020. /**
  6021. * Creates a new Color4 from the string containing valid hexadecimal values
  6022. * @param hex defines a string containing valid hexadecimal values
  6023. * @returns a new Color4 object
  6024. */
  6025. static FromHexString(hex: string): Color4;
  6026. /**
  6027. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6028. * @param left defines the start value
  6029. * @param right defines the end value
  6030. * @param amount defines the gradient factor
  6031. * @returns a new Color4 object
  6032. */
  6033. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6034. /**
  6035. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6036. * @param left defines the start value
  6037. * @param right defines the end value
  6038. * @param amount defines the gradient factor
  6039. * @param result defines the Color4 object where to store data
  6040. */
  6041. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6042. /**
  6043. * Creates a new Color4 from a Color3 and an alpha value
  6044. * @param color3 defines the source Color3 to read from
  6045. * @param alpha defines the alpha component (1.0 by default)
  6046. * @returns a new Color4 object
  6047. */
  6048. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6049. /**
  6050. * Creates a new Color4 from the starting index element of the given array
  6051. * @param array defines the source array to read from
  6052. * @param offset defines the offset in the source array
  6053. * @returns a new Color4 object
  6054. */
  6055. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6056. /**
  6057. * Creates a new Color3 from integer values (< 256)
  6058. * @param r defines the red component to read from (value between 0 and 255)
  6059. * @param g defines the green component to read from (value between 0 and 255)
  6060. * @param b defines the blue component to read from (value between 0 and 255)
  6061. * @param a defines the alpha component to read from (value between 0 and 255)
  6062. * @returns a new Color3 object
  6063. */
  6064. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6065. /**
  6066. * Check the content of a given array and convert it to an array containing RGBA data
  6067. * If the original array was already containing count * 4 values then it is returned directly
  6068. * @param colors defines the array to check
  6069. * @param count defines the number of RGBA data to expect
  6070. * @returns an array containing count * 4 values (RGBA)
  6071. */
  6072. static CheckColors4(colors: number[], count: number): number[];
  6073. }
  6074. /**
  6075. * @hidden
  6076. */
  6077. export class TmpColors {
  6078. static Color3: Color3[];
  6079. static Color4: Color4[];
  6080. }
  6081. }
  6082. declare module "babylonjs/Animations/animationKey" {
  6083. /**
  6084. * Defines an interface which represents an animation key frame
  6085. */
  6086. export interface IAnimationKey {
  6087. /**
  6088. * Frame of the key frame
  6089. */
  6090. frame: number;
  6091. /**
  6092. * Value at the specifies key frame
  6093. */
  6094. value: any;
  6095. /**
  6096. * The input tangent for the cubic hermite spline
  6097. */
  6098. inTangent?: any;
  6099. /**
  6100. * The output tangent for the cubic hermite spline
  6101. */
  6102. outTangent?: any;
  6103. /**
  6104. * The animation interpolation type
  6105. */
  6106. interpolation?: AnimationKeyInterpolation;
  6107. }
  6108. /**
  6109. * Enum for the animation key frame interpolation type
  6110. */
  6111. export enum AnimationKeyInterpolation {
  6112. /**
  6113. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6114. */
  6115. STEP = 1
  6116. }
  6117. }
  6118. declare module "babylonjs/Animations/animationRange" {
  6119. /**
  6120. * Represents the range of an animation
  6121. */
  6122. export class AnimationRange {
  6123. /**The name of the animation range**/
  6124. name: string;
  6125. /**The starting frame of the animation */
  6126. from: number;
  6127. /**The ending frame of the animation*/
  6128. to: number;
  6129. /**
  6130. * Initializes the range of an animation
  6131. * @param name The name of the animation range
  6132. * @param from The starting frame of the animation
  6133. * @param to The ending frame of the animation
  6134. */
  6135. constructor(
  6136. /**The name of the animation range**/
  6137. name: string,
  6138. /**The starting frame of the animation */
  6139. from: number,
  6140. /**The ending frame of the animation*/
  6141. to: number);
  6142. /**
  6143. * Makes a copy of the animation range
  6144. * @returns A copy of the animation range
  6145. */
  6146. clone(): AnimationRange;
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationEvent" {
  6150. /**
  6151. * Composed of a frame, and an action function
  6152. */
  6153. export class AnimationEvent {
  6154. /** The frame for which the event is triggered **/
  6155. frame: number;
  6156. /** The event to perform when triggered **/
  6157. action: (currentFrame: number) => void;
  6158. /** Specifies if the event should be triggered only once**/
  6159. onlyOnce?: boolean | undefined;
  6160. /**
  6161. * Specifies if the animation event is done
  6162. */
  6163. isDone: boolean;
  6164. /**
  6165. * Initializes the animation event
  6166. * @param frame The frame for which the event is triggered
  6167. * @param action The event to perform when triggered
  6168. * @param onlyOnce Specifies if the event should be triggered only once
  6169. */
  6170. constructor(
  6171. /** The frame for which the event is triggered **/
  6172. frame: number,
  6173. /** The event to perform when triggered **/
  6174. action: (currentFrame: number) => void,
  6175. /** Specifies if the event should be triggered only once**/
  6176. onlyOnce?: boolean | undefined);
  6177. /** @hidden */
  6178. _clone(): AnimationEvent;
  6179. }
  6180. }
  6181. declare module "babylonjs/Behaviors/behavior" {
  6182. import { Nullable } from "babylonjs/types";
  6183. /**
  6184. * Interface used to define a behavior
  6185. */
  6186. export interface Behavior<T> {
  6187. /** gets or sets behavior's name */
  6188. name: string;
  6189. /**
  6190. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6191. */
  6192. init(): void;
  6193. /**
  6194. * Called when the behavior is attached to a target
  6195. * @param target defines the target where the behavior is attached to
  6196. */
  6197. attach(target: T): void;
  6198. /**
  6199. * Called when the behavior is detached from its target
  6200. */
  6201. detach(): void;
  6202. }
  6203. /**
  6204. * Interface implemented by classes supporting behaviors
  6205. */
  6206. export interface IBehaviorAware<T> {
  6207. /**
  6208. * Attach a behavior
  6209. * @param behavior defines the behavior to attach
  6210. * @returns the current host
  6211. */
  6212. addBehavior(behavior: Behavior<T>): T;
  6213. /**
  6214. * Remove a behavior from the current object
  6215. * @param behavior defines the behavior to detach
  6216. * @returns the current host
  6217. */
  6218. removeBehavior(behavior: Behavior<T>): T;
  6219. /**
  6220. * Gets a behavior using its name to search
  6221. * @param name defines the name to search
  6222. * @returns the behavior or null if not found
  6223. */
  6224. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6225. }
  6226. }
  6227. declare module "babylonjs/Misc/smartArray" {
  6228. /**
  6229. * Defines an array and its length.
  6230. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6231. */
  6232. export interface ISmartArrayLike<T> {
  6233. /**
  6234. * The data of the array.
  6235. */
  6236. data: Array<T>;
  6237. /**
  6238. * The active length of the array.
  6239. */
  6240. length: number;
  6241. }
  6242. /**
  6243. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6244. */
  6245. export class SmartArray<T> implements ISmartArrayLike<T> {
  6246. /**
  6247. * The full set of data from the array.
  6248. */
  6249. data: Array<T>;
  6250. /**
  6251. * The active length of the array.
  6252. */
  6253. length: number;
  6254. protected _id: number;
  6255. /**
  6256. * Instantiates a Smart Array.
  6257. * @param capacity defines the default capacity of the array.
  6258. */
  6259. constructor(capacity: number);
  6260. /**
  6261. * Pushes a value at the end of the active data.
  6262. * @param value defines the object to push in the array.
  6263. */
  6264. push(value: T): void;
  6265. /**
  6266. * Iterates over the active data and apply the lambda to them.
  6267. * @param func defines the action to apply on each value.
  6268. */
  6269. forEach(func: (content: T) => void): void;
  6270. /**
  6271. * Sorts the full sets of data.
  6272. * @param compareFn defines the comparison function to apply.
  6273. */
  6274. sort(compareFn: (a: T, b: T) => number): void;
  6275. /**
  6276. * Resets the active data to an empty array.
  6277. */
  6278. reset(): void;
  6279. /**
  6280. * Releases all the data from the array as well as the array.
  6281. */
  6282. dispose(): void;
  6283. /**
  6284. * Concats the active data with a given array.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concat(array: any): void;
  6288. /**
  6289. * Returns the position of a value in the active data.
  6290. * @param value defines the value to find the index for
  6291. * @returns the index if found in the active data otherwise -1
  6292. */
  6293. indexOf(value: T): number;
  6294. /**
  6295. * Returns whether an element is part of the active data.
  6296. * @param value defines the value to look for
  6297. * @returns true if found in the active data otherwise false
  6298. */
  6299. contains(value: T): boolean;
  6300. private static _GlobalId;
  6301. }
  6302. /**
  6303. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6304. * The data in this array can only be present once
  6305. */
  6306. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6307. private _duplicateId;
  6308. /**
  6309. * Pushes a value at the end of the active data.
  6310. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Pushes a value at the end of the active data.
  6316. * If the data is already present, it won t be added again
  6317. * @param value defines the object to push in the array.
  6318. * @returns true if added false if it was already present
  6319. */
  6320. pushNoDuplicate(value: T): boolean;
  6321. /**
  6322. * Resets the active data to an empty array.
  6323. */
  6324. reset(): void;
  6325. /**
  6326. * Concats the active data with a given array.
  6327. * This ensures no dupplicate will be present in the result.
  6328. * @param array defines the data to concatenate with.
  6329. */
  6330. concatWithNoDuplicate(array: any): void;
  6331. }
  6332. }
  6333. declare module "babylonjs/Cameras/cameraInputsManager" {
  6334. import { Nullable } from "babylonjs/types";
  6335. import { Camera } from "babylonjs/Cameras/camera";
  6336. /**
  6337. * @ignore
  6338. * This is a list of all the different input types that are available in the application.
  6339. * Fo instance: ArcRotateCameraGamepadInput...
  6340. */
  6341. export var CameraInputTypes: {};
  6342. /**
  6343. * This is the contract to implement in order to create a new input class.
  6344. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6345. */
  6346. export interface ICameraInput<TCamera extends Camera> {
  6347. /**
  6348. * Defines the camera the input is attached to.
  6349. */
  6350. camera: Nullable<TCamera>;
  6351. /**
  6352. * Gets the class name of the current intput.
  6353. * @returns the class name
  6354. */
  6355. getClassName(): string;
  6356. /**
  6357. * Get the friendly name associated with the input class.
  6358. * @returns the input friendly name
  6359. */
  6360. getSimpleName(): string;
  6361. /**
  6362. * Attach the input controls to a specific dom element to get the input from.
  6363. * @param element Defines the element the controls should be listened from
  6364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6367. /**
  6368. * Detach the current controls from the specified dom element.
  6369. * @param element Defines the element to stop listening the inputs from
  6370. */
  6371. detachControl(element: Nullable<HTMLElement>): void;
  6372. /**
  6373. * Update the current camera state depending on the inputs that have been used this frame.
  6374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6375. */
  6376. checkInputs?: () => void;
  6377. }
  6378. /**
  6379. * Represents a map of input types to input instance or input index to input instance.
  6380. */
  6381. export interface CameraInputsMap<TCamera extends Camera> {
  6382. /**
  6383. * Accessor to the input by input type.
  6384. */
  6385. [name: string]: ICameraInput<TCamera>;
  6386. /**
  6387. * Accessor to the input by input index.
  6388. */
  6389. [idx: number]: ICameraInput<TCamera>;
  6390. }
  6391. /**
  6392. * This represents the input manager used within a camera.
  6393. * It helps dealing with all the different kind of input attached to a camera.
  6394. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6395. */
  6396. export class CameraInputsManager<TCamera extends Camera> {
  6397. /**
  6398. * Defines the list of inputs attahed to the camera.
  6399. */
  6400. attached: CameraInputsMap<TCamera>;
  6401. /**
  6402. * Defines the dom element the camera is collecting inputs from.
  6403. * This is null if the controls have not been attached.
  6404. */
  6405. attachedElement: Nullable<HTMLElement>;
  6406. /**
  6407. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6408. */
  6409. noPreventDefault: boolean;
  6410. /**
  6411. * Defined the camera the input manager belongs to.
  6412. */
  6413. camera: TCamera;
  6414. /**
  6415. * Update the current camera state depending on the inputs that have been used this frame.
  6416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6417. */
  6418. checkInputs: () => void;
  6419. /**
  6420. * Instantiate a new Camera Input Manager.
  6421. * @param camera Defines the camera the input manager blongs to
  6422. */
  6423. constructor(camera: TCamera);
  6424. /**
  6425. * Add an input method to a camera
  6426. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6427. * @param input camera input method
  6428. */
  6429. add(input: ICameraInput<TCamera>): void;
  6430. /**
  6431. * Remove a specific input method from a camera
  6432. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6433. * @param inputToRemove camera input method
  6434. */
  6435. remove(inputToRemove: ICameraInput<TCamera>): void;
  6436. /**
  6437. * Remove a specific input type from a camera
  6438. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6439. * @param inputType the type of the input to remove
  6440. */
  6441. removeByType(inputType: string): void;
  6442. private _addCheckInputs;
  6443. /**
  6444. * Attach the input controls to the currently attached dom element to listen the events from.
  6445. * @param input Defines the input to attach
  6446. */
  6447. attachInput(input: ICameraInput<TCamera>): void;
  6448. /**
  6449. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6450. * @param element Defines the dom element to collect the events from
  6451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6452. */
  6453. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6454. /**
  6455. * Detach the current manager inputs controls from a specific dom element.
  6456. * @param element Defines the dom element to collect the events from
  6457. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6458. */
  6459. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6460. /**
  6461. * Rebuild the dynamic inputCheck function from the current list of
  6462. * defined inputs in the manager.
  6463. */
  6464. rebuildInputCheck(): void;
  6465. /**
  6466. * Remove all attached input methods from a camera
  6467. */
  6468. clear(): void;
  6469. /**
  6470. * Serialize the current input manager attached to a camera.
  6471. * This ensures than once parsed,
  6472. * the input associated to the camera will be identical to the current ones
  6473. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6474. */
  6475. serialize(serializedCamera: any): void;
  6476. /**
  6477. * Parses an input manager serialized JSON to restore the previous list of inputs
  6478. * and states associated to a camera.
  6479. * @param parsedCamera Defines the JSON to parse
  6480. */
  6481. parse(parsedCamera: any): void;
  6482. }
  6483. }
  6484. declare module "babylonjs/Meshes/buffer" {
  6485. import { Nullable, DataArray } from "babylonjs/types";
  6486. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6487. /**
  6488. * Class used to store data that will be store in GPU memory
  6489. */
  6490. export class Buffer {
  6491. private _engine;
  6492. private _buffer;
  6493. /** @hidden */
  6494. _data: Nullable<DataArray>;
  6495. private _updatable;
  6496. private _instanced;
  6497. private _divisor;
  6498. /**
  6499. * Gets the byte stride.
  6500. */
  6501. readonly byteStride: number;
  6502. /**
  6503. * Constructor
  6504. * @param engine the engine
  6505. * @param data the data to use for this buffer
  6506. * @param updatable whether the data is updatable
  6507. * @param stride the stride (optional)
  6508. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6509. * @param instanced whether the buffer is instanced (optional)
  6510. * @param useBytes set to true if the stride in in bytes (optional)
  6511. * @param divisor sets an optional divisor for instances (1 by default)
  6512. */
  6513. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6514. /**
  6515. * Create a new VertexBuffer based on the current buffer
  6516. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6517. * @param offset defines offset in the buffer (0 by default)
  6518. * @param size defines the size in floats of attributes (position is 3 for instance)
  6519. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6520. * @param instanced defines if the vertex buffer contains indexed data
  6521. * @param useBytes defines if the offset and stride are in bytes *
  6522. * @param divisor sets an optional divisor for instances (1 by default)
  6523. * @returns the new vertex buffer
  6524. */
  6525. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6526. /**
  6527. * Gets a boolean indicating if the Buffer is updatable?
  6528. * @returns true if the buffer is updatable
  6529. */
  6530. isUpdatable(): boolean;
  6531. /**
  6532. * Gets current buffer's data
  6533. * @returns a DataArray or null
  6534. */
  6535. getData(): Nullable<DataArray>;
  6536. /**
  6537. * Gets underlying native buffer
  6538. * @returns underlying native buffer
  6539. */
  6540. getBuffer(): Nullable<DataBuffer>;
  6541. /**
  6542. * Gets the stride in float32 units (i.e. byte stride / 4).
  6543. * May not be an integer if the byte stride is not divisible by 4.
  6544. * @returns the stride in float32 units
  6545. * @deprecated Please use byteStride instead.
  6546. */
  6547. getStrideSize(): number;
  6548. /**
  6549. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6550. * @param data defines the data to store
  6551. */
  6552. create(data?: Nullable<DataArray>): void;
  6553. /** @hidden */
  6554. _rebuild(): void;
  6555. /**
  6556. * Update current buffer data
  6557. * @param data defines the data to store
  6558. */
  6559. update(data: DataArray): void;
  6560. /**
  6561. * Updates the data directly.
  6562. * @param data the new data
  6563. * @param offset the new offset
  6564. * @param vertexCount the vertex count (optional)
  6565. * @param useBytes set to true if the offset is in bytes
  6566. */
  6567. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6568. /**
  6569. * Release all resources
  6570. */
  6571. dispose(): void;
  6572. }
  6573. /**
  6574. * Specialized buffer used to store vertex data
  6575. */
  6576. export class VertexBuffer {
  6577. /** @hidden */
  6578. _buffer: Buffer;
  6579. private _kind;
  6580. private _size;
  6581. private _ownsBuffer;
  6582. private _instanced;
  6583. private _instanceDivisor;
  6584. /**
  6585. * The byte type.
  6586. */
  6587. static readonly BYTE: number;
  6588. /**
  6589. * The unsigned byte type.
  6590. */
  6591. static readonly UNSIGNED_BYTE: number;
  6592. /**
  6593. * The short type.
  6594. */
  6595. static readonly SHORT: number;
  6596. /**
  6597. * The unsigned short type.
  6598. */
  6599. static readonly UNSIGNED_SHORT: number;
  6600. /**
  6601. * The integer type.
  6602. */
  6603. static readonly INT: number;
  6604. /**
  6605. * The unsigned integer type.
  6606. */
  6607. static readonly UNSIGNED_INT: number;
  6608. /**
  6609. * The float type.
  6610. */
  6611. static readonly FLOAT: number;
  6612. /**
  6613. * Gets or sets the instance divisor when in instanced mode
  6614. */
  6615. get instanceDivisor(): number;
  6616. set instanceDivisor(value: number);
  6617. /**
  6618. * Gets the byte stride.
  6619. */
  6620. readonly byteStride: number;
  6621. /**
  6622. * Gets the byte offset.
  6623. */
  6624. readonly byteOffset: number;
  6625. /**
  6626. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6627. */
  6628. readonly normalized: boolean;
  6629. /**
  6630. * Gets the data type of each component in the array.
  6631. */
  6632. readonly type: number;
  6633. /**
  6634. * Constructor
  6635. * @param engine the engine
  6636. * @param data the data to use for this vertex buffer
  6637. * @param kind the vertex buffer kind
  6638. * @param updatable whether the data is updatable
  6639. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6640. * @param stride the stride (optional)
  6641. * @param instanced whether the buffer is instanced (optional)
  6642. * @param offset the offset of the data (optional)
  6643. * @param size the number of components (optional)
  6644. * @param type the type of the component (optional)
  6645. * @param normalized whether the data contains normalized data (optional)
  6646. * @param useBytes set to true if stride and offset are in bytes (optional)
  6647. * @param divisor defines the instance divisor to use (1 by default)
  6648. */
  6649. 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);
  6650. /** @hidden */
  6651. _rebuild(): void;
  6652. /**
  6653. * Returns the kind of the VertexBuffer (string)
  6654. * @returns a string
  6655. */
  6656. getKind(): string;
  6657. /**
  6658. * Gets a boolean indicating if the VertexBuffer is updatable?
  6659. * @returns true if the buffer is updatable
  6660. */
  6661. isUpdatable(): boolean;
  6662. /**
  6663. * Gets current buffer's data
  6664. * @returns a DataArray or null
  6665. */
  6666. getData(): Nullable<DataArray>;
  6667. /**
  6668. * Gets underlying native buffer
  6669. * @returns underlying native buffer
  6670. */
  6671. getBuffer(): Nullable<DataBuffer>;
  6672. /**
  6673. * Gets the stride in float32 units (i.e. byte stride / 4).
  6674. * May not be an integer if the byte stride is not divisible by 4.
  6675. * @returns the stride in float32 units
  6676. * @deprecated Please use byteStride instead.
  6677. */
  6678. getStrideSize(): number;
  6679. /**
  6680. * Returns the offset as a multiple of the type byte length.
  6681. * @returns the offset in bytes
  6682. * @deprecated Please use byteOffset instead.
  6683. */
  6684. getOffset(): number;
  6685. /**
  6686. * Returns the number of components per vertex attribute (integer)
  6687. * @returns the size in float
  6688. */
  6689. getSize(): number;
  6690. /**
  6691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6692. * @returns true if this buffer is instanced
  6693. */
  6694. getIsInstanced(): boolean;
  6695. /**
  6696. * Returns the instancing divisor, zero for non-instanced (integer).
  6697. * @returns a number
  6698. */
  6699. getInstanceDivisor(): number;
  6700. /**
  6701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6702. * @param data defines the data to store
  6703. */
  6704. create(data?: DataArray): void;
  6705. /**
  6706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6707. * This function will create a new buffer if the current one is not updatable
  6708. * @param data defines the data to store
  6709. */
  6710. update(data: DataArray): void;
  6711. /**
  6712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6713. * Returns the directly updated WebGLBuffer.
  6714. * @param data the new data
  6715. * @param offset the new offset
  6716. * @param useBytes set to true if the offset is in bytes
  6717. */
  6718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6719. /**
  6720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6721. */
  6722. dispose(): void;
  6723. /**
  6724. * Enumerates each value of this vertex buffer as numbers.
  6725. * @param count the number of values to enumerate
  6726. * @param callback the callback function called for each value
  6727. */
  6728. forEach(count: number, callback: (value: number, index: number) => void): void;
  6729. /**
  6730. * Positions
  6731. */
  6732. static readonly PositionKind: string;
  6733. /**
  6734. * Normals
  6735. */
  6736. static readonly NormalKind: string;
  6737. /**
  6738. * Tangents
  6739. */
  6740. static readonly TangentKind: string;
  6741. /**
  6742. * Texture coordinates
  6743. */
  6744. static readonly UVKind: string;
  6745. /**
  6746. * Texture coordinates 2
  6747. */
  6748. static readonly UV2Kind: string;
  6749. /**
  6750. * Texture coordinates 3
  6751. */
  6752. static readonly UV3Kind: string;
  6753. /**
  6754. * Texture coordinates 4
  6755. */
  6756. static readonly UV4Kind: string;
  6757. /**
  6758. * Texture coordinates 5
  6759. */
  6760. static readonly UV5Kind: string;
  6761. /**
  6762. * Texture coordinates 6
  6763. */
  6764. static readonly UV6Kind: string;
  6765. /**
  6766. * Colors
  6767. */
  6768. static readonly ColorKind: string;
  6769. /**
  6770. * Matrix indices (for bones)
  6771. */
  6772. static readonly MatricesIndicesKind: string;
  6773. /**
  6774. * Matrix weights (for bones)
  6775. */
  6776. static readonly MatricesWeightsKind: string;
  6777. /**
  6778. * Additional matrix indices (for bones)
  6779. */
  6780. static readonly MatricesIndicesExtraKind: string;
  6781. /**
  6782. * Additional matrix weights (for bones)
  6783. */
  6784. static readonly MatricesWeightsExtraKind: string;
  6785. /**
  6786. * Deduces the stride given a kind.
  6787. * @param kind The kind string to deduce
  6788. * @returns The deduced stride
  6789. */
  6790. static DeduceStride(kind: string): number;
  6791. /**
  6792. * Gets the byte length of the given type.
  6793. * @param type the type
  6794. * @returns the number of bytes
  6795. */
  6796. static GetTypeByteLength(type: number): number;
  6797. /**
  6798. * Enumerates each value of the given parameters as numbers.
  6799. * @param data the data to enumerate
  6800. * @param byteOffset the byte offset of the data
  6801. * @param byteStride the byte stride of the data
  6802. * @param componentCount the number of components per element
  6803. * @param componentType the type of the component
  6804. * @param count the number of values to enumerate
  6805. * @param normalized whether the data is normalized
  6806. * @param callback the callback function called for each value
  6807. */
  6808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6809. private static _GetFloatValue;
  6810. }
  6811. }
  6812. declare module "babylonjs/Collisions/intersectionInfo" {
  6813. import { Nullable } from "babylonjs/types";
  6814. /**
  6815. * @hidden
  6816. */
  6817. export class IntersectionInfo {
  6818. bu: Nullable<number>;
  6819. bv: Nullable<number>;
  6820. distance: number;
  6821. faceId: number;
  6822. subMeshId: number;
  6823. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6824. }
  6825. }
  6826. declare module "babylonjs/Culling/boundingSphere" {
  6827. import { DeepImmutable } from "babylonjs/types";
  6828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6829. import { Plane } from "babylonjs/Maths/math.plane";
  6830. /**
  6831. * Class used to store bounding sphere information
  6832. */
  6833. export class BoundingSphere {
  6834. /**
  6835. * Gets the center of the bounding sphere in local space
  6836. */
  6837. readonly center: Vector3;
  6838. /**
  6839. * Radius of the bounding sphere in local space
  6840. */
  6841. radius: number;
  6842. /**
  6843. * Gets the center of the bounding sphere in world space
  6844. */
  6845. readonly centerWorld: Vector3;
  6846. /**
  6847. * Radius of the bounding sphere in world space
  6848. */
  6849. radiusWorld: number;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * Creates a new bounding sphere
  6862. * @param min defines the minimum vector (in local space)
  6863. * @param max defines the maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6867. /**
  6868. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6869. * @param min defines the new minimum vector (in local space)
  6870. * @param max defines the new maximum vector (in local space)
  6871. * @param worldMatrix defines the new world matrix
  6872. */
  6873. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Scale the current bounding sphere by applying a scale factor
  6876. * @param factor defines the scale factor to apply
  6877. * @returns the current bounding box
  6878. */
  6879. scale(factor: number): BoundingSphere;
  6880. /**
  6881. * Gets the world matrix of the bounding box
  6882. * @returns a matrix
  6883. */
  6884. getWorldMatrix(): DeepImmutable<Matrix>;
  6885. /** @hidden */
  6886. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6887. /**
  6888. * Tests if the bounding sphere is intersecting the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an intersection
  6891. */
  6892. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if the bounding sphere center is in between the frustum planes.
  6895. * Used for optimistic fast inclusion.
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if the sphere center is in between the frustum planes
  6898. */
  6899. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding sphere
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding sphere
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Checks if two sphere intersct
  6908. * @param sphere0 sphere 0
  6909. * @param sphere1 sphere 1
  6910. * @returns true if the speres intersect
  6911. */
  6912. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6913. }
  6914. }
  6915. declare module "babylonjs/Culling/boundingBox" {
  6916. import { DeepImmutable } from "babylonjs/types";
  6917. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6918. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6919. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6920. import { Plane } from "babylonjs/Maths/math.plane";
  6921. /**
  6922. * Class used to store bounding box information
  6923. */
  6924. export class BoundingBox implements ICullable {
  6925. /**
  6926. * Gets the 8 vectors representing the bounding box in local space
  6927. */
  6928. readonly vectors: Vector3[];
  6929. /**
  6930. * Gets the center of the bounding box in local space
  6931. */
  6932. readonly center: Vector3;
  6933. /**
  6934. * Gets the center of the bounding box in world space
  6935. */
  6936. readonly centerWorld: Vector3;
  6937. /**
  6938. * Gets the extend size in local space
  6939. */
  6940. readonly extendSize: Vector3;
  6941. /**
  6942. * Gets the extend size in world space
  6943. */
  6944. readonly extendSizeWorld: Vector3;
  6945. /**
  6946. * Gets the OBB (object bounding box) directions
  6947. */
  6948. readonly directions: Vector3[];
  6949. /**
  6950. * Gets the 8 vectors representing the bounding box in world space
  6951. */
  6952. readonly vectorsWorld: Vector3[];
  6953. /**
  6954. * Gets the minimum vector in world space
  6955. */
  6956. readonly minimumWorld: Vector3;
  6957. /**
  6958. * Gets the maximum vector in world space
  6959. */
  6960. readonly maximumWorld: Vector3;
  6961. /**
  6962. * Gets the minimum vector in local space
  6963. */
  6964. readonly minimum: Vector3;
  6965. /**
  6966. * Gets the maximum vector in local space
  6967. */
  6968. readonly maximum: Vector3;
  6969. private _worldMatrix;
  6970. private static readonly TmpVector3;
  6971. /**
  6972. * @hidden
  6973. */
  6974. _tag: number;
  6975. /**
  6976. * Creates a new bounding box
  6977. * @param min defines the minimum vector (in local space)
  6978. * @param max defines the maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6982. /**
  6983. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6984. * @param min defines the new minimum vector (in local space)
  6985. * @param max defines the new maximum vector (in local space)
  6986. * @param worldMatrix defines the new world matrix
  6987. */
  6988. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6989. /**
  6990. * Scale the current bounding box by applying a scale factor
  6991. * @param factor defines the scale factor to apply
  6992. * @returns the current bounding box
  6993. */
  6994. scale(factor: number): BoundingBox;
  6995. /**
  6996. * Gets the world matrix of the bounding box
  6997. * @returns a matrix
  6998. */
  6999. getWorldMatrix(): DeepImmutable<Matrix>;
  7000. /** @hidden */
  7001. _update(world: DeepImmutable<Matrix>): void;
  7002. /**
  7003. * Tests if the bounding box is intersecting the frustum planes
  7004. * @param frustumPlanes defines the frustum planes to test
  7005. * @returns true if there is an intersection
  7006. */
  7007. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7008. /**
  7009. * Tests if the bounding box is entirely inside the frustum planes
  7010. * @param frustumPlanes defines the frustum planes to test
  7011. * @returns true if there is an inclusion
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7014. /**
  7015. * Tests if a point is inside the bounding box
  7016. * @param point defines the point to test
  7017. * @returns true if the point is inside the bounding box
  7018. */
  7019. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7020. /**
  7021. * Tests if the bounding box intersects with a bounding sphere
  7022. * @param sphere defines the sphere to test
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7026. /**
  7027. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7028. * @param min defines the min vector to use
  7029. * @param max defines the max vector to use
  7030. * @returns true if there is an intersection
  7031. */
  7032. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7033. /**
  7034. * Tests if two bounding boxes are intersections
  7035. * @param box0 defines the first box to test
  7036. * @param box1 defines the second box to test
  7037. * @returns true if there is an intersection
  7038. */
  7039. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7040. /**
  7041. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7042. * @param minPoint defines the minimum vector of the bounding box
  7043. * @param maxPoint defines the maximum vector of the bounding box
  7044. * @param sphereCenter defines the sphere center
  7045. * @param sphereRadius defines the sphere radius
  7046. * @returns true if there is an intersection
  7047. */
  7048. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an inclusion
  7054. */
  7055. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. /**
  7057. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7058. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @return true if there is an intersection
  7061. */
  7062. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. }
  7064. }
  7065. declare module "babylonjs/Collisions/collider" {
  7066. import { Nullable, IndicesArray } from "babylonjs/types";
  7067. import { Vector3 } from "babylonjs/Maths/math.vector";
  7068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7069. import { Plane } from "babylonjs/Maths/math.plane";
  7070. /** @hidden */
  7071. export class Collider {
  7072. /** Define if a collision was found */
  7073. collisionFound: boolean;
  7074. /**
  7075. * Define last intersection point in local space
  7076. */
  7077. intersectionPoint: Vector3;
  7078. /**
  7079. * Define last collided mesh
  7080. */
  7081. collidedMesh: Nullable<AbstractMesh>;
  7082. private _collisionPoint;
  7083. private _planeIntersectionPoint;
  7084. private _tempVector;
  7085. private _tempVector2;
  7086. private _tempVector3;
  7087. private _tempVector4;
  7088. private _edge;
  7089. private _baseToVertex;
  7090. private _destinationPoint;
  7091. private _slidePlaneNormal;
  7092. private _displacementVector;
  7093. /** @hidden */
  7094. _radius: Vector3;
  7095. /** @hidden */
  7096. _retry: number;
  7097. private _velocity;
  7098. private _basePoint;
  7099. private _epsilon;
  7100. /** @hidden */
  7101. _velocityWorldLength: number;
  7102. /** @hidden */
  7103. _basePointWorld: Vector3;
  7104. private _velocityWorld;
  7105. private _normalizedVelocity;
  7106. /** @hidden */
  7107. _initialVelocity: Vector3;
  7108. /** @hidden */
  7109. _initialPosition: Vector3;
  7110. private _nearestDistance;
  7111. private _collisionMask;
  7112. get collisionMask(): number;
  7113. set collisionMask(mask: number);
  7114. /**
  7115. * Gets the plane normal used to compute the sliding response (in local space)
  7116. */
  7117. get slidePlaneNormal(): Vector3;
  7118. /** @hidden */
  7119. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7120. /** @hidden */
  7121. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7122. /** @hidden */
  7123. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7124. /** @hidden */
  7125. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7126. /** @hidden */
  7127. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7128. /** @hidden */
  7129. _getResponse(pos: Vector3, vel: Vector3): void;
  7130. }
  7131. }
  7132. declare module "babylonjs/Culling/boundingInfo" {
  7133. import { DeepImmutable } from "babylonjs/types";
  7134. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7135. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7136. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7137. import { Plane } from "babylonjs/Maths/math.plane";
  7138. import { Collider } from "babylonjs/Collisions/collider";
  7139. /**
  7140. * Interface for cullable objects
  7141. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7142. */
  7143. export interface ICullable {
  7144. /**
  7145. * Checks if the object or part of the object is in the frustum
  7146. * @param frustumPlanes Camera near/planes
  7147. * @returns true if the object is in frustum otherwise false
  7148. */
  7149. isInFrustum(frustumPlanes: Plane[]): boolean;
  7150. /**
  7151. * Checks if a cullable object (mesh...) is in the camera frustum
  7152. * Unlike isInFrustum this cheks the full bounding box
  7153. * @param frustumPlanes Camera near/planes
  7154. * @returns true if the object is in frustum otherwise false
  7155. */
  7156. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7157. }
  7158. /**
  7159. * Info for a bounding data of a mesh
  7160. */
  7161. export class BoundingInfo implements ICullable {
  7162. /**
  7163. * Bounding box for the mesh
  7164. */
  7165. readonly boundingBox: BoundingBox;
  7166. /**
  7167. * Bounding sphere for the mesh
  7168. */
  7169. readonly boundingSphere: BoundingSphere;
  7170. private _isLocked;
  7171. private static readonly TmpVector3;
  7172. /**
  7173. * Constructs bounding info
  7174. * @param minimum min vector of the bounding box/sphere
  7175. * @param maximum max vector of the bounding box/sphere
  7176. * @param worldMatrix defines the new world matrix
  7177. */
  7178. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7179. /**
  7180. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7181. * @param min defines the new minimum vector (in local space)
  7182. * @param max defines the new maximum vector (in local space)
  7183. * @param worldMatrix defines the new world matrix
  7184. */
  7185. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7186. /**
  7187. * min vector of the bounding box/sphere
  7188. */
  7189. get minimum(): Vector3;
  7190. /**
  7191. * max vector of the bounding box/sphere
  7192. */
  7193. get maximum(): Vector3;
  7194. /**
  7195. * If the info is locked and won't be updated to avoid perf overhead
  7196. */
  7197. get isLocked(): boolean;
  7198. set isLocked(value: boolean);
  7199. /**
  7200. * Updates the bounding sphere and box
  7201. * @param world world matrix to be used to update
  7202. */
  7203. update(world: DeepImmutable<Matrix>): void;
  7204. /**
  7205. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7206. * @param center New center of the bounding info
  7207. * @param extend New extend of the bounding info
  7208. * @returns the current bounding info
  7209. */
  7210. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7211. /**
  7212. * Scale the current bounding info by applying a scale factor
  7213. * @param factor defines the scale factor to apply
  7214. * @returns the current bounding info
  7215. */
  7216. scale(factor: number): BoundingInfo;
  7217. /**
  7218. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7219. * @param frustumPlanes defines the frustum to test
  7220. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7221. * @returns true if the bounding info is in the frustum planes
  7222. */
  7223. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7224. /**
  7225. * Gets the world distance between the min and max points of the bounding box
  7226. */
  7227. get diagonalLength(): number;
  7228. /**
  7229. * Checks if a cullable object (mesh...) is in the camera frustum
  7230. * Unlike isInFrustum this cheks the full bounding box
  7231. * @param frustumPlanes Camera near/planes
  7232. * @returns true if the object is in frustum otherwise false
  7233. */
  7234. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7235. /** @hidden */
  7236. _checkCollision(collider: Collider): boolean;
  7237. /**
  7238. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7239. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7240. * @param point the point to check intersection with
  7241. * @returns if the point intersects
  7242. */
  7243. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7244. /**
  7245. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7246. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7247. * @param boundingInfo the bounding info to check intersection with
  7248. * @param precise if the intersection should be done using OBB
  7249. * @returns if the bounding info intersects
  7250. */
  7251. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7252. }
  7253. }
  7254. declare module "babylonjs/Maths/math.functions" {
  7255. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7256. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7257. /**
  7258. * Extracts minimum and maximum values from a list of indexed positions
  7259. * @param positions defines the positions to use
  7260. * @param indices defines the indices to the positions
  7261. * @param indexStart defines the start index
  7262. * @param indexCount defines the end index
  7263. * @param bias defines bias value to add to the result
  7264. * @return minimum and maximum values
  7265. */
  7266. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7267. minimum: Vector3;
  7268. maximum: Vector3;
  7269. };
  7270. /**
  7271. * Extracts minimum and maximum values from a list of positions
  7272. * @param positions defines the positions to use
  7273. * @param start defines the start index in the positions array
  7274. * @param count defines the number of positions to handle
  7275. * @param bias defines bias value to add to the result
  7276. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7277. * @return minimum and maximum values
  7278. */
  7279. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7280. minimum: Vector3;
  7281. maximum: Vector3;
  7282. };
  7283. }
  7284. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. /** @hidden */
  7287. export class WebGLDataBuffer extends DataBuffer {
  7288. private _buffer;
  7289. constructor(resource: WebGLBuffer);
  7290. get underlyingResource(): any;
  7291. }
  7292. }
  7293. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7294. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7295. import { Nullable } from "babylonjs/types";
  7296. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7297. /** @hidden */
  7298. export class WebGLPipelineContext implements IPipelineContext {
  7299. engine: ThinEngine;
  7300. program: Nullable<WebGLProgram>;
  7301. context?: WebGLRenderingContext;
  7302. vertexShader?: WebGLShader;
  7303. fragmentShader?: WebGLShader;
  7304. isParallelCompiled: boolean;
  7305. onCompiled?: () => void;
  7306. transformFeedback?: WebGLTransformFeedback | null;
  7307. vertexCompilationError: Nullable<string>;
  7308. fragmentCompilationError: Nullable<string>;
  7309. programLinkError: Nullable<string>;
  7310. programValidationError: Nullable<string>;
  7311. get isAsync(): boolean;
  7312. get isReady(): boolean;
  7313. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7314. _getVertexShaderCode(): string | null;
  7315. _getFragmentShaderCode(): string | null;
  7316. }
  7317. }
  7318. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7319. import { FloatArray, Nullable } from "babylonjs/types";
  7320. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7321. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7322. module "babylonjs/Engines/thinEngine" {
  7323. interface ThinEngine {
  7324. /**
  7325. * Create an uniform buffer
  7326. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7327. * @param elements defines the content of the uniform buffer
  7328. * @returns the webGL uniform buffer
  7329. */
  7330. createUniformBuffer(elements: FloatArray): DataBuffer;
  7331. /**
  7332. * Create a dynamic uniform buffer
  7333. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7334. * @param elements defines the content of the uniform buffer
  7335. * @returns the webGL uniform buffer
  7336. */
  7337. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7338. /**
  7339. * Update an existing uniform buffer
  7340. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7341. * @param uniformBuffer defines the target uniform buffer
  7342. * @param elements defines the content to update
  7343. * @param offset defines the offset in the uniform buffer where update should start
  7344. * @param count defines the size of the data to update
  7345. */
  7346. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7347. /**
  7348. * Bind an uniform buffer to the current webGL context
  7349. * @param buffer defines the buffer to bind
  7350. */
  7351. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7352. /**
  7353. * Bind a buffer to the current webGL context at a given location
  7354. * @param buffer defines the buffer to bind
  7355. * @param location defines the index where to bind the buffer
  7356. */
  7357. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7358. /**
  7359. * Bind a specific block at a given index in a specific shader program
  7360. * @param pipelineContext defines the pipeline context to use
  7361. * @param blockName defines the block name
  7362. * @param index defines the index where to bind the block
  7363. */
  7364. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7365. }
  7366. }
  7367. }
  7368. declare module "babylonjs/Materials/uniformBuffer" {
  7369. import { Nullable, FloatArray } from "babylonjs/types";
  7370. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7371. import { Engine } from "babylonjs/Engines/engine";
  7372. import { Effect } from "babylonjs/Materials/effect";
  7373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7374. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7375. import { Color3 } from "babylonjs/Maths/math.color";
  7376. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7377. /**
  7378. * Uniform buffer objects.
  7379. *
  7380. * Handles blocks of uniform on the GPU.
  7381. *
  7382. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7383. *
  7384. * For more information, please refer to :
  7385. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7386. */
  7387. export class UniformBuffer {
  7388. private _engine;
  7389. private _buffer;
  7390. private _data;
  7391. private _bufferData;
  7392. private _dynamic?;
  7393. private _uniformLocations;
  7394. private _uniformSizes;
  7395. private _uniformLocationPointer;
  7396. private _needSync;
  7397. private _noUBO;
  7398. private _currentEffect;
  7399. /** @hidden */
  7400. _alreadyBound: boolean;
  7401. private static _MAX_UNIFORM_SIZE;
  7402. private static _tempBuffer;
  7403. /**
  7404. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7409. /**
  7410. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7411. * This is dynamic to allow compat with webgl 1 and 2.
  7412. * You will need to pass the name of the uniform as well as the value.
  7413. */
  7414. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7415. /**
  7416. * Lambda to Update a single float in a uniform buffer.
  7417. * This is dynamic to allow compat with webgl 1 and 2.
  7418. * You will need to pass the name of the uniform as well as the value.
  7419. */
  7420. updateFloat: (name: string, x: number) => void;
  7421. /**
  7422. * Lambda to Update a vec2 of float in a uniform buffer.
  7423. * This is dynamic to allow compat with webgl 1 and 2.
  7424. * You will need to pass the name of the uniform as well as the value.
  7425. */
  7426. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7427. /**
  7428. * Lambda to Update a vec3 of float in a uniform buffer.
  7429. * This is dynamic to allow compat with webgl 1 and 2.
  7430. * You will need to pass the name of the uniform as well as the value.
  7431. */
  7432. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7433. /**
  7434. * Lambda to Update a vec4 of float in a uniform buffer.
  7435. * This is dynamic to allow compat with webgl 1 and 2.
  7436. * You will need to pass the name of the uniform as well as the value.
  7437. */
  7438. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7439. /**
  7440. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7441. * This is dynamic to allow compat with webgl 1 and 2.
  7442. * You will need to pass the name of the uniform as well as the value.
  7443. */
  7444. updateMatrix: (name: string, mat: Matrix) => void;
  7445. /**
  7446. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7447. * This is dynamic to allow compat with webgl 1 and 2.
  7448. * You will need to pass the name of the uniform as well as the value.
  7449. */
  7450. updateVector3: (name: string, vector: Vector3) => void;
  7451. /**
  7452. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7453. * This is dynamic to allow compat with webgl 1 and 2.
  7454. * You will need to pass the name of the uniform as well as the value.
  7455. */
  7456. updateVector4: (name: string, vector: Vector4) => void;
  7457. /**
  7458. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7459. * This is dynamic to allow compat with webgl 1 and 2.
  7460. * You will need to pass the name of the uniform as well as the value.
  7461. */
  7462. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7463. /**
  7464. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7465. * This is dynamic to allow compat with webgl 1 and 2.
  7466. * You will need to pass the name of the uniform as well as the value.
  7467. */
  7468. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7469. /**
  7470. * Instantiates a new Uniform buffer objects.
  7471. *
  7472. * Handles blocks of uniform on the GPU.
  7473. *
  7474. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7475. *
  7476. * For more information, please refer to :
  7477. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7478. * @param engine Define the engine the buffer is associated with
  7479. * @param data Define the data contained in the buffer
  7480. * @param dynamic Define if the buffer is updatable
  7481. */
  7482. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7483. /**
  7484. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7485. * or just falling back on setUniformXXX calls.
  7486. */
  7487. get useUbo(): boolean;
  7488. /**
  7489. * Indicates if the WebGL underlying uniform buffer is in sync
  7490. * with the javascript cache data.
  7491. */
  7492. get isSync(): boolean;
  7493. /**
  7494. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7495. * Also, a dynamic UniformBuffer will disable cache verification and always
  7496. * update the underlying WebGL uniform buffer to the GPU.
  7497. * @returns if Dynamic, otherwise false
  7498. */
  7499. isDynamic(): boolean;
  7500. /**
  7501. * The data cache on JS side.
  7502. * @returns the underlying data as a float array
  7503. */
  7504. getData(): Float32Array;
  7505. /**
  7506. * The underlying WebGL Uniform buffer.
  7507. * @returns the webgl buffer
  7508. */
  7509. getBuffer(): Nullable<DataBuffer>;
  7510. /**
  7511. * std140 layout specifies how to align data within an UBO structure.
  7512. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7513. * for specs.
  7514. */
  7515. private _fillAlignment;
  7516. /**
  7517. * Adds an uniform in the buffer.
  7518. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7519. * for the layout to be correct !
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param size Data size, or data directly.
  7522. */
  7523. addUniform(name: string, size: number | number[]): void;
  7524. /**
  7525. * Adds a Matrix 4x4 to the uniform buffer.
  7526. * @param name Name of the uniform, as used in the uniform block in the shader.
  7527. * @param mat A 4x4 matrix.
  7528. */
  7529. addMatrix(name: string, mat: Matrix): void;
  7530. /**
  7531. * Adds a vec2 to the uniform buffer.
  7532. * @param name Name of the uniform, as used in the uniform block in the shader.
  7533. * @param x Define the x component value of the vec2
  7534. * @param y Define the y component value of the vec2
  7535. */
  7536. addFloat2(name: string, x: number, y: number): void;
  7537. /**
  7538. * Adds a vec3 to the uniform buffer.
  7539. * @param name Name of the uniform, as used in the uniform block in the shader.
  7540. * @param x Define the x component value of the vec3
  7541. * @param y Define the y component value of the vec3
  7542. * @param z Define the z component value of the vec3
  7543. */
  7544. addFloat3(name: string, x: number, y: number, z: number): void;
  7545. /**
  7546. * Adds a vec3 to the uniform buffer.
  7547. * @param name Name of the uniform, as used in the uniform block in the shader.
  7548. * @param color Define the vec3 from a Color
  7549. */
  7550. addColor3(name: string, color: Color3): void;
  7551. /**
  7552. * Adds a vec4 to the uniform buffer.
  7553. * @param name Name of the uniform, as used in the uniform block in the shader.
  7554. * @param color Define the rgb components from a Color
  7555. * @param alpha Define the a component of the vec4
  7556. */
  7557. addColor4(name: string, color: Color3, alpha: number): void;
  7558. /**
  7559. * Adds a vec3 to the uniform buffer.
  7560. * @param name Name of the uniform, as used in the uniform block in the shader.
  7561. * @param vector Define the vec3 components from a Vector
  7562. */
  7563. addVector3(name: string, vector: Vector3): void;
  7564. /**
  7565. * Adds a Matrix 3x3 to the uniform buffer.
  7566. * @param name Name of the uniform, as used in the uniform block in the shader.
  7567. */
  7568. addMatrix3x3(name: string): void;
  7569. /**
  7570. * Adds a Matrix 2x2 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. */
  7573. addMatrix2x2(name: string): void;
  7574. /**
  7575. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7576. */
  7577. create(): void;
  7578. /** @hidden */
  7579. _rebuild(): void;
  7580. /**
  7581. * Updates the WebGL Uniform Buffer on the GPU.
  7582. * If the `dynamic` flag is set to true, no cache comparison is done.
  7583. * Otherwise, the buffer will be updated only if the cache differs.
  7584. */
  7585. update(): void;
  7586. /**
  7587. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7588. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7589. * @param data Define the flattened data
  7590. * @param size Define the size of the data.
  7591. */
  7592. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7593. private _valueCache;
  7594. private _cacheMatrix;
  7595. private _updateMatrix3x3ForUniform;
  7596. private _updateMatrix3x3ForEffect;
  7597. private _updateMatrix2x2ForEffect;
  7598. private _updateMatrix2x2ForUniform;
  7599. private _updateFloatForEffect;
  7600. private _updateFloatForUniform;
  7601. private _updateFloat2ForEffect;
  7602. private _updateFloat2ForUniform;
  7603. private _updateFloat3ForEffect;
  7604. private _updateFloat3ForUniform;
  7605. private _updateFloat4ForEffect;
  7606. private _updateFloat4ForUniform;
  7607. private _updateMatrixForEffect;
  7608. private _updateMatrixForUniform;
  7609. private _updateVector3ForEffect;
  7610. private _updateVector3ForUniform;
  7611. private _updateVector4ForEffect;
  7612. private _updateVector4ForUniform;
  7613. private _updateColor3ForEffect;
  7614. private _updateColor3ForUniform;
  7615. private _updateColor4ForEffect;
  7616. private _updateColor4ForUniform;
  7617. /**
  7618. * Sets a sampler uniform on the effect.
  7619. * @param name Define the name of the sampler.
  7620. * @param texture Define the texture to set in the sampler
  7621. */
  7622. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7623. /**
  7624. * Directly updates the value of the uniform in the cache AND on the GPU.
  7625. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7626. * @param data Define the flattened data
  7627. */
  7628. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7629. /**
  7630. * Binds this uniform buffer to an effect.
  7631. * @param effect Define the effect to bind the buffer to
  7632. * @param name Name of the uniform block in the shader.
  7633. */
  7634. bindToEffect(effect: Effect, name: string): void;
  7635. /**
  7636. * Disposes the uniform buffer.
  7637. */
  7638. dispose(): void;
  7639. }
  7640. }
  7641. declare module "babylonjs/Misc/iInspectable" {
  7642. /**
  7643. * Enum that determines the text-wrapping mode to use.
  7644. */
  7645. export enum InspectableType {
  7646. /**
  7647. * Checkbox for booleans
  7648. */
  7649. Checkbox = 0,
  7650. /**
  7651. * Sliders for numbers
  7652. */
  7653. Slider = 1,
  7654. /**
  7655. * Vector3
  7656. */
  7657. Vector3 = 2,
  7658. /**
  7659. * Quaternions
  7660. */
  7661. Quaternion = 3,
  7662. /**
  7663. * Color3
  7664. */
  7665. Color3 = 4,
  7666. /**
  7667. * String
  7668. */
  7669. String = 5
  7670. }
  7671. /**
  7672. * Interface used to define custom inspectable properties.
  7673. * This interface is used by the inspector to display custom property grids
  7674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7675. */
  7676. export interface IInspectable {
  7677. /**
  7678. * Gets the label to display
  7679. */
  7680. label: string;
  7681. /**
  7682. * Gets the name of the property to edit
  7683. */
  7684. propertyName: string;
  7685. /**
  7686. * Gets the type of the editor to use
  7687. */
  7688. type: InspectableType;
  7689. /**
  7690. * Gets the minimum value of the property when using in "slider" mode
  7691. */
  7692. min?: number;
  7693. /**
  7694. * Gets the maximum value of the property when using in "slider" mode
  7695. */
  7696. max?: number;
  7697. /**
  7698. * Gets the setp to use when using in "slider" mode
  7699. */
  7700. step?: number;
  7701. }
  7702. }
  7703. declare module "babylonjs/Misc/timingTools" {
  7704. /**
  7705. * Class used to provide helper for timing
  7706. */
  7707. export class TimingTools {
  7708. /**
  7709. * Polyfill for setImmediate
  7710. * @param action defines the action to execute after the current execution block
  7711. */
  7712. static SetImmediate(action: () => void): void;
  7713. }
  7714. }
  7715. declare module "babylonjs/Misc/instantiationTools" {
  7716. /**
  7717. * Class used to enable instatition of objects by class name
  7718. */
  7719. export class InstantiationTools {
  7720. /**
  7721. * Use this object to register external classes like custom textures or material
  7722. * to allow the laoders to instantiate them
  7723. */
  7724. static RegisteredExternalClasses: {
  7725. [key: string]: Object;
  7726. };
  7727. /**
  7728. * Tries to instantiate a new object from a given class name
  7729. * @param className defines the class name to instantiate
  7730. * @returns the new object or null if the system was not able to do the instantiation
  7731. */
  7732. static Instantiate(className: string): any;
  7733. }
  7734. }
  7735. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7736. /**
  7737. * Define options used to create a depth texture
  7738. */
  7739. export class DepthTextureCreationOptions {
  7740. /** Specifies whether or not a stencil should be allocated in the texture */
  7741. generateStencil?: boolean;
  7742. /** Specifies whether or not bilinear filtering is enable on the texture */
  7743. bilinearFiltering?: boolean;
  7744. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7745. comparisonFunction?: number;
  7746. /** Specifies if the created texture is a cube texture */
  7747. isCube?: boolean;
  7748. }
  7749. }
  7750. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7752. import { Nullable } from "babylonjs/types";
  7753. import { Scene } from "babylonjs/scene";
  7754. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7755. module "babylonjs/Engines/thinEngine" {
  7756. interface ThinEngine {
  7757. /**
  7758. * Creates a depth stencil cube texture.
  7759. * This is only available in WebGL 2.
  7760. * @param size The size of face edge in the cube texture.
  7761. * @param options The options defining the cube texture.
  7762. * @returns The cube texture
  7763. */
  7764. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7765. /**
  7766. * Creates a cube texture
  7767. * @param rootUrl defines the url where the files to load is located
  7768. * @param scene defines the current scene
  7769. * @param files defines the list of files to load (1 per face)
  7770. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7771. * @param onLoad defines an optional callback raised when the texture is loaded
  7772. * @param onError defines an optional callback raised if there is an issue to load the texture
  7773. * @param format defines the format of the data
  7774. * @param forcedExtension defines the extension to use to pick the right loader
  7775. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7776. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7777. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7778. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7779. * @returns the cube texture as an InternalTexture
  7780. */
  7781. 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>): InternalTexture;
  7782. /**
  7783. * Creates a cube texture
  7784. * @param rootUrl defines the url where the files to load is located
  7785. * @param scene defines the current scene
  7786. * @param files defines the list of files to load (1 per face)
  7787. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7788. * @param onLoad defines an optional callback raised when the texture is loaded
  7789. * @param onError defines an optional callback raised if there is an issue to load the texture
  7790. * @param format defines the format of the data
  7791. * @param forcedExtension defines the extension to use to pick the right loader
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. 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;
  7795. /**
  7796. * Creates a cube texture
  7797. * @param rootUrl defines the url where the files to load is located
  7798. * @param scene defines the current scene
  7799. * @param files defines the list of files to load (1 per face)
  7800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7801. * @param onLoad defines an optional callback raised when the texture is loaded
  7802. * @param onError defines an optional callback raised if there is an issue to load the texture
  7803. * @param format defines the format of the data
  7804. * @param forcedExtension defines the extension to use to pick the right loader
  7805. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7808. * @returns the cube texture as an InternalTexture
  7809. */
  7810. 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;
  7811. /** @hidden */
  7812. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7813. /** @hidden */
  7814. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7815. /** @hidden */
  7816. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7817. /** @hidden */
  7818. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7819. /**
  7820. * @hidden
  7821. */
  7822. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7823. }
  7824. }
  7825. }
  7826. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7827. import { Nullable } from "babylonjs/types";
  7828. import { Scene } from "babylonjs/scene";
  7829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7831. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7832. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7833. import { Observable } from "babylonjs/Misc/observable";
  7834. /**
  7835. * Class for creating a cube texture
  7836. */
  7837. export class CubeTexture extends BaseTexture {
  7838. private _delayedOnLoad;
  7839. /**
  7840. * Observable triggered once the texture has been loaded.
  7841. */
  7842. onLoadObservable: Observable<CubeTexture>;
  7843. /**
  7844. * The url of the texture
  7845. */
  7846. url: string;
  7847. /**
  7848. * Gets or sets the center of the bounding box associated with the cube texture.
  7849. * It must define where the camera used to render the texture was set
  7850. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7851. */
  7852. boundingBoxPosition: Vector3;
  7853. private _boundingBoxSize;
  7854. /**
  7855. * Gets or sets the size of the bounding box associated with the cube texture
  7856. * When defined, the cubemap will switch to local mode
  7857. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7858. * @example https://www.babylonjs-playground.com/#RNASML
  7859. */
  7860. set boundingBoxSize(value: Vector3);
  7861. /**
  7862. * Returns the bounding box size
  7863. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7864. */
  7865. get boundingBoxSize(): Vector3;
  7866. protected _rotationY: number;
  7867. /**
  7868. * Sets texture matrix rotation angle around Y axis in radians.
  7869. */
  7870. set rotationY(value: number);
  7871. /**
  7872. * Gets texture matrix rotation angle around Y axis radians.
  7873. */
  7874. get rotationY(): number;
  7875. /**
  7876. * Are mip maps generated for this texture or not.
  7877. */
  7878. get noMipmap(): boolean;
  7879. private _noMipmap;
  7880. private _files;
  7881. protected _forcedExtension: Nullable<string>;
  7882. private _extensions;
  7883. private _textureMatrix;
  7884. private _format;
  7885. private _createPolynomials;
  7886. /**
  7887. * Creates a cube texture from an array of image urls
  7888. * @param files defines an array of image urls
  7889. * @param scene defines the hosting scene
  7890. * @param noMipmap specifies if mip maps are not used
  7891. * @returns a cube texture
  7892. */
  7893. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7894. /**
  7895. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7896. * @param url defines the url of the prefiltered texture
  7897. * @param scene defines the scene the texture is attached to
  7898. * @param forcedExtension defines the extension of the file if different from the url
  7899. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7900. * @return the prefiltered texture
  7901. */
  7902. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7903. /**
  7904. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7905. * as prefiltered data.
  7906. * @param rootUrl defines the url of the texture or the root name of the six images
  7907. * @param null defines the scene or engine the texture is attached to
  7908. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7909. * @param noMipmap defines if mipmaps should be created or not
  7910. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7911. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7912. * @param onError defines a callback triggered in case of error during load
  7913. * @param format defines the internal format to use for the texture once loaded
  7914. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7915. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7916. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7917. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7918. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7919. * @return the cube texture
  7920. */
  7921. 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);
  7922. /**
  7923. * Get the current class name of the texture useful for serialization or dynamic coding.
  7924. * @returns "CubeTexture"
  7925. */
  7926. getClassName(): string;
  7927. /**
  7928. * Update the url (and optional buffer) of this texture if url was null during construction.
  7929. * @param url the url of the texture
  7930. * @param forcedExtension defines the extension to use
  7931. * @param onLoad callback called when the texture is loaded (defaults to null)
  7932. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7933. */
  7934. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7935. /**
  7936. * Delays loading of the cube texture
  7937. * @param forcedExtension defines the extension to use
  7938. */
  7939. delayLoad(forcedExtension?: string): void;
  7940. /**
  7941. * Returns the reflection texture matrix
  7942. * @returns the reflection texture matrix
  7943. */
  7944. getReflectionTextureMatrix(): Matrix;
  7945. /**
  7946. * Sets the reflection texture matrix
  7947. * @param value Reflection texture matrix
  7948. */
  7949. setReflectionTextureMatrix(value: Matrix): void;
  7950. /**
  7951. * Parses text to create a cube texture
  7952. * @param parsedTexture define the serialized text to read from
  7953. * @param scene defines the hosting scene
  7954. * @param rootUrl defines the root url of the cube texture
  7955. * @returns a cube texture
  7956. */
  7957. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7958. /**
  7959. * Makes a clone, or deep copy, of the cube texture
  7960. * @returns a new cube texture
  7961. */
  7962. clone(): CubeTexture;
  7963. }
  7964. }
  7965. declare module "babylonjs/Materials/materialDefines" {
  7966. /**
  7967. * Manages the defines for the Material
  7968. */
  7969. export class MaterialDefines {
  7970. /** @hidden */
  7971. protected _keys: string[];
  7972. private _isDirty;
  7973. /** @hidden */
  7974. _renderId: number;
  7975. /** @hidden */
  7976. _areLightsDirty: boolean;
  7977. /** @hidden */
  7978. _areLightsDisposed: boolean;
  7979. /** @hidden */
  7980. _areAttributesDirty: boolean;
  7981. /** @hidden */
  7982. _areTexturesDirty: boolean;
  7983. /** @hidden */
  7984. _areFresnelDirty: boolean;
  7985. /** @hidden */
  7986. _areMiscDirty: boolean;
  7987. /** @hidden */
  7988. _areImageProcessingDirty: boolean;
  7989. /** @hidden */
  7990. _normals: boolean;
  7991. /** @hidden */
  7992. _uvs: boolean;
  7993. /** @hidden */
  7994. _needNormals: boolean;
  7995. /** @hidden */
  7996. _needUVs: boolean;
  7997. [id: string]: any;
  7998. /**
  7999. * Specifies if the material needs to be re-calculated
  8000. */
  8001. get isDirty(): boolean;
  8002. /**
  8003. * Marks the material to indicate that it has been re-calculated
  8004. */
  8005. markAsProcessed(): void;
  8006. /**
  8007. * Marks the material to indicate that it needs to be re-calculated
  8008. */
  8009. markAsUnprocessed(): void;
  8010. /**
  8011. * Marks the material to indicate all of its defines need to be re-calculated
  8012. */
  8013. markAllAsDirty(): void;
  8014. /**
  8015. * Marks the material to indicate that image processing needs to be re-calculated
  8016. */
  8017. markAsImageProcessingDirty(): void;
  8018. /**
  8019. * Marks the material to indicate the lights need to be re-calculated
  8020. * @param disposed Defines whether the light is dirty due to dispose or not
  8021. */
  8022. markAsLightDirty(disposed?: boolean): void;
  8023. /**
  8024. * Marks the attribute state as changed
  8025. */
  8026. markAsAttributesDirty(): void;
  8027. /**
  8028. * Marks the texture state as changed
  8029. */
  8030. markAsTexturesDirty(): void;
  8031. /**
  8032. * Marks the fresnel state as changed
  8033. */
  8034. markAsFresnelDirty(): void;
  8035. /**
  8036. * Marks the misc state as changed
  8037. */
  8038. markAsMiscDirty(): void;
  8039. /**
  8040. * Rebuilds the material defines
  8041. */
  8042. rebuild(): void;
  8043. /**
  8044. * Specifies if two material defines are equal
  8045. * @param other - A material define instance to compare to
  8046. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8047. */
  8048. isEqual(other: MaterialDefines): boolean;
  8049. /**
  8050. * Clones this instance's defines to another instance
  8051. * @param other - material defines to clone values to
  8052. */
  8053. cloneTo(other: MaterialDefines): void;
  8054. /**
  8055. * Resets the material define values
  8056. */
  8057. reset(): void;
  8058. /**
  8059. * Converts the material define values to a string
  8060. * @returns - String of material define information
  8061. */
  8062. toString(): string;
  8063. }
  8064. }
  8065. declare module "babylonjs/Materials/colorCurves" {
  8066. import { Effect } from "babylonjs/Materials/effect";
  8067. /**
  8068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8070. * 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;
  8071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8072. */
  8073. export class ColorCurves {
  8074. private _dirty;
  8075. private _tempColor;
  8076. private _globalCurve;
  8077. private _highlightsCurve;
  8078. private _midtonesCurve;
  8079. private _shadowsCurve;
  8080. private _positiveCurve;
  8081. private _negativeCurve;
  8082. private _globalHue;
  8083. private _globalDensity;
  8084. private _globalSaturation;
  8085. private _globalExposure;
  8086. /**
  8087. * Gets the global Hue value.
  8088. * 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).
  8089. */
  8090. get globalHue(): number;
  8091. /**
  8092. * Sets the global Hue value.
  8093. * 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).
  8094. */
  8095. set globalHue(value: number);
  8096. /**
  8097. * Gets the global Density value.
  8098. * 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.
  8099. * Values less than zero provide a filter of opposite hue.
  8100. */
  8101. get globalDensity(): number;
  8102. /**
  8103. * Sets the global Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. set globalDensity(value: number);
  8108. /**
  8109. * Gets the global Saturation value.
  8110. * 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.
  8111. */
  8112. get globalSaturation(): number;
  8113. /**
  8114. * Sets the global Saturation value.
  8115. * 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.
  8116. */
  8117. set globalSaturation(value: number);
  8118. /**
  8119. * Gets the global Exposure value.
  8120. * 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.
  8121. */
  8122. get globalExposure(): number;
  8123. /**
  8124. * Sets the global Exposure value.
  8125. * 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.
  8126. */
  8127. set globalExposure(value: number);
  8128. private _highlightsHue;
  8129. private _highlightsDensity;
  8130. private _highlightsSaturation;
  8131. private _highlightsExposure;
  8132. /**
  8133. * Gets the highlights Hue value.
  8134. * 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).
  8135. */
  8136. get highlightsHue(): number;
  8137. /**
  8138. * Sets the highlights Hue value.
  8139. * 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).
  8140. */
  8141. set highlightsHue(value: number);
  8142. /**
  8143. * Gets the highlights Density value.
  8144. * 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.
  8145. * Values less than zero provide a filter of opposite hue.
  8146. */
  8147. get highlightsDensity(): number;
  8148. /**
  8149. * Sets the highlights Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. set highlightsDensity(value: number);
  8154. /**
  8155. * Gets the highlights Saturation value.
  8156. * 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.
  8157. */
  8158. get highlightsSaturation(): number;
  8159. /**
  8160. * Sets the highlights Saturation value.
  8161. * 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.
  8162. */
  8163. set highlightsSaturation(value: number);
  8164. /**
  8165. * Gets the highlights Exposure value.
  8166. * 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.
  8167. */
  8168. get highlightsExposure(): number;
  8169. /**
  8170. * Sets the highlights Exposure value.
  8171. * 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.
  8172. */
  8173. set highlightsExposure(value: number);
  8174. private _midtonesHue;
  8175. private _midtonesDensity;
  8176. private _midtonesSaturation;
  8177. private _midtonesExposure;
  8178. /**
  8179. * Gets the midtones Hue value.
  8180. * 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).
  8181. */
  8182. get midtonesHue(): number;
  8183. /**
  8184. * Sets the midtones Hue value.
  8185. * 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).
  8186. */
  8187. set midtonesHue(value: number);
  8188. /**
  8189. * Gets the midtones Density value.
  8190. * 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.
  8191. * Values less than zero provide a filter of opposite hue.
  8192. */
  8193. get midtonesDensity(): number;
  8194. /**
  8195. * Sets the midtones Density value.
  8196. * 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.
  8197. * Values less than zero provide a filter of opposite hue.
  8198. */
  8199. set midtonesDensity(value: number);
  8200. /**
  8201. * Gets the midtones Saturation value.
  8202. * 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.
  8203. */
  8204. get midtonesSaturation(): number;
  8205. /**
  8206. * Sets the midtones Saturation value.
  8207. * 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.
  8208. */
  8209. set midtonesSaturation(value: number);
  8210. /**
  8211. * Gets the midtones Exposure value.
  8212. * 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.
  8213. */
  8214. get midtonesExposure(): number;
  8215. /**
  8216. * Sets the midtones Exposure value.
  8217. * 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.
  8218. */
  8219. set midtonesExposure(value: number);
  8220. private _shadowsHue;
  8221. private _shadowsDensity;
  8222. private _shadowsSaturation;
  8223. private _shadowsExposure;
  8224. /**
  8225. * Gets the shadows Hue value.
  8226. * 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).
  8227. */
  8228. get shadowsHue(): number;
  8229. /**
  8230. * Sets the shadows Hue value.
  8231. * 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).
  8232. */
  8233. set shadowsHue(value: number);
  8234. /**
  8235. * Gets the shadows Density value.
  8236. * 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.
  8237. * Values less than zero provide a filter of opposite hue.
  8238. */
  8239. get shadowsDensity(): number;
  8240. /**
  8241. * Sets the shadows Density value.
  8242. * 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.
  8243. * Values less than zero provide a filter of opposite hue.
  8244. */
  8245. set shadowsDensity(value: number);
  8246. /**
  8247. * Gets the shadows Saturation value.
  8248. * 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.
  8249. */
  8250. get shadowsSaturation(): number;
  8251. /**
  8252. * Sets the shadows Saturation value.
  8253. * 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.
  8254. */
  8255. set shadowsSaturation(value: number);
  8256. /**
  8257. * Gets the shadows Exposure value.
  8258. * 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.
  8259. */
  8260. get shadowsExposure(): number;
  8261. /**
  8262. * Sets the shadows Exposure value.
  8263. * 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.
  8264. */
  8265. set shadowsExposure(value: number);
  8266. /**
  8267. * Returns the class name
  8268. * @returns The class name
  8269. */
  8270. getClassName(): string;
  8271. /**
  8272. * Binds the color curves to the shader.
  8273. * @param colorCurves The color curve to bind
  8274. * @param effect The effect to bind to
  8275. * @param positiveUniform The positive uniform shader parameter
  8276. * @param neutralUniform The neutral uniform shader parameter
  8277. * @param negativeUniform The negative uniform shader parameter
  8278. */
  8279. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8280. /**
  8281. * Prepare the list of uniforms associated with the ColorCurves effects.
  8282. * @param uniformsList The list of uniforms used in the effect
  8283. */
  8284. static PrepareUniforms(uniformsList: string[]): void;
  8285. /**
  8286. * Returns color grading data based on a hue, density, saturation and exposure value.
  8287. * @param filterHue The hue of the color filter.
  8288. * @param filterDensity The density of the color filter.
  8289. * @param saturation The saturation.
  8290. * @param exposure The exposure.
  8291. * @param result The result data container.
  8292. */
  8293. private getColorGradingDataToRef;
  8294. /**
  8295. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8296. * @param value The input slider value in range [-100,100].
  8297. * @returns Adjusted value.
  8298. */
  8299. private static applyColorGradingSliderNonlinear;
  8300. /**
  8301. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8302. * @param hue The hue (H) input.
  8303. * @param saturation The saturation (S) input.
  8304. * @param brightness The brightness (B) input.
  8305. * @result An RGBA color represented as Vector4.
  8306. */
  8307. private static fromHSBToRef;
  8308. /**
  8309. * Returns a value clamped between min and max
  8310. * @param value The value to clamp
  8311. * @param min The minimum of value
  8312. * @param max The maximum of value
  8313. * @returns The clamped value.
  8314. */
  8315. private static clamp;
  8316. /**
  8317. * Clones the current color curve instance.
  8318. * @return The cloned curves
  8319. */
  8320. clone(): ColorCurves;
  8321. /**
  8322. * Serializes the current color curve instance to a json representation.
  8323. * @return a JSON representation
  8324. */
  8325. serialize(): any;
  8326. /**
  8327. * Parses the color curve from a json representation.
  8328. * @param source the JSON source to parse
  8329. * @return The parsed curves
  8330. */
  8331. static Parse(source: any): ColorCurves;
  8332. }
  8333. }
  8334. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8335. import { Observable } from "babylonjs/Misc/observable";
  8336. import { Nullable } from "babylonjs/types";
  8337. import { Color4 } from "babylonjs/Maths/math.color";
  8338. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8339. import { Effect } from "babylonjs/Materials/effect";
  8340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8341. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8342. /**
  8343. * Interface to follow in your material defines to integrate easily the
  8344. * Image proccessing functions.
  8345. * @hidden
  8346. */
  8347. export interface IImageProcessingConfigurationDefines {
  8348. IMAGEPROCESSING: boolean;
  8349. VIGNETTE: boolean;
  8350. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8351. VIGNETTEBLENDMODEOPAQUE: boolean;
  8352. TONEMAPPING: boolean;
  8353. TONEMAPPING_ACES: boolean;
  8354. CONTRAST: boolean;
  8355. EXPOSURE: boolean;
  8356. COLORCURVES: boolean;
  8357. COLORGRADING: boolean;
  8358. COLORGRADING3D: boolean;
  8359. SAMPLER3DGREENDEPTH: boolean;
  8360. SAMPLER3DBGRMAP: boolean;
  8361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8362. }
  8363. /**
  8364. * @hidden
  8365. */
  8366. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8367. IMAGEPROCESSING: boolean;
  8368. VIGNETTE: boolean;
  8369. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8370. VIGNETTEBLENDMODEOPAQUE: boolean;
  8371. TONEMAPPING: boolean;
  8372. TONEMAPPING_ACES: boolean;
  8373. CONTRAST: boolean;
  8374. COLORCURVES: boolean;
  8375. COLORGRADING: boolean;
  8376. COLORGRADING3D: boolean;
  8377. SAMPLER3DGREENDEPTH: boolean;
  8378. SAMPLER3DBGRMAP: boolean;
  8379. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8380. EXPOSURE: boolean;
  8381. constructor();
  8382. }
  8383. /**
  8384. * This groups together the common properties used for image processing either in direct forward pass
  8385. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8386. * or not.
  8387. */
  8388. export class ImageProcessingConfiguration {
  8389. /**
  8390. * Default tone mapping applied in BabylonJS.
  8391. */
  8392. static readonly TONEMAPPING_STANDARD: number;
  8393. /**
  8394. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8395. * to other engines rendering to increase portability.
  8396. */
  8397. static readonly TONEMAPPING_ACES: number;
  8398. /**
  8399. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8400. */
  8401. colorCurves: Nullable<ColorCurves>;
  8402. private _colorCurvesEnabled;
  8403. /**
  8404. * Gets wether the color curves effect is enabled.
  8405. */
  8406. get colorCurvesEnabled(): boolean;
  8407. /**
  8408. * Sets wether the color curves effect is enabled.
  8409. */
  8410. set colorCurvesEnabled(value: boolean);
  8411. private _colorGradingTexture;
  8412. /**
  8413. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8414. */
  8415. get colorGradingTexture(): Nullable<BaseTexture>;
  8416. /**
  8417. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8418. */
  8419. set colorGradingTexture(value: Nullable<BaseTexture>);
  8420. private _colorGradingEnabled;
  8421. /**
  8422. * Gets wether the color grading effect is enabled.
  8423. */
  8424. get colorGradingEnabled(): boolean;
  8425. /**
  8426. * Sets wether the color grading effect is enabled.
  8427. */
  8428. set colorGradingEnabled(value: boolean);
  8429. private _colorGradingWithGreenDepth;
  8430. /**
  8431. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8432. */
  8433. get colorGradingWithGreenDepth(): boolean;
  8434. /**
  8435. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8436. */
  8437. set colorGradingWithGreenDepth(value: boolean);
  8438. private _colorGradingBGR;
  8439. /**
  8440. * Gets wether the color grading texture contains BGR values.
  8441. */
  8442. get colorGradingBGR(): boolean;
  8443. /**
  8444. * Sets wether the color grading texture contains BGR values.
  8445. */
  8446. set colorGradingBGR(value: boolean);
  8447. /** @hidden */
  8448. _exposure: number;
  8449. /**
  8450. * Gets the Exposure used in the effect.
  8451. */
  8452. get exposure(): number;
  8453. /**
  8454. * Sets the Exposure used in the effect.
  8455. */
  8456. set exposure(value: number);
  8457. private _toneMappingEnabled;
  8458. /**
  8459. * Gets wether the tone mapping effect is enabled.
  8460. */
  8461. get toneMappingEnabled(): boolean;
  8462. /**
  8463. * Sets wether the tone mapping effect is enabled.
  8464. */
  8465. set toneMappingEnabled(value: boolean);
  8466. private _toneMappingType;
  8467. /**
  8468. * Gets the type of tone mapping effect.
  8469. */
  8470. get toneMappingType(): number;
  8471. /**
  8472. * Sets the type of tone mapping effect used in BabylonJS.
  8473. */
  8474. set toneMappingType(value: number);
  8475. protected _contrast: number;
  8476. /**
  8477. * Gets the contrast used in the effect.
  8478. */
  8479. get contrast(): number;
  8480. /**
  8481. * Sets the contrast used in the effect.
  8482. */
  8483. set contrast(value: number);
  8484. /**
  8485. * Vignette stretch size.
  8486. */
  8487. vignetteStretch: number;
  8488. /**
  8489. * Vignette centre X Offset.
  8490. */
  8491. vignetteCentreX: number;
  8492. /**
  8493. * Vignette centre Y Offset.
  8494. */
  8495. vignetteCentreY: number;
  8496. /**
  8497. * Vignette weight or intensity of the vignette effect.
  8498. */
  8499. vignetteWeight: number;
  8500. /**
  8501. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8502. * if vignetteEnabled is set to true.
  8503. */
  8504. vignetteColor: Color4;
  8505. /**
  8506. * Camera field of view used by the Vignette effect.
  8507. */
  8508. vignetteCameraFov: number;
  8509. private _vignetteBlendMode;
  8510. /**
  8511. * Gets the vignette blend mode allowing different kind of effect.
  8512. */
  8513. get vignetteBlendMode(): number;
  8514. /**
  8515. * Sets the vignette blend mode allowing different kind of effect.
  8516. */
  8517. set vignetteBlendMode(value: number);
  8518. private _vignetteEnabled;
  8519. /**
  8520. * Gets wether the vignette effect is enabled.
  8521. */
  8522. get vignetteEnabled(): boolean;
  8523. /**
  8524. * Sets wether the vignette effect is enabled.
  8525. */
  8526. set vignetteEnabled(value: boolean);
  8527. private _applyByPostProcess;
  8528. /**
  8529. * Gets wether the image processing is applied through a post process or not.
  8530. */
  8531. get applyByPostProcess(): boolean;
  8532. /**
  8533. * Sets wether the image processing is applied through a post process or not.
  8534. */
  8535. set applyByPostProcess(value: boolean);
  8536. private _isEnabled;
  8537. /**
  8538. * Gets wether the image processing is enabled or not.
  8539. */
  8540. get isEnabled(): boolean;
  8541. /**
  8542. * Sets wether the image processing is enabled or not.
  8543. */
  8544. set isEnabled(value: boolean);
  8545. /**
  8546. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8547. */
  8548. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8549. /**
  8550. * Method called each time the image processing information changes requires to recompile the effect.
  8551. */
  8552. protected _updateParameters(): void;
  8553. /**
  8554. * Gets the current class name.
  8555. * @return "ImageProcessingConfiguration"
  8556. */
  8557. getClassName(): string;
  8558. /**
  8559. * Prepare the list of uniforms associated with the Image Processing effects.
  8560. * @param uniforms The list of uniforms used in the effect
  8561. * @param defines the list of defines currently in use
  8562. */
  8563. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8564. /**
  8565. * Prepare the list of samplers associated with the Image Processing effects.
  8566. * @param samplersList The list of uniforms used in the effect
  8567. * @param defines the list of defines currently in use
  8568. */
  8569. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8570. /**
  8571. * Prepare the list of defines associated to the shader.
  8572. * @param defines the list of defines to complete
  8573. * @param forPostProcess Define if we are currently in post process mode or not
  8574. */
  8575. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8576. /**
  8577. * Returns true if all the image processing information are ready.
  8578. * @returns True if ready, otherwise, false
  8579. */
  8580. isReady(): boolean;
  8581. /**
  8582. * Binds the image processing to the shader.
  8583. * @param effect The effect to bind to
  8584. * @param overrideAspectRatio Override the aspect ratio of the effect
  8585. */
  8586. bind(effect: Effect, overrideAspectRatio?: number): void;
  8587. /**
  8588. * Clones the current image processing instance.
  8589. * @return The cloned image processing
  8590. */
  8591. clone(): ImageProcessingConfiguration;
  8592. /**
  8593. * Serializes the current image processing instance to a json representation.
  8594. * @return a JSON representation
  8595. */
  8596. serialize(): any;
  8597. /**
  8598. * Parses the image processing from a json representation.
  8599. * @param source the JSON source to parse
  8600. * @return The parsed image processing
  8601. */
  8602. static Parse(source: any): ImageProcessingConfiguration;
  8603. private static _VIGNETTEMODE_MULTIPLY;
  8604. private static _VIGNETTEMODE_OPAQUE;
  8605. /**
  8606. * Used to apply the vignette as a mix with the pixel color.
  8607. */
  8608. static get VIGNETTEMODE_MULTIPLY(): number;
  8609. /**
  8610. * Used to apply the vignette as a replacement of the pixel color.
  8611. */
  8612. static get VIGNETTEMODE_OPAQUE(): number;
  8613. }
  8614. }
  8615. declare module "babylonjs/Shaders/postprocess.vertex" {
  8616. /** @hidden */
  8617. export var postprocessVertexShader: {
  8618. name: string;
  8619. shader: string;
  8620. };
  8621. }
  8622. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8624. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8626. module "babylonjs/Engines/thinEngine" {
  8627. interface ThinEngine {
  8628. /**
  8629. * Creates a new render target texture
  8630. * @param size defines the size of the texture
  8631. * @param options defines the options used to create the texture
  8632. * @returns a new render target texture stored in an InternalTexture
  8633. */
  8634. createRenderTargetTexture(size: number | {
  8635. width: number;
  8636. height: number;
  8637. layers?: number;
  8638. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8639. /**
  8640. * Creates a depth stencil texture.
  8641. * This is only available in WebGL 2 or with the depth texture extension available.
  8642. * @param size The size of face edge in the texture.
  8643. * @param options The options defining the texture.
  8644. * @returns The texture
  8645. */
  8646. createDepthStencilTexture(size: number | {
  8647. width: number;
  8648. height: number;
  8649. layers?: number;
  8650. }, options: DepthTextureCreationOptions): InternalTexture;
  8651. /** @hidden */
  8652. _createDepthStencilTexture(size: number | {
  8653. width: number;
  8654. height: number;
  8655. layers?: number;
  8656. }, options: DepthTextureCreationOptions): InternalTexture;
  8657. }
  8658. }
  8659. }
  8660. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8661. /**
  8662. * Defines the kind of connection point for node based material
  8663. */
  8664. export enum NodeMaterialBlockConnectionPointTypes {
  8665. /** Float */
  8666. Float = 1,
  8667. /** Int */
  8668. Int = 2,
  8669. /** Vector2 */
  8670. Vector2 = 4,
  8671. /** Vector3 */
  8672. Vector3 = 8,
  8673. /** Vector4 */
  8674. Vector4 = 16,
  8675. /** Color3 */
  8676. Color3 = 32,
  8677. /** Color4 */
  8678. Color4 = 64,
  8679. /** Matrix */
  8680. Matrix = 128,
  8681. /** Custom object */
  8682. Object = 256,
  8683. /** Detect type based on connection */
  8684. AutoDetect = 1024,
  8685. /** Output type that will be defined by input type */
  8686. BasedOnInput = 2048
  8687. }
  8688. }
  8689. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8690. /**
  8691. * Enum used to define the target of a block
  8692. */
  8693. export enum NodeMaterialBlockTargets {
  8694. /** Vertex shader */
  8695. Vertex = 1,
  8696. /** Fragment shader */
  8697. Fragment = 2,
  8698. /** Neutral */
  8699. Neutral = 4,
  8700. /** Vertex and Fragment */
  8701. VertexAndFragment = 3
  8702. }
  8703. }
  8704. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8705. /**
  8706. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8707. */
  8708. export enum NodeMaterialBlockConnectionPointMode {
  8709. /** Value is an uniform */
  8710. Uniform = 0,
  8711. /** Value is a mesh attribute */
  8712. Attribute = 1,
  8713. /** Value is a varying between vertex and fragment shaders */
  8714. Varying = 2,
  8715. /** Mode is undefined */
  8716. Undefined = 3
  8717. }
  8718. }
  8719. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8720. /**
  8721. * Enum used to define system values e.g. values automatically provided by the system
  8722. */
  8723. export enum NodeMaterialSystemValues {
  8724. /** World */
  8725. World = 1,
  8726. /** View */
  8727. View = 2,
  8728. /** Projection */
  8729. Projection = 3,
  8730. /** ViewProjection */
  8731. ViewProjection = 4,
  8732. /** WorldView */
  8733. WorldView = 5,
  8734. /** WorldViewProjection */
  8735. WorldViewProjection = 6,
  8736. /** CameraPosition */
  8737. CameraPosition = 7,
  8738. /** Fog Color */
  8739. FogColor = 8,
  8740. /** Delta time */
  8741. DeltaTime = 9
  8742. }
  8743. }
  8744. declare module "babylonjs/Maths/math.axis" {
  8745. import { Vector3 } from "babylonjs/Maths/math.vector";
  8746. /** Defines supported spaces */
  8747. export enum Space {
  8748. /** Local (object) space */
  8749. LOCAL = 0,
  8750. /** World space */
  8751. WORLD = 1,
  8752. /** Bone space */
  8753. BONE = 2
  8754. }
  8755. /** Defines the 3 main axes */
  8756. export class Axis {
  8757. /** X axis */
  8758. static X: Vector3;
  8759. /** Y axis */
  8760. static Y: Vector3;
  8761. /** Z axis */
  8762. static Z: Vector3;
  8763. }
  8764. }
  8765. declare module "babylonjs/Maths/math.frustum" {
  8766. import { Matrix } from "babylonjs/Maths/math.vector";
  8767. import { DeepImmutable } from "babylonjs/types";
  8768. import { Plane } from "babylonjs/Maths/math.plane";
  8769. /**
  8770. * Represents a camera frustum
  8771. */
  8772. export class Frustum {
  8773. /**
  8774. * Gets the planes representing the frustum
  8775. * @param transform matrix to be applied to the returned planes
  8776. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8777. */
  8778. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8779. /**
  8780. * Gets the near frustum plane transformed by the transform matrix
  8781. * @param transform transformation matrix to be applied to the resulting frustum plane
  8782. * @param frustumPlane the resuling frustum plane
  8783. */
  8784. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8785. /**
  8786. * Gets the far frustum plane transformed by the transform matrix
  8787. * @param transform transformation matrix to be applied to the resulting frustum plane
  8788. * @param frustumPlane the resuling frustum plane
  8789. */
  8790. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8791. /**
  8792. * Gets the left frustum plane transformed by the transform matrix
  8793. * @param transform transformation matrix to be applied to the resulting frustum plane
  8794. * @param frustumPlane the resuling frustum plane
  8795. */
  8796. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8797. /**
  8798. * Gets the right frustum plane transformed by the transform matrix
  8799. * @param transform transformation matrix to be applied to the resulting frustum plane
  8800. * @param frustumPlane the resuling frustum plane
  8801. */
  8802. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8803. /**
  8804. * Gets the top frustum plane transformed by the transform matrix
  8805. * @param transform transformation matrix to be applied to the resulting frustum plane
  8806. * @param frustumPlane the resuling frustum plane
  8807. */
  8808. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8809. /**
  8810. * Gets the bottom frustum plane transformed by the transform matrix
  8811. * @param transform transformation matrix to be applied to the resulting frustum plane
  8812. * @param frustumPlane the resuling frustum plane
  8813. */
  8814. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8815. /**
  8816. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8817. * @param transform transformation matrix to be applied to the resulting frustum planes
  8818. * @param frustumPlanes the resuling frustum planes
  8819. */
  8820. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8821. }
  8822. }
  8823. declare module "babylonjs/Maths/math.size" {
  8824. /**
  8825. * Interface for the size containing width and height
  8826. */
  8827. export interface ISize {
  8828. /**
  8829. * Width
  8830. */
  8831. width: number;
  8832. /**
  8833. * Heighht
  8834. */
  8835. height: number;
  8836. }
  8837. /**
  8838. * Size containing widht and height
  8839. */
  8840. export class Size implements ISize {
  8841. /**
  8842. * Width
  8843. */
  8844. width: number;
  8845. /**
  8846. * Height
  8847. */
  8848. height: number;
  8849. /**
  8850. * Creates a Size object from the given width and height (floats).
  8851. * @param width width of the new size
  8852. * @param height height of the new size
  8853. */
  8854. constructor(width: number, height: number);
  8855. /**
  8856. * Returns a string with the Size width and height
  8857. * @returns a string with the Size width and height
  8858. */
  8859. toString(): string;
  8860. /**
  8861. * "Size"
  8862. * @returns the string "Size"
  8863. */
  8864. getClassName(): string;
  8865. /**
  8866. * Returns the Size hash code.
  8867. * @returns a hash code for a unique width and height
  8868. */
  8869. getHashCode(): number;
  8870. /**
  8871. * Updates the current size from the given one.
  8872. * @param src the given size
  8873. */
  8874. copyFrom(src: Size): void;
  8875. /**
  8876. * Updates in place the current Size from the given floats.
  8877. * @param width width of the new size
  8878. * @param height height of the new size
  8879. * @returns the updated Size.
  8880. */
  8881. copyFromFloats(width: number, height: number): Size;
  8882. /**
  8883. * Updates in place the current Size from the given floats.
  8884. * @param width width to set
  8885. * @param height height to set
  8886. * @returns the updated Size.
  8887. */
  8888. set(width: number, height: number): Size;
  8889. /**
  8890. * Multiplies the width and height by numbers
  8891. * @param w factor to multiple the width by
  8892. * @param h factor to multiple the height by
  8893. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8894. */
  8895. multiplyByFloats(w: number, h: number): Size;
  8896. /**
  8897. * Clones the size
  8898. * @returns a new Size copied from the given one.
  8899. */
  8900. clone(): Size;
  8901. /**
  8902. * True if the current Size and the given one width and height are strictly equal.
  8903. * @param other the other size to compare against
  8904. * @returns True if the current Size and the given one width and height are strictly equal.
  8905. */
  8906. equals(other: Size): boolean;
  8907. /**
  8908. * The surface of the Size : width * height (float).
  8909. */
  8910. get surface(): number;
  8911. /**
  8912. * Create a new size of zero
  8913. * @returns a new Size set to (0.0, 0.0)
  8914. */
  8915. static Zero(): Size;
  8916. /**
  8917. * Sums the width and height of two sizes
  8918. * @param otherSize size to add to this size
  8919. * @returns a new Size set as the addition result of the current Size and the given one.
  8920. */
  8921. add(otherSize: Size): Size;
  8922. /**
  8923. * Subtracts the width and height of two
  8924. * @param otherSize size to subtract to this size
  8925. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8926. */
  8927. subtract(otherSize: Size): Size;
  8928. /**
  8929. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8930. * @param start starting size to lerp between
  8931. * @param end end size to lerp between
  8932. * @param amount amount to lerp between the start and end values
  8933. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8934. */
  8935. static Lerp(start: Size, end: Size, amount: number): Size;
  8936. }
  8937. }
  8938. declare module "babylonjs/Maths/math.vertexFormat" {
  8939. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8940. /**
  8941. * Contains position and normal vectors for a vertex
  8942. */
  8943. export class PositionNormalVertex {
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position: Vector3;
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal: Vector3;
  8948. /**
  8949. * Creates a PositionNormalVertex
  8950. * @param position the position of the vertex (defaut: 0,0,0)
  8951. * @param normal the normal of the vertex (defaut: 0,1,0)
  8952. */
  8953. constructor(
  8954. /** the position of the vertex (defaut: 0,0,0) */
  8955. position?: Vector3,
  8956. /** the normal of the vertex (defaut: 0,1,0) */
  8957. normal?: Vector3);
  8958. /**
  8959. * Clones the PositionNormalVertex
  8960. * @returns the cloned PositionNormalVertex
  8961. */
  8962. clone(): PositionNormalVertex;
  8963. }
  8964. /**
  8965. * Contains position, normal and uv vectors for a vertex
  8966. */
  8967. export class PositionNormalTextureVertex {
  8968. /** the position of the vertex (defaut: 0,0,0) */
  8969. position: Vector3;
  8970. /** the normal of the vertex (defaut: 0,1,0) */
  8971. normal: Vector3;
  8972. /** the uv of the vertex (default: 0,0) */
  8973. uv: Vector2;
  8974. /**
  8975. * Creates a PositionNormalTextureVertex
  8976. * @param position the position of the vertex (defaut: 0,0,0)
  8977. * @param normal the normal of the vertex (defaut: 0,1,0)
  8978. * @param uv the uv of the vertex (default: 0,0)
  8979. */
  8980. constructor(
  8981. /** the position of the vertex (defaut: 0,0,0) */
  8982. position?: Vector3,
  8983. /** the normal of the vertex (defaut: 0,1,0) */
  8984. normal?: Vector3,
  8985. /** the uv of the vertex (default: 0,0) */
  8986. uv?: Vector2);
  8987. /**
  8988. * Clones the PositionNormalTextureVertex
  8989. * @returns the cloned PositionNormalTextureVertex
  8990. */
  8991. clone(): PositionNormalTextureVertex;
  8992. }
  8993. }
  8994. declare module "babylonjs/Maths/math" {
  8995. export * from "babylonjs/Maths/math.axis";
  8996. export * from "babylonjs/Maths/math.color";
  8997. export * from "babylonjs/Maths/math.constants";
  8998. export * from "babylonjs/Maths/math.frustum";
  8999. export * from "babylonjs/Maths/math.path";
  9000. export * from "babylonjs/Maths/math.plane";
  9001. export * from "babylonjs/Maths/math.size";
  9002. export * from "babylonjs/Maths/math.vector";
  9003. export * from "babylonjs/Maths/math.vertexFormat";
  9004. export * from "babylonjs/Maths/math.viewport";
  9005. }
  9006. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9007. /**
  9008. * Enum defining the type of animations supported by InputBlock
  9009. */
  9010. export enum AnimatedInputBlockTypes {
  9011. /** No animation */
  9012. None = 0,
  9013. /** Time based animation. Will only work for floats */
  9014. Time = 1
  9015. }
  9016. }
  9017. declare module "babylonjs/Lights/shadowLight" {
  9018. import { Camera } from "babylonjs/Cameras/camera";
  9019. import { Scene } from "babylonjs/scene";
  9020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9022. import { Light } from "babylonjs/Lights/light";
  9023. /**
  9024. * Interface describing all the common properties and methods a shadow light needs to implement.
  9025. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9026. * as well as binding the different shadow properties to the effects.
  9027. */
  9028. export interface IShadowLight extends Light {
  9029. /**
  9030. * The light id in the scene (used in scene.findLighById for instance)
  9031. */
  9032. id: string;
  9033. /**
  9034. * The position the shdow will be casted from.
  9035. */
  9036. position: Vector3;
  9037. /**
  9038. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9039. */
  9040. direction: Vector3;
  9041. /**
  9042. * The transformed position. Position of the light in world space taking parenting in account.
  9043. */
  9044. transformedPosition: Vector3;
  9045. /**
  9046. * The transformed direction. Direction of the light in world space taking parenting in account.
  9047. */
  9048. transformedDirection: Vector3;
  9049. /**
  9050. * The friendly name of the light in the scene.
  9051. */
  9052. name: string;
  9053. /**
  9054. * Defines the shadow projection clipping minimum z value.
  9055. */
  9056. shadowMinZ: number;
  9057. /**
  9058. * Defines the shadow projection clipping maximum z value.
  9059. */
  9060. shadowMaxZ: number;
  9061. /**
  9062. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9063. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9064. */
  9065. computeTransformedInformation(): boolean;
  9066. /**
  9067. * Gets the scene the light belongs to.
  9068. * @returns The scene
  9069. */
  9070. getScene(): Scene;
  9071. /**
  9072. * Callback defining a custom Projection Matrix Builder.
  9073. * This can be used to override the default projection matrix computation.
  9074. */
  9075. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9076. /**
  9077. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9078. * @param matrix The materix to updated with the projection information
  9079. * @param viewMatrix The transform matrix of the light
  9080. * @param renderList The list of mesh to render in the map
  9081. * @returns The current light
  9082. */
  9083. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9084. /**
  9085. * Gets the current depth scale used in ESM.
  9086. * @returns The scale
  9087. */
  9088. getDepthScale(): number;
  9089. /**
  9090. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9091. * @returns true if a cube texture needs to be use
  9092. */
  9093. needCube(): boolean;
  9094. /**
  9095. * Detects if the projection matrix requires to be recomputed this frame.
  9096. * @returns true if it requires to be recomputed otherwise, false.
  9097. */
  9098. needProjectionMatrixCompute(): boolean;
  9099. /**
  9100. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9101. */
  9102. forceProjectionMatrixCompute(): void;
  9103. /**
  9104. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9105. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9106. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9107. */
  9108. getShadowDirection(faceIndex?: number): Vector3;
  9109. /**
  9110. * Gets the minZ used for shadow according to both the scene and the light.
  9111. * @param activeCamera The camera we are returning the min for
  9112. * @returns the depth min z
  9113. */
  9114. getDepthMinZ(activeCamera: Camera): number;
  9115. /**
  9116. * Gets the maxZ used for shadow according to both the scene and the light.
  9117. * @param activeCamera The camera we are returning the max for
  9118. * @returns the depth max z
  9119. */
  9120. getDepthMaxZ(activeCamera: Camera): number;
  9121. }
  9122. /**
  9123. * Base implementation IShadowLight
  9124. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9125. */
  9126. export abstract class ShadowLight extends Light implements IShadowLight {
  9127. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9128. protected _position: Vector3;
  9129. protected _setPosition(value: Vector3): void;
  9130. /**
  9131. * Sets the position the shadow will be casted from. Also use as the light position for both
  9132. * point and spot lights.
  9133. */
  9134. get position(): Vector3;
  9135. /**
  9136. * Sets the position the shadow will be casted from. Also use as the light position for both
  9137. * point and spot lights.
  9138. */
  9139. set position(value: Vector3);
  9140. protected _direction: Vector3;
  9141. protected _setDirection(value: Vector3): void;
  9142. /**
  9143. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9144. * Also use as the light direction on spot and directional lights.
  9145. */
  9146. get direction(): Vector3;
  9147. /**
  9148. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9149. * Also use as the light direction on spot and directional lights.
  9150. */
  9151. set direction(value: Vector3);
  9152. protected _shadowMinZ: number;
  9153. /**
  9154. * Gets the shadow projection clipping minimum z value.
  9155. */
  9156. get shadowMinZ(): number;
  9157. /**
  9158. * Sets the shadow projection clipping minimum z value.
  9159. */
  9160. set shadowMinZ(value: number);
  9161. protected _shadowMaxZ: number;
  9162. /**
  9163. * Sets the shadow projection clipping maximum z value.
  9164. */
  9165. get shadowMaxZ(): number;
  9166. /**
  9167. * Gets the shadow projection clipping maximum z value.
  9168. */
  9169. set shadowMaxZ(value: number);
  9170. /**
  9171. * Callback defining a custom Projection Matrix Builder.
  9172. * This can be used to override the default projection matrix computation.
  9173. */
  9174. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9175. /**
  9176. * The transformed position. Position of the light in world space taking parenting in account.
  9177. */
  9178. transformedPosition: Vector3;
  9179. /**
  9180. * The transformed direction. Direction of the light in world space taking parenting in account.
  9181. */
  9182. transformedDirection: Vector3;
  9183. private _needProjectionMatrixCompute;
  9184. /**
  9185. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9186. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9187. */
  9188. computeTransformedInformation(): boolean;
  9189. /**
  9190. * Return the depth scale used for the shadow map.
  9191. * @returns the depth scale.
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9196. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9197. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9198. */
  9199. getShadowDirection(faceIndex?: number): Vector3;
  9200. /**
  9201. * Returns the ShadowLight absolute position in the World.
  9202. * @returns the position vector in world space
  9203. */
  9204. getAbsolutePosition(): Vector3;
  9205. /**
  9206. * Sets the ShadowLight direction toward the passed target.
  9207. * @param target The point to target in local space
  9208. * @returns the updated ShadowLight direction
  9209. */
  9210. setDirectionToTarget(target: Vector3): Vector3;
  9211. /**
  9212. * Returns the light rotation in euler definition.
  9213. * @returns the x y z rotation in local space.
  9214. */
  9215. getRotation(): Vector3;
  9216. /**
  9217. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9218. * @returns true if a cube texture needs to be use
  9219. */
  9220. needCube(): boolean;
  9221. /**
  9222. * Detects if the projection matrix requires to be recomputed this frame.
  9223. * @returns true if it requires to be recomputed otherwise, false.
  9224. */
  9225. needProjectionMatrixCompute(): boolean;
  9226. /**
  9227. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9228. */
  9229. forceProjectionMatrixCompute(): void;
  9230. /** @hidden */
  9231. _initCache(): void;
  9232. /** @hidden */
  9233. _isSynchronized(): boolean;
  9234. /**
  9235. * Computes the world matrix of the node
  9236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9237. * @returns the world matrix
  9238. */
  9239. computeWorldMatrix(force?: boolean): Matrix;
  9240. /**
  9241. * Gets the minZ used for shadow according to both the scene and the light.
  9242. * @param activeCamera The camera we are returning the min for
  9243. * @returns the depth min z
  9244. */
  9245. getDepthMinZ(activeCamera: Camera): number;
  9246. /**
  9247. * Gets the maxZ used for shadow according to both the scene and the light.
  9248. * @param activeCamera The camera we are returning the max for
  9249. * @returns the depth max z
  9250. */
  9251. getDepthMaxZ(activeCamera: Camera): number;
  9252. /**
  9253. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9254. * @param matrix The materix to updated with the projection information
  9255. * @param viewMatrix The transform matrix of the light
  9256. * @param renderList The list of mesh to render in the map
  9257. * @returns The current light
  9258. */
  9259. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9260. }
  9261. }
  9262. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9263. /** @hidden */
  9264. export var packingFunctions: {
  9265. name: string;
  9266. shader: string;
  9267. };
  9268. }
  9269. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9270. /** @hidden */
  9271. export var bayerDitherFunctions: {
  9272. name: string;
  9273. shader: string;
  9274. };
  9275. }
  9276. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9277. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9278. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9279. /** @hidden */
  9280. export var shadowMapFragmentDeclaration: {
  9281. name: string;
  9282. shader: string;
  9283. };
  9284. }
  9285. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9286. /** @hidden */
  9287. export var clipPlaneFragmentDeclaration: {
  9288. name: string;
  9289. shader: string;
  9290. };
  9291. }
  9292. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9293. /** @hidden */
  9294. export var clipPlaneFragment: {
  9295. name: string;
  9296. shader: string;
  9297. };
  9298. }
  9299. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9300. /** @hidden */
  9301. export var shadowMapFragment: {
  9302. name: string;
  9303. shader: string;
  9304. };
  9305. }
  9306. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9307. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9310. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9311. /** @hidden */
  9312. export var shadowMapPixelShader: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9318. /** @hidden */
  9319. export var bonesDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9325. /** @hidden */
  9326. export var morphTargetsVertexGlobalDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9332. /** @hidden */
  9333. export var morphTargetsVertexDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9339. /** @hidden */
  9340. export var instancesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9346. /** @hidden */
  9347. export var helperFunctions: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9353. /** @hidden */
  9354. export var shadowMapVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9360. /** @hidden */
  9361. export var clipPlaneVertexDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9367. /** @hidden */
  9368. export var morphTargetsVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9374. /** @hidden */
  9375. export var instancesVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9381. /** @hidden */
  9382. export var bonesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9388. /** @hidden */
  9389. export var shadowMapVertexNormalBias: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9395. /** @hidden */
  9396. export var shadowMapVertexMetric: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9402. /** @hidden */
  9403. export var clipPlaneVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9409. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9412. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9414. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9415. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9417. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9418. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9419. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9420. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9421. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9422. /** @hidden */
  9423. export var shadowMapVertexShader: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9429. /** @hidden */
  9430. export var depthBoxBlurPixelShader: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9436. /** @hidden */
  9437. export var shadowMapFragmentSoftTransparentShadow: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Materials/effectFallbacks" {
  9443. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9444. import { Effect } from "babylonjs/Materials/effect";
  9445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9446. /**
  9447. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9448. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9449. */
  9450. export class EffectFallbacks implements IEffectFallbacks {
  9451. private _defines;
  9452. private _currentRank;
  9453. private _maxRank;
  9454. private _mesh;
  9455. /**
  9456. * Removes the fallback from the bound mesh.
  9457. */
  9458. unBindMesh(): void;
  9459. /**
  9460. * Adds a fallback on the specified property.
  9461. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9462. * @param define The name of the define in the shader
  9463. */
  9464. addFallback(rank: number, define: string): void;
  9465. /**
  9466. * Sets the mesh to use CPU skinning when needing to fallback.
  9467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9468. * @param mesh The mesh to use the fallbacks.
  9469. */
  9470. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9471. /**
  9472. * Checks to see if more fallbacks are still availible.
  9473. */
  9474. get hasMoreFallbacks(): boolean;
  9475. /**
  9476. * Removes the defines that should be removed when falling back.
  9477. * @param currentDefines defines the current define statements for the shader.
  9478. * @param effect defines the current effect we try to compile
  9479. * @returns The resulting defines with defines of the current rank removed.
  9480. */
  9481. reduce(currentDefines: string, effect: Effect): string;
  9482. }
  9483. }
  9484. declare module "babylonjs/Actions/action" {
  9485. import { Observable } from "babylonjs/Misc/observable";
  9486. import { Condition } from "babylonjs/Actions/condition";
  9487. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9488. import { Scene } from "babylonjs/scene";
  9489. import { ActionManager } from "babylonjs/Actions/actionManager";
  9490. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9491. import { Node } from "babylonjs/node";
  9492. /**
  9493. * Interface used to define Action
  9494. */
  9495. export interface IAction {
  9496. /**
  9497. * Trigger for the action
  9498. */
  9499. trigger: number;
  9500. /** Options of the trigger */
  9501. triggerOptions: any;
  9502. /**
  9503. * Gets the trigger parameters
  9504. * @returns the trigger parameters
  9505. */
  9506. getTriggerParameter(): any;
  9507. /**
  9508. * Internal only - executes current action event
  9509. * @hidden
  9510. */
  9511. _executeCurrent(evt?: ActionEvent): void;
  9512. /**
  9513. * Serialize placeholder for child classes
  9514. * @param parent of child
  9515. * @returns the serialized object
  9516. */
  9517. serialize(parent: any): any;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. _prepare(): void;
  9523. /**
  9524. * Internal only - manager for action
  9525. * @hidden
  9526. */
  9527. _actionManager: AbstractActionManager;
  9528. /**
  9529. * Adds action to chain of actions, may be a DoNothingAction
  9530. * @param action defines the next action to execute
  9531. * @returns The action passed in
  9532. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9533. */
  9534. then(action: IAction): IAction;
  9535. }
  9536. /**
  9537. * The action to be carried out following a trigger
  9538. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9539. */
  9540. export class Action implements IAction {
  9541. /** the trigger, with or without parameters, for the action */
  9542. triggerOptions: any;
  9543. /**
  9544. * Trigger for the action
  9545. */
  9546. trigger: number;
  9547. /**
  9548. * Internal only - manager for action
  9549. * @hidden
  9550. */
  9551. _actionManager: ActionManager;
  9552. private _nextActiveAction;
  9553. private _child;
  9554. private _condition?;
  9555. private _triggerParameter;
  9556. /**
  9557. * An event triggered prior to action being executed.
  9558. */
  9559. onBeforeExecuteObservable: Observable<Action>;
  9560. /**
  9561. * Creates a new Action
  9562. * @param triggerOptions the trigger, with or without parameters, for the action
  9563. * @param condition an optional determinant of action
  9564. */
  9565. constructor(
  9566. /** the trigger, with or without parameters, for the action */
  9567. triggerOptions: any, condition?: Condition);
  9568. /**
  9569. * Internal only
  9570. * @hidden
  9571. */
  9572. _prepare(): void;
  9573. /**
  9574. * Gets the trigger parameters
  9575. * @returns the trigger parameters
  9576. */
  9577. getTriggerParameter(): any;
  9578. /**
  9579. * Internal only - executes current action event
  9580. * @hidden
  9581. */
  9582. _executeCurrent(evt?: ActionEvent): void;
  9583. /**
  9584. * Execute placeholder for child classes
  9585. * @param evt optional action event
  9586. */
  9587. execute(evt?: ActionEvent): void;
  9588. /**
  9589. * Skips to next active action
  9590. */
  9591. skipToNextActiveAction(): void;
  9592. /**
  9593. * Adds action to chain of actions, may be a DoNothingAction
  9594. * @param action defines the next action to execute
  9595. * @returns The action passed in
  9596. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9597. */
  9598. then(action: Action): Action;
  9599. /**
  9600. * Internal only
  9601. * @hidden
  9602. */
  9603. _getProperty(propertyPath: string): string;
  9604. /**
  9605. * Internal only
  9606. * @hidden
  9607. */
  9608. _getEffectiveTarget(target: any, propertyPath: string): any;
  9609. /**
  9610. * Serialize placeholder for child classes
  9611. * @param parent of child
  9612. * @returns the serialized object
  9613. */
  9614. serialize(parent: any): any;
  9615. /**
  9616. * Internal only called by serialize
  9617. * @hidden
  9618. */
  9619. protected _serialize(serializedAction: any, parent?: any): any;
  9620. /**
  9621. * Internal only
  9622. * @hidden
  9623. */
  9624. static _SerializeValueAsString: (value: any) => string;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. static _GetTargetProperty: (target: Scene | Node) => {
  9630. name: string;
  9631. targetType: string;
  9632. value: string;
  9633. };
  9634. }
  9635. }
  9636. declare module "babylonjs/Actions/condition" {
  9637. import { ActionManager } from "babylonjs/Actions/actionManager";
  9638. /**
  9639. * A Condition applied to an Action
  9640. */
  9641. export class Condition {
  9642. /**
  9643. * Internal only - manager for action
  9644. * @hidden
  9645. */
  9646. _actionManager: ActionManager;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. _evaluationId: number;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. _currentResult: boolean;
  9657. /**
  9658. * Creates a new Condition
  9659. * @param actionManager the manager of the action the condition is applied to
  9660. */
  9661. constructor(actionManager: ActionManager);
  9662. /**
  9663. * Check if the current condition is valid
  9664. * @returns a boolean
  9665. */
  9666. isValid(): boolean;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. _getProperty(propertyPath: string): string;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. _getEffectiveTarget(target: any, propertyPath: string): any;
  9677. /**
  9678. * Serialize placeholder for child classes
  9679. * @returns the serialized object
  9680. */
  9681. serialize(): any;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. protected _serialize(serializedCondition: any): any;
  9687. }
  9688. /**
  9689. * Defines specific conditional operators as extensions of Condition
  9690. */
  9691. export class ValueCondition extends Condition {
  9692. /** path to specify the property of the target the conditional operator uses */
  9693. propertyPath: string;
  9694. /** the value compared by the conditional operator against the current value of the property */
  9695. value: any;
  9696. /** the conditional operator, default ValueCondition.IsEqual */
  9697. operator: number;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. private static _IsEqual;
  9703. /**
  9704. * Internal only
  9705. * @hidden
  9706. */
  9707. private static _IsDifferent;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private static _IsGreater;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private static _IsLesser;
  9718. /**
  9719. * returns the number for IsEqual
  9720. */
  9721. static get IsEqual(): number;
  9722. /**
  9723. * Returns the number for IsDifferent
  9724. */
  9725. static get IsDifferent(): number;
  9726. /**
  9727. * Returns the number for IsGreater
  9728. */
  9729. static get IsGreater(): number;
  9730. /**
  9731. * Returns the number for IsLesser
  9732. */
  9733. static get IsLesser(): number;
  9734. /**
  9735. * Internal only The action manager for the condition
  9736. * @hidden
  9737. */
  9738. _actionManager: ActionManager;
  9739. /**
  9740. * Internal only
  9741. * @hidden
  9742. */
  9743. private _target;
  9744. /**
  9745. * Internal only
  9746. * @hidden
  9747. */
  9748. private _effectiveTarget;
  9749. /**
  9750. * Internal only
  9751. * @hidden
  9752. */
  9753. private _property;
  9754. /**
  9755. * Creates a new ValueCondition
  9756. * @param actionManager manager for the action the condition applies to
  9757. * @param target for the action
  9758. * @param propertyPath path to specify the property of the target the conditional operator uses
  9759. * @param value the value compared by the conditional operator against the current value of the property
  9760. * @param operator the conditional operator, default ValueCondition.IsEqual
  9761. */
  9762. constructor(actionManager: ActionManager, target: any,
  9763. /** path to specify the property of the target the conditional operator uses */
  9764. propertyPath: string,
  9765. /** the value compared by the conditional operator against the current value of the property */
  9766. value: any,
  9767. /** the conditional operator, default ValueCondition.IsEqual */
  9768. operator?: number);
  9769. /**
  9770. * Compares the given value with the property value for the specified conditional operator
  9771. * @returns the result of the comparison
  9772. */
  9773. isValid(): boolean;
  9774. /**
  9775. * Serialize the ValueCondition into a JSON compatible object
  9776. * @returns serialization object
  9777. */
  9778. serialize(): any;
  9779. /**
  9780. * Gets the name of the conditional operator for the ValueCondition
  9781. * @param operator the conditional operator
  9782. * @returns the name
  9783. */
  9784. static GetOperatorName(operator: number): string;
  9785. }
  9786. /**
  9787. * Defines a predicate condition as an extension of Condition
  9788. */
  9789. export class PredicateCondition extends Condition {
  9790. /** defines the predicate function used to validate the condition */
  9791. predicate: () => boolean;
  9792. /**
  9793. * Internal only - manager for action
  9794. * @hidden
  9795. */
  9796. _actionManager: ActionManager;
  9797. /**
  9798. * Creates a new PredicateCondition
  9799. * @param actionManager manager for the action the condition applies to
  9800. * @param predicate defines the predicate function used to validate the condition
  9801. */
  9802. constructor(actionManager: ActionManager,
  9803. /** defines the predicate function used to validate the condition */
  9804. predicate: () => boolean);
  9805. /**
  9806. * @returns the validity of the predicate condition
  9807. */
  9808. isValid(): boolean;
  9809. }
  9810. /**
  9811. * Defines a state condition as an extension of Condition
  9812. */
  9813. export class StateCondition extends Condition {
  9814. /** Value to compare with target state */
  9815. value: string;
  9816. /**
  9817. * Internal only - manager for action
  9818. * @hidden
  9819. */
  9820. _actionManager: ActionManager;
  9821. /**
  9822. * Internal only
  9823. * @hidden
  9824. */
  9825. private _target;
  9826. /**
  9827. * Creates a new StateCondition
  9828. * @param actionManager manager for the action the condition applies to
  9829. * @param target of the condition
  9830. * @param value to compare with target state
  9831. */
  9832. constructor(actionManager: ActionManager, target: any,
  9833. /** Value to compare with target state */
  9834. value: string);
  9835. /**
  9836. * Gets a boolean indicating if the current condition is met
  9837. * @returns the validity of the state
  9838. */
  9839. isValid(): boolean;
  9840. /**
  9841. * Serialize the StateCondition into a JSON compatible object
  9842. * @returns serialization object
  9843. */
  9844. serialize(): any;
  9845. }
  9846. }
  9847. declare module "babylonjs/Actions/directActions" {
  9848. import { Action } from "babylonjs/Actions/action";
  9849. import { Condition } from "babylonjs/Actions/condition";
  9850. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9851. /**
  9852. * This defines an action responsible to toggle a boolean once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class SwitchBooleanAction extends Action {
  9856. /**
  9857. * The path to the boolean property in the target object
  9858. */
  9859. propertyPath: string;
  9860. private _target;
  9861. private _effectiveTarget;
  9862. private _property;
  9863. /**
  9864. * Instantiate the action
  9865. * @param triggerOptions defines the trigger options
  9866. * @param target defines the object containing the boolean
  9867. * @param propertyPath defines the path to the boolean property in the target object
  9868. * @param condition defines the trigger related conditions
  9869. */
  9870. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9871. /** @hidden */
  9872. _prepare(): void;
  9873. /**
  9874. * Execute the action toggle the boolean value.
  9875. */
  9876. execute(): void;
  9877. /**
  9878. * Serializes the actions and its related information.
  9879. * @param parent defines the object to serialize in
  9880. * @returns the serialized object
  9881. */
  9882. serialize(parent: any): any;
  9883. }
  9884. /**
  9885. * This defines an action responsible to set a the state field of the target
  9886. * to a desired value once triggered.
  9887. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9888. */
  9889. export class SetStateAction extends Action {
  9890. /**
  9891. * The value to store in the state field.
  9892. */
  9893. value: string;
  9894. private _target;
  9895. /**
  9896. * Instantiate the action
  9897. * @param triggerOptions defines the trigger options
  9898. * @param target defines the object containing the state property
  9899. * @param value defines the value to store in the state field
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9903. /**
  9904. * Execute the action and store the value on the target state property.
  9905. */
  9906. execute(): void;
  9907. /**
  9908. * Serializes the actions and its related information.
  9909. * @param parent defines the object to serialize in
  9910. * @returns the serialized object
  9911. */
  9912. serialize(parent: any): any;
  9913. }
  9914. /**
  9915. * This defines an action responsible to set a property of the target
  9916. * to a desired value once triggered.
  9917. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9918. */
  9919. export class SetValueAction extends Action {
  9920. /**
  9921. * The path of the property to set in the target.
  9922. */
  9923. propertyPath: string;
  9924. /**
  9925. * The value to set in the property
  9926. */
  9927. value: any;
  9928. private _target;
  9929. private _effectiveTarget;
  9930. private _property;
  9931. /**
  9932. * Instantiate the action
  9933. * @param triggerOptions defines the trigger options
  9934. * @param target defines the object containing the property
  9935. * @param propertyPath defines the path of the property to set in the target
  9936. * @param value defines the value to set in the property
  9937. * @param condition defines the trigger related conditions
  9938. */
  9939. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9940. /** @hidden */
  9941. _prepare(): void;
  9942. /**
  9943. * Execute the action and set the targetted property to the desired value.
  9944. */
  9945. execute(): void;
  9946. /**
  9947. * Serializes the actions and its related information.
  9948. * @param parent defines the object to serialize in
  9949. * @returns the serialized object
  9950. */
  9951. serialize(parent: any): any;
  9952. }
  9953. /**
  9954. * This defines an action responsible to increment the target value
  9955. * to a desired value once triggered.
  9956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9957. */
  9958. export class IncrementValueAction extends Action {
  9959. /**
  9960. * The path of the property to increment in the target.
  9961. */
  9962. propertyPath: string;
  9963. /**
  9964. * The value we should increment the property by.
  9965. */
  9966. value: any;
  9967. private _target;
  9968. private _effectiveTarget;
  9969. private _property;
  9970. /**
  9971. * Instantiate the action
  9972. * @param triggerOptions defines the trigger options
  9973. * @param target defines the object containing the property
  9974. * @param propertyPath defines the path of the property to increment in the target
  9975. * @param value defines the value value we should increment the property by
  9976. * @param condition defines the trigger related conditions
  9977. */
  9978. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9979. /** @hidden */
  9980. _prepare(): void;
  9981. /**
  9982. * Execute the action and increment the target of the value amount.
  9983. */
  9984. execute(): void;
  9985. /**
  9986. * Serializes the actions and its related information.
  9987. * @param parent defines the object to serialize in
  9988. * @returns the serialized object
  9989. */
  9990. serialize(parent: any): any;
  9991. }
  9992. /**
  9993. * This defines an action responsible to start an animation once triggered.
  9994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9995. */
  9996. export class PlayAnimationAction extends Action {
  9997. /**
  9998. * Where the animation should start (animation frame)
  9999. */
  10000. from: number;
  10001. /**
  10002. * Where the animation should stop (animation frame)
  10003. */
  10004. to: number;
  10005. /**
  10006. * Define if the animation should loop or stop after the first play.
  10007. */
  10008. loop?: boolean;
  10009. private _target;
  10010. /**
  10011. * Instantiate the action
  10012. * @param triggerOptions defines the trigger options
  10013. * @param target defines the target animation or animation name
  10014. * @param from defines from where the animation should start (animation frame)
  10015. * @param end defines where the animation should stop (animation frame)
  10016. * @param loop defines if the animation should loop or stop after the first play
  10017. * @param condition defines the trigger related conditions
  10018. */
  10019. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10020. /** @hidden */
  10021. _prepare(): void;
  10022. /**
  10023. * Execute the action and play the animation.
  10024. */
  10025. execute(): void;
  10026. /**
  10027. * Serializes the actions and its related information.
  10028. * @param parent defines the object to serialize in
  10029. * @returns the serialized object
  10030. */
  10031. serialize(parent: any): any;
  10032. }
  10033. /**
  10034. * This defines an action responsible to stop an animation once triggered.
  10035. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10036. */
  10037. export class StopAnimationAction extends Action {
  10038. private _target;
  10039. /**
  10040. * Instantiate the action
  10041. * @param triggerOptions defines the trigger options
  10042. * @param target defines the target animation or animation name
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and stop the animation.
  10050. */
  10051. execute(): void;
  10052. /**
  10053. * Serializes the actions and its related information.
  10054. * @param parent defines the object to serialize in
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. }
  10059. /**
  10060. * This defines an action responsible that does nothing once triggered.
  10061. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10062. */
  10063. export class DoNothingAction extends Action {
  10064. /**
  10065. * Instantiate the action
  10066. * @param triggerOptions defines the trigger options
  10067. * @param condition defines the trigger related conditions
  10068. */
  10069. constructor(triggerOptions?: any, condition?: Condition);
  10070. /**
  10071. * Execute the action and do nothing.
  10072. */
  10073. execute(): void;
  10074. /**
  10075. * Serializes the actions and its related information.
  10076. * @param parent defines the object to serialize in
  10077. * @returns the serialized object
  10078. */
  10079. serialize(parent: any): any;
  10080. }
  10081. /**
  10082. * This defines an action responsible to trigger several actions once triggered.
  10083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10084. */
  10085. export class CombineAction extends Action {
  10086. /**
  10087. * The list of aggregated animations to run.
  10088. */
  10089. children: Action[];
  10090. /**
  10091. * Instantiate the action
  10092. * @param triggerOptions defines the trigger options
  10093. * @param children defines the list of aggregated animations to run
  10094. * @param condition defines the trigger related conditions
  10095. */
  10096. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10097. /** @hidden */
  10098. _prepare(): void;
  10099. /**
  10100. * Execute the action and executes all the aggregated actions.
  10101. */
  10102. execute(evt: ActionEvent): void;
  10103. /**
  10104. * Serializes the actions and its related information.
  10105. * @param parent defines the object to serialize in
  10106. * @returns the serialized object
  10107. */
  10108. serialize(parent: any): any;
  10109. }
  10110. /**
  10111. * This defines an action responsible to run code (external event) once triggered.
  10112. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10113. */
  10114. export class ExecuteCodeAction extends Action {
  10115. /**
  10116. * The callback function to run.
  10117. */
  10118. func: (evt: ActionEvent) => void;
  10119. /**
  10120. * Instantiate the action
  10121. * @param triggerOptions defines the trigger options
  10122. * @param func defines the callback function to run
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10126. /**
  10127. * Execute the action and run the attached code.
  10128. */
  10129. execute(evt: ActionEvent): void;
  10130. }
  10131. /**
  10132. * This defines an action responsible to set the parent property of the target once triggered.
  10133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class SetParentAction extends Action {
  10136. private _parent;
  10137. private _target;
  10138. /**
  10139. * Instantiate the action
  10140. * @param triggerOptions defines the trigger options
  10141. * @param target defines the target containing the parent property
  10142. * @param parent defines from where the animation should start (animation frame)
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and set the parent property.
  10150. */
  10151. execute(): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. }
  10160. declare module "babylonjs/Actions/actionManager" {
  10161. import { Nullable } from "babylonjs/types";
  10162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10163. import { Scene } from "babylonjs/scene";
  10164. import { IAction } from "babylonjs/Actions/action";
  10165. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10166. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10167. /**
  10168. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10169. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10171. */
  10172. export class ActionManager extends AbstractActionManager {
  10173. /**
  10174. * Nothing
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly NothingTrigger: number;
  10178. /**
  10179. * On pick
  10180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10181. */
  10182. static readonly OnPickTrigger: number;
  10183. /**
  10184. * On left pick
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnLeftPickTrigger: number;
  10188. /**
  10189. * On right pick
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnRightPickTrigger: number;
  10193. /**
  10194. * On center pick
  10195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnCenterPickTrigger: number;
  10198. /**
  10199. * On pick down
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnPickDownTrigger: number;
  10203. /**
  10204. * On double pick
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnDoublePickTrigger: number;
  10208. /**
  10209. * On pick up
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnPickUpTrigger: number;
  10213. /**
  10214. * On pick out.
  10215. * This trigger will only be raised if you also declared a OnPickDown
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnPickOutTrigger: number;
  10219. /**
  10220. * On long press
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnLongPressTrigger: number;
  10224. /**
  10225. * On pointer over
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10227. */
  10228. static readonly OnPointerOverTrigger: number;
  10229. /**
  10230. * On pointer out
  10231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10232. */
  10233. static readonly OnPointerOutTrigger: number;
  10234. /**
  10235. * On every frame
  10236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10237. */
  10238. static readonly OnEveryFrameTrigger: number;
  10239. /**
  10240. * On intersection enter
  10241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10242. */
  10243. static readonly OnIntersectionEnterTrigger: number;
  10244. /**
  10245. * On intersection exit
  10246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10247. */
  10248. static readonly OnIntersectionExitTrigger: number;
  10249. /**
  10250. * On key down
  10251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10252. */
  10253. static readonly OnKeyDownTrigger: number;
  10254. /**
  10255. * On key up
  10256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10257. */
  10258. static readonly OnKeyUpTrigger: number;
  10259. private _scene;
  10260. /**
  10261. * Creates a new action manager
  10262. * @param scene defines the hosting scene
  10263. */
  10264. constructor(scene: Scene);
  10265. /**
  10266. * Releases all associated resources
  10267. */
  10268. dispose(): void;
  10269. /**
  10270. * Gets hosting scene
  10271. * @returns the hosting scene
  10272. */
  10273. getScene(): Scene;
  10274. /**
  10275. * Does this action manager handles actions of any of the given triggers
  10276. * @param triggers defines the triggers to be tested
  10277. * @return a boolean indicating whether one (or more) of the triggers is handled
  10278. */
  10279. hasSpecificTriggers(triggers: number[]): boolean;
  10280. /**
  10281. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10282. * speed.
  10283. * @param triggerA defines the trigger to be tested
  10284. * @param triggerB defines the trigger to be tested
  10285. * @return a boolean indicating whether one (or more) of the triggers is handled
  10286. */
  10287. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10288. /**
  10289. * Does this action manager handles actions of a given trigger
  10290. * @param trigger defines the trigger to be tested
  10291. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10292. * @return whether the trigger is handled
  10293. */
  10294. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10295. /**
  10296. * Does this action manager has pointer triggers
  10297. */
  10298. get hasPointerTriggers(): boolean;
  10299. /**
  10300. * Does this action manager has pick triggers
  10301. */
  10302. get hasPickTriggers(): boolean;
  10303. /**
  10304. * Registers an action to this action manager
  10305. * @param action defines the action to be registered
  10306. * @return the action amended (prepared) after registration
  10307. */
  10308. registerAction(action: IAction): Nullable<IAction>;
  10309. /**
  10310. * Unregisters an action to this action manager
  10311. * @param action defines the action to be unregistered
  10312. * @return a boolean indicating whether the action has been unregistered
  10313. */
  10314. unregisterAction(action: IAction): Boolean;
  10315. /**
  10316. * Process a specific trigger
  10317. * @param trigger defines the trigger to process
  10318. * @param evt defines the event details to be processed
  10319. */
  10320. processTrigger(trigger: number, evt?: IActionEvent): void;
  10321. /** @hidden */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /** @hidden */
  10324. _getProperty(propertyPath: string): string;
  10325. /**
  10326. * Serialize this manager to a JSON object
  10327. * @param name defines the property name to store this manager
  10328. * @returns a JSON representation of this manager
  10329. */
  10330. serialize(name: string): any;
  10331. /**
  10332. * Creates a new ActionManager from a JSON data
  10333. * @param parsedActions defines the JSON data to read from
  10334. * @param object defines the hosting mesh
  10335. * @param scene defines the hosting scene
  10336. */
  10337. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10338. /**
  10339. * Get a trigger name by index
  10340. * @param trigger defines the trigger index
  10341. * @returns a trigger name
  10342. */
  10343. static GetTriggerName(trigger: number): string;
  10344. }
  10345. }
  10346. declare module "babylonjs/Sprites/sprite" {
  10347. import { Vector3 } from "babylonjs/Maths/math.vector";
  10348. import { Nullable } from "babylonjs/types";
  10349. import { ActionManager } from "babylonjs/Actions/actionManager";
  10350. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10351. import { Color4 } from "babylonjs/Maths/math.color";
  10352. import { Observable } from "babylonjs/Misc/observable";
  10353. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10354. import { Animation } from "babylonjs/Animations/animation";
  10355. /**
  10356. * Class used to represent a sprite
  10357. * @see https://doc.babylonjs.com/babylon101/sprites
  10358. */
  10359. export class Sprite implements IAnimatable {
  10360. /** defines the name */
  10361. name: string;
  10362. /** Gets or sets the current world position */
  10363. position: Vector3;
  10364. /** Gets or sets the main color */
  10365. color: Color4;
  10366. /** Gets or sets the width */
  10367. width: number;
  10368. /** Gets or sets the height */
  10369. height: number;
  10370. /** Gets or sets rotation angle */
  10371. angle: number;
  10372. /** Gets or sets the cell index in the sprite sheet */
  10373. cellIndex: number;
  10374. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10375. cellRef: string;
  10376. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10377. invertU: boolean;
  10378. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10379. invertV: boolean;
  10380. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10381. disposeWhenFinishedAnimating: boolean;
  10382. /** Gets the list of attached animations */
  10383. animations: Nullable<Array<Animation>>;
  10384. /** Gets or sets a boolean indicating if the sprite can be picked */
  10385. isPickable: boolean;
  10386. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10387. useAlphaForPicking: boolean;
  10388. /** @hidden */
  10389. _xOffset: number;
  10390. /** @hidden */
  10391. _yOffset: number;
  10392. /** @hidden */
  10393. _xSize: number;
  10394. /** @hidden */
  10395. _ySize: number;
  10396. /**
  10397. * Gets or sets the associated action manager
  10398. */
  10399. actionManager: Nullable<ActionManager>;
  10400. /**
  10401. * An event triggered when the control has been disposed
  10402. */
  10403. onDisposeObservable: Observable<Sprite>;
  10404. private _animationStarted;
  10405. private _loopAnimation;
  10406. private _fromIndex;
  10407. private _toIndex;
  10408. private _delay;
  10409. private _direction;
  10410. private _manager;
  10411. private _time;
  10412. private _onAnimationEnd;
  10413. /**
  10414. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10415. */
  10416. isVisible: boolean;
  10417. /**
  10418. * Gets or sets the sprite size
  10419. */
  10420. get size(): number;
  10421. set size(value: number);
  10422. /**
  10423. * Returns a boolean indicating if the animation is started
  10424. */
  10425. get animationStarted(): boolean;
  10426. /**
  10427. * Gets or sets the unique id of the sprite
  10428. */
  10429. uniqueId: number;
  10430. /**
  10431. * Gets the manager of this sprite
  10432. */
  10433. get manager(): ISpriteManager;
  10434. /**
  10435. * Creates a new Sprite
  10436. * @param name defines the name
  10437. * @param manager defines the manager
  10438. */
  10439. constructor(
  10440. /** defines the name */
  10441. name: string, manager: ISpriteManager);
  10442. /**
  10443. * Returns the string "Sprite"
  10444. * @returns "Sprite"
  10445. */
  10446. getClassName(): string;
  10447. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10448. get fromIndex(): number;
  10449. set fromIndex(value: number);
  10450. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10451. get toIndex(): number;
  10452. set toIndex(value: number);
  10453. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10454. get loopAnimation(): boolean;
  10455. set loopAnimation(value: boolean);
  10456. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10457. get delay(): number;
  10458. set delay(value: number);
  10459. /**
  10460. * Starts an animation
  10461. * @param from defines the initial key
  10462. * @param to defines the end key
  10463. * @param loop defines if the animation must loop
  10464. * @param delay defines the start delay (in ms)
  10465. * @param onAnimationEnd defines a callback to call when animation ends
  10466. */
  10467. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10468. /** Stops current animation (if any) */
  10469. stopAnimation(): void;
  10470. /** @hidden */
  10471. _animate(deltaTime: number): void;
  10472. /** Release associated resources */
  10473. dispose(): void;
  10474. /**
  10475. * Serializes the sprite to a JSON object
  10476. * @returns the JSON object
  10477. */
  10478. serialize(): any;
  10479. /**
  10480. * Parses a JSON object to create a new sprite
  10481. * @param parsedSprite The JSON object to parse
  10482. * @param manager defines the hosting manager
  10483. * @returns the new sprite
  10484. */
  10485. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10486. }
  10487. }
  10488. declare module "babylonjs/Collisions/pickingInfo" {
  10489. import { Nullable } from "babylonjs/types";
  10490. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10492. import { Sprite } from "babylonjs/Sprites/sprite";
  10493. import { Ray } from "babylonjs/Culling/ray";
  10494. /**
  10495. * Information about the result of picking within a scene
  10496. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10497. */
  10498. export class PickingInfo {
  10499. /** @hidden */
  10500. _pickingUnavailable: boolean;
  10501. /**
  10502. * If the pick collided with an object
  10503. */
  10504. hit: boolean;
  10505. /**
  10506. * Distance away where the pick collided
  10507. */
  10508. distance: number;
  10509. /**
  10510. * The location of pick collision
  10511. */
  10512. pickedPoint: Nullable<Vector3>;
  10513. /**
  10514. * The mesh corresponding the the pick collision
  10515. */
  10516. pickedMesh: Nullable<AbstractMesh>;
  10517. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10518. bu: number;
  10519. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10520. bv: number;
  10521. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10522. faceId: number;
  10523. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10524. subMeshFaceId: number;
  10525. /** Id of the the submesh that was picked */
  10526. subMeshId: number;
  10527. /** If a sprite was picked, this will be the sprite the pick collided with */
  10528. pickedSprite: Nullable<Sprite>;
  10529. /**
  10530. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10531. */
  10532. originMesh: Nullable<AbstractMesh>;
  10533. /**
  10534. * The ray that was used to perform the picking.
  10535. */
  10536. ray: Nullable<Ray>;
  10537. /**
  10538. * Gets the normal correspodning to the face the pick collided with
  10539. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10540. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10541. * @returns The normal correspodning to the face the pick collided with
  10542. */
  10543. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10544. /**
  10545. * Gets the texture coordinates of where the pick occured
  10546. * @returns the vector containing the coordnates of the texture
  10547. */
  10548. getTextureCoordinates(): Nullable<Vector2>;
  10549. }
  10550. }
  10551. declare module "babylonjs/Culling/ray" {
  10552. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10553. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10555. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10556. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10557. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10558. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10559. import { Plane } from "babylonjs/Maths/math.plane";
  10560. /**
  10561. * Class representing a ray with position and direction
  10562. */
  10563. export class Ray {
  10564. /** origin point */
  10565. origin: Vector3;
  10566. /** direction */
  10567. direction: Vector3;
  10568. /** length of the ray */
  10569. length: number;
  10570. private static readonly TmpVector3;
  10571. private _tmpRay;
  10572. /**
  10573. * Creates a new ray
  10574. * @param origin origin point
  10575. * @param direction direction
  10576. * @param length length of the ray
  10577. */
  10578. constructor(
  10579. /** origin point */
  10580. origin: Vector3,
  10581. /** direction */
  10582. direction: Vector3,
  10583. /** length of the ray */
  10584. length?: number);
  10585. /**
  10586. * Checks if the ray intersects a box
  10587. * This does not account for the ray lenght by design to improve perfs.
  10588. * @param minimum bound of the box
  10589. * @param maximum bound of the box
  10590. * @param intersectionTreshold extra extend to be added to the box in all direction
  10591. * @returns if the box was hit
  10592. */
  10593. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10594. /**
  10595. * Checks if the ray intersects a box
  10596. * This does not account for the ray lenght by design to improve perfs.
  10597. * @param box the bounding box to check
  10598. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10599. * @returns if the box was hit
  10600. */
  10601. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10602. /**
  10603. * If the ray hits a sphere
  10604. * @param sphere the bounding sphere to check
  10605. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10606. * @returns true if it hits the sphere
  10607. */
  10608. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10609. /**
  10610. * If the ray hits a triange
  10611. * @param vertex0 triangle vertex
  10612. * @param vertex1 triangle vertex
  10613. * @param vertex2 triangle vertex
  10614. * @returns intersection information if hit
  10615. */
  10616. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10617. /**
  10618. * Checks if ray intersects a plane
  10619. * @param plane the plane to check
  10620. * @returns the distance away it was hit
  10621. */
  10622. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10623. /**
  10624. * Calculate the intercept of a ray on a given axis
  10625. * @param axis to check 'x' | 'y' | 'z'
  10626. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10627. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10628. */
  10629. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10630. /**
  10631. * Checks if ray intersects a mesh
  10632. * @param mesh the mesh to check
  10633. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10634. * @returns picking info of the intersecton
  10635. */
  10636. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10637. /**
  10638. * Checks if ray intersects a mesh
  10639. * @param meshes the meshes to check
  10640. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10641. * @param results array to store result in
  10642. * @returns Array of picking infos
  10643. */
  10644. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10645. private _comparePickingInfo;
  10646. private static smallnum;
  10647. private static rayl;
  10648. /**
  10649. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10650. * @param sega the first point of the segment to test the intersection against
  10651. * @param segb the second point of the segment to test the intersection against
  10652. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10653. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10654. */
  10655. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10656. /**
  10657. * Update the ray from viewport position
  10658. * @param x position
  10659. * @param y y position
  10660. * @param viewportWidth viewport width
  10661. * @param viewportHeight viewport height
  10662. * @param world world matrix
  10663. * @param view view matrix
  10664. * @param projection projection matrix
  10665. * @returns this ray updated
  10666. */
  10667. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10668. /**
  10669. * Creates a ray with origin and direction of 0,0,0
  10670. * @returns the new ray
  10671. */
  10672. static Zero(): Ray;
  10673. /**
  10674. * Creates a new ray from screen space and viewport
  10675. * @param x position
  10676. * @param y y position
  10677. * @param viewportWidth viewport width
  10678. * @param viewportHeight viewport height
  10679. * @param world world matrix
  10680. * @param view view matrix
  10681. * @param projection projection matrix
  10682. * @returns new ray
  10683. */
  10684. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10685. /**
  10686. * 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
  10687. * transformed to the given world matrix.
  10688. * @param origin The origin point
  10689. * @param end The end point
  10690. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10691. * @returns the new ray
  10692. */
  10693. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10694. /**
  10695. * Transforms a ray by a matrix
  10696. * @param ray ray to transform
  10697. * @param matrix matrix to apply
  10698. * @returns the resulting new ray
  10699. */
  10700. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10701. /**
  10702. * Transforms a ray by a matrix
  10703. * @param ray ray to transform
  10704. * @param matrix matrix to apply
  10705. * @param result ray to store result in
  10706. */
  10707. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10708. /**
  10709. * Unproject a ray from screen space to object space
  10710. * @param sourceX defines the screen space x coordinate to use
  10711. * @param sourceY defines the screen space y coordinate to use
  10712. * @param viewportWidth defines the current width of the viewport
  10713. * @param viewportHeight defines the current height of the viewport
  10714. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10715. * @param view defines the view matrix to use
  10716. * @param projection defines the projection matrix to use
  10717. */
  10718. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10719. }
  10720. /**
  10721. * Type used to define predicate used to select faces when a mesh intersection is detected
  10722. */
  10723. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10724. module "babylonjs/scene" {
  10725. interface Scene {
  10726. /** @hidden */
  10727. _tempPickingRay: Nullable<Ray>;
  10728. /** @hidden */
  10729. _cachedRayForTransform: Ray;
  10730. /** @hidden */
  10731. _pickWithRayInverseMatrix: Matrix;
  10732. /** @hidden */
  10733. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10734. /** @hidden */
  10735. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10736. }
  10737. }
  10738. }
  10739. declare module "babylonjs/sceneComponent" {
  10740. import { Scene } from "babylonjs/scene";
  10741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10743. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10744. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10745. import { Nullable } from "babylonjs/types";
  10746. import { Camera } from "babylonjs/Cameras/camera";
  10747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10748. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10749. import { AbstractScene } from "babylonjs/abstractScene";
  10750. import { Mesh } from "babylonjs/Meshes/mesh";
  10751. /**
  10752. * Groups all the scene component constants in one place to ease maintenance.
  10753. * @hidden
  10754. */
  10755. export class SceneComponentConstants {
  10756. static readonly NAME_EFFECTLAYER: string;
  10757. static readonly NAME_LAYER: string;
  10758. static readonly NAME_LENSFLARESYSTEM: string;
  10759. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10760. static readonly NAME_PARTICLESYSTEM: string;
  10761. static readonly NAME_GAMEPAD: string;
  10762. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10763. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10764. static readonly NAME_PREPASSRENDERER: string;
  10765. static readonly NAME_DEPTHRENDERER: string;
  10766. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10767. static readonly NAME_SPRITE: string;
  10768. static readonly NAME_OUTLINERENDERER: string;
  10769. static readonly NAME_PROCEDURALTEXTURE: string;
  10770. static readonly NAME_SHADOWGENERATOR: string;
  10771. static readonly NAME_OCTREE: string;
  10772. static readonly NAME_PHYSICSENGINE: string;
  10773. static readonly NAME_AUDIO: string;
  10774. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10775. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10776. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10777. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10778. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10779. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10780. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10781. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10782. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10783. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10784. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10785. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10786. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10787. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10788. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10789. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10790. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10791. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10792. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10793. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10794. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10795. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10796. static readonly STEP_AFTERRENDER_AUDIO: number;
  10797. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10798. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10799. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10800. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10801. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10802. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10803. static readonly STEP_POINTERMOVE_SPRITE: number;
  10804. static readonly STEP_POINTERDOWN_SPRITE: number;
  10805. static readonly STEP_POINTERUP_SPRITE: number;
  10806. }
  10807. /**
  10808. * This represents a scene component.
  10809. *
  10810. * This is used to decouple the dependency the scene is having on the different workloads like
  10811. * layers, post processes...
  10812. */
  10813. export interface ISceneComponent {
  10814. /**
  10815. * The name of the component. Each component must have a unique name.
  10816. */
  10817. name: string;
  10818. /**
  10819. * The scene the component belongs to.
  10820. */
  10821. scene: Scene;
  10822. /**
  10823. * Register the component to one instance of a scene.
  10824. */
  10825. register(): void;
  10826. /**
  10827. * Rebuilds the elements related to this component in case of
  10828. * context lost for instance.
  10829. */
  10830. rebuild(): void;
  10831. /**
  10832. * Disposes the component and the associated ressources.
  10833. */
  10834. dispose(): void;
  10835. }
  10836. /**
  10837. * This represents a SERIALIZABLE scene component.
  10838. *
  10839. * This extends Scene Component to add Serialization methods on top.
  10840. */
  10841. export interface ISceneSerializableComponent extends ISceneComponent {
  10842. /**
  10843. * Adds all the elements from the container to the scene
  10844. * @param container the container holding the elements
  10845. */
  10846. addFromContainer(container: AbstractScene): void;
  10847. /**
  10848. * Removes all the elements in the container from the scene
  10849. * @param container contains the elements to remove
  10850. * @param dispose if the removed element should be disposed (default: false)
  10851. */
  10852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10853. /**
  10854. * Serializes the component data to the specified json object
  10855. * @param serializationObject The object to serialize to
  10856. */
  10857. serialize(serializationObject: any): void;
  10858. }
  10859. /**
  10860. * Strong typing of a Mesh related stage step action
  10861. */
  10862. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10863. /**
  10864. * Strong typing of a Evaluate Sub Mesh related stage step action
  10865. */
  10866. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10867. /**
  10868. * Strong typing of a Active Mesh related stage step action
  10869. */
  10870. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10871. /**
  10872. * Strong typing of a Camera related stage step action
  10873. */
  10874. export type CameraStageAction = (camera: Camera) => void;
  10875. /**
  10876. * Strong typing of a Camera Frame buffer related stage step action
  10877. */
  10878. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10879. /**
  10880. * Strong typing of a Render Target related stage step action
  10881. */
  10882. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10883. /**
  10884. * Strong typing of a RenderingGroup related stage step action
  10885. */
  10886. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10887. /**
  10888. * Strong typing of a Mesh Render related stage step action
  10889. */
  10890. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10891. /**
  10892. * Strong typing of a simple stage step action
  10893. */
  10894. export type SimpleStageAction = () => void;
  10895. /**
  10896. * Strong typing of a render target action.
  10897. */
  10898. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10899. /**
  10900. * Strong typing of a pointer move action.
  10901. */
  10902. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10903. /**
  10904. * Strong typing of a pointer up/down action.
  10905. */
  10906. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10907. /**
  10908. * Representation of a stage in the scene (Basically a list of ordered steps)
  10909. * @hidden
  10910. */
  10911. export class Stage<T extends Function> extends Array<{
  10912. index: number;
  10913. component: ISceneComponent;
  10914. action: T;
  10915. }> {
  10916. /**
  10917. * Hide ctor from the rest of the world.
  10918. * @param items The items to add.
  10919. */
  10920. private constructor();
  10921. /**
  10922. * Creates a new Stage.
  10923. * @returns A new instance of a Stage
  10924. */
  10925. static Create<T extends Function>(): Stage<T>;
  10926. /**
  10927. * Registers a step in an ordered way in the targeted stage.
  10928. * @param index Defines the position to register the step in
  10929. * @param component Defines the component attached to the step
  10930. * @param action Defines the action to launch during the step
  10931. */
  10932. registerStep(index: number, component: ISceneComponent, action: T): void;
  10933. /**
  10934. * Clears all the steps from the stage.
  10935. */
  10936. clear(): void;
  10937. }
  10938. }
  10939. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10940. import { Nullable } from "babylonjs/types";
  10941. import { Observable } from "babylonjs/Misc/observable";
  10942. import { Scene } from "babylonjs/scene";
  10943. import { Sprite } from "babylonjs/Sprites/sprite";
  10944. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10945. import { Ray } from "babylonjs/Culling/ray";
  10946. import { Camera } from "babylonjs/Cameras/camera";
  10947. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10948. import { ISceneComponent } from "babylonjs/sceneComponent";
  10949. module "babylonjs/scene" {
  10950. interface Scene {
  10951. /** @hidden */
  10952. _pointerOverSprite: Nullable<Sprite>;
  10953. /** @hidden */
  10954. _pickedDownSprite: Nullable<Sprite>;
  10955. /** @hidden */
  10956. _tempSpritePickingRay: Nullable<Ray>;
  10957. /**
  10958. * All of the sprite managers added to this scene
  10959. * @see https://doc.babylonjs.com/babylon101/sprites
  10960. */
  10961. spriteManagers: Array<ISpriteManager>;
  10962. /**
  10963. * An event triggered when sprites rendering is about to start
  10964. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10965. */
  10966. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10967. /**
  10968. * An event triggered when sprites rendering is done
  10969. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10970. */
  10971. onAfterSpritesRenderingObservable: Observable<Scene>;
  10972. /** @hidden */
  10973. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10974. /** Launch a ray to try to pick a sprite in the scene
  10975. * @param x position on screen
  10976. * @param y position on screen
  10977. * @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
  10978. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10979. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10980. * @returns a PickingInfo
  10981. */
  10982. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10983. /** Use the given ray to pick a sprite in the scene
  10984. * @param ray The ray (in world space) to use to pick meshes
  10985. * @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
  10986. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10987. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10988. * @returns a PickingInfo
  10989. */
  10990. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10991. /** @hidden */
  10992. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10993. /** Launch a ray to try to pick sprites in the scene
  10994. * @param x position on screen
  10995. * @param y position on screen
  10996. * @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
  10997. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10998. * @returns a PickingInfo array
  10999. */
  11000. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11001. /** Use the given ray to pick sprites in the scene
  11002. * @param ray The ray (in world space) to use to pick meshes
  11003. * @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
  11004. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11005. * @returns a PickingInfo array
  11006. */
  11007. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11008. /**
  11009. * Force the sprite under the pointer
  11010. * @param sprite defines the sprite to use
  11011. */
  11012. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11013. /**
  11014. * Gets the sprite under the pointer
  11015. * @returns a Sprite or null if no sprite is under the pointer
  11016. */
  11017. getPointerOverSprite(): Nullable<Sprite>;
  11018. }
  11019. }
  11020. /**
  11021. * Defines the sprite scene component responsible to manage sprites
  11022. * in a given scene.
  11023. */
  11024. export class SpriteSceneComponent implements ISceneComponent {
  11025. /**
  11026. * The component name helpfull to identify the component in the list of scene components.
  11027. */
  11028. readonly name: string;
  11029. /**
  11030. * The scene the component belongs to.
  11031. */
  11032. scene: Scene;
  11033. /** @hidden */
  11034. private _spritePredicate;
  11035. /**
  11036. * Creates a new instance of the component for the given scene
  11037. * @param scene Defines the scene to register the component in
  11038. */
  11039. constructor(scene: Scene);
  11040. /**
  11041. * Registers the component in a given scene
  11042. */
  11043. register(): void;
  11044. /**
  11045. * Rebuilds the elements related to this component in case of
  11046. * context lost for instance.
  11047. */
  11048. rebuild(): void;
  11049. /**
  11050. * Disposes the component and the associated ressources.
  11051. */
  11052. dispose(): void;
  11053. private _pickSpriteButKeepRay;
  11054. private _pointerMove;
  11055. private _pointerDown;
  11056. private _pointerUp;
  11057. }
  11058. }
  11059. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11060. /** @hidden */
  11061. export var fogFragmentDeclaration: {
  11062. name: string;
  11063. shader: string;
  11064. };
  11065. }
  11066. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11067. /** @hidden */
  11068. export var fogFragment: {
  11069. name: string;
  11070. shader: string;
  11071. };
  11072. }
  11073. declare module "babylonjs/Shaders/sprites.fragment" {
  11074. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11075. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11076. /** @hidden */
  11077. export var spritesPixelShader: {
  11078. name: string;
  11079. shader: string;
  11080. };
  11081. }
  11082. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11083. /** @hidden */
  11084. export var fogVertexDeclaration: {
  11085. name: string;
  11086. shader: string;
  11087. };
  11088. }
  11089. declare module "babylonjs/Shaders/sprites.vertex" {
  11090. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11091. /** @hidden */
  11092. export var spritesVertexShader: {
  11093. name: string;
  11094. shader: string;
  11095. };
  11096. }
  11097. declare module "babylonjs/Sprites/spriteManager" {
  11098. import { IDisposable, Scene } from "babylonjs/scene";
  11099. import { Nullable } from "babylonjs/types";
  11100. import { Observable } from "babylonjs/Misc/observable";
  11101. import { Sprite } from "babylonjs/Sprites/sprite";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { Camera } from "babylonjs/Cameras/camera";
  11104. import { Texture } from "babylonjs/Materials/Textures/texture";
  11105. import "babylonjs/Shaders/sprites.fragment";
  11106. import "babylonjs/Shaders/sprites.vertex";
  11107. import { Ray } from "babylonjs/Culling/ray";
  11108. /**
  11109. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11110. */
  11111. export interface ISpriteManager extends IDisposable {
  11112. /**
  11113. * Gets manager's name
  11114. */
  11115. name: string;
  11116. /**
  11117. * Restricts the camera to viewing objects with the same layerMask.
  11118. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11119. */
  11120. layerMask: number;
  11121. /**
  11122. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11123. */
  11124. isPickable: boolean;
  11125. /**
  11126. * Gets the hosting scene
  11127. */
  11128. scene: Scene;
  11129. /**
  11130. * Specifies the rendering group id for this mesh (0 by default)
  11131. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11132. */
  11133. renderingGroupId: number;
  11134. /**
  11135. * Defines the list of sprites managed by the manager.
  11136. */
  11137. sprites: Array<Sprite>;
  11138. /**
  11139. * Gets or sets the spritesheet texture
  11140. */
  11141. texture: Texture;
  11142. /** Defines the default width of a cell in the spritesheet */
  11143. cellWidth: number;
  11144. /** Defines the default height of a cell in the spritesheet */
  11145. cellHeight: number;
  11146. /**
  11147. * Tests the intersection of a sprite with a specific ray.
  11148. * @param ray The ray we are sending to test the collision
  11149. * @param camera The camera space we are sending rays in
  11150. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11151. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11152. * @returns picking info or null.
  11153. */
  11154. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11155. /**
  11156. * Intersects the sprites with a ray
  11157. * @param ray defines the ray to intersect with
  11158. * @param camera defines the current active camera
  11159. * @param predicate defines a predicate used to select candidate sprites
  11160. * @returns null if no hit or a PickingInfo array
  11161. */
  11162. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11163. /**
  11164. * Renders the list of sprites on screen.
  11165. */
  11166. render(): void;
  11167. }
  11168. /**
  11169. * Class used to manage multiple sprites on the same spritesheet
  11170. * @see https://doc.babylonjs.com/babylon101/sprites
  11171. */
  11172. export class SpriteManager implements ISpriteManager {
  11173. /** defines the manager's name */
  11174. name: string;
  11175. /** Define the Url to load snippets */
  11176. static SnippetUrl: string;
  11177. /** Snippet ID if the manager was created from the snippet server */
  11178. snippetId: string;
  11179. /** Gets the list of sprites */
  11180. sprites: Sprite[];
  11181. /** Gets or sets the rendering group id (0 by default) */
  11182. renderingGroupId: number;
  11183. /** Gets or sets camera layer mask */
  11184. layerMask: number;
  11185. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11186. fogEnabled: boolean;
  11187. /** Gets or sets a boolean indicating if the sprites are pickable */
  11188. isPickable: boolean;
  11189. /** Defines the default width of a cell in the spritesheet */
  11190. cellWidth: number;
  11191. /** Defines the default height of a cell in the spritesheet */
  11192. cellHeight: number;
  11193. /** Associative array from JSON sprite data file */
  11194. private _cellData;
  11195. /** Array of sprite names from JSON sprite data file */
  11196. private _spriteMap;
  11197. /** True when packed cell data from JSON file is ready*/
  11198. private _packedAndReady;
  11199. private _textureContent;
  11200. /**
  11201. * An event triggered when the manager is disposed.
  11202. */
  11203. onDisposeObservable: Observable<SpriteManager>;
  11204. private _onDisposeObserver;
  11205. /**
  11206. * Callback called when the manager is disposed
  11207. */
  11208. set onDispose(callback: () => void);
  11209. private _capacity;
  11210. private _fromPacked;
  11211. private _spriteTexture;
  11212. private _epsilon;
  11213. private _scene;
  11214. private _vertexData;
  11215. private _buffer;
  11216. private _vertexBuffers;
  11217. private _indexBuffer;
  11218. private _effectBase;
  11219. private _effectFog;
  11220. /**
  11221. * Gets or sets the unique id of the sprite
  11222. */
  11223. uniqueId: number;
  11224. /**
  11225. * Gets the array of sprites
  11226. */
  11227. get children(): Sprite[];
  11228. /**
  11229. * Gets the hosting scene
  11230. */
  11231. get scene(): Scene;
  11232. /**
  11233. * Gets the capacity of the manager
  11234. */
  11235. get capacity(): number;
  11236. /**
  11237. * Gets or sets the spritesheet texture
  11238. */
  11239. get texture(): Texture;
  11240. set texture(value: Texture);
  11241. private _blendMode;
  11242. /**
  11243. * Blend mode use to render the particle, it can be any of
  11244. * the static Constants.ALPHA_x properties provided in this class.
  11245. * Default value is Constants.ALPHA_COMBINE
  11246. */
  11247. get blendMode(): number;
  11248. set blendMode(blendMode: number);
  11249. /** Disables writing to the depth buffer when rendering the sprites.
  11250. * It can be handy to disable depth writing when using textures without alpha channel
  11251. * and setting some specific blend modes.
  11252. */
  11253. disableDepthWrite: boolean;
  11254. /**
  11255. * Creates a new sprite manager
  11256. * @param name defines the manager's name
  11257. * @param imgUrl defines the sprite sheet url
  11258. * @param capacity defines the maximum allowed number of sprites
  11259. * @param cellSize defines the size of a sprite cell
  11260. * @param scene defines the hosting scene
  11261. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11262. * @param samplingMode defines the smapling mode to use with spritesheet
  11263. * @param fromPacked set to false; do not alter
  11264. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11265. */
  11266. constructor(
  11267. /** defines the manager's name */
  11268. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11269. /**
  11270. * Returns the string "SpriteManager"
  11271. * @returns "SpriteManager"
  11272. */
  11273. getClassName(): string;
  11274. private _makePacked;
  11275. private _appendSpriteVertex;
  11276. private _checkTextureAlpha;
  11277. /**
  11278. * Intersects the sprites with a ray
  11279. * @param ray defines the ray to intersect with
  11280. * @param camera defines the current active camera
  11281. * @param predicate defines a predicate used to select candidate sprites
  11282. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11283. * @returns null if no hit or a PickingInfo
  11284. */
  11285. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11286. /**
  11287. * Intersects the sprites with a ray
  11288. * @param ray defines the ray to intersect with
  11289. * @param camera defines the current active camera
  11290. * @param predicate defines a predicate used to select candidate sprites
  11291. * @returns null if no hit or a PickingInfo array
  11292. */
  11293. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11294. /**
  11295. * Render all child sprites
  11296. */
  11297. render(): void;
  11298. /**
  11299. * Release associated resources
  11300. */
  11301. dispose(): void;
  11302. /**
  11303. * Serializes the sprite manager to a JSON object
  11304. * @param serializeTexture defines if the texture must be serialized as well
  11305. * @returns the JSON object
  11306. */
  11307. serialize(serializeTexture?: boolean): any;
  11308. /**
  11309. * Parses a JSON object to create a new sprite manager.
  11310. * @param parsedManager The JSON object to parse
  11311. * @param scene The scene to create the sprite managerin
  11312. * @param rootUrl The root url to use to load external dependencies like texture
  11313. * @returns the new sprite manager
  11314. */
  11315. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11316. /**
  11317. * Creates a sprite manager from a snippet saved in a remote file
  11318. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11319. * @param url defines the url to load from
  11320. * @param scene defines the hosting scene
  11321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11322. * @returns a promise that will resolve to the new sprite manager
  11323. */
  11324. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11325. /**
  11326. * Creates a sprite manager from a snippet saved by the sprite editor
  11327. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11328. * @param scene defines the hosting scene
  11329. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11330. * @returns a promise that will resolve to the new sprite manager
  11331. */
  11332. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11333. }
  11334. }
  11335. declare module "babylonjs/Misc/gradients" {
  11336. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11337. /** Interface used by value gradients (color, factor, ...) */
  11338. export interface IValueGradient {
  11339. /**
  11340. * Gets or sets the gradient value (between 0 and 1)
  11341. */
  11342. gradient: number;
  11343. }
  11344. /** Class used to store color4 gradient */
  11345. export class ColorGradient implements IValueGradient {
  11346. /**
  11347. * Gets or sets the gradient value (between 0 and 1)
  11348. */
  11349. gradient: number;
  11350. /**
  11351. * Gets or sets first associated color
  11352. */
  11353. color1: Color4;
  11354. /**
  11355. * Gets or sets second associated color
  11356. */
  11357. color2?: Color4 | undefined;
  11358. /**
  11359. * Creates a new color4 gradient
  11360. * @param gradient gets or sets the gradient value (between 0 and 1)
  11361. * @param color1 gets or sets first associated color
  11362. * @param color2 gets or sets first second color
  11363. */
  11364. constructor(
  11365. /**
  11366. * Gets or sets the gradient value (between 0 and 1)
  11367. */
  11368. gradient: number,
  11369. /**
  11370. * Gets or sets first associated color
  11371. */
  11372. color1: Color4,
  11373. /**
  11374. * Gets or sets second associated color
  11375. */
  11376. color2?: Color4 | undefined);
  11377. /**
  11378. * Will get a color picked randomly between color1 and color2.
  11379. * If color2 is undefined then color1 will be used
  11380. * @param result defines the target Color4 to store the result in
  11381. */
  11382. getColorToRef(result: Color4): void;
  11383. }
  11384. /** Class used to store color 3 gradient */
  11385. export class Color3Gradient implements IValueGradient {
  11386. /**
  11387. * Gets or sets the gradient value (between 0 and 1)
  11388. */
  11389. gradient: number;
  11390. /**
  11391. * Gets or sets the associated color
  11392. */
  11393. color: Color3;
  11394. /**
  11395. * Creates a new color3 gradient
  11396. * @param gradient gets or sets the gradient value (between 0 and 1)
  11397. * @param color gets or sets associated color
  11398. */
  11399. constructor(
  11400. /**
  11401. * Gets or sets the gradient value (between 0 and 1)
  11402. */
  11403. gradient: number,
  11404. /**
  11405. * Gets or sets the associated color
  11406. */
  11407. color: Color3);
  11408. }
  11409. /** Class used to store factor gradient */
  11410. export class FactorGradient implements IValueGradient {
  11411. /**
  11412. * Gets or sets the gradient value (between 0 and 1)
  11413. */
  11414. gradient: number;
  11415. /**
  11416. * Gets or sets first associated factor
  11417. */
  11418. factor1: number;
  11419. /**
  11420. * Gets or sets second associated factor
  11421. */
  11422. factor2?: number | undefined;
  11423. /**
  11424. * Creates a new factor gradient
  11425. * @param gradient gets or sets the gradient value (between 0 and 1)
  11426. * @param factor1 gets or sets first associated factor
  11427. * @param factor2 gets or sets second associated factor
  11428. */
  11429. constructor(
  11430. /**
  11431. * Gets or sets the gradient value (between 0 and 1)
  11432. */
  11433. gradient: number,
  11434. /**
  11435. * Gets or sets first associated factor
  11436. */
  11437. factor1: number,
  11438. /**
  11439. * Gets or sets second associated factor
  11440. */
  11441. factor2?: number | undefined);
  11442. /**
  11443. * Will get a number picked randomly between factor1 and factor2.
  11444. * If factor2 is undefined then factor1 will be used
  11445. * @returns the picked number
  11446. */
  11447. getFactor(): number;
  11448. }
  11449. /**
  11450. * Helper used to simplify some generic gradient tasks
  11451. */
  11452. export class GradientHelper {
  11453. /**
  11454. * Gets the current gradient from an array of IValueGradient
  11455. * @param ratio defines the current ratio to get
  11456. * @param gradients defines the array of IValueGradient
  11457. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11458. */
  11459. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11460. }
  11461. }
  11462. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11463. import { Nullable } from "babylonjs/types";
  11464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11465. import { Scene } from "babylonjs/scene";
  11466. module "babylonjs/Engines/thinEngine" {
  11467. interface ThinEngine {
  11468. /**
  11469. * Creates a raw texture
  11470. * @param data defines the data to store in the texture
  11471. * @param width defines the width of the texture
  11472. * @param height defines the height of the texture
  11473. * @param format defines the format of the data
  11474. * @param generateMipMaps defines if the engine should generate the mip levels
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11477. * @param compression defines the compression used (null by default)
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. * @returns the raw texture inside an InternalTexture
  11480. */
  11481. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11482. /**
  11483. * Update a raw texture
  11484. * @param texture defines the texture to update
  11485. * @param data defines the data to store in the texture
  11486. * @param format defines the format of the data
  11487. * @param invertY defines if data must be stored with Y axis inverted
  11488. */
  11489. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11490. /**
  11491. * Update a raw texture
  11492. * @param texture defines the texture to update
  11493. * @param data defines the data to store in the texture
  11494. * @param format defines the format of the data
  11495. * @param invertY defines if data must be stored with Y axis inverted
  11496. * @param compression defines the compression used (null by default)
  11497. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11498. */
  11499. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11500. /**
  11501. * Creates a new raw cube texture
  11502. * @param data defines the array of data to use to create each face
  11503. * @param size defines the size of the textures
  11504. * @param format defines the format of the data
  11505. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11506. * @param generateMipMaps defines if the engine should generate the mip levels
  11507. * @param invertY defines if data must be stored with Y axis inverted
  11508. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11509. * @param compression defines the compression used (null by default)
  11510. * @returns the cube texture as an InternalTexture
  11511. */
  11512. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11513. /**
  11514. * Update a raw cube texture
  11515. * @param texture defines the texture to udpdate
  11516. * @param data defines the data to store
  11517. * @param format defines the data format
  11518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11519. * @param invertY defines if data must be stored with Y axis inverted
  11520. */
  11521. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11522. /**
  11523. * Update a raw cube texture
  11524. * @param texture defines the texture to udpdate
  11525. * @param data defines the data to store
  11526. * @param format defines the data format
  11527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. * @param compression defines the compression used (null by default)
  11530. */
  11531. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11532. /**
  11533. * Update a raw cube texture
  11534. * @param texture defines the texture to udpdate
  11535. * @param data defines the data to store
  11536. * @param format defines the data format
  11537. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11538. * @param invertY defines if data must be stored with Y axis inverted
  11539. * @param compression defines the compression used (null by default)
  11540. * @param level defines which level of the texture to update
  11541. */
  11542. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11543. /**
  11544. * Creates a new raw cube texture from a specified url
  11545. * @param url defines the url where the data is located
  11546. * @param scene defines the current scene
  11547. * @param size defines the size of the textures
  11548. * @param format defines the format of the data
  11549. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11550. * @param noMipmap defines if the engine should avoid generating the mip levels
  11551. * @param callback defines a callback used to extract texture data from loaded data
  11552. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11553. * @param onLoad defines a callback called when texture is loaded
  11554. * @param onError defines a callback called if there is an error
  11555. * @returns the cube texture as an InternalTexture
  11556. */
  11557. 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;
  11558. /**
  11559. * Creates a new raw cube texture from a specified url
  11560. * @param url defines the url where the data is located
  11561. * @param scene defines the current scene
  11562. * @param size defines the size of the textures
  11563. * @param format defines the format of the data
  11564. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11565. * @param noMipmap defines if the engine should avoid generating the mip levels
  11566. * @param callback defines a callback used to extract texture data from loaded data
  11567. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11568. * @param onLoad defines a callback called when texture is loaded
  11569. * @param onError defines a callback called if there is an error
  11570. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11571. * @param invertY defines if data must be stored with Y axis inverted
  11572. * @returns the cube texture as an InternalTexture
  11573. */
  11574. 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;
  11575. /**
  11576. * Creates a new raw 3D texture
  11577. * @param data defines the data used to create the texture
  11578. * @param width defines the width of the texture
  11579. * @param height defines the height of the texture
  11580. * @param depth defines the depth of the texture
  11581. * @param format defines the format of the texture
  11582. * @param generateMipMaps defines if the engine must generate mip levels
  11583. * @param invertY defines if data must be stored with Y axis inverted
  11584. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11585. * @param compression defines the compressed used (can be null)
  11586. * @param textureType defines the compressed used (can be null)
  11587. * @returns a new raw 3D texture (stored in an InternalTexture)
  11588. */
  11589. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11590. /**
  11591. * Update a raw 3D texture
  11592. * @param texture defines the texture to update
  11593. * @param data defines the data to store
  11594. * @param format defines the data format
  11595. * @param invertY defines if data must be stored with Y axis inverted
  11596. */
  11597. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11598. /**
  11599. * Update a raw 3D texture
  11600. * @param texture defines the texture to update
  11601. * @param data defines the data to store
  11602. * @param format defines the data format
  11603. * @param invertY defines if data must be stored with Y axis inverted
  11604. * @param compression defines the used compression (can be null)
  11605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11606. */
  11607. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11608. /**
  11609. * Creates a new raw 2D array texture
  11610. * @param data defines the data used to create the texture
  11611. * @param width defines the width of the texture
  11612. * @param height defines the height of the texture
  11613. * @param depth defines the number of layers of the texture
  11614. * @param format defines the format of the texture
  11615. * @param generateMipMaps defines if the engine must generate mip levels
  11616. * @param invertY defines if data must be stored with Y axis inverted
  11617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11618. * @param compression defines the compressed used (can be null)
  11619. * @param textureType defines the compressed used (can be null)
  11620. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11621. */
  11622. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11623. /**
  11624. * Update a raw 2D array texture
  11625. * @param texture defines the texture to update
  11626. * @param data defines the data to store
  11627. * @param format defines the data format
  11628. * @param invertY defines if data must be stored with Y axis inverted
  11629. */
  11630. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11631. /**
  11632. * Update a raw 2D array texture
  11633. * @param texture defines the texture to update
  11634. * @param data defines the data to store
  11635. * @param format defines the data format
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. * @param compression defines the used compression (can be null)
  11638. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11639. */
  11640. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11641. }
  11642. }
  11643. }
  11644. declare module "babylonjs/Materials/Textures/rawTexture" {
  11645. import { Scene } from "babylonjs/scene";
  11646. import { Texture } from "babylonjs/Materials/Textures/texture";
  11647. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11648. /**
  11649. * Raw texture can help creating a texture directly from an array of data.
  11650. * This can be super useful if you either get the data from an uncompressed source or
  11651. * if you wish to create your texture pixel by pixel.
  11652. */
  11653. export class RawTexture extends Texture {
  11654. /**
  11655. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11656. */
  11657. format: number;
  11658. /**
  11659. * Instantiates a new RawTexture.
  11660. * Raw texture can help creating a texture directly from an array of data.
  11661. * This can be super useful if you either get the data from an uncompressed source or
  11662. * if you wish to create your texture pixel by pixel.
  11663. * @param data define the array of data to use to create the texture
  11664. * @param width define the width of the texture
  11665. * @param height define the height of the texture
  11666. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11667. * @param scene define the scene the texture belongs to
  11668. * @param generateMipMaps define whether mip maps should be generated or not
  11669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11672. */
  11673. constructor(data: ArrayBufferView, width: number, height: number,
  11674. /**
  11675. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11676. */
  11677. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11678. /**
  11679. * Updates the texture underlying data.
  11680. * @param data Define the new data of the texture
  11681. */
  11682. update(data: ArrayBufferView): void;
  11683. /**
  11684. * Creates a luminance texture from some data.
  11685. * @param data Define the texture data
  11686. * @param width Define the width of the texture
  11687. * @param height Define the height of the texture
  11688. * @param scene Define the scene the texture belongs to
  11689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11692. * @returns the luminance texture
  11693. */
  11694. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11695. /**
  11696. * Creates a luminance alpha texture from some data.
  11697. * @param data Define the texture data
  11698. * @param width Define the width of the texture
  11699. * @param height Define the height of the texture
  11700. * @param scene Define the scene the texture belongs to
  11701. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11704. * @returns the luminance alpha texture
  11705. */
  11706. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11707. /**
  11708. * Creates an alpha texture from some data.
  11709. * @param data Define the texture data
  11710. * @param width Define the width of the texture
  11711. * @param height Define the height of the texture
  11712. * @param scene Define the scene the texture belongs to
  11713. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11714. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11715. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11716. * @returns the alpha texture
  11717. */
  11718. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11719. /**
  11720. * Creates a RGB texture from some data.
  11721. * @param data Define the texture data
  11722. * @param width Define the width of the texture
  11723. * @param height Define the height of the texture
  11724. * @param scene Define the scene the texture belongs to
  11725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11728. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11729. * @returns the RGB alpha texture
  11730. */
  11731. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11732. /**
  11733. * Creates a RGBA texture from some data.
  11734. * @param data Define the texture data
  11735. * @param width Define the width of the texture
  11736. * @param height Define the height of the texture
  11737. * @param scene Define the scene the texture belongs to
  11738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11742. * @returns the RGBA texture
  11743. */
  11744. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11745. /**
  11746. * Creates a R texture from some data.
  11747. * @param data Define the texture data
  11748. * @param width Define the width of the texture
  11749. * @param height Define the height of the texture
  11750. * @param scene Define the scene the texture belongs to
  11751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11755. * @returns the R texture
  11756. */
  11757. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11758. }
  11759. }
  11760. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11761. import { Scene } from "babylonjs/scene";
  11762. import { ISceneComponent } from "babylonjs/sceneComponent";
  11763. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11764. module "babylonjs/abstractScene" {
  11765. interface AbstractScene {
  11766. /**
  11767. * The list of procedural textures added to the scene
  11768. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11769. */
  11770. proceduralTextures: Array<ProceduralTexture>;
  11771. }
  11772. }
  11773. /**
  11774. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11775. * in a given scene.
  11776. */
  11777. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11778. /**
  11779. * The component name helpfull to identify the component in the list of scene components.
  11780. */
  11781. readonly name: string;
  11782. /**
  11783. * The scene the component belongs to.
  11784. */
  11785. scene: Scene;
  11786. /**
  11787. * Creates a new instance of the component for the given scene
  11788. * @param scene Defines the scene to register the component in
  11789. */
  11790. constructor(scene: Scene);
  11791. /**
  11792. * Registers the component in a given scene
  11793. */
  11794. register(): void;
  11795. /**
  11796. * Rebuilds the elements related to this component in case of
  11797. * context lost for instance.
  11798. */
  11799. rebuild(): void;
  11800. /**
  11801. * Disposes the component and the associated ressources.
  11802. */
  11803. dispose(): void;
  11804. private _beforeClear;
  11805. }
  11806. }
  11807. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11808. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11809. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11810. module "babylonjs/Engines/thinEngine" {
  11811. interface ThinEngine {
  11812. /**
  11813. * Creates a new render target cube texture
  11814. * @param size defines the size of the texture
  11815. * @param options defines the options used to create the texture
  11816. * @returns a new render target cube texture stored in an InternalTexture
  11817. */
  11818. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11819. }
  11820. }
  11821. }
  11822. declare module "babylonjs/Shaders/procedural.vertex" {
  11823. /** @hidden */
  11824. export var proceduralVertexShader: {
  11825. name: string;
  11826. shader: string;
  11827. };
  11828. }
  11829. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11830. import { Observable } from "babylonjs/Misc/observable";
  11831. import { Nullable } from "babylonjs/types";
  11832. import { Scene } from "babylonjs/scene";
  11833. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11834. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11835. import { Effect } from "babylonjs/Materials/effect";
  11836. import { Texture } from "babylonjs/Materials/Textures/texture";
  11837. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11838. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11839. import "babylonjs/Shaders/procedural.vertex";
  11840. /**
  11841. * 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.
  11842. * This is the base class of any Procedural texture and contains most of the shareable code.
  11843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11844. */
  11845. export class ProceduralTexture extends Texture {
  11846. isCube: boolean;
  11847. /**
  11848. * Define if the texture is enabled or not (disabled texture will not render)
  11849. */
  11850. isEnabled: boolean;
  11851. /**
  11852. * Define if the texture must be cleared before rendering (default is true)
  11853. */
  11854. autoClear: boolean;
  11855. /**
  11856. * Callback called when the texture is generated
  11857. */
  11858. onGenerated: () => void;
  11859. /**
  11860. * Event raised when the texture is generated
  11861. */
  11862. onGeneratedObservable: Observable<ProceduralTexture>;
  11863. /** @hidden */
  11864. _generateMipMaps: boolean;
  11865. /** @hidden **/
  11866. _effect: Effect;
  11867. /** @hidden */
  11868. _textures: {
  11869. [key: string]: Texture;
  11870. };
  11871. /** @hidden */
  11872. protected _fallbackTexture: Nullable<Texture>;
  11873. private _size;
  11874. private _currentRefreshId;
  11875. private _frameId;
  11876. private _refreshRate;
  11877. private _vertexBuffers;
  11878. private _indexBuffer;
  11879. private _uniforms;
  11880. private _samplers;
  11881. private _fragment;
  11882. private _floats;
  11883. private _ints;
  11884. private _floatsArrays;
  11885. private _colors3;
  11886. private _colors4;
  11887. private _vectors2;
  11888. private _vectors3;
  11889. private _matrices;
  11890. private _fallbackTextureUsed;
  11891. private _fullEngine;
  11892. private _cachedDefines;
  11893. private _contentUpdateId;
  11894. private _contentData;
  11895. /**
  11896. * Instantiates a new procedural texture.
  11897. * 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.
  11898. * This is the base class of any Procedural texture and contains most of the shareable code.
  11899. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11900. * @param name Define the name of the texture
  11901. * @param size Define the size of the texture to create
  11902. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11903. * @param scene Define the scene the texture belongs to
  11904. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11905. * @param generateMipMaps Define if the texture should creates mip maps or not
  11906. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11907. */
  11908. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11909. /**
  11910. * The effect that is created when initializing the post process.
  11911. * @returns The created effect corresponding the the postprocess.
  11912. */
  11913. getEffect(): Effect;
  11914. /**
  11915. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11916. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11917. */
  11918. getContent(): Nullable<ArrayBufferView>;
  11919. private _createIndexBuffer;
  11920. /** @hidden */
  11921. _rebuild(): void;
  11922. /**
  11923. * Resets the texture in order to recreate its associated resources.
  11924. * This can be called in case of context loss
  11925. */
  11926. reset(): void;
  11927. protected _getDefines(): string;
  11928. /**
  11929. * Is the texture ready to be used ? (rendered at least once)
  11930. * @returns true if ready, otherwise, false.
  11931. */
  11932. isReady(): boolean;
  11933. /**
  11934. * Resets the refresh counter of the texture and start bak from scratch.
  11935. * Could be useful to regenerate the texture if it is setup to render only once.
  11936. */
  11937. resetRefreshCounter(): void;
  11938. /**
  11939. * Set the fragment shader to use in order to render the texture.
  11940. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11941. */
  11942. setFragment(fragment: any): void;
  11943. /**
  11944. * Define the refresh rate of the texture or the rendering frequency.
  11945. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11946. */
  11947. get refreshRate(): number;
  11948. set refreshRate(value: number);
  11949. /** @hidden */
  11950. _shouldRender(): boolean;
  11951. /**
  11952. * Get the size the texture is rendering at.
  11953. * @returns the size (texture is always squared)
  11954. */
  11955. getRenderSize(): number;
  11956. /**
  11957. * Resize the texture to new value.
  11958. * @param size Define the new size the texture should have
  11959. * @param generateMipMaps Define whether the new texture should create mip maps
  11960. */
  11961. resize(size: number, generateMipMaps: boolean): void;
  11962. private _checkUniform;
  11963. /**
  11964. * Set a texture in the shader program used to render.
  11965. * @param name Define the name of the uniform samplers as defined in the shader
  11966. * @param texture Define the texture to bind to this sampler
  11967. * @return the texture itself allowing "fluent" like uniform updates
  11968. */
  11969. setTexture(name: string, texture: Texture): ProceduralTexture;
  11970. /**
  11971. * Set a float in the shader.
  11972. * @param name Define the name of the uniform as defined in the shader
  11973. * @param value Define the value to give to the uniform
  11974. * @return the texture itself allowing "fluent" like uniform updates
  11975. */
  11976. setFloat(name: string, value: number): ProceduralTexture;
  11977. /**
  11978. * Set a int in the shader.
  11979. * @param name Define the name of the uniform as defined in the shader
  11980. * @param value Define the value to give to the uniform
  11981. * @return the texture itself allowing "fluent" like uniform updates
  11982. */
  11983. setInt(name: string, value: number): ProceduralTexture;
  11984. /**
  11985. * Set an array of floats in the shader.
  11986. * @param name Define the name of the uniform as defined in the shader
  11987. * @param value Define the value to give to the uniform
  11988. * @return the texture itself allowing "fluent" like uniform updates
  11989. */
  11990. setFloats(name: string, value: number[]): ProceduralTexture;
  11991. /**
  11992. * Set a vec3 in the shader from a Color3.
  11993. * @param name Define the name of the uniform as defined in the shader
  11994. * @param value Define the value to give to the uniform
  11995. * @return the texture itself allowing "fluent" like uniform updates
  11996. */
  11997. setColor3(name: string, value: Color3): ProceduralTexture;
  11998. /**
  11999. * Set a vec4 in the shader from a Color4.
  12000. * @param name Define the name of the uniform as defined in the shader
  12001. * @param value Define the value to give to the uniform
  12002. * @return the texture itself allowing "fluent" like uniform updates
  12003. */
  12004. setColor4(name: string, value: Color4): ProceduralTexture;
  12005. /**
  12006. * Set a vec2 in the shader from a Vector2.
  12007. * @param name Define the name of the uniform as defined in the shader
  12008. * @param value Define the value to give to the uniform
  12009. * @return the texture itself allowing "fluent" like uniform updates
  12010. */
  12011. setVector2(name: string, value: Vector2): ProceduralTexture;
  12012. /**
  12013. * Set a vec3 in the shader from a Vector3.
  12014. * @param name Define the name of the uniform as defined in the shader
  12015. * @param value Define the value to give to the uniform
  12016. * @return the texture itself allowing "fluent" like uniform updates
  12017. */
  12018. setVector3(name: string, value: Vector3): ProceduralTexture;
  12019. /**
  12020. * Set a mat4 in the shader from a MAtrix.
  12021. * @param name Define the name of the uniform as defined in the shader
  12022. * @param value Define the value to give to the uniform
  12023. * @return the texture itself allowing "fluent" like uniform updates
  12024. */
  12025. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12026. /**
  12027. * Render the texture to its associated render target.
  12028. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12029. */
  12030. render(useCameraPostProcess?: boolean): void;
  12031. /**
  12032. * Clone the texture.
  12033. * @returns the cloned texture
  12034. */
  12035. clone(): ProceduralTexture;
  12036. /**
  12037. * Dispose the texture and release its asoociated resources.
  12038. */
  12039. dispose(): void;
  12040. }
  12041. }
  12042. declare module "babylonjs/Particles/baseParticleSystem" {
  12043. import { Nullable } from "babylonjs/types";
  12044. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12046. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12047. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12048. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12049. import { Scene } from "babylonjs/scene";
  12050. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12051. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12052. import { Texture } from "babylonjs/Materials/Textures/texture";
  12053. import { Color4 } from "babylonjs/Maths/math.color";
  12054. import { Animation } from "babylonjs/Animations/animation";
  12055. /**
  12056. * This represents the base class for particle system in Babylon.
  12057. * 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.
  12058. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12059. * @example https://doc.babylonjs.com/babylon101/particles
  12060. */
  12061. export class BaseParticleSystem {
  12062. /**
  12063. * Source color is added to the destination color without alpha affecting the result
  12064. */
  12065. static BLENDMODE_ONEONE: number;
  12066. /**
  12067. * Blend current color and particle color using particle’s alpha
  12068. */
  12069. static BLENDMODE_STANDARD: number;
  12070. /**
  12071. * Add current color and particle color multiplied by particle’s alpha
  12072. */
  12073. static BLENDMODE_ADD: number;
  12074. /**
  12075. * Multiply current color with particle color
  12076. */
  12077. static BLENDMODE_MULTIPLY: number;
  12078. /**
  12079. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12080. */
  12081. static BLENDMODE_MULTIPLYADD: number;
  12082. /**
  12083. * List of animations used by the particle system.
  12084. */
  12085. animations: Animation[];
  12086. /**
  12087. * Gets or sets the unique id of the particle system
  12088. */
  12089. uniqueId: number;
  12090. /**
  12091. * The id of the Particle system.
  12092. */
  12093. id: string;
  12094. /**
  12095. * The friendly name of the Particle system.
  12096. */
  12097. name: string;
  12098. /**
  12099. * Snippet ID if the particle system was created from the snippet server
  12100. */
  12101. snippetId: string;
  12102. /**
  12103. * The rendering group used by the Particle system to chose when to render.
  12104. */
  12105. renderingGroupId: number;
  12106. /**
  12107. * The emitter represents the Mesh or position we are attaching the particle system to.
  12108. */
  12109. emitter: Nullable<AbstractMesh | Vector3>;
  12110. /**
  12111. * The maximum number of particles to emit per frame
  12112. */
  12113. emitRate: number;
  12114. /**
  12115. * If you want to launch only a few particles at once, that can be done, as well.
  12116. */
  12117. manualEmitCount: number;
  12118. /**
  12119. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12120. */
  12121. updateSpeed: number;
  12122. /**
  12123. * The amount of time the particle system is running (depends of the overall update speed).
  12124. */
  12125. targetStopDuration: number;
  12126. /**
  12127. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12128. */
  12129. disposeOnStop: boolean;
  12130. /**
  12131. * Minimum power of emitting particles.
  12132. */
  12133. minEmitPower: number;
  12134. /**
  12135. * Maximum power of emitting particles.
  12136. */
  12137. maxEmitPower: number;
  12138. /**
  12139. * Minimum life time of emitting particles.
  12140. */
  12141. minLifeTime: number;
  12142. /**
  12143. * Maximum life time of emitting particles.
  12144. */
  12145. maxLifeTime: number;
  12146. /**
  12147. * Minimum Size of emitting particles.
  12148. */
  12149. minSize: number;
  12150. /**
  12151. * Maximum Size of emitting particles.
  12152. */
  12153. maxSize: number;
  12154. /**
  12155. * Minimum scale of emitting particles on X axis.
  12156. */
  12157. minScaleX: number;
  12158. /**
  12159. * Maximum scale of emitting particles on X axis.
  12160. */
  12161. maxScaleX: number;
  12162. /**
  12163. * Minimum scale of emitting particles on Y axis.
  12164. */
  12165. minScaleY: number;
  12166. /**
  12167. * Maximum scale of emitting particles on Y axis.
  12168. */
  12169. maxScaleY: number;
  12170. /**
  12171. * Gets or sets the minimal initial rotation in radians.
  12172. */
  12173. minInitialRotation: number;
  12174. /**
  12175. * Gets or sets the maximal initial rotation in radians.
  12176. */
  12177. maxInitialRotation: number;
  12178. /**
  12179. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12180. */
  12181. minAngularSpeed: number;
  12182. /**
  12183. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12184. */
  12185. maxAngularSpeed: number;
  12186. /**
  12187. * The texture used to render each particle. (this can be a spritesheet)
  12188. */
  12189. particleTexture: Nullable<Texture>;
  12190. /**
  12191. * The layer mask we are rendering the particles through.
  12192. */
  12193. layerMask: number;
  12194. /**
  12195. * This can help using your own shader to render the particle system.
  12196. * The according effect will be created
  12197. */
  12198. customShader: any;
  12199. /**
  12200. * By default particle system starts as soon as they are created. This prevents the
  12201. * automatic start to happen and let you decide when to start emitting particles.
  12202. */
  12203. preventAutoStart: boolean;
  12204. private _noiseTexture;
  12205. /**
  12206. * Gets or sets a texture used to add random noise to particle positions
  12207. */
  12208. get noiseTexture(): Nullable<ProceduralTexture>;
  12209. set noiseTexture(value: Nullable<ProceduralTexture>);
  12210. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12211. noiseStrength: Vector3;
  12212. /**
  12213. * Callback triggered when the particle animation is ending.
  12214. */
  12215. onAnimationEnd: Nullable<() => void>;
  12216. /**
  12217. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12218. */
  12219. blendMode: number;
  12220. /**
  12221. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12222. * to override the particles.
  12223. */
  12224. forceDepthWrite: boolean;
  12225. /** 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 */
  12226. preWarmCycles: number;
  12227. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12228. preWarmStepOffset: number;
  12229. /**
  12230. * 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)
  12231. */
  12232. spriteCellChangeSpeed: number;
  12233. /**
  12234. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12235. */
  12236. startSpriteCellID: number;
  12237. /**
  12238. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12239. */
  12240. endSpriteCellID: number;
  12241. /**
  12242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12243. */
  12244. spriteCellWidth: number;
  12245. /**
  12246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12247. */
  12248. spriteCellHeight: number;
  12249. /**
  12250. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12251. */
  12252. spriteRandomStartCell: boolean;
  12253. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12254. translationPivot: Vector2;
  12255. /** @hidden */
  12256. protected _isAnimationSheetEnabled: boolean;
  12257. /**
  12258. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12259. */
  12260. beginAnimationOnStart: boolean;
  12261. /**
  12262. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12263. */
  12264. beginAnimationFrom: number;
  12265. /**
  12266. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12267. */
  12268. beginAnimationTo: number;
  12269. /**
  12270. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12271. */
  12272. beginAnimationLoop: boolean;
  12273. /**
  12274. * Gets or sets a world offset applied to all particles
  12275. */
  12276. worldOffset: Vector3;
  12277. /**
  12278. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12279. */
  12280. get isAnimationSheetEnabled(): boolean;
  12281. set isAnimationSheetEnabled(value: boolean);
  12282. /**
  12283. * Get hosting scene
  12284. * @returns the scene
  12285. */
  12286. getScene(): Scene;
  12287. /**
  12288. * You can use gravity if you want to give an orientation to your particles.
  12289. */
  12290. gravity: Vector3;
  12291. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12292. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12293. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12294. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12295. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12296. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12297. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12298. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12299. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12300. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12301. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12302. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12303. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12304. /**
  12305. * Defines the delay in milliseconds before starting the system (0 by default)
  12306. */
  12307. startDelay: number;
  12308. /**
  12309. * Gets the current list of drag gradients.
  12310. * You must use addDragGradient and removeDragGradient to udpate this list
  12311. * @returns the list of drag gradients
  12312. */
  12313. getDragGradients(): Nullable<Array<FactorGradient>>;
  12314. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12315. limitVelocityDamping: number;
  12316. /**
  12317. * Gets the current list of limit velocity gradients.
  12318. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12319. * @returns the list of limit velocity gradients
  12320. */
  12321. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12322. /**
  12323. * Gets the current list of color gradients.
  12324. * You must use addColorGradient and removeColorGradient to udpate this list
  12325. * @returns the list of color gradients
  12326. */
  12327. getColorGradients(): Nullable<Array<ColorGradient>>;
  12328. /**
  12329. * Gets the current list of size gradients.
  12330. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12331. * @returns the list of size gradients
  12332. */
  12333. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12334. /**
  12335. * Gets the current list of color remap gradients.
  12336. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12337. * @returns the list of color remap gradients
  12338. */
  12339. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12340. /**
  12341. * Gets the current list of alpha remap gradients.
  12342. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12343. * @returns the list of alpha remap gradients
  12344. */
  12345. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12346. /**
  12347. * Gets the current list of life time gradients.
  12348. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12349. * @returns the list of life time gradients
  12350. */
  12351. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12352. /**
  12353. * Gets the current list of angular speed gradients.
  12354. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12355. * @returns the list of angular speed gradients
  12356. */
  12357. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12358. /**
  12359. * Gets the current list of velocity gradients.
  12360. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12361. * @returns the list of velocity gradients
  12362. */
  12363. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12364. /**
  12365. * Gets the current list of start size gradients.
  12366. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12367. * @returns the list of start size gradients
  12368. */
  12369. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12370. /**
  12371. * Gets the current list of emit rate gradients.
  12372. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12373. * @returns the list of emit rate gradients
  12374. */
  12375. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12376. /**
  12377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12378. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12379. */
  12380. get direction1(): Vector3;
  12381. set direction1(value: Vector3);
  12382. /**
  12383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12384. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12385. */
  12386. get direction2(): Vector3;
  12387. set direction2(value: Vector3);
  12388. /**
  12389. * 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.
  12390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12391. */
  12392. get minEmitBox(): Vector3;
  12393. set minEmitBox(value: Vector3);
  12394. /**
  12395. * 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.
  12396. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12397. */
  12398. get maxEmitBox(): Vector3;
  12399. set maxEmitBox(value: Vector3);
  12400. /**
  12401. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12402. */
  12403. color1: Color4;
  12404. /**
  12405. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12406. */
  12407. color2: Color4;
  12408. /**
  12409. * Color the particle will have at the end of its lifetime
  12410. */
  12411. colorDead: Color4;
  12412. /**
  12413. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12414. */
  12415. textureMask: Color4;
  12416. /**
  12417. * The particle emitter type defines the emitter used by the particle system.
  12418. * It can be for example box, sphere, or cone...
  12419. */
  12420. particleEmitterType: IParticleEmitterType;
  12421. /** @hidden */
  12422. _isSubEmitter: boolean;
  12423. /**
  12424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12425. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12426. */
  12427. billboardMode: number;
  12428. protected _isBillboardBased: boolean;
  12429. /**
  12430. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12431. */
  12432. get isBillboardBased(): boolean;
  12433. set isBillboardBased(value: boolean);
  12434. /**
  12435. * The scene the particle system belongs to.
  12436. */
  12437. protected _scene: Scene;
  12438. /**
  12439. * Local cache of defines for image processing.
  12440. */
  12441. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12442. /**
  12443. * Default configuration related to image processing available in the standard Material.
  12444. */
  12445. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12446. /**
  12447. * Gets the image processing configuration used either in this material.
  12448. */
  12449. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12450. /**
  12451. * Sets the Default image processing configuration used either in the this material.
  12452. *
  12453. * If sets to null, the scene one is in use.
  12454. */
  12455. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12456. /**
  12457. * Attaches a new image processing configuration to the Standard Material.
  12458. * @param configuration
  12459. */
  12460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12461. /** @hidden */
  12462. protected _reset(): void;
  12463. /** @hidden */
  12464. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12465. /**
  12466. * Instantiates a particle system.
  12467. * 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.
  12468. * @param name The name of the particle system
  12469. */
  12470. constructor(name: string);
  12471. /**
  12472. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12475. * @returns the emitter
  12476. */
  12477. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12478. /**
  12479. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12480. * @param radius The radius of the hemisphere to emit from
  12481. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12482. * @returns the emitter
  12483. */
  12484. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12485. /**
  12486. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12487. * @param radius The radius of the sphere to emit from
  12488. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12489. * @returns the emitter
  12490. */
  12491. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12492. /**
  12493. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12494. * @param radius The radius of the sphere to emit from
  12495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12497. * @returns the emitter
  12498. */
  12499. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12500. /**
  12501. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12502. * @param radius The radius of the emission cylinder
  12503. * @param height The height of the emission cylinder
  12504. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12505. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12506. * @returns the emitter
  12507. */
  12508. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12509. /**
  12510. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12511. * @param radius The radius of the cylinder to emit from
  12512. * @param height The height of the emission cylinder
  12513. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12516. * @returns the emitter
  12517. */
  12518. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12519. /**
  12520. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12521. * @param radius The radius of the cone to emit from
  12522. * @param angle The base angle of the cone
  12523. * @returns the emitter
  12524. */
  12525. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12526. /**
  12527. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12530. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12531. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12532. * @returns the emitter
  12533. */
  12534. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12535. }
  12536. }
  12537. declare module "babylonjs/Particles/subEmitter" {
  12538. import { Scene } from "babylonjs/scene";
  12539. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12540. /**
  12541. * Type of sub emitter
  12542. */
  12543. export enum SubEmitterType {
  12544. /**
  12545. * Attached to the particle over it's lifetime
  12546. */
  12547. ATTACHED = 0,
  12548. /**
  12549. * Created when the particle dies
  12550. */
  12551. END = 1
  12552. }
  12553. /**
  12554. * Sub emitter class used to emit particles from an existing particle
  12555. */
  12556. export class SubEmitter {
  12557. /**
  12558. * the particle system to be used by the sub emitter
  12559. */
  12560. particleSystem: ParticleSystem;
  12561. /**
  12562. * Type of the submitter (Default: END)
  12563. */
  12564. type: SubEmitterType;
  12565. /**
  12566. * 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)
  12567. * Note: This only is supported when using an emitter of type Mesh
  12568. */
  12569. inheritDirection: boolean;
  12570. /**
  12571. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12572. */
  12573. inheritedVelocityAmount: number;
  12574. /**
  12575. * Creates a sub emitter
  12576. * @param particleSystem the particle system to be used by the sub emitter
  12577. */
  12578. constructor(
  12579. /**
  12580. * the particle system to be used by the sub emitter
  12581. */
  12582. particleSystem: ParticleSystem);
  12583. /**
  12584. * Clones the sub emitter
  12585. * @returns the cloned sub emitter
  12586. */
  12587. clone(): SubEmitter;
  12588. /**
  12589. * Serialize current object to a JSON object
  12590. * @returns the serialized object
  12591. */
  12592. serialize(): any;
  12593. /** @hidden */
  12594. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12595. /**
  12596. * Creates a new SubEmitter from a serialized JSON version
  12597. * @param serializationObject defines the JSON object to read from
  12598. * @param scene defines the hosting scene
  12599. * @param rootUrl defines the rootUrl for data loading
  12600. * @returns a new SubEmitter
  12601. */
  12602. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12603. /** Release associated resources */
  12604. dispose(): void;
  12605. }
  12606. }
  12607. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12608. /** @hidden */
  12609. export var imageProcessingDeclaration: {
  12610. name: string;
  12611. shader: string;
  12612. };
  12613. }
  12614. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12615. /** @hidden */
  12616. export var imageProcessingFunctions: {
  12617. name: string;
  12618. shader: string;
  12619. };
  12620. }
  12621. declare module "babylonjs/Shaders/particles.fragment" {
  12622. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12623. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12624. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12625. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12626. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12627. /** @hidden */
  12628. export var particlesPixelShader: {
  12629. name: string;
  12630. shader: string;
  12631. };
  12632. }
  12633. declare module "babylonjs/Shaders/particles.vertex" {
  12634. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12636. /** @hidden */
  12637. export var particlesVertexShader: {
  12638. name: string;
  12639. shader: string;
  12640. };
  12641. }
  12642. declare module "babylonjs/Particles/particleSystem" {
  12643. import { Nullable } from "babylonjs/types";
  12644. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12645. import { Observable } from "babylonjs/Misc/observable";
  12646. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12647. import { Effect } from "babylonjs/Materials/effect";
  12648. import { Scene, IDisposable } from "babylonjs/scene";
  12649. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12650. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12651. import { Particle } from "babylonjs/Particles/particle";
  12652. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12653. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12654. import "babylonjs/Shaders/particles.fragment";
  12655. import "babylonjs/Shaders/particles.vertex";
  12656. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12657. /**
  12658. * This represents a particle system in Babylon.
  12659. * 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.
  12660. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12661. * @example https://doc.babylonjs.com/babylon101/particles
  12662. */
  12663. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12664. /**
  12665. * Billboard mode will only apply to Y axis
  12666. */
  12667. static readonly BILLBOARDMODE_Y: number;
  12668. /**
  12669. * Billboard mode will apply to all axes
  12670. */
  12671. static readonly BILLBOARDMODE_ALL: number;
  12672. /**
  12673. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12674. */
  12675. static readonly BILLBOARDMODE_STRETCHED: number;
  12676. /**
  12677. * This function can be defined to provide custom update for active particles.
  12678. * This function will be called instead of regular update (age, position, color, etc.).
  12679. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12680. */
  12681. updateFunction: (particles: Particle[]) => void;
  12682. private _emitterWorldMatrix;
  12683. /**
  12684. * This function can be defined to specify initial direction for every new particle.
  12685. * It by default use the emitterType defined function
  12686. */
  12687. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12688. /**
  12689. * This function can be defined to specify initial position for every new particle.
  12690. * It by default use the emitterType defined function
  12691. */
  12692. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12693. /**
  12694. * @hidden
  12695. */
  12696. _inheritedVelocityOffset: Vector3;
  12697. /**
  12698. * An event triggered when the system is disposed
  12699. */
  12700. onDisposeObservable: Observable<IParticleSystem>;
  12701. private _onDisposeObserver;
  12702. /**
  12703. * Sets a callback that will be triggered when the system is disposed
  12704. */
  12705. set onDispose(callback: () => void);
  12706. private _particles;
  12707. private _epsilon;
  12708. private _capacity;
  12709. private _stockParticles;
  12710. private _newPartsExcess;
  12711. private _vertexData;
  12712. private _vertexBuffer;
  12713. private _vertexBuffers;
  12714. private _spriteBuffer;
  12715. private _indexBuffer;
  12716. private _effect;
  12717. private _customEffect;
  12718. private _cachedDefines;
  12719. private _scaledColorStep;
  12720. private _colorDiff;
  12721. private _scaledDirection;
  12722. private _scaledGravity;
  12723. private _currentRenderId;
  12724. private _alive;
  12725. private _useInstancing;
  12726. private _started;
  12727. private _stopped;
  12728. private _actualFrame;
  12729. private _scaledUpdateSpeed;
  12730. private _vertexBufferSize;
  12731. /** @hidden */
  12732. _currentEmitRateGradient: Nullable<FactorGradient>;
  12733. /** @hidden */
  12734. _currentEmitRate1: number;
  12735. /** @hidden */
  12736. _currentEmitRate2: number;
  12737. /** @hidden */
  12738. _currentStartSizeGradient: Nullable<FactorGradient>;
  12739. /** @hidden */
  12740. _currentStartSize1: number;
  12741. /** @hidden */
  12742. _currentStartSize2: number;
  12743. private readonly _rawTextureWidth;
  12744. private _rampGradientsTexture;
  12745. private _useRampGradients;
  12746. /** Gets or sets a boolean indicating that ramp gradients must be used
  12747. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12748. */
  12749. get useRampGradients(): boolean;
  12750. set useRampGradients(value: boolean);
  12751. /**
  12752. * 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.
  12753. * 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: [])
  12754. */
  12755. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12756. private _subEmitters;
  12757. /**
  12758. * @hidden
  12759. * If the particle systems emitter should be disposed when the particle system is disposed
  12760. */
  12761. _disposeEmitterOnDispose: boolean;
  12762. /**
  12763. * The current active Sub-systems, this property is used by the root particle system only.
  12764. */
  12765. activeSubSystems: Array<ParticleSystem>;
  12766. /**
  12767. * Specifies if the particles are updated in emitter local space or world space
  12768. */
  12769. isLocal: boolean;
  12770. private _rootParticleSystem;
  12771. /**
  12772. * Gets the current list of active particles
  12773. */
  12774. get particles(): Particle[];
  12775. /**
  12776. * Gets the number of particles active at the same time.
  12777. * @returns The number of active particles.
  12778. */
  12779. getActiveCount(): number;
  12780. /**
  12781. * Returns the string "ParticleSystem"
  12782. * @returns a string containing the class name
  12783. */
  12784. getClassName(): string;
  12785. /**
  12786. * Gets a boolean indicating that the system is stopping
  12787. * @returns true if the system is currently stopping
  12788. */
  12789. isStopping(): boolean;
  12790. /**
  12791. * Gets the custom effect used to render the particles
  12792. * @param blendMode Blend mode for which the effect should be retrieved
  12793. * @returns The effect
  12794. */
  12795. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12796. /**
  12797. * Sets the custom effect used to render the particles
  12798. * @param effect The effect to set
  12799. * @param blendMode Blend mode for which the effect should be set
  12800. */
  12801. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12802. /** @hidden */
  12803. private _onBeforeDrawParticlesObservable;
  12804. /**
  12805. * Observable that will be called just before the particles are drawn
  12806. */
  12807. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12808. /**
  12809. * Gets the name of the particle vertex shader
  12810. */
  12811. get vertexShaderName(): string;
  12812. /**
  12813. * Instantiates a particle system.
  12814. * 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.
  12815. * @param name The name of the particle system
  12816. * @param capacity The max number of particles alive at the same time
  12817. * @param scene The scene the particle system belongs to
  12818. * @param customEffect a custom effect used to change the way particles are rendered by default
  12819. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12820. * @param epsilon Offset used to render the particles
  12821. */
  12822. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12823. private _addFactorGradient;
  12824. private _removeFactorGradient;
  12825. /**
  12826. * Adds a new life time gradient
  12827. * @param gradient defines the gradient to use (between 0 and 1)
  12828. * @param factor defines the life time factor to affect to the specified gradient
  12829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12830. * @returns the current particle system
  12831. */
  12832. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12833. /**
  12834. * Remove a specific life time gradient
  12835. * @param gradient defines the gradient to remove
  12836. * @returns the current particle system
  12837. */
  12838. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12839. /**
  12840. * Adds a new size gradient
  12841. * @param gradient defines the gradient to use (between 0 and 1)
  12842. * @param factor defines the size factor to affect to the specified gradient
  12843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12844. * @returns the current particle system
  12845. */
  12846. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12847. /**
  12848. * Remove a specific size gradient
  12849. * @param gradient defines the gradient to remove
  12850. * @returns the current particle system
  12851. */
  12852. removeSizeGradient(gradient: number): IParticleSystem;
  12853. /**
  12854. * Adds a new color remap gradient
  12855. * @param gradient defines the gradient to use (between 0 and 1)
  12856. * @param min defines the color remap minimal range
  12857. * @param max defines the color remap maximal range
  12858. * @returns the current particle system
  12859. */
  12860. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12861. /**
  12862. * Remove a specific color remap gradient
  12863. * @param gradient defines the gradient to remove
  12864. * @returns the current particle system
  12865. */
  12866. removeColorRemapGradient(gradient: number): IParticleSystem;
  12867. /**
  12868. * Adds a new alpha remap gradient
  12869. * @param gradient defines the gradient to use (between 0 and 1)
  12870. * @param min defines the alpha remap minimal range
  12871. * @param max defines the alpha remap maximal range
  12872. * @returns the current particle system
  12873. */
  12874. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12875. /**
  12876. * Remove a specific alpha remap gradient
  12877. * @param gradient defines the gradient to remove
  12878. * @returns the current particle system
  12879. */
  12880. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12881. /**
  12882. * Adds a new angular speed gradient
  12883. * @param gradient defines the gradient to use (between 0 and 1)
  12884. * @param factor defines the angular speed to affect to the specified gradient
  12885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12886. * @returns the current particle system
  12887. */
  12888. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12889. /**
  12890. * Remove a specific angular speed gradient
  12891. * @param gradient defines the gradient to remove
  12892. * @returns the current particle system
  12893. */
  12894. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12895. /**
  12896. * Adds a new velocity gradient
  12897. * @param gradient defines the gradient to use (between 0 and 1)
  12898. * @param factor defines the velocity to affect to the specified gradient
  12899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12900. * @returns the current particle system
  12901. */
  12902. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12903. /**
  12904. * Remove a specific velocity gradient
  12905. * @param gradient defines the gradient to remove
  12906. * @returns the current particle system
  12907. */
  12908. removeVelocityGradient(gradient: number): IParticleSystem;
  12909. /**
  12910. * Adds a new limit velocity gradient
  12911. * @param gradient defines the gradient to use (between 0 and 1)
  12912. * @param factor defines the limit velocity value to affect to the specified gradient
  12913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12914. * @returns the current particle system
  12915. */
  12916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12917. /**
  12918. * Remove a specific limit velocity gradient
  12919. * @param gradient defines the gradient to remove
  12920. * @returns the current particle system
  12921. */
  12922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12923. /**
  12924. * Adds a new drag gradient
  12925. * @param gradient defines the gradient to use (between 0 and 1)
  12926. * @param factor defines the drag value to affect to the specified gradient
  12927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12928. * @returns the current particle system
  12929. */
  12930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12931. /**
  12932. * Remove a specific drag gradient
  12933. * @param gradient defines the gradient to remove
  12934. * @returns the current particle system
  12935. */
  12936. removeDragGradient(gradient: number): IParticleSystem;
  12937. /**
  12938. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12939. * @param gradient defines the gradient to use (between 0 and 1)
  12940. * @param factor defines the emit rate value to affect to the specified gradient
  12941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12942. * @returns the current particle system
  12943. */
  12944. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12945. /**
  12946. * Remove a specific emit rate gradient
  12947. * @param gradient defines the gradient to remove
  12948. * @returns the current particle system
  12949. */
  12950. removeEmitRateGradient(gradient: number): IParticleSystem;
  12951. /**
  12952. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12953. * @param gradient defines the gradient to use (between 0 and 1)
  12954. * @param factor defines the start size value to affect to the specified gradient
  12955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12956. * @returns the current particle system
  12957. */
  12958. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12959. /**
  12960. * Remove a specific start size gradient
  12961. * @param gradient defines the gradient to remove
  12962. * @returns the current particle system
  12963. */
  12964. removeStartSizeGradient(gradient: number): IParticleSystem;
  12965. private _createRampGradientTexture;
  12966. /**
  12967. * Gets the current list of ramp gradients.
  12968. * You must use addRampGradient and removeRampGradient to udpate this list
  12969. * @returns the list of ramp gradients
  12970. */
  12971. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12972. /** Force the system to rebuild all gradients that need to be resync */
  12973. forceRefreshGradients(): void;
  12974. private _syncRampGradientTexture;
  12975. /**
  12976. * Adds a new ramp gradient used to remap particle colors
  12977. * @param gradient defines the gradient to use (between 0 and 1)
  12978. * @param color defines the color to affect to the specified gradient
  12979. * @returns the current particle system
  12980. */
  12981. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12982. /**
  12983. * Remove a specific ramp gradient
  12984. * @param gradient defines the gradient to remove
  12985. * @returns the current particle system
  12986. */
  12987. removeRampGradient(gradient: number): ParticleSystem;
  12988. /**
  12989. * Adds a new color gradient
  12990. * @param gradient defines the gradient to use (between 0 and 1)
  12991. * @param color1 defines the color to affect to the specified gradient
  12992. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12993. * @returns this particle system
  12994. */
  12995. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12996. /**
  12997. * Remove a specific color gradient
  12998. * @param gradient defines the gradient to remove
  12999. * @returns this particle system
  13000. */
  13001. removeColorGradient(gradient: number): IParticleSystem;
  13002. private _fetchR;
  13003. protected _reset(): void;
  13004. private _resetEffect;
  13005. private _createVertexBuffers;
  13006. private _createIndexBuffer;
  13007. /**
  13008. * Gets the maximum number of particles active at the same time.
  13009. * @returns The max number of active particles.
  13010. */
  13011. getCapacity(): number;
  13012. /**
  13013. * Gets whether there are still active particles in the system.
  13014. * @returns True if it is alive, otherwise false.
  13015. */
  13016. isAlive(): boolean;
  13017. /**
  13018. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13019. * @returns True if it has been started, otherwise false.
  13020. */
  13021. isStarted(): boolean;
  13022. private _prepareSubEmitterInternalArray;
  13023. /**
  13024. * Starts the particle system and begins to emit
  13025. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13026. */
  13027. start(delay?: number): void;
  13028. /**
  13029. * Stops the particle system.
  13030. * @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.
  13031. */
  13032. stop(stopSubEmitters?: boolean): void;
  13033. /**
  13034. * Remove all active particles
  13035. */
  13036. reset(): void;
  13037. /**
  13038. * @hidden (for internal use only)
  13039. */
  13040. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13041. /**
  13042. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13043. * Its lifetime will start back at 0.
  13044. */
  13045. recycleParticle: (particle: Particle) => void;
  13046. private _stopSubEmitters;
  13047. private _createParticle;
  13048. private _removeFromRoot;
  13049. private _emitFromParticle;
  13050. private _update;
  13051. /** @hidden */
  13052. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13053. /** @hidden */
  13054. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13055. /**
  13056. * Fill the defines array according to the current settings of the particle system
  13057. * @param defines Array to be updated
  13058. * @param blendMode blend mode to take into account when updating the array
  13059. */
  13060. fillDefines(defines: Array<string>, blendMode: number): void;
  13061. /**
  13062. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13063. * @param uniforms Uniforms array to fill
  13064. * @param attributes Attributes array to fill
  13065. * @param samplers Samplers array to fill
  13066. */
  13067. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13068. /** @hidden */
  13069. private _getEffect;
  13070. /**
  13071. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13072. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13073. */
  13074. animate(preWarmOnly?: boolean): void;
  13075. private _appendParticleVertices;
  13076. /**
  13077. * Rebuilds the particle system.
  13078. */
  13079. rebuild(): void;
  13080. /**
  13081. * Is this system ready to be used/rendered
  13082. * @return true if the system is ready
  13083. */
  13084. isReady(): boolean;
  13085. private _render;
  13086. /**
  13087. * Renders the particle system in its current state.
  13088. * @returns the current number of particles
  13089. */
  13090. render(): number;
  13091. /**
  13092. * Disposes the particle system and free the associated resources
  13093. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13094. */
  13095. dispose(disposeTexture?: boolean): void;
  13096. /**
  13097. * Clones the particle system.
  13098. * @param name The name of the cloned object
  13099. * @param newEmitter The new emitter to use
  13100. * @returns the cloned particle system
  13101. */
  13102. clone(name: string, newEmitter: any): ParticleSystem;
  13103. /**
  13104. * Serializes the particle system to a JSON object
  13105. * @param serializeTexture defines if the texture must be serialized as well
  13106. * @returns the JSON object
  13107. */
  13108. serialize(serializeTexture?: boolean): any;
  13109. /** @hidden */
  13110. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13111. /** @hidden */
  13112. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13113. /**
  13114. * Parses a JSON object to create a particle system.
  13115. * @param parsedParticleSystem The JSON object to parse
  13116. * @param scene The scene to create the particle system in
  13117. * @param rootUrl The root url to use to load external dependencies like texture
  13118. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13119. * @returns the Parsed particle system
  13120. */
  13121. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13122. }
  13123. }
  13124. declare module "babylonjs/Particles/particle" {
  13125. import { Nullable } from "babylonjs/types";
  13126. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13127. import { Color4 } from "babylonjs/Maths/math.color";
  13128. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13129. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13130. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13131. /**
  13132. * A particle represents one of the element emitted by a particle system.
  13133. * This is mainly define by its coordinates, direction, velocity and age.
  13134. */
  13135. export class Particle {
  13136. /**
  13137. * The particle system the particle belongs to.
  13138. */
  13139. particleSystem: ParticleSystem;
  13140. private static _Count;
  13141. /**
  13142. * Unique ID of the particle
  13143. */
  13144. id: number;
  13145. /**
  13146. * The world position of the particle in the scene.
  13147. */
  13148. position: Vector3;
  13149. /**
  13150. * The world direction of the particle in the scene.
  13151. */
  13152. direction: Vector3;
  13153. /**
  13154. * The color of the particle.
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * The color change of the particle per step.
  13159. */
  13160. colorStep: Color4;
  13161. /**
  13162. * Defines how long will the life of the particle be.
  13163. */
  13164. lifeTime: number;
  13165. /**
  13166. * The current age of the particle.
  13167. */
  13168. age: number;
  13169. /**
  13170. * The current size of the particle.
  13171. */
  13172. size: number;
  13173. /**
  13174. * The current scale of the particle.
  13175. */
  13176. scale: Vector2;
  13177. /**
  13178. * The current angle of the particle.
  13179. */
  13180. angle: number;
  13181. /**
  13182. * Defines how fast is the angle changing.
  13183. */
  13184. angularSpeed: number;
  13185. /**
  13186. * Defines the cell index used by the particle to be rendered from a sprite.
  13187. */
  13188. cellIndex: number;
  13189. /**
  13190. * The information required to support color remapping
  13191. */
  13192. remapData: Vector4;
  13193. /** @hidden */
  13194. _randomCellOffset?: number;
  13195. /** @hidden */
  13196. _initialDirection: Nullable<Vector3>;
  13197. /** @hidden */
  13198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13199. /** @hidden */
  13200. _initialStartSpriteCellID: number;
  13201. /** @hidden */
  13202. _initialEndSpriteCellID: number;
  13203. /** @hidden */
  13204. _currentColorGradient: Nullable<ColorGradient>;
  13205. /** @hidden */
  13206. _currentColor1: Color4;
  13207. /** @hidden */
  13208. _currentColor2: Color4;
  13209. /** @hidden */
  13210. _currentSizeGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentSize1: number;
  13213. /** @hidden */
  13214. _currentSize2: number;
  13215. /** @hidden */
  13216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13217. /** @hidden */
  13218. _currentAngularSpeed1: number;
  13219. /** @hidden */
  13220. _currentAngularSpeed2: number;
  13221. /** @hidden */
  13222. _currentVelocityGradient: Nullable<FactorGradient>;
  13223. /** @hidden */
  13224. _currentVelocity1: number;
  13225. /** @hidden */
  13226. _currentVelocity2: number;
  13227. /** @hidden */
  13228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13229. /** @hidden */
  13230. _currentLimitVelocity1: number;
  13231. /** @hidden */
  13232. _currentLimitVelocity2: number;
  13233. /** @hidden */
  13234. _currentDragGradient: Nullable<FactorGradient>;
  13235. /** @hidden */
  13236. _currentDrag1: number;
  13237. /** @hidden */
  13238. _currentDrag2: number;
  13239. /** @hidden */
  13240. _randomNoiseCoordinates1: Vector3;
  13241. /** @hidden */
  13242. _randomNoiseCoordinates2: Vector3;
  13243. /** @hidden */
  13244. _localPosition?: Vector3;
  13245. /**
  13246. * Creates a new instance Particle
  13247. * @param particleSystem the particle system the particle belongs to
  13248. */
  13249. constructor(
  13250. /**
  13251. * The particle system the particle belongs to.
  13252. */
  13253. particleSystem: ParticleSystem);
  13254. private updateCellInfoFromSystem;
  13255. /**
  13256. * Defines how the sprite cell index is updated for the particle
  13257. */
  13258. updateCellIndex(): void;
  13259. /** @hidden */
  13260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13261. /** @hidden */
  13262. _inheritParticleInfoToSubEmitters(): void;
  13263. /** @hidden */
  13264. _reset(): void;
  13265. /**
  13266. * Copy the properties of particle to another one.
  13267. * @param other the particle to copy the information to.
  13268. */
  13269. copyTo(other: Particle): void;
  13270. }
  13271. }
  13272. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Effect } from "babylonjs/Materials/effect";
  13275. import { Particle } from "babylonjs/Particles/particle";
  13276. import { Scene } from "babylonjs/scene";
  13277. /**
  13278. * Particle emitter represents a volume emitting particles.
  13279. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13280. */
  13281. export interface IParticleEmitterType {
  13282. /**
  13283. * Called by the particle System when the direction is computed for the created particle.
  13284. * @param worldMatrix is the world matrix of the particle system
  13285. * @param directionToUpdate is the direction vector to update with the result
  13286. * @param particle is the particle we are computed the direction for
  13287. * @param isLocal defines if the direction should be set in local space
  13288. */
  13289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13290. /**
  13291. * Called by the particle System when the position is computed for the created particle.
  13292. * @param worldMatrix is the world matrix of the particle system
  13293. * @param positionToUpdate is the position vector to update with the result
  13294. * @param particle is the particle we are computed the position for
  13295. * @param isLocal defines if the position should be set in local space
  13296. */
  13297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13298. /**
  13299. * Clones the current emitter and returns a copy of it
  13300. * @returns the new emitter
  13301. */
  13302. clone(): IParticleEmitterType;
  13303. /**
  13304. * Called by the GPUParticleSystem to setup the update shader
  13305. * @param effect defines the update shader
  13306. */
  13307. applyToShader(effect: Effect): void;
  13308. /**
  13309. * Returns a string to use to update the GPU particles update shader
  13310. * @returns the effect defines string
  13311. */
  13312. getEffectDefines(): string;
  13313. /**
  13314. * Returns a string representing the class name
  13315. * @returns a string containing the class name
  13316. */
  13317. getClassName(): string;
  13318. /**
  13319. * Serializes the particle system to a JSON object.
  13320. * @returns the JSON object
  13321. */
  13322. serialize(): any;
  13323. /**
  13324. * Parse properties from a JSON object
  13325. * @param serializationObject defines the JSON object
  13326. * @param scene defines the hosting scene
  13327. */
  13328. parse(serializationObject: any, scene: Scene): void;
  13329. }
  13330. }
  13331. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13332. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13333. import { Effect } from "babylonjs/Materials/effect";
  13334. import { Particle } from "babylonjs/Particles/particle";
  13335. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13336. /**
  13337. * Particle emitter emitting particles from the inside of a box.
  13338. * It emits the particles randomly between 2 given directions.
  13339. */
  13340. export class BoxParticleEmitter implements IParticleEmitterType {
  13341. /**
  13342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13343. */
  13344. direction1: Vector3;
  13345. /**
  13346. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13347. */
  13348. direction2: Vector3;
  13349. /**
  13350. * 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.
  13351. */
  13352. minEmitBox: Vector3;
  13353. /**
  13354. * 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.
  13355. */
  13356. maxEmitBox: Vector3;
  13357. /**
  13358. * Creates a new instance BoxParticleEmitter
  13359. */
  13360. constructor();
  13361. /**
  13362. * Called by the particle System when the direction is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param directionToUpdate is the direction vector to update with the result
  13365. * @param particle is the particle we are computed the direction for
  13366. * @param isLocal defines if the direction should be set in local space
  13367. */
  13368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Called by the particle System when the position is computed for the created particle.
  13371. * @param worldMatrix is the world matrix of the particle system
  13372. * @param positionToUpdate is the position vector to update with the result
  13373. * @param particle is the particle we are computed the position for
  13374. * @param isLocal defines if the position should be set in local space
  13375. */
  13376. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13377. /**
  13378. * Clones the current emitter and returns a copy of it
  13379. * @returns the new emitter
  13380. */
  13381. clone(): BoxParticleEmitter;
  13382. /**
  13383. * Called by the GPUParticleSystem to setup the update shader
  13384. * @param effect defines the update shader
  13385. */
  13386. applyToShader(effect: Effect): void;
  13387. /**
  13388. * Returns a string to use to update the GPU particles update shader
  13389. * @returns a string containng the defines string
  13390. */
  13391. getEffectDefines(): string;
  13392. /**
  13393. * Returns the string "BoxParticleEmitter"
  13394. * @returns a string containing the class name
  13395. */
  13396. getClassName(): string;
  13397. /**
  13398. * Serializes the particle system to a JSON object.
  13399. * @returns the JSON object
  13400. */
  13401. serialize(): any;
  13402. /**
  13403. * Parse properties from a JSON object
  13404. * @param serializationObject defines the JSON object
  13405. */
  13406. parse(serializationObject: any): void;
  13407. }
  13408. }
  13409. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13410. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13411. import { Effect } from "babylonjs/Materials/effect";
  13412. import { Particle } from "babylonjs/Particles/particle";
  13413. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13414. /**
  13415. * Particle emitter emitting particles from the inside of a cone.
  13416. * It emits the particles alongside the cone volume from the base to the particle.
  13417. * The emission direction might be randomized.
  13418. */
  13419. export class ConeParticleEmitter implements IParticleEmitterType {
  13420. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13421. directionRandomizer: number;
  13422. private _radius;
  13423. private _angle;
  13424. private _height;
  13425. /**
  13426. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13427. */
  13428. radiusRange: number;
  13429. /**
  13430. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13431. */
  13432. heightRange: number;
  13433. /**
  13434. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13435. */
  13436. emitFromSpawnPointOnly: boolean;
  13437. /**
  13438. * Gets or sets the radius of the emission cone
  13439. */
  13440. get radius(): number;
  13441. set radius(value: number);
  13442. /**
  13443. * Gets or sets the angle of the emission cone
  13444. */
  13445. get angle(): number;
  13446. set angle(value: number);
  13447. private _buildHeight;
  13448. /**
  13449. * Creates a new instance ConeParticleEmitter
  13450. * @param radius the radius of the emission cone (1 by default)
  13451. * @param angle the cone base angle (PI by default)
  13452. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13453. */
  13454. constructor(radius?: number, angle?: number,
  13455. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13456. directionRandomizer?: number);
  13457. /**
  13458. * Called by the particle System when the direction is computed for the created particle.
  13459. * @param worldMatrix is the world matrix of the particle system
  13460. * @param directionToUpdate is the direction vector to update with the result
  13461. * @param particle is the particle we are computed the direction for
  13462. * @param isLocal defines if the direction should be set in local space
  13463. */
  13464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13465. /**
  13466. * Called by the particle System when the position is computed for the created particle.
  13467. * @param worldMatrix is the world matrix of the particle system
  13468. * @param positionToUpdate is the position vector to update with the result
  13469. * @param particle is the particle we are computed the position for
  13470. * @param isLocal defines if the position should be set in local space
  13471. */
  13472. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13473. /**
  13474. * Clones the current emitter and returns a copy of it
  13475. * @returns the new emitter
  13476. */
  13477. clone(): ConeParticleEmitter;
  13478. /**
  13479. * Called by the GPUParticleSystem to setup the update shader
  13480. * @param effect defines the update shader
  13481. */
  13482. applyToShader(effect: Effect): void;
  13483. /**
  13484. * Returns a string to use to update the GPU particles update shader
  13485. * @returns a string containng the defines string
  13486. */
  13487. getEffectDefines(): string;
  13488. /**
  13489. * Returns the string "ConeParticleEmitter"
  13490. * @returns a string containing the class name
  13491. */
  13492. getClassName(): string;
  13493. /**
  13494. * Serializes the particle system to a JSON object.
  13495. * @returns the JSON object
  13496. */
  13497. serialize(): any;
  13498. /**
  13499. * Parse properties from a JSON object
  13500. * @param serializationObject defines the JSON object
  13501. */
  13502. parse(serializationObject: any): void;
  13503. }
  13504. }
  13505. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13506. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13507. import { Effect } from "babylonjs/Materials/effect";
  13508. import { Particle } from "babylonjs/Particles/particle";
  13509. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13510. /**
  13511. * Particle emitter emitting particles from the inside of a cylinder.
  13512. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13513. */
  13514. export class CylinderParticleEmitter implements IParticleEmitterType {
  13515. /**
  13516. * The radius of the emission cylinder.
  13517. */
  13518. radius: number;
  13519. /**
  13520. * The height of the emission cylinder.
  13521. */
  13522. height: number;
  13523. /**
  13524. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13525. */
  13526. radiusRange: number;
  13527. /**
  13528. * How much to randomize the particle direction [0-1].
  13529. */
  13530. directionRandomizer: number;
  13531. /**
  13532. * Creates a new instance CylinderParticleEmitter
  13533. * @param radius the radius of the emission cylinder (1 by default)
  13534. * @param height the height of the emission cylinder (1 by default)
  13535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13536. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13537. */
  13538. constructor(
  13539. /**
  13540. * The radius of the emission cylinder.
  13541. */
  13542. radius?: number,
  13543. /**
  13544. * The height of the emission cylinder.
  13545. */
  13546. height?: number,
  13547. /**
  13548. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13549. */
  13550. radiusRange?: number,
  13551. /**
  13552. * How much to randomize the particle direction [0-1].
  13553. */
  13554. directionRandomizer?: number);
  13555. /**
  13556. * Called by the particle System when the direction is computed for the created particle.
  13557. * @param worldMatrix is the world matrix of the particle system
  13558. * @param directionToUpdate is the direction vector to update with the result
  13559. * @param particle is the particle we are computed the direction for
  13560. * @param isLocal defines if the direction should be set in local space
  13561. */
  13562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13563. /**
  13564. * Called by the particle System when the position is computed for the created particle.
  13565. * @param worldMatrix is the world matrix of the particle system
  13566. * @param positionToUpdate is the position vector to update with the result
  13567. * @param particle is the particle we are computed the position for
  13568. * @param isLocal defines if the position should be set in local space
  13569. */
  13570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13571. /**
  13572. * Clones the current emitter and returns a copy of it
  13573. * @returns the new emitter
  13574. */
  13575. clone(): CylinderParticleEmitter;
  13576. /**
  13577. * Called by the GPUParticleSystem to setup the update shader
  13578. * @param effect defines the update shader
  13579. */
  13580. applyToShader(effect: Effect): void;
  13581. /**
  13582. * Returns a string to use to update the GPU particles update shader
  13583. * @returns a string containng the defines string
  13584. */
  13585. getEffectDefines(): string;
  13586. /**
  13587. * Returns the string "CylinderParticleEmitter"
  13588. * @returns a string containing the class name
  13589. */
  13590. getClassName(): string;
  13591. /**
  13592. * Serializes the particle system to a JSON object.
  13593. * @returns the JSON object
  13594. */
  13595. serialize(): any;
  13596. /**
  13597. * Parse properties from a JSON object
  13598. * @param serializationObject defines the JSON object
  13599. */
  13600. parse(serializationObject: any): void;
  13601. }
  13602. /**
  13603. * Particle emitter emitting particles from the inside of a cylinder.
  13604. * It emits the particles randomly between two vectors.
  13605. */
  13606. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13607. /**
  13608. * The min limit of the emission direction.
  13609. */
  13610. direction1: Vector3;
  13611. /**
  13612. * The max limit of the emission direction.
  13613. */
  13614. direction2: Vector3;
  13615. /**
  13616. * Creates a new instance CylinderDirectedParticleEmitter
  13617. * @param radius the radius of the emission cylinder (1 by default)
  13618. * @param height the height of the emission cylinder (1 by default)
  13619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13620. * @param direction1 the min limit of the emission direction (up vector by default)
  13621. * @param direction2 the max limit of the emission direction (up vector by default)
  13622. */
  13623. constructor(radius?: number, height?: number, radiusRange?: number,
  13624. /**
  13625. * The min limit of the emission direction.
  13626. */
  13627. direction1?: Vector3,
  13628. /**
  13629. * The max limit of the emission direction.
  13630. */
  13631. direction2?: Vector3);
  13632. /**
  13633. * Called by the particle System when the direction is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param directionToUpdate is the direction vector to update with the result
  13636. * @param particle is the particle we are computed the direction for
  13637. */
  13638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13639. /**
  13640. * Clones the current emitter and returns a copy of it
  13641. * @returns the new emitter
  13642. */
  13643. clone(): CylinderDirectedParticleEmitter;
  13644. /**
  13645. * Called by the GPUParticleSystem to setup the update shader
  13646. * @param effect defines the update shader
  13647. */
  13648. applyToShader(effect: Effect): void;
  13649. /**
  13650. * Returns a string to use to update the GPU particles update shader
  13651. * @returns a string containng the defines string
  13652. */
  13653. getEffectDefines(): string;
  13654. /**
  13655. * Returns the string "CylinderDirectedParticleEmitter"
  13656. * @returns a string containing the class name
  13657. */
  13658. getClassName(): string;
  13659. /**
  13660. * Serializes the particle system to a JSON object.
  13661. * @returns the JSON object
  13662. */
  13663. serialize(): any;
  13664. /**
  13665. * Parse properties from a JSON object
  13666. * @param serializationObject defines the JSON object
  13667. */
  13668. parse(serializationObject: any): void;
  13669. }
  13670. }
  13671. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13672. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13673. import { Effect } from "babylonjs/Materials/effect";
  13674. import { Particle } from "babylonjs/Particles/particle";
  13675. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a hemisphere.
  13678. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13679. */
  13680. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission hemisphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance HemisphericParticleEmitter
  13695. * @param radius the radius of the emission hemisphere (1 by default)
  13696. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission hemisphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): HemisphericParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "HemisphericParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. }
  13760. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13761. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13762. import { Effect } from "babylonjs/Materials/effect";
  13763. import { Particle } from "babylonjs/Particles/particle";
  13764. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13765. /**
  13766. * Particle emitter emitting particles from a point.
  13767. * It emits the particles randomly between 2 given directions.
  13768. */
  13769. export class PointParticleEmitter implements IParticleEmitterType {
  13770. /**
  13771. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13772. */
  13773. direction1: Vector3;
  13774. /**
  13775. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13776. */
  13777. direction2: Vector3;
  13778. /**
  13779. * Creates a new instance PointParticleEmitter
  13780. */
  13781. constructor();
  13782. /**
  13783. * Called by the particle System when the direction is computed for the created particle.
  13784. * @param worldMatrix is the world matrix of the particle system
  13785. * @param directionToUpdate is the direction vector to update with the result
  13786. * @param particle is the particle we are computed the direction for
  13787. * @param isLocal defines if the direction should be set in local space
  13788. */
  13789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13790. /**
  13791. * Called by the particle System when the position is computed for the created particle.
  13792. * @param worldMatrix is the world matrix of the particle system
  13793. * @param positionToUpdate is the position vector to update with the result
  13794. * @param particle is the particle we are computed the position for
  13795. * @param isLocal defines if the position should be set in local space
  13796. */
  13797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13798. /**
  13799. * Clones the current emitter and returns a copy of it
  13800. * @returns the new emitter
  13801. */
  13802. clone(): PointParticleEmitter;
  13803. /**
  13804. * Called by the GPUParticleSystem to setup the update shader
  13805. * @param effect defines the update shader
  13806. */
  13807. applyToShader(effect: Effect): void;
  13808. /**
  13809. * Returns a string to use to update the GPU particles update shader
  13810. * @returns a string containng the defines string
  13811. */
  13812. getEffectDefines(): string;
  13813. /**
  13814. * Returns the string "PointParticleEmitter"
  13815. * @returns a string containing the class name
  13816. */
  13817. getClassName(): string;
  13818. /**
  13819. * Serializes the particle system to a JSON object.
  13820. * @returns the JSON object
  13821. */
  13822. serialize(): any;
  13823. /**
  13824. * Parse properties from a JSON object
  13825. * @param serializationObject defines the JSON object
  13826. */
  13827. parse(serializationObject: any): void;
  13828. }
  13829. }
  13830. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13831. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13832. import { Effect } from "babylonjs/Materials/effect";
  13833. import { Particle } from "babylonjs/Particles/particle";
  13834. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13835. /**
  13836. * Particle emitter emitting particles from the inside of a sphere.
  13837. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13838. */
  13839. export class SphereParticleEmitter implements IParticleEmitterType {
  13840. /**
  13841. * The radius of the emission sphere.
  13842. */
  13843. radius: number;
  13844. /**
  13845. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13846. */
  13847. radiusRange: number;
  13848. /**
  13849. * How much to randomize the particle direction [0-1].
  13850. */
  13851. directionRandomizer: number;
  13852. /**
  13853. * Creates a new instance SphereParticleEmitter
  13854. * @param radius the radius of the emission sphere (1 by default)
  13855. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13856. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13857. */
  13858. constructor(
  13859. /**
  13860. * The radius of the emission sphere.
  13861. */
  13862. radius?: number,
  13863. /**
  13864. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13865. */
  13866. radiusRange?: number,
  13867. /**
  13868. * How much to randomize the particle direction [0-1].
  13869. */
  13870. directionRandomizer?: number);
  13871. /**
  13872. * Called by the particle System when the direction is computed for the created particle.
  13873. * @param worldMatrix is the world matrix of the particle system
  13874. * @param directionToUpdate is the direction vector to update with the result
  13875. * @param particle is the particle we are computed the direction for
  13876. * @param isLocal defines if the direction should be set in local space
  13877. */
  13878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13879. /**
  13880. * Called by the particle System when the position is computed for the created particle.
  13881. * @param worldMatrix is the world matrix of the particle system
  13882. * @param positionToUpdate is the position vector to update with the result
  13883. * @param particle is the particle we are computed the position for
  13884. * @param isLocal defines if the position should be set in local space
  13885. */
  13886. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13887. /**
  13888. * Clones the current emitter and returns a copy of it
  13889. * @returns the new emitter
  13890. */
  13891. clone(): SphereParticleEmitter;
  13892. /**
  13893. * Called by the GPUParticleSystem to setup the update shader
  13894. * @param effect defines the update shader
  13895. */
  13896. applyToShader(effect: Effect): void;
  13897. /**
  13898. * Returns a string to use to update the GPU particles update shader
  13899. * @returns a string containng the defines string
  13900. */
  13901. getEffectDefines(): string;
  13902. /**
  13903. * Returns the string "SphereParticleEmitter"
  13904. * @returns a string containing the class name
  13905. */
  13906. getClassName(): string;
  13907. /**
  13908. * Serializes the particle system to a JSON object.
  13909. * @returns the JSON object
  13910. */
  13911. serialize(): any;
  13912. /**
  13913. * Parse properties from a JSON object
  13914. * @param serializationObject defines the JSON object
  13915. */
  13916. parse(serializationObject: any): void;
  13917. }
  13918. /**
  13919. * Particle emitter emitting particles from the inside of a sphere.
  13920. * It emits the particles randomly between two vectors.
  13921. */
  13922. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13923. /**
  13924. * The min limit of the emission direction.
  13925. */
  13926. direction1: Vector3;
  13927. /**
  13928. * The max limit of the emission direction.
  13929. */
  13930. direction2: Vector3;
  13931. /**
  13932. * Creates a new instance SphereDirectedParticleEmitter
  13933. * @param radius the radius of the emission sphere (1 by default)
  13934. * @param direction1 the min limit of the emission direction (up vector by default)
  13935. * @param direction2 the max limit of the emission direction (up vector by default)
  13936. */
  13937. constructor(radius?: number,
  13938. /**
  13939. * The min limit of the emission direction.
  13940. */
  13941. direction1?: Vector3,
  13942. /**
  13943. * The max limit of the emission direction.
  13944. */
  13945. direction2?: Vector3);
  13946. /**
  13947. * Called by the particle System when the direction is computed for the created particle.
  13948. * @param worldMatrix is the world matrix of the particle system
  13949. * @param directionToUpdate is the direction vector to update with the result
  13950. * @param particle is the particle we are computed the direction for
  13951. */
  13952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13953. /**
  13954. * Clones the current emitter and returns a copy of it
  13955. * @returns the new emitter
  13956. */
  13957. clone(): SphereDirectedParticleEmitter;
  13958. /**
  13959. * Called by the GPUParticleSystem to setup the update shader
  13960. * @param effect defines the update shader
  13961. */
  13962. applyToShader(effect: Effect): void;
  13963. /**
  13964. * Returns a string to use to update the GPU particles update shader
  13965. * @returns a string containng the defines string
  13966. */
  13967. getEffectDefines(): string;
  13968. /**
  13969. * Returns the string "SphereDirectedParticleEmitter"
  13970. * @returns a string containing the class name
  13971. */
  13972. getClassName(): string;
  13973. /**
  13974. * Serializes the particle system to a JSON object.
  13975. * @returns the JSON object
  13976. */
  13977. serialize(): any;
  13978. /**
  13979. * Parse properties from a JSON object
  13980. * @param serializationObject defines the JSON object
  13981. */
  13982. parse(serializationObject: any): void;
  13983. }
  13984. }
  13985. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13987. import { Effect } from "babylonjs/Materials/effect";
  13988. import { Particle } from "babylonjs/Particles/particle";
  13989. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13990. import { Nullable } from "babylonjs/types";
  13991. /**
  13992. * Particle emitter emitting particles from a custom list of positions.
  13993. */
  13994. export class CustomParticleEmitter implements IParticleEmitterType {
  13995. /**
  13996. * Gets or sets the position generator that will create the inital position of each particle.
  13997. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13998. */
  13999. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14000. /**
  14001. * Gets or sets the destination generator that will create the final destination of each particle.
  14002. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14003. */
  14004. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14005. /**
  14006. * Creates a new instance CustomParticleEmitter
  14007. */
  14008. constructor();
  14009. /**
  14010. * Called by the particle System when the direction is computed for the created particle.
  14011. * @param worldMatrix is the world matrix of the particle system
  14012. * @param directionToUpdate is the direction vector to update with the result
  14013. * @param particle is the particle we are computed the direction for
  14014. * @param isLocal defines if the direction should be set in local space
  14015. */
  14016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14017. /**
  14018. * Called by the particle System when the position is computed for the created particle.
  14019. * @param worldMatrix is the world matrix of the particle system
  14020. * @param positionToUpdate is the position vector to update with the result
  14021. * @param particle is the particle we are computed the position for
  14022. * @param isLocal defines if the position should be set in local space
  14023. */
  14024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14025. /**
  14026. * Clones the current emitter and returns a copy of it
  14027. * @returns the new emitter
  14028. */
  14029. clone(): CustomParticleEmitter;
  14030. /**
  14031. * Called by the GPUParticleSystem to setup the update shader
  14032. * @param effect defines the update shader
  14033. */
  14034. applyToShader(effect: Effect): void;
  14035. /**
  14036. * Returns a string to use to update the GPU particles update shader
  14037. * @returns a string containng the defines string
  14038. */
  14039. getEffectDefines(): string;
  14040. /**
  14041. * Returns the string "PointParticleEmitter"
  14042. * @returns a string containing the class name
  14043. */
  14044. getClassName(): string;
  14045. /**
  14046. * Serializes the particle system to a JSON object.
  14047. * @returns the JSON object
  14048. */
  14049. serialize(): any;
  14050. /**
  14051. * Parse properties from a JSON object
  14052. * @param serializationObject defines the JSON object
  14053. */
  14054. parse(serializationObject: any): void;
  14055. }
  14056. }
  14057. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14058. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14059. import { Effect } from "babylonjs/Materials/effect";
  14060. import { Particle } from "babylonjs/Particles/particle";
  14061. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14062. import { Nullable } from "babylonjs/types";
  14063. import { Scene } from "babylonjs/scene";
  14064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14065. /**
  14066. * Particle emitter emitting particles from the inside of a box.
  14067. * It emits the particles randomly between 2 given directions.
  14068. */
  14069. export class MeshParticleEmitter implements IParticleEmitterType {
  14070. private _indices;
  14071. private _positions;
  14072. private _normals;
  14073. private _storedNormal;
  14074. private _mesh;
  14075. /**
  14076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14077. */
  14078. direction1: Vector3;
  14079. /**
  14080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14081. */
  14082. direction2: Vector3;
  14083. /**
  14084. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14085. */
  14086. useMeshNormalsForDirection: boolean;
  14087. /** Defines the mesh to use as source */
  14088. get mesh(): Nullable<AbstractMesh>;
  14089. set mesh(value: Nullable<AbstractMesh>);
  14090. /**
  14091. * Creates a new instance MeshParticleEmitter
  14092. * @param mesh defines the mesh to use as source
  14093. */
  14094. constructor(mesh?: Nullable<AbstractMesh>);
  14095. /**
  14096. * Called by the particle System when the direction is computed for the created particle.
  14097. * @param worldMatrix is the world matrix of the particle system
  14098. * @param directionToUpdate is the direction vector to update with the result
  14099. * @param particle is the particle we are computed the direction for
  14100. * @param isLocal defines if the direction should be set in local space
  14101. */
  14102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14103. /**
  14104. * Called by the particle System when the position is computed for the created particle.
  14105. * @param worldMatrix is the world matrix of the particle system
  14106. * @param positionToUpdate is the position vector to update with the result
  14107. * @param particle is the particle we are computed the position for
  14108. * @param isLocal defines if the position should be set in local space
  14109. */
  14110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14111. /**
  14112. * Clones the current emitter and returns a copy of it
  14113. * @returns the new emitter
  14114. */
  14115. clone(): MeshParticleEmitter;
  14116. /**
  14117. * Called by the GPUParticleSystem to setup the update shader
  14118. * @param effect defines the update shader
  14119. */
  14120. applyToShader(effect: Effect): void;
  14121. /**
  14122. * Returns a string to use to update the GPU particles update shader
  14123. * @returns a string containng the defines string
  14124. */
  14125. getEffectDefines(): string;
  14126. /**
  14127. * Returns the string "BoxParticleEmitter"
  14128. * @returns a string containing the class name
  14129. */
  14130. getClassName(): string;
  14131. /**
  14132. * Serializes the particle system to a JSON object.
  14133. * @returns the JSON object
  14134. */
  14135. serialize(): any;
  14136. /**
  14137. * Parse properties from a JSON object
  14138. * @param serializationObject defines the JSON object
  14139. * @param scene defines the hosting scene
  14140. */
  14141. parse(serializationObject: any, scene: Scene): void;
  14142. }
  14143. }
  14144. declare module "babylonjs/Particles/EmitterTypes/index" {
  14145. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14146. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14147. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14148. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14149. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14150. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14151. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14152. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14153. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14154. }
  14155. declare module "babylonjs/Particles/IParticleSystem" {
  14156. import { Nullable } from "babylonjs/types";
  14157. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14158. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14161. import { Texture } from "babylonjs/Materials/Textures/texture";
  14162. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14163. import { Scene } from "babylonjs/scene";
  14164. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14165. import { Effect } from "babylonjs/Materials/effect";
  14166. import { Observable } from "babylonjs/Misc/observable";
  14167. import { Animation } from "babylonjs/Animations/animation";
  14168. /**
  14169. * Interface representing a particle system in Babylon.js.
  14170. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14171. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14172. */
  14173. export interface IParticleSystem {
  14174. /**
  14175. * List of animations used by the particle system.
  14176. */
  14177. animations: Animation[];
  14178. /**
  14179. * The id of the Particle system.
  14180. */
  14181. id: string;
  14182. /**
  14183. * The name of the Particle system.
  14184. */
  14185. name: string;
  14186. /**
  14187. * The emitter represents the Mesh or position we are attaching the particle system to.
  14188. */
  14189. emitter: Nullable<AbstractMesh | Vector3>;
  14190. /**
  14191. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14192. */
  14193. isBillboardBased: boolean;
  14194. /**
  14195. * The rendering group used by the Particle system to chose when to render.
  14196. */
  14197. renderingGroupId: number;
  14198. /**
  14199. * The layer mask we are rendering the particles through.
  14200. */
  14201. layerMask: number;
  14202. /**
  14203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14204. */
  14205. updateSpeed: number;
  14206. /**
  14207. * The amount of time the particle system is running (depends of the overall update speed).
  14208. */
  14209. targetStopDuration: number;
  14210. /**
  14211. * The texture used to render each particle. (this can be a spritesheet)
  14212. */
  14213. particleTexture: Nullable<Texture>;
  14214. /**
  14215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14216. */
  14217. blendMode: number;
  14218. /**
  14219. * Minimum life time of emitting particles.
  14220. */
  14221. minLifeTime: number;
  14222. /**
  14223. * Maximum life time of emitting particles.
  14224. */
  14225. maxLifeTime: number;
  14226. /**
  14227. * Minimum Size of emitting particles.
  14228. */
  14229. minSize: number;
  14230. /**
  14231. * Maximum Size of emitting particles.
  14232. */
  14233. maxSize: number;
  14234. /**
  14235. * Minimum scale of emitting particles on X axis.
  14236. */
  14237. minScaleX: number;
  14238. /**
  14239. * Maximum scale of emitting particles on X axis.
  14240. */
  14241. maxScaleX: number;
  14242. /**
  14243. * Minimum scale of emitting particles on Y axis.
  14244. */
  14245. minScaleY: number;
  14246. /**
  14247. * Maximum scale of emitting particles on Y axis.
  14248. */
  14249. maxScaleY: number;
  14250. /**
  14251. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14252. */
  14253. color1: Color4;
  14254. /**
  14255. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14256. */
  14257. color2: Color4;
  14258. /**
  14259. * Color the particle will have at the end of its lifetime.
  14260. */
  14261. colorDead: Color4;
  14262. /**
  14263. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14264. */
  14265. emitRate: number;
  14266. /**
  14267. * You can use gravity if you want to give an orientation to your particles.
  14268. */
  14269. gravity: Vector3;
  14270. /**
  14271. * Minimum power of emitting particles.
  14272. */
  14273. minEmitPower: number;
  14274. /**
  14275. * Maximum power of emitting particles.
  14276. */
  14277. maxEmitPower: number;
  14278. /**
  14279. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14280. */
  14281. minAngularSpeed: number;
  14282. /**
  14283. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14284. */
  14285. maxAngularSpeed: number;
  14286. /**
  14287. * Gets or sets the minimal initial rotation in radians.
  14288. */
  14289. minInitialRotation: number;
  14290. /**
  14291. * Gets or sets the maximal initial rotation in radians.
  14292. */
  14293. maxInitialRotation: number;
  14294. /**
  14295. * The particle emitter type defines the emitter used by the particle system.
  14296. * It can be for example box, sphere, or cone...
  14297. */
  14298. particleEmitterType: Nullable<IParticleEmitterType>;
  14299. /**
  14300. * Defines the delay in milliseconds before starting the system (0 by default)
  14301. */
  14302. startDelay: number;
  14303. /**
  14304. * 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
  14305. */
  14306. preWarmCycles: number;
  14307. /**
  14308. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14309. */
  14310. preWarmStepOffset: number;
  14311. /**
  14312. * 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)
  14313. */
  14314. spriteCellChangeSpeed: number;
  14315. /**
  14316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14317. */
  14318. startSpriteCellID: number;
  14319. /**
  14320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14321. */
  14322. endSpriteCellID: number;
  14323. /**
  14324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14325. */
  14326. spriteCellWidth: number;
  14327. /**
  14328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14329. */
  14330. spriteCellHeight: number;
  14331. /**
  14332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14333. */
  14334. spriteRandomStartCell: boolean;
  14335. /**
  14336. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14337. */
  14338. isAnimationSheetEnabled: boolean;
  14339. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14340. translationPivot: Vector2;
  14341. /**
  14342. * Gets or sets a texture used to add random noise to particle positions
  14343. */
  14344. noiseTexture: Nullable<BaseTexture>;
  14345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14346. noiseStrength: Vector3;
  14347. /**
  14348. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14349. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14350. */
  14351. billboardMode: number;
  14352. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14353. limitVelocityDamping: number;
  14354. /**
  14355. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14356. */
  14357. beginAnimationOnStart: boolean;
  14358. /**
  14359. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14360. */
  14361. beginAnimationFrom: number;
  14362. /**
  14363. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14364. */
  14365. beginAnimationTo: number;
  14366. /**
  14367. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14368. */
  14369. beginAnimationLoop: boolean;
  14370. /**
  14371. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14372. */
  14373. disposeOnStop: boolean;
  14374. /**
  14375. * Specifies if the particles are updated in emitter local space or world space
  14376. */
  14377. isLocal: boolean;
  14378. /** Snippet ID if the particle system was created from the snippet server */
  14379. snippetId: string;
  14380. /**
  14381. * Gets the maximum number of particles active at the same time.
  14382. * @returns The max number of active particles.
  14383. */
  14384. getCapacity(): number;
  14385. /**
  14386. * Gets the number of particles active at the same time.
  14387. * @returns The number of active particles.
  14388. */
  14389. getActiveCount(): number;
  14390. /**
  14391. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14392. * @returns True if it has been started, otherwise false.
  14393. */
  14394. isStarted(): boolean;
  14395. /**
  14396. * Animates the particle system for this frame.
  14397. */
  14398. animate(): void;
  14399. /**
  14400. * Renders the particle system in its current state.
  14401. * @returns the current number of particles
  14402. */
  14403. render(): number;
  14404. /**
  14405. * Dispose the particle system and frees its associated resources.
  14406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14407. */
  14408. dispose(disposeTexture?: boolean): void;
  14409. /**
  14410. * An event triggered when the system is disposed
  14411. */
  14412. onDisposeObservable: Observable<IParticleSystem>;
  14413. /**
  14414. * Clones the particle system.
  14415. * @param name The name of the cloned object
  14416. * @param newEmitter The new emitter to use
  14417. * @returns the cloned particle system
  14418. */
  14419. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14420. /**
  14421. * Serializes the particle system to a JSON object
  14422. * @param serializeTexture defines if the texture must be serialized as well
  14423. * @returns the JSON object
  14424. */
  14425. serialize(serializeTexture: boolean): any;
  14426. /**
  14427. * Rebuild the particle system
  14428. */
  14429. rebuild(): void;
  14430. /** Force the system to rebuild all gradients that need to be resync */
  14431. forceRefreshGradients(): void;
  14432. /**
  14433. * Starts the particle system and begins to emit
  14434. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14435. */
  14436. start(delay?: number): void;
  14437. /**
  14438. * Stops the particle system.
  14439. */
  14440. stop(): void;
  14441. /**
  14442. * Remove all active particles
  14443. */
  14444. reset(): void;
  14445. /**
  14446. * Gets a boolean indicating that the system is stopping
  14447. * @returns true if the system is currently stopping
  14448. */
  14449. isStopping(): boolean;
  14450. /**
  14451. * Is this system ready to be used/rendered
  14452. * @return true if the system is ready
  14453. */
  14454. isReady(): boolean;
  14455. /**
  14456. * Returns the string "ParticleSystem"
  14457. * @returns a string containing the class name
  14458. */
  14459. getClassName(): string;
  14460. /**
  14461. * Gets the custom effect used to render the particles
  14462. * @param blendMode Blend mode for which the effect should be retrieved
  14463. * @returns The effect
  14464. */
  14465. getCustomEffect(blendMode: number): Nullable<Effect>;
  14466. /**
  14467. * Sets the custom effect used to render the particles
  14468. * @param effect The effect to set
  14469. * @param blendMode Blend mode for which the effect should be set
  14470. */
  14471. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14472. /**
  14473. * Fill the defines array according to the current settings of the particle system
  14474. * @param defines Array to be updated
  14475. * @param blendMode blend mode to take into account when updating the array
  14476. */
  14477. fillDefines(defines: Array<string>, blendMode: number): void;
  14478. /**
  14479. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14480. * @param uniforms Uniforms array to fill
  14481. * @param attributes Attributes array to fill
  14482. * @param samplers Samplers array to fill
  14483. */
  14484. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14485. /**
  14486. * Observable that will be called just before the particles are drawn
  14487. */
  14488. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14489. /**
  14490. * Gets the name of the particle vertex shader
  14491. */
  14492. vertexShaderName: string;
  14493. /**
  14494. * Adds a new color gradient
  14495. * @param gradient defines the gradient to use (between 0 and 1)
  14496. * @param color1 defines the color to affect to the specified gradient
  14497. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14498. * @returns the current particle system
  14499. */
  14500. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14501. /**
  14502. * Remove a specific color gradient
  14503. * @param gradient defines the gradient to remove
  14504. * @returns the current particle system
  14505. */
  14506. removeColorGradient(gradient: number): IParticleSystem;
  14507. /**
  14508. * Adds a new size gradient
  14509. * @param gradient defines the gradient to use (between 0 and 1)
  14510. * @param factor defines the size factor to affect to the specified gradient
  14511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14512. * @returns the current particle system
  14513. */
  14514. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14515. /**
  14516. * Remove a specific size gradient
  14517. * @param gradient defines the gradient to remove
  14518. * @returns the current particle system
  14519. */
  14520. removeSizeGradient(gradient: number): IParticleSystem;
  14521. /**
  14522. * Gets the current list of color gradients.
  14523. * You must use addColorGradient and removeColorGradient to udpate this list
  14524. * @returns the list of color gradients
  14525. */
  14526. getColorGradients(): Nullable<Array<ColorGradient>>;
  14527. /**
  14528. * Gets the current list of size gradients.
  14529. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14530. * @returns the list of size gradients
  14531. */
  14532. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14533. /**
  14534. * Gets the current list of angular speed gradients.
  14535. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14536. * @returns the list of angular speed gradients
  14537. */
  14538. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14539. /**
  14540. * Adds a new angular speed gradient
  14541. * @param gradient defines the gradient to use (between 0 and 1)
  14542. * @param factor defines the angular speed to affect to the specified gradient
  14543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14544. * @returns the current particle system
  14545. */
  14546. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14547. /**
  14548. * Remove a specific angular speed gradient
  14549. * @param gradient defines the gradient to remove
  14550. * @returns the current particle system
  14551. */
  14552. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14553. /**
  14554. * Gets the current list of velocity gradients.
  14555. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14556. * @returns the list of velocity gradients
  14557. */
  14558. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14559. /**
  14560. * Adds a new velocity gradient
  14561. * @param gradient defines the gradient to use (between 0 and 1)
  14562. * @param factor defines the velocity to affect to the specified gradient
  14563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14564. * @returns the current particle system
  14565. */
  14566. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14567. /**
  14568. * Remove a specific velocity gradient
  14569. * @param gradient defines the gradient to remove
  14570. * @returns the current particle system
  14571. */
  14572. removeVelocityGradient(gradient: number): IParticleSystem;
  14573. /**
  14574. * Gets the current list of limit velocity gradients.
  14575. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14576. * @returns the list of limit velocity gradients
  14577. */
  14578. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14579. /**
  14580. * Adds a new limit velocity gradient
  14581. * @param gradient defines the gradient to use (between 0 and 1)
  14582. * @param factor defines the limit velocity to affect to the specified gradient
  14583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14584. * @returns the current particle system
  14585. */
  14586. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14587. /**
  14588. * Remove a specific limit velocity gradient
  14589. * @param gradient defines the gradient to remove
  14590. * @returns the current particle system
  14591. */
  14592. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14593. /**
  14594. * Adds a new drag gradient
  14595. * @param gradient defines the gradient to use (between 0 and 1)
  14596. * @param factor defines the drag to affect to the specified gradient
  14597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14598. * @returns the current particle system
  14599. */
  14600. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14601. /**
  14602. * Remove a specific drag gradient
  14603. * @param gradient defines the gradient to remove
  14604. * @returns the current particle system
  14605. */
  14606. removeDragGradient(gradient: number): IParticleSystem;
  14607. /**
  14608. * Gets the current list of drag gradients.
  14609. * You must use addDragGradient and removeDragGradient to udpate this list
  14610. * @returns the list of drag gradients
  14611. */
  14612. getDragGradients(): Nullable<Array<FactorGradient>>;
  14613. /**
  14614. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14615. * @param gradient defines the gradient to use (between 0 and 1)
  14616. * @param factor defines the emit rate to affect to the specified gradient
  14617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14618. * @returns the current particle system
  14619. */
  14620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14621. /**
  14622. * Remove a specific emit rate gradient
  14623. * @param gradient defines the gradient to remove
  14624. * @returns the current particle system
  14625. */
  14626. removeEmitRateGradient(gradient: number): IParticleSystem;
  14627. /**
  14628. * Gets the current list of emit rate gradients.
  14629. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14630. * @returns the list of emit rate gradients
  14631. */
  14632. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14633. /**
  14634. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14635. * @param gradient defines the gradient to use (between 0 and 1)
  14636. * @param factor defines the start size to affect to the specified gradient
  14637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14638. * @returns the current particle system
  14639. */
  14640. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14641. /**
  14642. * Remove a specific start size gradient
  14643. * @param gradient defines the gradient to remove
  14644. * @returns the current particle system
  14645. */
  14646. removeStartSizeGradient(gradient: number): IParticleSystem;
  14647. /**
  14648. * Gets the current list of start size gradients.
  14649. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14650. * @returns the list of start size gradients
  14651. */
  14652. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14653. /**
  14654. * Adds a new life time gradient
  14655. * @param gradient defines the gradient to use (between 0 and 1)
  14656. * @param factor defines the life time factor to affect to the specified gradient
  14657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14658. * @returns the current particle system
  14659. */
  14660. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14661. /**
  14662. * Remove a specific life time gradient
  14663. * @param gradient defines the gradient to remove
  14664. * @returns the current particle system
  14665. */
  14666. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14667. /**
  14668. * Gets the current list of life time gradients.
  14669. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14670. * @returns the list of life time gradients
  14671. */
  14672. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14673. /**
  14674. * Gets the current list of color gradients.
  14675. * You must use addColorGradient and removeColorGradient to udpate this list
  14676. * @returns the list of color gradients
  14677. */
  14678. getColorGradients(): Nullable<Array<ColorGradient>>;
  14679. /**
  14680. * Adds a new ramp gradient used to remap particle colors
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color defines the color to affect to the specified gradient
  14683. * @returns the current particle system
  14684. */
  14685. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14686. /**
  14687. * Gets the current list of ramp gradients.
  14688. * You must use addRampGradient and removeRampGradient to udpate this list
  14689. * @returns the list of ramp gradients
  14690. */
  14691. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14692. /** Gets or sets a boolean indicating that ramp gradients must be used
  14693. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14694. */
  14695. useRampGradients: boolean;
  14696. /**
  14697. * Adds a new color remap gradient
  14698. * @param gradient defines the gradient to use (between 0 and 1)
  14699. * @param min defines the color remap minimal range
  14700. * @param max defines the color remap maximal range
  14701. * @returns the current particle system
  14702. */
  14703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14704. /**
  14705. * Gets the current list of color remap gradients.
  14706. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14707. * @returns the list of color remap gradients
  14708. */
  14709. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14710. /**
  14711. * Adds a new alpha remap gradient
  14712. * @param gradient defines the gradient to use (between 0 and 1)
  14713. * @param min defines the alpha remap minimal range
  14714. * @param max defines the alpha remap maximal range
  14715. * @returns the current particle system
  14716. */
  14717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14718. /**
  14719. * Gets the current list of alpha remap gradients.
  14720. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14721. * @returns the list of alpha remap gradients
  14722. */
  14723. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14724. /**
  14725. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14728. * @returns the emitter
  14729. */
  14730. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14731. /**
  14732. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14733. * @param radius The radius of the hemisphere to emit from
  14734. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14735. * @returns the emitter
  14736. */
  14737. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14738. /**
  14739. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14740. * @param radius The radius of the sphere to emit from
  14741. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14742. * @returns the emitter
  14743. */
  14744. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14745. /**
  14746. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14747. * @param radius The radius of the sphere to emit from
  14748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14750. * @returns the emitter
  14751. */
  14752. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14753. /**
  14754. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14755. * @param radius The radius of the emission cylinder
  14756. * @param height The height of the emission cylinder
  14757. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14758. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14759. * @returns the emitter
  14760. */
  14761. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14762. /**
  14763. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14764. * @param radius The radius of the cylinder to emit from
  14765. * @param height The height of the emission cylinder
  14766. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14769. * @returns the emitter
  14770. */
  14771. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14772. /**
  14773. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14774. * @param radius The radius of the cone to emit from
  14775. * @param angle The base angle of the cone
  14776. * @returns the emitter
  14777. */
  14778. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14779. /**
  14780. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14781. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14782. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14783. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14784. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14785. * @returns the emitter
  14786. */
  14787. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14788. /**
  14789. * Get hosting scene
  14790. * @returns the scene
  14791. */
  14792. getScene(): Scene;
  14793. }
  14794. }
  14795. declare module "babylonjs/Meshes/transformNode" {
  14796. import { DeepImmutable } from "babylonjs/types";
  14797. import { Observable } from "babylonjs/Misc/observable";
  14798. import { Nullable } from "babylonjs/types";
  14799. import { Camera } from "babylonjs/Cameras/camera";
  14800. import { Scene } from "babylonjs/scene";
  14801. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14802. import { Node } from "babylonjs/node";
  14803. import { Bone } from "babylonjs/Bones/bone";
  14804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14805. import { Space } from "babylonjs/Maths/math.axis";
  14806. /**
  14807. * 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.
  14808. * @see https://doc.babylonjs.com/how_to/transformnode
  14809. */
  14810. export class TransformNode extends Node {
  14811. /**
  14812. * Object will not rotate to face the camera
  14813. */
  14814. static BILLBOARDMODE_NONE: number;
  14815. /**
  14816. * Object will rotate to face the camera but only on the x axis
  14817. */
  14818. static BILLBOARDMODE_X: number;
  14819. /**
  14820. * Object will rotate to face the camera but only on the y axis
  14821. */
  14822. static BILLBOARDMODE_Y: number;
  14823. /**
  14824. * Object will rotate to face the camera but only on the z axis
  14825. */
  14826. static BILLBOARDMODE_Z: number;
  14827. /**
  14828. * Object will rotate to face the camera
  14829. */
  14830. static BILLBOARDMODE_ALL: number;
  14831. /**
  14832. * Object will rotate to face the camera's position instead of orientation
  14833. */
  14834. static BILLBOARDMODE_USE_POSITION: number;
  14835. private static _TmpRotation;
  14836. private static _TmpScaling;
  14837. private static _TmpTranslation;
  14838. private _forward;
  14839. private _forwardInverted;
  14840. private _up;
  14841. private _right;
  14842. private _rightInverted;
  14843. private _position;
  14844. private _rotation;
  14845. private _rotationQuaternion;
  14846. protected _scaling: Vector3;
  14847. protected _isDirty: boolean;
  14848. private _transformToBoneReferal;
  14849. private _isAbsoluteSynced;
  14850. private _billboardMode;
  14851. /**
  14852. * Gets or sets the billboard mode. Default is 0.
  14853. *
  14854. * | Value | Type | Description |
  14855. * | --- | --- | --- |
  14856. * | 0 | BILLBOARDMODE_NONE | |
  14857. * | 1 | BILLBOARDMODE_X | |
  14858. * | 2 | BILLBOARDMODE_Y | |
  14859. * | 4 | BILLBOARDMODE_Z | |
  14860. * | 7 | BILLBOARDMODE_ALL | |
  14861. *
  14862. */
  14863. get billboardMode(): number;
  14864. set billboardMode(value: number);
  14865. private _preserveParentRotationForBillboard;
  14866. /**
  14867. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14868. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14869. */
  14870. get preserveParentRotationForBillboard(): boolean;
  14871. set preserveParentRotationForBillboard(value: boolean);
  14872. /**
  14873. * 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
  14874. */
  14875. scalingDeterminant: number;
  14876. private _infiniteDistance;
  14877. /**
  14878. * Gets or sets the distance of the object to max, often used by skybox
  14879. */
  14880. get infiniteDistance(): boolean;
  14881. set infiniteDistance(value: boolean);
  14882. /**
  14883. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14884. * By default the system will update normals to compensate
  14885. */
  14886. ignoreNonUniformScaling: boolean;
  14887. /**
  14888. * 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
  14889. */
  14890. reIntegrateRotationIntoRotationQuaternion: boolean;
  14891. /** @hidden */
  14892. _poseMatrix: Nullable<Matrix>;
  14893. /** @hidden */
  14894. _localMatrix: Matrix;
  14895. private _usePivotMatrix;
  14896. private _absolutePosition;
  14897. private _absoluteScaling;
  14898. private _absoluteRotationQuaternion;
  14899. private _pivotMatrix;
  14900. private _pivotMatrixInverse;
  14901. protected _postMultiplyPivotMatrix: boolean;
  14902. protected _isWorldMatrixFrozen: boolean;
  14903. /** @hidden */
  14904. _indexInSceneTransformNodesArray: number;
  14905. /**
  14906. * An event triggered after the world matrix is updated
  14907. */
  14908. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14909. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14910. /**
  14911. * Gets a string identifying the name of the class
  14912. * @returns "TransformNode" string
  14913. */
  14914. getClassName(): string;
  14915. /**
  14916. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14917. */
  14918. get position(): Vector3;
  14919. set position(newPosition: Vector3);
  14920. /**
  14921. * 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)).
  14922. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14923. */
  14924. get rotation(): Vector3;
  14925. set rotation(newRotation: Vector3);
  14926. /**
  14927. * 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)).
  14928. */
  14929. get scaling(): Vector3;
  14930. set scaling(newScaling: Vector3);
  14931. /**
  14932. * 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).
  14933. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14934. */
  14935. get rotationQuaternion(): Nullable<Quaternion>;
  14936. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14937. /**
  14938. * The forward direction of that transform in world space.
  14939. */
  14940. get forward(): Vector3;
  14941. /**
  14942. * The up direction of that transform in world space.
  14943. */
  14944. get up(): Vector3;
  14945. /**
  14946. * The right direction of that transform in world space.
  14947. */
  14948. get right(): Vector3;
  14949. /**
  14950. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14951. * @param matrix the matrix to copy the pose from
  14952. * @returns this TransformNode.
  14953. */
  14954. updatePoseMatrix(matrix: Matrix): TransformNode;
  14955. /**
  14956. * Returns the mesh Pose matrix.
  14957. * @returns the pose matrix
  14958. */
  14959. getPoseMatrix(): Matrix;
  14960. /** @hidden */
  14961. _isSynchronized(): boolean;
  14962. /** @hidden */
  14963. _initCache(): void;
  14964. /**
  14965. * Flag the transform node as dirty (Forcing it to update everything)
  14966. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14967. * @returns this transform node
  14968. */
  14969. markAsDirty(property: string): TransformNode;
  14970. /**
  14971. * Returns the current mesh absolute position.
  14972. * Returns a Vector3.
  14973. */
  14974. get absolutePosition(): Vector3;
  14975. /**
  14976. * Returns the current mesh absolute scaling.
  14977. * Returns a Vector3.
  14978. */
  14979. get absoluteScaling(): Vector3;
  14980. /**
  14981. * Returns the current mesh absolute rotation.
  14982. * Returns a Quaternion.
  14983. */
  14984. get absoluteRotationQuaternion(): Quaternion;
  14985. /**
  14986. * Sets a new matrix to apply before all other transformation
  14987. * @param matrix defines the transform matrix
  14988. * @returns the current TransformNode
  14989. */
  14990. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14991. /**
  14992. * Sets a new pivot matrix to the current node
  14993. * @param matrix defines the new pivot matrix to use
  14994. * @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
  14995. * @returns the current TransformNode
  14996. */
  14997. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14998. /**
  14999. * Returns the mesh pivot matrix.
  15000. * Default : Identity.
  15001. * @returns the matrix
  15002. */
  15003. getPivotMatrix(): Matrix;
  15004. /**
  15005. * Instantiate (when possible) or clone that node with its hierarchy
  15006. * @param newParent defines the new parent to use for the instance (or clone)
  15007. * @param options defines options to configure how copy is done
  15008. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15009. * @returns an instance (or a clone) of the current node with its hiearchy
  15010. */
  15011. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15012. doNotInstantiate: boolean;
  15013. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15014. /**
  15015. * Prevents the World matrix to be computed any longer
  15016. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15017. * @returns the TransformNode.
  15018. */
  15019. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15020. /**
  15021. * Allows back the World matrix computation.
  15022. * @returns the TransformNode.
  15023. */
  15024. unfreezeWorldMatrix(): this;
  15025. /**
  15026. * True if the World matrix has been frozen.
  15027. */
  15028. get isWorldMatrixFrozen(): boolean;
  15029. /**
  15030. * Retuns the mesh absolute position in the World.
  15031. * @returns a Vector3.
  15032. */
  15033. getAbsolutePosition(): Vector3;
  15034. /**
  15035. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15036. * @param absolutePosition the absolute position to set
  15037. * @returns the TransformNode.
  15038. */
  15039. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15040. /**
  15041. * Sets the mesh position in its local space.
  15042. * @param vector3 the position to set in localspace
  15043. * @returns the TransformNode.
  15044. */
  15045. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15046. /**
  15047. * Returns the mesh position in the local space from the current World matrix values.
  15048. * @returns a new Vector3.
  15049. */
  15050. getPositionExpressedInLocalSpace(): Vector3;
  15051. /**
  15052. * Translates the mesh along the passed Vector3 in its local space.
  15053. * @param vector3 the distance to translate in localspace
  15054. * @returns the TransformNode.
  15055. */
  15056. locallyTranslate(vector3: Vector3): TransformNode;
  15057. private static _lookAtVectorCache;
  15058. /**
  15059. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15060. * @param targetPoint the position (must be in same space as current mesh) to look at
  15061. * @param yawCor optional yaw (y-axis) correction in radians
  15062. * @param pitchCor optional pitch (x-axis) correction in radians
  15063. * @param rollCor optional roll (z-axis) correction in radians
  15064. * @param space the choosen space of the target
  15065. * @returns the TransformNode.
  15066. */
  15067. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15068. /**
  15069. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15070. * This Vector3 is expressed in the World space.
  15071. * @param localAxis axis to rotate
  15072. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15073. */
  15074. getDirection(localAxis: Vector3): Vector3;
  15075. /**
  15076. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15077. * localAxis is expressed in the mesh local space.
  15078. * result is computed in the Wordl space from the mesh World matrix.
  15079. * @param localAxis axis to rotate
  15080. * @param result the resulting transformnode
  15081. * @returns this TransformNode.
  15082. */
  15083. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15084. /**
  15085. * Sets this transform node rotation to the given local axis.
  15086. * @param localAxis the axis in local space
  15087. * @param yawCor optional yaw (y-axis) correction in radians
  15088. * @param pitchCor optional pitch (x-axis) correction in radians
  15089. * @param rollCor optional roll (z-axis) correction in radians
  15090. * @returns this TransformNode
  15091. */
  15092. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15093. /**
  15094. * Sets a new pivot point to the current node
  15095. * @param point defines the new pivot point to use
  15096. * @param space defines if the point is in world or local space (local by default)
  15097. * @returns the current TransformNode
  15098. */
  15099. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15100. /**
  15101. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15102. * @returns the pivot point
  15103. */
  15104. getPivotPoint(): Vector3;
  15105. /**
  15106. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15107. * @param result the vector3 to store the result
  15108. * @returns this TransformNode.
  15109. */
  15110. getPivotPointToRef(result: Vector3): TransformNode;
  15111. /**
  15112. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15113. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15114. */
  15115. getAbsolutePivotPoint(): Vector3;
  15116. /**
  15117. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15118. * @param result vector3 to store the result
  15119. * @returns this TransformNode.
  15120. */
  15121. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15122. /**
  15123. * Defines the passed node as the parent of the current node.
  15124. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15125. * @see https://doc.babylonjs.com/how_to/parenting
  15126. * @param node the node ot set as the parent
  15127. * @returns this TransformNode.
  15128. */
  15129. setParent(node: Nullable<Node>): TransformNode;
  15130. private _nonUniformScaling;
  15131. /**
  15132. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15133. */
  15134. get nonUniformScaling(): boolean;
  15135. /** @hidden */
  15136. _updateNonUniformScalingState(value: boolean): boolean;
  15137. /**
  15138. * Attach the current TransformNode to another TransformNode associated with a bone
  15139. * @param bone Bone affecting the TransformNode
  15140. * @param affectedTransformNode TransformNode associated with the bone
  15141. * @returns this object
  15142. */
  15143. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15144. /**
  15145. * Detach the transform node if its associated with a bone
  15146. * @returns this object
  15147. */
  15148. detachFromBone(): TransformNode;
  15149. private static _rotationAxisCache;
  15150. /**
  15151. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15152. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15153. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15154. * The passed axis is also normalized.
  15155. * @param axis the axis to rotate around
  15156. * @param amount the amount to rotate in radians
  15157. * @param space Space to rotate in (Default: local)
  15158. * @returns the TransformNode.
  15159. */
  15160. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15161. /**
  15162. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15163. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15164. * The passed axis is also normalized. .
  15165. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15166. * @param point the point to rotate around
  15167. * @param axis the axis to rotate around
  15168. * @param amount the amount to rotate in radians
  15169. * @returns the TransformNode
  15170. */
  15171. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15172. /**
  15173. * Translates the mesh along the axis vector for the passed distance in the given space.
  15174. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15175. * @param axis the axis to translate in
  15176. * @param distance the distance to translate
  15177. * @param space Space to rotate in (Default: local)
  15178. * @returns the TransformNode.
  15179. */
  15180. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15181. /**
  15182. * Adds a rotation step to the mesh current rotation.
  15183. * x, y, z are Euler angles expressed in radians.
  15184. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15185. * This means this rotation is made in the mesh local space only.
  15186. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15187. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15188. * ```javascript
  15189. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15190. * ```
  15191. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15192. * 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.
  15193. * @param x Rotation to add
  15194. * @param y Rotation to add
  15195. * @param z Rotation to add
  15196. * @returns the TransformNode.
  15197. */
  15198. addRotation(x: number, y: number, z: number): TransformNode;
  15199. /**
  15200. * @hidden
  15201. */
  15202. protected _getEffectiveParent(): Nullable<Node>;
  15203. /**
  15204. * Computes the world matrix of the node
  15205. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15206. * @returns the world matrix
  15207. */
  15208. computeWorldMatrix(force?: boolean): Matrix;
  15209. /**
  15210. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15211. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15212. */
  15213. resetLocalMatrix(independentOfChildren?: boolean): void;
  15214. protected _afterComputeWorldMatrix(): void;
  15215. /**
  15216. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15217. * @param func callback function to add
  15218. *
  15219. * @returns the TransformNode.
  15220. */
  15221. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15222. /**
  15223. * Removes a registered callback function.
  15224. * @param func callback function to remove
  15225. * @returns the TransformNode.
  15226. */
  15227. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15228. /**
  15229. * Gets the position of the current mesh in camera space
  15230. * @param camera defines the camera to use
  15231. * @returns a position
  15232. */
  15233. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15234. /**
  15235. * Returns the distance from the mesh to the active camera
  15236. * @param camera defines the camera to use
  15237. * @returns the distance
  15238. */
  15239. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15240. /**
  15241. * Clone the current transform node
  15242. * @param name Name of the new clone
  15243. * @param newParent New parent for the clone
  15244. * @param doNotCloneChildren Do not clone children hierarchy
  15245. * @returns the new transform node
  15246. */
  15247. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15248. /**
  15249. * Serializes the objects information.
  15250. * @param currentSerializationObject defines the object to serialize in
  15251. * @returns the serialized object
  15252. */
  15253. serialize(currentSerializationObject?: any): any;
  15254. /**
  15255. * Returns a new TransformNode object parsed from the source provided.
  15256. * @param parsedTransformNode is the source.
  15257. * @param scene the scne the object belongs to
  15258. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15259. * @returns a new TransformNode object parsed from the source provided.
  15260. */
  15261. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15262. /**
  15263. * Get all child-transformNodes of this node
  15264. * @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
  15265. * @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
  15266. * @returns an array of TransformNode
  15267. */
  15268. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15269. /**
  15270. * Releases resources associated with this transform node.
  15271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15273. */
  15274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15275. /**
  15276. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15277. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15278. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15279. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15280. * @returns the current mesh
  15281. */
  15282. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15283. private _syncAbsoluteScalingAndRotation;
  15284. }
  15285. }
  15286. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15287. /**
  15288. * Class used to override all child animations of a given target
  15289. */
  15290. export class AnimationPropertiesOverride {
  15291. /**
  15292. * Gets or sets a value indicating if animation blending must be used
  15293. */
  15294. enableBlending: boolean;
  15295. /**
  15296. * Gets or sets the blending speed to use when enableBlending is true
  15297. */
  15298. blendingSpeed: number;
  15299. /**
  15300. * Gets or sets the default loop mode to use
  15301. */
  15302. loopMode: number;
  15303. }
  15304. }
  15305. declare module "babylonjs/Bones/bone" {
  15306. import { Skeleton } from "babylonjs/Bones/skeleton";
  15307. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15308. import { Nullable } from "babylonjs/types";
  15309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15311. import { Node } from "babylonjs/node";
  15312. import { Space } from "babylonjs/Maths/math.axis";
  15313. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15314. /**
  15315. * Class used to store bone information
  15316. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15317. */
  15318. export class Bone extends Node {
  15319. /**
  15320. * defines the bone name
  15321. */
  15322. name: string;
  15323. private static _tmpVecs;
  15324. private static _tmpQuat;
  15325. private static _tmpMats;
  15326. /**
  15327. * Gets the list of child bones
  15328. */
  15329. children: Bone[];
  15330. /** Gets the animations associated with this bone */
  15331. animations: import("babylonjs/Animations/animation").Animation[];
  15332. /**
  15333. * Gets or sets bone length
  15334. */
  15335. length: number;
  15336. /**
  15337. * @hidden Internal only
  15338. * Set this value to map this bone to a different index in the transform matrices
  15339. * Set this value to -1 to exclude the bone from the transform matrices
  15340. */
  15341. _index: Nullable<number>;
  15342. private _skeleton;
  15343. private _localMatrix;
  15344. private _restPose;
  15345. private _baseMatrix;
  15346. private _absoluteTransform;
  15347. private _invertedAbsoluteTransform;
  15348. private _parent;
  15349. private _scalingDeterminant;
  15350. private _worldTransform;
  15351. private _localScaling;
  15352. private _localRotation;
  15353. private _localPosition;
  15354. private _needToDecompose;
  15355. private _needToCompose;
  15356. /** @hidden */
  15357. _linkedTransformNode: Nullable<TransformNode>;
  15358. /** @hidden */
  15359. _waitingTransformNodeId: Nullable<string>;
  15360. /** @hidden */
  15361. get _matrix(): Matrix;
  15362. /** @hidden */
  15363. set _matrix(value: Matrix);
  15364. /**
  15365. * Create a new bone
  15366. * @param name defines the bone name
  15367. * @param skeleton defines the parent skeleton
  15368. * @param parentBone defines the parent (can be null if the bone is the root)
  15369. * @param localMatrix defines the local matrix
  15370. * @param restPose defines the rest pose matrix
  15371. * @param baseMatrix defines the base matrix
  15372. * @param index defines index of the bone in the hiearchy
  15373. */
  15374. constructor(
  15375. /**
  15376. * defines the bone name
  15377. */
  15378. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15379. /**
  15380. * Gets the current object class name.
  15381. * @return the class name
  15382. */
  15383. getClassName(): string;
  15384. /**
  15385. * Gets the parent skeleton
  15386. * @returns a skeleton
  15387. */
  15388. getSkeleton(): Skeleton;
  15389. /**
  15390. * Gets parent bone
  15391. * @returns a bone or null if the bone is the root of the bone hierarchy
  15392. */
  15393. getParent(): Nullable<Bone>;
  15394. /**
  15395. * Returns an array containing the root bones
  15396. * @returns an array containing the root bones
  15397. */
  15398. getChildren(): Array<Bone>;
  15399. /**
  15400. * Gets the node index in matrix array generated for rendering
  15401. * @returns the node index
  15402. */
  15403. getIndex(): number;
  15404. /**
  15405. * Sets the parent bone
  15406. * @param parent defines the parent (can be null if the bone is the root)
  15407. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15408. */
  15409. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15410. /**
  15411. * Gets the local matrix
  15412. * @returns a matrix
  15413. */
  15414. getLocalMatrix(): Matrix;
  15415. /**
  15416. * Gets the base matrix (initial matrix which remains unchanged)
  15417. * @returns a matrix
  15418. */
  15419. getBaseMatrix(): Matrix;
  15420. /**
  15421. * Gets the rest pose matrix
  15422. * @returns a matrix
  15423. */
  15424. getRestPose(): Matrix;
  15425. /**
  15426. * Sets the rest pose matrix
  15427. * @param matrix the local-space rest pose to set for this bone
  15428. */
  15429. setRestPose(matrix: Matrix): void;
  15430. /**
  15431. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15432. */
  15433. getWorldMatrix(): Matrix;
  15434. /**
  15435. * Sets the local matrix to rest pose matrix
  15436. */
  15437. returnToRest(): void;
  15438. /**
  15439. * Gets the inverse of the absolute transform matrix.
  15440. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15441. * @returns a matrix
  15442. */
  15443. getInvertedAbsoluteTransform(): Matrix;
  15444. /**
  15445. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15446. * @returns a matrix
  15447. */
  15448. getAbsoluteTransform(): Matrix;
  15449. /**
  15450. * Links with the given transform node.
  15451. * The local matrix of this bone is copied from the transform node every frame.
  15452. * @param transformNode defines the transform node to link to
  15453. */
  15454. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15455. /**
  15456. * Gets the node used to drive the bone's transformation
  15457. * @returns a transform node or null
  15458. */
  15459. getTransformNode(): Nullable<TransformNode>;
  15460. /** Gets or sets current position (in local space) */
  15461. get position(): Vector3;
  15462. set position(newPosition: Vector3);
  15463. /** Gets or sets current rotation (in local space) */
  15464. get rotation(): Vector3;
  15465. set rotation(newRotation: Vector3);
  15466. /** Gets or sets current rotation quaternion (in local space) */
  15467. get rotationQuaternion(): Quaternion;
  15468. set rotationQuaternion(newRotation: Quaternion);
  15469. /** Gets or sets current scaling (in local space) */
  15470. get scaling(): Vector3;
  15471. set scaling(newScaling: Vector3);
  15472. /**
  15473. * Gets the animation properties override
  15474. */
  15475. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15476. private _decompose;
  15477. private _compose;
  15478. /**
  15479. * Update the base and local matrices
  15480. * @param matrix defines the new base or local matrix
  15481. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15482. * @param updateLocalMatrix defines if the local matrix should be updated
  15483. */
  15484. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15485. /** @hidden */
  15486. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15487. /**
  15488. * Flag the bone as dirty (Forcing it to update everything)
  15489. */
  15490. markAsDirty(): void;
  15491. /** @hidden */
  15492. _markAsDirtyAndCompose(): void;
  15493. private _markAsDirtyAndDecompose;
  15494. /**
  15495. * Translate the bone in local or world space
  15496. * @param vec The amount to translate the bone
  15497. * @param space The space that the translation is in
  15498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15499. */
  15500. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15501. /**
  15502. * Set the postion of the bone in local or world space
  15503. * @param position The position to set the bone
  15504. * @param space The space that the position is in
  15505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15506. */
  15507. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15508. /**
  15509. * Set the absolute position of the bone (world space)
  15510. * @param position The position to set the bone
  15511. * @param mesh The mesh that this bone is attached to
  15512. */
  15513. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15514. /**
  15515. * Scale the bone on the x, y and z axes (in local space)
  15516. * @param x The amount to scale the bone on the x axis
  15517. * @param y The amount to scale the bone on the y axis
  15518. * @param z The amount to scale the bone on the z axis
  15519. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15520. */
  15521. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15522. /**
  15523. * Set the bone scaling in local space
  15524. * @param scale defines the scaling vector
  15525. */
  15526. setScale(scale: Vector3): void;
  15527. /**
  15528. * Gets the current scaling in local space
  15529. * @returns the current scaling vector
  15530. */
  15531. getScale(): Vector3;
  15532. /**
  15533. * Gets the current scaling in local space and stores it in a target vector
  15534. * @param result defines the target vector
  15535. */
  15536. getScaleToRef(result: Vector3): void;
  15537. /**
  15538. * Set the yaw, pitch, and roll of the bone in local or world space
  15539. * @param yaw The rotation of the bone on the y axis
  15540. * @param pitch The rotation of the bone on the x axis
  15541. * @param roll The rotation of the bone on the z axis
  15542. * @param space The space that the axes of rotation are in
  15543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15544. */
  15545. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15546. /**
  15547. * Add a rotation to the bone on an axis in local or world space
  15548. * @param axis The axis to rotate the bone on
  15549. * @param amount The amount to rotate the bone
  15550. * @param space The space that the axis is in
  15551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15552. */
  15553. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15554. /**
  15555. * Set the rotation of the bone to a particular axis angle in local or world space
  15556. * @param axis The axis to rotate the bone on
  15557. * @param angle The angle that the bone should be rotated to
  15558. * @param space The space that the axis is in
  15559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15560. */
  15561. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15562. /**
  15563. * Set the euler rotation of the bone in local of world space
  15564. * @param rotation The euler rotation that the bone should be set to
  15565. * @param space The space that the rotation is in
  15566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15567. */
  15568. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15569. /**
  15570. * Set the quaternion rotation of the bone in local of world space
  15571. * @param quat The quaternion rotation that the bone should be set to
  15572. * @param space The space that the rotation is in
  15573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15574. */
  15575. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15576. /**
  15577. * Set the rotation matrix of the bone in local of world space
  15578. * @param rotMat The rotation matrix that the bone should be set to
  15579. * @param space The space that the rotation is in
  15580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15581. */
  15582. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15583. private _rotateWithMatrix;
  15584. private _getNegativeRotationToRef;
  15585. /**
  15586. * Get the position of the bone in local or world space
  15587. * @param space The space that the returned position is in
  15588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15589. * @returns The position of the bone
  15590. */
  15591. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15592. /**
  15593. * Copy the position of the bone to a vector3 in local or world space
  15594. * @param space The space that the returned position is in
  15595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15596. * @param result The vector3 to copy the position to
  15597. */
  15598. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15599. /**
  15600. * Get the absolute position of the bone (world space)
  15601. * @param mesh The mesh that this bone is attached to
  15602. * @returns The absolute position of the bone
  15603. */
  15604. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15605. /**
  15606. * Copy the absolute position of the bone (world space) to the result param
  15607. * @param mesh The mesh that this bone is attached to
  15608. * @param result The vector3 to copy the absolute position to
  15609. */
  15610. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15611. /**
  15612. * Compute the absolute transforms of this bone and its children
  15613. */
  15614. computeAbsoluteTransforms(): void;
  15615. /**
  15616. * Get the world direction from an axis that is in the local space of the bone
  15617. * @param localAxis The local direction that is used to compute the world direction
  15618. * @param mesh The mesh that this bone is attached to
  15619. * @returns The world direction
  15620. */
  15621. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15622. /**
  15623. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15624. * @param localAxis The local direction that is used to compute the world direction
  15625. * @param mesh The mesh that this bone is attached to
  15626. * @param result The vector3 that the world direction will be copied to
  15627. */
  15628. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15629. /**
  15630. * Get the euler rotation of the bone in local or world space
  15631. * @param space The space that the rotation should be in
  15632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15633. * @returns The euler rotation
  15634. */
  15635. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15636. /**
  15637. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15638. * @param space The space that the rotation should be in
  15639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15640. * @param result The vector3 that the rotation should be copied to
  15641. */
  15642. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15643. /**
  15644. * Get the quaternion rotation of the bone in either local or world space
  15645. * @param space The space that the rotation should be in
  15646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15647. * @returns The quaternion rotation
  15648. */
  15649. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15650. /**
  15651. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15652. * @param space The space that the rotation should be in
  15653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15654. * @param result The quaternion that the rotation should be copied to
  15655. */
  15656. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15657. /**
  15658. * Get the rotation matrix of the bone in local or world space
  15659. * @param space The space that the rotation should be in
  15660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15661. * @returns The rotation matrix
  15662. */
  15663. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15664. /**
  15665. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15666. * @param space The space that the rotation should be in
  15667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15668. * @param result The quaternion that the rotation should be copied to
  15669. */
  15670. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15671. /**
  15672. * Get the world position of a point that is in the local space of the bone
  15673. * @param position The local position
  15674. * @param mesh The mesh that this bone is attached to
  15675. * @returns The world position
  15676. */
  15677. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15678. /**
  15679. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15680. * @param position The local position
  15681. * @param mesh The mesh that this bone is attached to
  15682. * @param result The vector3 that the world position should be copied to
  15683. */
  15684. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15685. /**
  15686. * Get the local position of a point that is in world space
  15687. * @param position The world position
  15688. * @param mesh The mesh that this bone is attached to
  15689. * @returns The local position
  15690. */
  15691. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15692. /**
  15693. * Get the local position of a point that is in world space and copy it to the result param
  15694. * @param position The world position
  15695. * @param mesh The mesh that this bone is attached to
  15696. * @param result The vector3 that the local position should be copied to
  15697. */
  15698. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15699. }
  15700. }
  15701. declare module "babylonjs/Animations/runtimeAnimation" {
  15702. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15703. import { Animatable } from "babylonjs/Animations/animatable";
  15704. import { Scene } from "babylonjs/scene";
  15705. /**
  15706. * Defines a runtime animation
  15707. */
  15708. export class RuntimeAnimation {
  15709. private _events;
  15710. /**
  15711. * The current frame of the runtime animation
  15712. */
  15713. private _currentFrame;
  15714. /**
  15715. * The animation used by the runtime animation
  15716. */
  15717. private _animation;
  15718. /**
  15719. * The target of the runtime animation
  15720. */
  15721. private _target;
  15722. /**
  15723. * The initiating animatable
  15724. */
  15725. private _host;
  15726. /**
  15727. * The original value of the runtime animation
  15728. */
  15729. private _originalValue;
  15730. /**
  15731. * The original blend value of the runtime animation
  15732. */
  15733. private _originalBlendValue;
  15734. /**
  15735. * The offsets cache of the runtime animation
  15736. */
  15737. private _offsetsCache;
  15738. /**
  15739. * The high limits cache of the runtime animation
  15740. */
  15741. private _highLimitsCache;
  15742. /**
  15743. * Specifies if the runtime animation has been stopped
  15744. */
  15745. private _stopped;
  15746. /**
  15747. * The blending factor of the runtime animation
  15748. */
  15749. private _blendingFactor;
  15750. /**
  15751. * The BabylonJS scene
  15752. */
  15753. private _scene;
  15754. /**
  15755. * The current value of the runtime animation
  15756. */
  15757. private _currentValue;
  15758. /** @hidden */
  15759. _animationState: _IAnimationState;
  15760. /**
  15761. * The active target of the runtime animation
  15762. */
  15763. private _activeTargets;
  15764. private _currentActiveTarget;
  15765. private _directTarget;
  15766. /**
  15767. * The target path of the runtime animation
  15768. */
  15769. private _targetPath;
  15770. /**
  15771. * The weight of the runtime animation
  15772. */
  15773. private _weight;
  15774. /**
  15775. * The ratio offset of the runtime animation
  15776. */
  15777. private _ratioOffset;
  15778. /**
  15779. * The previous delay of the runtime animation
  15780. */
  15781. private _previousDelay;
  15782. /**
  15783. * The previous ratio of the runtime animation
  15784. */
  15785. private _previousRatio;
  15786. private _enableBlending;
  15787. private _keys;
  15788. private _minFrame;
  15789. private _maxFrame;
  15790. private _minValue;
  15791. private _maxValue;
  15792. private _targetIsArray;
  15793. /**
  15794. * Gets the current frame of the runtime animation
  15795. */
  15796. get currentFrame(): number;
  15797. /**
  15798. * Gets the weight of the runtime animation
  15799. */
  15800. get weight(): number;
  15801. /**
  15802. * Gets the current value of the runtime animation
  15803. */
  15804. get currentValue(): any;
  15805. /**
  15806. * Gets the target path of the runtime animation
  15807. */
  15808. get targetPath(): string;
  15809. /**
  15810. * Gets the actual target of the runtime animation
  15811. */
  15812. get target(): any;
  15813. /**
  15814. * Gets the additive state of the runtime animation
  15815. */
  15816. get isAdditive(): boolean;
  15817. /** @hidden */
  15818. _onLoop: () => void;
  15819. /**
  15820. * Create a new RuntimeAnimation object
  15821. * @param target defines the target of the animation
  15822. * @param animation defines the source animation object
  15823. * @param scene defines the hosting scene
  15824. * @param host defines the initiating Animatable
  15825. */
  15826. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15827. private _preparePath;
  15828. /**
  15829. * Gets the animation from the runtime animation
  15830. */
  15831. get animation(): Animation;
  15832. /**
  15833. * Resets the runtime animation to the beginning
  15834. * @param restoreOriginal defines whether to restore the target property to the original value
  15835. */
  15836. reset(restoreOriginal?: boolean): void;
  15837. /**
  15838. * Specifies if the runtime animation is stopped
  15839. * @returns Boolean specifying if the runtime animation is stopped
  15840. */
  15841. isStopped(): boolean;
  15842. /**
  15843. * Disposes of the runtime animation
  15844. */
  15845. dispose(): void;
  15846. /**
  15847. * Apply the interpolated value to the target
  15848. * @param currentValue defines the value computed by the animation
  15849. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15850. */
  15851. setValue(currentValue: any, weight: number): void;
  15852. private _getOriginalValues;
  15853. private _setValue;
  15854. /**
  15855. * Gets the loop pmode of the runtime animation
  15856. * @returns Loop Mode
  15857. */
  15858. private _getCorrectLoopMode;
  15859. /**
  15860. * Move the current animation to a given frame
  15861. * @param frame defines the frame to move to
  15862. */
  15863. goToFrame(frame: number): void;
  15864. /**
  15865. * @hidden Internal use only
  15866. */
  15867. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15868. /**
  15869. * Execute the current animation
  15870. * @param delay defines the delay to add to the current frame
  15871. * @param from defines the lower bound of the animation range
  15872. * @param to defines the upper bound of the animation range
  15873. * @param loop defines if the current animation must loop
  15874. * @param speedRatio defines the current speed ratio
  15875. * @param weight defines the weight of the animation (default is -1 so no weight)
  15876. * @param onLoop optional callback called when animation loops
  15877. * @returns a boolean indicating if the animation is running
  15878. */
  15879. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15880. }
  15881. }
  15882. declare module "babylonjs/Animations/animatable" {
  15883. import { Animation } from "babylonjs/Animations/animation";
  15884. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15885. import { Nullable } from "babylonjs/types";
  15886. import { Observable } from "babylonjs/Misc/observable";
  15887. import { Scene } from "babylonjs/scene";
  15888. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15889. import { Node } from "babylonjs/node";
  15890. /**
  15891. * Class used to store an actual running animation
  15892. */
  15893. export class Animatable {
  15894. /** defines the target object */
  15895. target: any;
  15896. /** defines the starting frame number (default is 0) */
  15897. fromFrame: number;
  15898. /** defines the ending frame number (default is 100) */
  15899. toFrame: number;
  15900. /** defines if the animation must loop (default is false) */
  15901. loopAnimation: boolean;
  15902. /** defines a callback to call when animation ends if it is not looping */
  15903. onAnimationEnd?: (() => void) | null | undefined;
  15904. /** defines a callback to call when animation loops */
  15905. onAnimationLoop?: (() => void) | null | undefined;
  15906. /** defines whether the animation should be evaluated additively */
  15907. isAdditive: boolean;
  15908. private _localDelayOffset;
  15909. private _pausedDelay;
  15910. private _runtimeAnimations;
  15911. private _paused;
  15912. private _scene;
  15913. private _speedRatio;
  15914. private _weight;
  15915. private _syncRoot;
  15916. /**
  15917. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15918. * This will only apply for non looping animation (default is true)
  15919. */
  15920. disposeOnEnd: boolean;
  15921. /**
  15922. * Gets a boolean indicating if the animation has started
  15923. */
  15924. animationStarted: boolean;
  15925. /**
  15926. * Observer raised when the animation ends
  15927. */
  15928. onAnimationEndObservable: Observable<Animatable>;
  15929. /**
  15930. * Observer raised when the animation loops
  15931. */
  15932. onAnimationLoopObservable: Observable<Animatable>;
  15933. /**
  15934. * Gets the root Animatable used to synchronize and normalize animations
  15935. */
  15936. get syncRoot(): Nullable<Animatable>;
  15937. /**
  15938. * Gets the current frame of the first RuntimeAnimation
  15939. * Used to synchronize Animatables
  15940. */
  15941. get masterFrame(): number;
  15942. /**
  15943. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15944. */
  15945. get weight(): number;
  15946. set weight(value: number);
  15947. /**
  15948. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15949. */
  15950. get speedRatio(): number;
  15951. set speedRatio(value: number);
  15952. /**
  15953. * Creates a new Animatable
  15954. * @param scene defines the hosting scene
  15955. * @param target defines the target object
  15956. * @param fromFrame defines the starting frame number (default is 0)
  15957. * @param toFrame defines the ending frame number (default is 100)
  15958. * @param loopAnimation defines if the animation must loop (default is false)
  15959. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15960. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15961. * @param animations defines a group of animation to add to the new Animatable
  15962. * @param onAnimationLoop defines a callback to call when animation loops
  15963. * @param isAdditive defines whether the animation should be evaluated additively
  15964. */
  15965. constructor(scene: Scene,
  15966. /** defines the target object */
  15967. target: any,
  15968. /** defines the starting frame number (default is 0) */
  15969. fromFrame?: number,
  15970. /** defines the ending frame number (default is 100) */
  15971. toFrame?: number,
  15972. /** defines if the animation must loop (default is false) */
  15973. loopAnimation?: boolean, speedRatio?: number,
  15974. /** defines a callback to call when animation ends if it is not looping */
  15975. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15976. /** defines a callback to call when animation loops */
  15977. onAnimationLoop?: (() => void) | null | undefined,
  15978. /** defines whether the animation should be evaluated additively */
  15979. isAdditive?: boolean);
  15980. /**
  15981. * Synchronize and normalize current Animatable with a source Animatable
  15982. * This is useful when using animation weights and when animations are not of the same length
  15983. * @param root defines the root Animatable to synchronize with
  15984. * @returns the current Animatable
  15985. */
  15986. syncWith(root: Animatable): Animatable;
  15987. /**
  15988. * Gets the list of runtime animations
  15989. * @returns an array of RuntimeAnimation
  15990. */
  15991. getAnimations(): RuntimeAnimation[];
  15992. /**
  15993. * Adds more animations to the current animatable
  15994. * @param target defines the target of the animations
  15995. * @param animations defines the new animations to add
  15996. */
  15997. appendAnimations(target: any, animations: Animation[]): void;
  15998. /**
  15999. * Gets the source animation for a specific property
  16000. * @param property defines the propertyu to look for
  16001. * @returns null or the source animation for the given property
  16002. */
  16003. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16004. /**
  16005. * Gets the runtime animation for a specific property
  16006. * @param property defines the propertyu to look for
  16007. * @returns null or the runtime animation for the given property
  16008. */
  16009. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16010. /**
  16011. * Resets the animatable to its original state
  16012. */
  16013. reset(): void;
  16014. /**
  16015. * Allows the animatable to blend with current running animations
  16016. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16017. * @param blendingSpeed defines the blending speed to use
  16018. */
  16019. enableBlending(blendingSpeed: number): void;
  16020. /**
  16021. * Disable animation blending
  16022. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16023. */
  16024. disableBlending(): void;
  16025. /**
  16026. * Jump directly to a given frame
  16027. * @param frame defines the frame to jump to
  16028. */
  16029. goToFrame(frame: number): void;
  16030. /**
  16031. * Pause the animation
  16032. */
  16033. pause(): void;
  16034. /**
  16035. * Restart the animation
  16036. */
  16037. restart(): void;
  16038. private _raiseOnAnimationEnd;
  16039. /**
  16040. * Stop and delete the current animation
  16041. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16042. * @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)
  16043. */
  16044. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16045. /**
  16046. * Wait asynchronously for the animation to end
  16047. * @returns a promise which will be fullfilled when the animation ends
  16048. */
  16049. waitAsync(): Promise<Animatable>;
  16050. /** @hidden */
  16051. _animate(delay: number): boolean;
  16052. }
  16053. module "babylonjs/scene" {
  16054. interface Scene {
  16055. /** @hidden */
  16056. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16057. /** @hidden */
  16058. _processLateAnimationBindingsForMatrices(holder: {
  16059. totalWeight: number;
  16060. totalAdditiveWeight: number;
  16061. animations: RuntimeAnimation[];
  16062. additiveAnimations: RuntimeAnimation[];
  16063. originalValue: Matrix;
  16064. }): any;
  16065. /** @hidden */
  16066. _processLateAnimationBindingsForQuaternions(holder: {
  16067. totalWeight: number;
  16068. totalAdditiveWeight: number;
  16069. animations: RuntimeAnimation[];
  16070. additiveAnimations: RuntimeAnimation[];
  16071. originalValue: Quaternion;
  16072. }, refQuaternion: Quaternion): Quaternion;
  16073. /** @hidden */
  16074. _processLateAnimationBindings(): void;
  16075. /**
  16076. * Will start the animation sequence of a given target
  16077. * @param target defines the target
  16078. * @param from defines from which frame should animation start
  16079. * @param to defines until which frame should animation run.
  16080. * @param weight defines the weight to apply to the animation (1.0 by default)
  16081. * @param loop defines if the animation loops
  16082. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16083. * @param onAnimationEnd defines the function to be executed when the animation ends
  16084. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16085. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16086. * @param onAnimationLoop defines the callback to call when an animation loops
  16087. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16088. * @returns the animatable object created for this animation
  16089. */
  16090. 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;
  16091. /**
  16092. * Will start the animation sequence of a given target
  16093. * @param target defines the target
  16094. * @param from defines from which frame should animation start
  16095. * @param to defines until which frame should animation run.
  16096. * @param loop defines if the animation loops
  16097. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16098. * @param onAnimationEnd defines the function to be executed when the animation ends
  16099. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16100. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16101. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16102. * @param onAnimationLoop defines the callback to call when an animation loops
  16103. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16104. * @returns the animatable object created for this animation
  16105. */
  16106. 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;
  16107. /**
  16108. * Will start the animation sequence of a given target and its hierarchy
  16109. * @param target defines the target
  16110. * @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.
  16111. * @param from defines from which frame should animation start
  16112. * @param to defines until which frame should animation run.
  16113. * @param loop defines if the animation loops
  16114. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16115. * @param onAnimationEnd defines the function to be executed when the animation ends
  16116. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16117. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16119. * @param onAnimationLoop defines the callback to call when an animation loops
  16120. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16121. * @returns the list of created animatables
  16122. */
  16123. 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[];
  16124. /**
  16125. * Begin a new animation on a given node
  16126. * @param target defines the target where the animation will take place
  16127. * @param animations defines the list of animations to start
  16128. * @param from defines the initial value
  16129. * @param to defines the final value
  16130. * @param loop defines if you want animation to loop (off by default)
  16131. * @param speedRatio defines the speed ratio to apply to all animations
  16132. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16133. * @param onAnimationLoop defines the callback to call when an animation loops
  16134. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16135. * @returns the list of created animatables
  16136. */
  16137. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16138. /**
  16139. * Begin a new animation on a given node and its hierarchy
  16140. * @param target defines the root node where the animation will take place
  16141. * @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.
  16142. * @param animations defines the list of animations to start
  16143. * @param from defines the initial value
  16144. * @param to defines the final value
  16145. * @param loop defines if you want animation to loop (off by default)
  16146. * @param speedRatio defines the speed ratio to apply to all animations
  16147. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16148. * @param onAnimationLoop defines the callback to call when an animation loops
  16149. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16150. * @returns the list of animatables created for all nodes
  16151. */
  16152. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16153. /**
  16154. * Gets the animatable associated with a specific target
  16155. * @param target defines the target of the animatable
  16156. * @returns the required animatable if found
  16157. */
  16158. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16159. /**
  16160. * Gets all animatables associated with a given target
  16161. * @param target defines the target to look animatables for
  16162. * @returns an array of Animatables
  16163. */
  16164. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16165. /**
  16166. * Stops and removes all animations that have been applied to the scene
  16167. */
  16168. stopAllAnimations(): void;
  16169. /**
  16170. * Gets the current delta time used by animation engine
  16171. */
  16172. deltaTime: number;
  16173. }
  16174. }
  16175. module "babylonjs/Bones/bone" {
  16176. interface Bone {
  16177. /**
  16178. * Copy an animation range from another bone
  16179. * @param source defines the source bone
  16180. * @param rangeName defines the range name to copy
  16181. * @param frameOffset defines the frame offset
  16182. * @param rescaleAsRequired defines if rescaling must be applied if required
  16183. * @param skelDimensionsRatio defines the scaling ratio
  16184. * @returns true if operation was successful
  16185. */
  16186. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16187. }
  16188. }
  16189. }
  16190. declare module "babylonjs/Bones/skeleton" {
  16191. import { Bone } from "babylonjs/Bones/bone";
  16192. import { Observable } from "babylonjs/Misc/observable";
  16193. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16194. import { Scene } from "babylonjs/scene";
  16195. import { Nullable } from "babylonjs/types";
  16196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16197. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16198. import { Animatable } from "babylonjs/Animations/animatable";
  16199. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16200. import { Animation } from "babylonjs/Animations/animation";
  16201. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16202. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16203. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16204. /**
  16205. * Class used to handle skinning animations
  16206. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16207. */
  16208. export class Skeleton implements IAnimatable {
  16209. /** defines the skeleton name */
  16210. name: string;
  16211. /** defines the skeleton Id */
  16212. id: string;
  16213. /**
  16214. * Defines the list of child bones
  16215. */
  16216. bones: Bone[];
  16217. /**
  16218. * Defines an estimate of the dimension of the skeleton at rest
  16219. */
  16220. dimensionsAtRest: Vector3;
  16221. /**
  16222. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16223. */
  16224. needInitialSkinMatrix: boolean;
  16225. /**
  16226. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16227. */
  16228. overrideMesh: Nullable<AbstractMesh>;
  16229. /**
  16230. * Gets the list of animations attached to this skeleton
  16231. */
  16232. animations: Array<Animation>;
  16233. private _scene;
  16234. private _isDirty;
  16235. private _transformMatrices;
  16236. private _transformMatrixTexture;
  16237. private _meshesWithPoseMatrix;
  16238. private _animatables;
  16239. private _identity;
  16240. private _synchronizedWithMesh;
  16241. private _ranges;
  16242. private _lastAbsoluteTransformsUpdateId;
  16243. private _canUseTextureForBones;
  16244. private _uniqueId;
  16245. /** @hidden */
  16246. _numBonesWithLinkedTransformNode: number;
  16247. /** @hidden */
  16248. _hasWaitingData: Nullable<boolean>;
  16249. /**
  16250. * Specifies if the skeleton should be serialized
  16251. */
  16252. doNotSerialize: boolean;
  16253. private _useTextureToStoreBoneMatrices;
  16254. /**
  16255. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16256. * Please note that this option is not available if the hardware does not support it
  16257. */
  16258. get useTextureToStoreBoneMatrices(): boolean;
  16259. set useTextureToStoreBoneMatrices(value: boolean);
  16260. private _animationPropertiesOverride;
  16261. /**
  16262. * Gets or sets the animation properties override
  16263. */
  16264. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16265. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16266. /**
  16267. * List of inspectable custom properties (used by the Inspector)
  16268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16269. */
  16270. inspectableCustomProperties: IInspectable[];
  16271. /**
  16272. * An observable triggered before computing the skeleton's matrices
  16273. */
  16274. onBeforeComputeObservable: Observable<Skeleton>;
  16275. /**
  16276. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16277. */
  16278. get isUsingTextureForMatrices(): boolean;
  16279. /**
  16280. * Gets the unique ID of this skeleton
  16281. */
  16282. get uniqueId(): number;
  16283. /**
  16284. * Creates a new skeleton
  16285. * @param name defines the skeleton name
  16286. * @param id defines the skeleton Id
  16287. * @param scene defines the hosting scene
  16288. */
  16289. constructor(
  16290. /** defines the skeleton name */
  16291. name: string,
  16292. /** defines the skeleton Id */
  16293. id: string, scene: Scene);
  16294. /**
  16295. * Gets the current object class name.
  16296. * @return the class name
  16297. */
  16298. getClassName(): string;
  16299. /**
  16300. * Returns an array containing the root bones
  16301. * @returns an array containing the root bones
  16302. */
  16303. getChildren(): Array<Bone>;
  16304. /**
  16305. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16306. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16307. * @returns a Float32Array containing matrices data
  16308. */
  16309. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16310. /**
  16311. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16312. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16313. * @returns a raw texture containing the data
  16314. */
  16315. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16316. /**
  16317. * Gets the current hosting scene
  16318. * @returns a scene object
  16319. */
  16320. getScene(): Scene;
  16321. /**
  16322. * Gets a string representing the current skeleton data
  16323. * @param fullDetails defines a boolean indicating if we want a verbose version
  16324. * @returns a string representing the current skeleton data
  16325. */
  16326. toString(fullDetails?: boolean): string;
  16327. /**
  16328. * Get bone's index searching by name
  16329. * @param name defines bone's name to search for
  16330. * @return the indice of the bone. Returns -1 if not found
  16331. */
  16332. getBoneIndexByName(name: string): number;
  16333. /**
  16334. * Creater a new animation range
  16335. * @param name defines the name of the range
  16336. * @param from defines the start key
  16337. * @param to defines the end key
  16338. */
  16339. createAnimationRange(name: string, from: number, to: number): void;
  16340. /**
  16341. * Delete a specific animation range
  16342. * @param name defines the name of the range
  16343. * @param deleteFrames defines if frames must be removed as well
  16344. */
  16345. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16346. /**
  16347. * Gets a specific animation range
  16348. * @param name defines the name of the range to look for
  16349. * @returns the requested animation range or null if not found
  16350. */
  16351. getAnimationRange(name: string): Nullable<AnimationRange>;
  16352. /**
  16353. * Gets the list of all animation ranges defined on this skeleton
  16354. * @returns an array
  16355. */
  16356. getAnimationRanges(): Nullable<AnimationRange>[];
  16357. /**
  16358. * Copy animation range from a source skeleton.
  16359. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16360. * @param source defines the source skeleton
  16361. * @param name defines the name of the range to copy
  16362. * @param rescaleAsRequired defines if rescaling must be applied if required
  16363. * @returns true if operation was successful
  16364. */
  16365. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16366. /**
  16367. * Forces the skeleton to go to rest pose
  16368. */
  16369. returnToRest(): void;
  16370. private _getHighestAnimationFrame;
  16371. /**
  16372. * Begin a specific animation range
  16373. * @param name defines the name of the range to start
  16374. * @param loop defines if looping must be turned on (false by default)
  16375. * @param speedRatio defines the speed ratio to apply (1 by default)
  16376. * @param onAnimationEnd defines a callback which will be called when animation will end
  16377. * @returns a new animatable
  16378. */
  16379. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16380. /**
  16381. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16382. * @param skeleton defines the Skeleton containing the animation range to convert
  16383. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16384. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16385. * @returns the original skeleton
  16386. */
  16387. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16388. /** @hidden */
  16389. _markAsDirty(): void;
  16390. /** @hidden */
  16391. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16392. /** @hidden */
  16393. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16394. private _computeTransformMatrices;
  16395. /**
  16396. * Build all resources required to render a skeleton
  16397. */
  16398. prepare(): void;
  16399. /**
  16400. * Gets the list of animatables currently running for this skeleton
  16401. * @returns an array of animatables
  16402. */
  16403. getAnimatables(): IAnimatable[];
  16404. /**
  16405. * Clone the current skeleton
  16406. * @param name defines the name of the new skeleton
  16407. * @param id defines the id of the new skeleton
  16408. * @returns the new skeleton
  16409. */
  16410. clone(name: string, id?: string): Skeleton;
  16411. /**
  16412. * Enable animation blending for this skeleton
  16413. * @param blendingSpeed defines the blending speed to apply
  16414. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16415. */
  16416. enableBlending(blendingSpeed?: number): void;
  16417. /**
  16418. * Releases all resources associated with the current skeleton
  16419. */
  16420. dispose(): void;
  16421. /**
  16422. * Serialize the skeleton in a JSON object
  16423. * @returns a JSON object
  16424. */
  16425. serialize(): any;
  16426. /**
  16427. * Creates a new skeleton from serialized data
  16428. * @param parsedSkeleton defines the serialized data
  16429. * @param scene defines the hosting scene
  16430. * @returns a new skeleton
  16431. */
  16432. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16433. /**
  16434. * Compute all node absolute transforms
  16435. * @param forceUpdate defines if computation must be done even if cache is up to date
  16436. */
  16437. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16438. /**
  16439. * Gets the root pose matrix
  16440. * @returns a matrix
  16441. */
  16442. getPoseMatrix(): Nullable<Matrix>;
  16443. /**
  16444. * Sorts bones per internal index
  16445. */
  16446. sortBones(): void;
  16447. private _sortBones;
  16448. }
  16449. }
  16450. declare module "babylonjs/Meshes/instancedMesh" {
  16451. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16452. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16453. import { Camera } from "babylonjs/Cameras/camera";
  16454. import { Node } from "babylonjs/node";
  16455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16456. import { Mesh } from "babylonjs/Meshes/mesh";
  16457. import { Material } from "babylonjs/Materials/material";
  16458. import { Skeleton } from "babylonjs/Bones/skeleton";
  16459. import { Light } from "babylonjs/Lights/light";
  16460. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16461. /**
  16462. * Creates an instance based on a source mesh.
  16463. */
  16464. export class InstancedMesh extends AbstractMesh {
  16465. private _sourceMesh;
  16466. private _currentLOD;
  16467. /** @hidden */
  16468. _indexInSourceMeshInstanceArray: number;
  16469. constructor(name: string, source: Mesh);
  16470. /**
  16471. * Returns the string "InstancedMesh".
  16472. */
  16473. getClassName(): string;
  16474. /** Gets the list of lights affecting that mesh */
  16475. get lightSources(): Light[];
  16476. _resyncLightSources(): void;
  16477. _resyncLightSource(light: Light): void;
  16478. _removeLightSource(light: Light, dispose: boolean): void;
  16479. /**
  16480. * If the source mesh receives shadows
  16481. */
  16482. get receiveShadows(): boolean;
  16483. /**
  16484. * The material of the source mesh
  16485. */
  16486. get material(): Nullable<Material>;
  16487. /**
  16488. * Visibility of the source mesh
  16489. */
  16490. get visibility(): number;
  16491. /**
  16492. * Skeleton of the source mesh
  16493. */
  16494. get skeleton(): Nullable<Skeleton>;
  16495. /**
  16496. * Rendering ground id of the source mesh
  16497. */
  16498. get renderingGroupId(): number;
  16499. set renderingGroupId(value: number);
  16500. /**
  16501. * Returns the total number of vertices (integer).
  16502. */
  16503. getTotalVertices(): number;
  16504. /**
  16505. * Returns a positive integer : the total number of indices in this mesh geometry.
  16506. * @returns the numner of indices or zero if the mesh has no geometry.
  16507. */
  16508. getTotalIndices(): number;
  16509. /**
  16510. * The source mesh of the instance
  16511. */
  16512. get sourceMesh(): Mesh;
  16513. /**
  16514. * Creates a new InstancedMesh object from the mesh model.
  16515. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16516. * @param name defines the name of the new instance
  16517. * @returns a new InstancedMesh
  16518. */
  16519. createInstance(name: string): InstancedMesh;
  16520. /**
  16521. * Is this node ready to be used/rendered
  16522. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16523. * @return {boolean} is it ready
  16524. */
  16525. isReady(completeCheck?: boolean): boolean;
  16526. /**
  16527. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16528. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16529. * @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.
  16530. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16531. */
  16532. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16533. /**
  16534. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16535. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16536. * The `data` are either a numeric array either a Float32Array.
  16537. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16538. * 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).
  16539. * Note that a new underlying VertexBuffer object is created each call.
  16540. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16541. *
  16542. * Possible `kind` values :
  16543. * - VertexBuffer.PositionKind
  16544. * - VertexBuffer.UVKind
  16545. * - VertexBuffer.UV2Kind
  16546. * - VertexBuffer.UV3Kind
  16547. * - VertexBuffer.UV4Kind
  16548. * - VertexBuffer.UV5Kind
  16549. * - VertexBuffer.UV6Kind
  16550. * - VertexBuffer.ColorKind
  16551. * - VertexBuffer.MatricesIndicesKind
  16552. * - VertexBuffer.MatricesIndicesExtraKind
  16553. * - VertexBuffer.MatricesWeightsKind
  16554. * - VertexBuffer.MatricesWeightsExtraKind
  16555. *
  16556. * Returns the Mesh.
  16557. */
  16558. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16559. /**
  16560. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16561. * If the mesh has no geometry, it is simply returned as it is.
  16562. * The `data` are either a numeric array either a Float32Array.
  16563. * No new underlying VertexBuffer object is created.
  16564. * 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.
  16565. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16566. *
  16567. * Possible `kind` values :
  16568. * - VertexBuffer.PositionKind
  16569. * - VertexBuffer.UVKind
  16570. * - VertexBuffer.UV2Kind
  16571. * - VertexBuffer.UV3Kind
  16572. * - VertexBuffer.UV4Kind
  16573. * - VertexBuffer.UV5Kind
  16574. * - VertexBuffer.UV6Kind
  16575. * - VertexBuffer.ColorKind
  16576. * - VertexBuffer.MatricesIndicesKind
  16577. * - VertexBuffer.MatricesIndicesExtraKind
  16578. * - VertexBuffer.MatricesWeightsKind
  16579. * - VertexBuffer.MatricesWeightsExtraKind
  16580. *
  16581. * Returns the Mesh.
  16582. */
  16583. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16584. /**
  16585. * Sets the mesh indices.
  16586. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16587. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16588. * This method creates a new index buffer each call.
  16589. * Returns the Mesh.
  16590. */
  16591. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16592. /**
  16593. * Boolean : True if the mesh owns the requested kind of data.
  16594. */
  16595. isVerticesDataPresent(kind: string): boolean;
  16596. /**
  16597. * Returns an array of indices (IndicesArray).
  16598. */
  16599. getIndices(): Nullable<IndicesArray>;
  16600. get _positions(): Nullable<Vector3[]>;
  16601. /**
  16602. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16603. * This means the mesh underlying bounding box and sphere are recomputed.
  16604. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16605. * @returns the current mesh
  16606. */
  16607. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16608. /** @hidden */
  16609. _preActivate(): InstancedMesh;
  16610. /** @hidden */
  16611. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16612. /** @hidden */
  16613. _postActivate(): void;
  16614. getWorldMatrix(): Matrix;
  16615. get isAnInstance(): boolean;
  16616. /**
  16617. * Returns the current associated LOD AbstractMesh.
  16618. */
  16619. getLOD(camera: Camera): AbstractMesh;
  16620. /** @hidden */
  16621. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16622. /** @hidden */
  16623. _syncSubMeshes(): InstancedMesh;
  16624. /** @hidden */
  16625. _generatePointsArray(): boolean;
  16626. /**
  16627. * Creates a new InstancedMesh from the current mesh.
  16628. * - name (string) : the cloned mesh name
  16629. * - newParent (optional Node) : the optional Node to parent the clone to.
  16630. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16631. *
  16632. * Returns the clone.
  16633. */
  16634. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16635. /**
  16636. * Disposes the InstancedMesh.
  16637. * Returns nothing.
  16638. */
  16639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16640. }
  16641. module "babylonjs/Meshes/mesh" {
  16642. interface Mesh {
  16643. /**
  16644. * Register a custom buffer that will be instanced
  16645. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16646. * @param kind defines the buffer kind
  16647. * @param stride defines the stride in floats
  16648. */
  16649. registerInstancedBuffer(kind: string, stride: number): void;
  16650. /**
  16651. * true to use the edge renderer for all instances of this mesh
  16652. */
  16653. edgesShareWithInstances: boolean;
  16654. /** @hidden */
  16655. _userInstancedBuffersStorage: {
  16656. data: {
  16657. [key: string]: Float32Array;
  16658. };
  16659. sizes: {
  16660. [key: string]: number;
  16661. };
  16662. vertexBuffers: {
  16663. [key: string]: Nullable<VertexBuffer>;
  16664. };
  16665. strides: {
  16666. [key: string]: number;
  16667. };
  16668. };
  16669. }
  16670. }
  16671. module "babylonjs/Meshes/abstractMesh" {
  16672. interface AbstractMesh {
  16673. /**
  16674. * Object used to store instanced buffers defined by user
  16675. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16676. */
  16677. instancedBuffers: {
  16678. [key: string]: any;
  16679. };
  16680. }
  16681. }
  16682. }
  16683. declare module "babylonjs/Materials/shaderMaterial" {
  16684. import { Nullable } from "babylonjs/types";
  16685. import { Scene } from "babylonjs/scene";
  16686. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16688. import { Mesh } from "babylonjs/Meshes/mesh";
  16689. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16691. import { Effect } from "babylonjs/Materials/effect";
  16692. import { Material } from "babylonjs/Materials/material";
  16693. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16694. /**
  16695. * Defines the options associated with the creation of a shader material.
  16696. */
  16697. export interface IShaderMaterialOptions {
  16698. /**
  16699. * Does the material work in alpha blend mode
  16700. */
  16701. needAlphaBlending: boolean;
  16702. /**
  16703. * Does the material work in alpha test mode
  16704. */
  16705. needAlphaTesting: boolean;
  16706. /**
  16707. * The list of attribute names used in the shader
  16708. */
  16709. attributes: string[];
  16710. /**
  16711. * The list of unifrom names used in the shader
  16712. */
  16713. uniforms: string[];
  16714. /**
  16715. * The list of UBO names used in the shader
  16716. */
  16717. uniformBuffers: string[];
  16718. /**
  16719. * The list of sampler names used in the shader
  16720. */
  16721. samplers: string[];
  16722. /**
  16723. * The list of defines used in the shader
  16724. */
  16725. defines: string[];
  16726. }
  16727. /**
  16728. * 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.
  16729. *
  16730. * This returned material effects how the mesh will look based on the code in the shaders.
  16731. *
  16732. * @see https://doc.babylonjs.com/how_to/shader_material
  16733. */
  16734. export class ShaderMaterial extends Material {
  16735. private _shaderPath;
  16736. private _options;
  16737. private _textures;
  16738. private _textureArrays;
  16739. private _floats;
  16740. private _ints;
  16741. private _floatsArrays;
  16742. private _colors3;
  16743. private _colors3Arrays;
  16744. private _colors4;
  16745. private _colors4Arrays;
  16746. private _vectors2;
  16747. private _vectors3;
  16748. private _vectors4;
  16749. private _matrices;
  16750. private _matrixArrays;
  16751. private _matrices3x3;
  16752. private _matrices2x2;
  16753. private _vectors2Arrays;
  16754. private _vectors3Arrays;
  16755. private _vectors4Arrays;
  16756. private _cachedWorldViewMatrix;
  16757. private _cachedWorldViewProjectionMatrix;
  16758. private _renderId;
  16759. private _multiview;
  16760. private _cachedDefines;
  16761. /** Define the Url to load snippets */
  16762. static SnippetUrl: string;
  16763. /** Snippet ID if the material was created from the snippet server */
  16764. snippetId: string;
  16765. /**
  16766. * Instantiate a new shader material.
  16767. * 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.
  16768. * This returned material effects how the mesh will look based on the code in the shaders.
  16769. * @see https://doc.babylonjs.com/how_to/shader_material
  16770. * @param name Define the name of the material in the scene
  16771. * @param scene Define the scene the material belongs to
  16772. * @param shaderPath Defines the route to the shader code in one of three ways:
  16773. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16774. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16775. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16776. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16777. * @param options Define the options used to create the shader
  16778. */
  16779. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16780. /**
  16781. * Gets the shader path used to define the shader code
  16782. * It can be modified to trigger a new compilation
  16783. */
  16784. get shaderPath(): any;
  16785. /**
  16786. * Sets the shader path used to define the shader code
  16787. * It can be modified to trigger a new compilation
  16788. */
  16789. set shaderPath(shaderPath: any);
  16790. /**
  16791. * Gets the options used to compile the shader.
  16792. * They can be modified to trigger a new compilation
  16793. */
  16794. get options(): IShaderMaterialOptions;
  16795. /**
  16796. * Gets the current class name of the material e.g. "ShaderMaterial"
  16797. * Mainly use in serialization.
  16798. * @returns the class name
  16799. */
  16800. getClassName(): string;
  16801. /**
  16802. * Specifies if the material will require alpha blending
  16803. * @returns a boolean specifying if alpha blending is needed
  16804. */
  16805. needAlphaBlending(): boolean;
  16806. /**
  16807. * Specifies if this material should be rendered in alpha test mode
  16808. * @returns a boolean specifying if an alpha test is needed.
  16809. */
  16810. needAlphaTesting(): boolean;
  16811. private _checkUniform;
  16812. /**
  16813. * Set a texture in the shader.
  16814. * @param name Define the name of the uniform samplers as defined in the shader
  16815. * @param texture Define the texture to bind to this sampler
  16816. * @return the material itself allowing "fluent" like uniform updates
  16817. */
  16818. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16819. /**
  16820. * Set a texture array in the shader.
  16821. * @param name Define the name of the uniform sampler array as defined in the shader
  16822. * @param textures Define the list of textures to bind to this sampler
  16823. * @return the material itself allowing "fluent" like uniform updates
  16824. */
  16825. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16826. /**
  16827. * Set a float in the shader.
  16828. * @param name Define the name of the uniform as defined in the shader
  16829. * @param value Define the value to give to the uniform
  16830. * @return the material itself allowing "fluent" like uniform updates
  16831. */
  16832. setFloat(name: string, value: number): ShaderMaterial;
  16833. /**
  16834. * Set a int in the shader.
  16835. * @param name Define the name of the uniform as defined in the shader
  16836. * @param value Define the value to give to the uniform
  16837. * @return the material itself allowing "fluent" like uniform updates
  16838. */
  16839. setInt(name: string, value: number): ShaderMaterial;
  16840. /**
  16841. * Set an array of floats in the shader.
  16842. * @param name Define the name of the uniform as defined in the shader
  16843. * @param value Define the value to give to the uniform
  16844. * @return the material itself allowing "fluent" like uniform updates
  16845. */
  16846. setFloats(name: string, value: number[]): ShaderMaterial;
  16847. /**
  16848. * Set a vec3 in the shader from a Color3.
  16849. * @param name Define the name of the uniform as defined in the shader
  16850. * @param value Define the value to give to the uniform
  16851. * @return the material itself allowing "fluent" like uniform updates
  16852. */
  16853. setColor3(name: string, value: Color3): ShaderMaterial;
  16854. /**
  16855. * Set a vec3 array in the shader from a Color3 array.
  16856. * @param name Define the name of the uniform as defined in the shader
  16857. * @param value Define the value to give to the uniform
  16858. * @return the material itself allowing "fluent" like uniform updates
  16859. */
  16860. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16861. /**
  16862. * Set a vec4 in the shader from a Color4.
  16863. * @param name Define the name of the uniform as defined in the shader
  16864. * @param value Define the value to give to the uniform
  16865. * @return the material itself allowing "fluent" like uniform updates
  16866. */
  16867. setColor4(name: string, value: Color4): ShaderMaterial;
  16868. /**
  16869. * Set a vec4 array in the shader from a Color4 array.
  16870. * @param name Define the name of the uniform as defined in the shader
  16871. * @param value Define the value to give to the uniform
  16872. * @return the material itself allowing "fluent" like uniform updates
  16873. */
  16874. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16875. /**
  16876. * Set a vec2 in the shader from a Vector2.
  16877. * @param name Define the name of the uniform as defined in the shader
  16878. * @param value Define the value to give to the uniform
  16879. * @return the material itself allowing "fluent" like uniform updates
  16880. */
  16881. setVector2(name: string, value: Vector2): ShaderMaterial;
  16882. /**
  16883. * Set a vec3 in the shader from a Vector3.
  16884. * @param name Define the name of the uniform as defined in the shader
  16885. * @param value Define the value to give to the uniform
  16886. * @return the material itself allowing "fluent" like uniform updates
  16887. */
  16888. setVector3(name: string, value: Vector3): ShaderMaterial;
  16889. /**
  16890. * Set a vec4 in the shader from a Vector4.
  16891. * @param name Define the name of the uniform as defined in the shader
  16892. * @param value Define the value to give to the uniform
  16893. * @return the material itself allowing "fluent" like uniform updates
  16894. */
  16895. setVector4(name: string, value: Vector4): ShaderMaterial;
  16896. /**
  16897. * Set a mat4 in the shader from a Matrix.
  16898. * @param name Define the name of the uniform as defined in the shader
  16899. * @param value Define the value to give to the uniform
  16900. * @return the material itself allowing "fluent" like uniform updates
  16901. */
  16902. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16903. /**
  16904. * Set a float32Array in the shader from a matrix array.
  16905. * @param name Define the name of the uniform as defined in the shader
  16906. * @param value Define the value to give to the uniform
  16907. * @return the material itself allowing "fluent" like uniform updates
  16908. */
  16909. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16910. /**
  16911. * Set a mat3 in the shader from a Float32Array.
  16912. * @param name Define the name of the uniform as defined in the shader
  16913. * @param value Define the value to give to the uniform
  16914. * @return the material itself allowing "fluent" like uniform updates
  16915. */
  16916. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16917. /**
  16918. * Set a mat2 in the shader from a Float32Array.
  16919. * @param name Define the name of the uniform as defined in the shader
  16920. * @param value Define the value to give to the uniform
  16921. * @return the material itself allowing "fluent" like uniform updates
  16922. */
  16923. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16924. /**
  16925. * Set a vec2 array in the shader from a number array.
  16926. * @param name Define the name of the uniform as defined in the shader
  16927. * @param value Define the value to give to the uniform
  16928. * @return the material itself allowing "fluent" like uniform updates
  16929. */
  16930. setArray2(name: string, value: number[]): ShaderMaterial;
  16931. /**
  16932. * Set a vec3 array in the shader from a number array.
  16933. * @param name Define the name of the uniform as defined in the shader
  16934. * @param value Define the value to give to the uniform
  16935. * @return the material itself allowing "fluent" like uniform updates
  16936. */
  16937. setArray3(name: string, value: number[]): ShaderMaterial;
  16938. /**
  16939. * Set a vec4 array in the shader from a number array.
  16940. * @param name Define the name of the uniform as defined in the shader
  16941. * @param value Define the value to give to the uniform
  16942. * @return the material itself allowing "fluent" like uniform updates
  16943. */
  16944. setArray4(name: string, value: number[]): ShaderMaterial;
  16945. private _checkCache;
  16946. /**
  16947. * Specifies that the submesh is ready to be used
  16948. * @param mesh defines the mesh to check
  16949. * @param subMesh defines which submesh to check
  16950. * @param useInstances specifies that instances should be used
  16951. * @returns a boolean indicating that the submesh is ready or not
  16952. */
  16953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16954. /**
  16955. * Checks if the material is ready to render the requested mesh
  16956. * @param mesh Define the mesh to render
  16957. * @param useInstances Define whether or not the material is used with instances
  16958. * @returns true if ready, otherwise false
  16959. */
  16960. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16961. /**
  16962. * Binds the world matrix to the material
  16963. * @param world defines the world transformation matrix
  16964. * @param effectOverride - If provided, use this effect instead of internal effect
  16965. */
  16966. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16967. /**
  16968. * Binds the submesh to this material by preparing the effect and shader to draw
  16969. * @param world defines the world transformation matrix
  16970. * @param mesh defines the mesh containing the submesh
  16971. * @param subMesh defines the submesh to bind the material to
  16972. */
  16973. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16974. /**
  16975. * Binds the material to the mesh
  16976. * @param world defines the world transformation matrix
  16977. * @param mesh defines the mesh to bind the material to
  16978. * @param effectOverride - If provided, use this effect instead of internal effect
  16979. */
  16980. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16981. protected _afterBind(mesh?: Mesh): void;
  16982. /**
  16983. * Gets the active textures from the material
  16984. * @returns an array of textures
  16985. */
  16986. getActiveTextures(): BaseTexture[];
  16987. /**
  16988. * Specifies if the material uses a texture
  16989. * @param texture defines the texture to check against the material
  16990. * @returns a boolean specifying if the material uses the texture
  16991. */
  16992. hasTexture(texture: BaseTexture): boolean;
  16993. /**
  16994. * Makes a duplicate of the material, and gives it a new name
  16995. * @param name defines the new name for the duplicated material
  16996. * @returns the cloned material
  16997. */
  16998. clone(name: string): ShaderMaterial;
  16999. /**
  17000. * Disposes the material
  17001. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17002. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17003. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17004. */
  17005. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17006. /**
  17007. * Serializes this material in a JSON representation
  17008. * @returns the serialized material object
  17009. */
  17010. serialize(): any;
  17011. /**
  17012. * Creates a shader material from parsed shader material data
  17013. * @param source defines the JSON represnetation of the material
  17014. * @param scene defines the hosting scene
  17015. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17016. * @returns a new material
  17017. */
  17018. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17019. /**
  17020. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17021. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17022. * @param url defines the url to load from
  17023. * @param scene defines the hosting scene
  17024. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17025. * @returns a promise that will resolve to the new ShaderMaterial
  17026. */
  17027. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17028. /**
  17029. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17030. * @param snippetId defines the snippet to load
  17031. * @param scene defines the hosting scene
  17032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17033. * @returns a promise that will resolve to the new ShaderMaterial
  17034. */
  17035. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17036. }
  17037. }
  17038. declare module "babylonjs/Shaders/color.fragment" {
  17039. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17041. /** @hidden */
  17042. export var colorPixelShader: {
  17043. name: string;
  17044. shader: string;
  17045. };
  17046. }
  17047. declare module "babylonjs/Shaders/color.vertex" {
  17048. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17049. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17050. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17051. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17052. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17053. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17054. /** @hidden */
  17055. export var colorVertexShader: {
  17056. name: string;
  17057. shader: string;
  17058. };
  17059. }
  17060. declare module "babylonjs/Meshes/linesMesh" {
  17061. import { Nullable } from "babylonjs/types";
  17062. import { Scene } from "babylonjs/scene";
  17063. import { Color3 } from "babylonjs/Maths/math.color";
  17064. import { Node } from "babylonjs/node";
  17065. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17066. import { Mesh } from "babylonjs/Meshes/mesh";
  17067. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17068. import { Effect } from "babylonjs/Materials/effect";
  17069. import { Material } from "babylonjs/Materials/material";
  17070. import "babylonjs/Shaders/color.fragment";
  17071. import "babylonjs/Shaders/color.vertex";
  17072. /**
  17073. * Line mesh
  17074. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17075. */
  17076. export class LinesMesh extends Mesh {
  17077. /**
  17078. * If vertex color should be applied to the mesh
  17079. */
  17080. readonly useVertexColor?: boolean | undefined;
  17081. /**
  17082. * If vertex alpha should be applied to the mesh
  17083. */
  17084. readonly useVertexAlpha?: boolean | undefined;
  17085. /**
  17086. * Color of the line (Default: White)
  17087. */
  17088. color: Color3;
  17089. /**
  17090. * Alpha of the line (Default: 1)
  17091. */
  17092. alpha: number;
  17093. /**
  17094. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17095. * This margin is expressed in world space coordinates, so its value may vary.
  17096. * Default value is 0.1
  17097. */
  17098. intersectionThreshold: number;
  17099. private _colorShader;
  17100. private color4;
  17101. /**
  17102. * Creates a new LinesMesh
  17103. * @param name defines the name
  17104. * @param scene defines the hosting scene
  17105. * @param parent defines the parent mesh if any
  17106. * @param source defines the optional source LinesMesh used to clone data from
  17107. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17108. * When false, achieved by calling a clone(), also passing False.
  17109. * This will make creation of children, recursive.
  17110. * @param useVertexColor defines if this LinesMesh supports vertex color
  17111. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17112. */
  17113. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17114. /**
  17115. * If vertex color should be applied to the mesh
  17116. */
  17117. useVertexColor?: boolean | undefined,
  17118. /**
  17119. * If vertex alpha should be applied to the mesh
  17120. */
  17121. useVertexAlpha?: boolean | undefined);
  17122. private _addClipPlaneDefine;
  17123. private _removeClipPlaneDefine;
  17124. isReady(): boolean;
  17125. /**
  17126. * Returns the string "LineMesh"
  17127. */
  17128. getClassName(): string;
  17129. /**
  17130. * @hidden
  17131. */
  17132. get material(): Material;
  17133. /**
  17134. * @hidden
  17135. */
  17136. set material(value: Material);
  17137. /**
  17138. * @hidden
  17139. */
  17140. get checkCollisions(): boolean;
  17141. /** @hidden */
  17142. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17143. /** @hidden */
  17144. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17145. /**
  17146. * Disposes of the line mesh
  17147. * @param doNotRecurse If children should be disposed
  17148. */
  17149. dispose(doNotRecurse?: boolean): void;
  17150. /**
  17151. * Returns a new LineMesh object cloned from the current one.
  17152. */
  17153. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17154. /**
  17155. * Creates a new InstancedLinesMesh object from the mesh model.
  17156. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17157. * @param name defines the name of the new instance
  17158. * @returns a new InstancedLinesMesh
  17159. */
  17160. createInstance(name: string): InstancedLinesMesh;
  17161. }
  17162. /**
  17163. * Creates an instance based on a source LinesMesh
  17164. */
  17165. export class InstancedLinesMesh extends InstancedMesh {
  17166. /**
  17167. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17168. * This margin is expressed in world space coordinates, so its value may vary.
  17169. * Initilized with the intersectionThreshold value of the source LinesMesh
  17170. */
  17171. intersectionThreshold: number;
  17172. constructor(name: string, source: LinesMesh);
  17173. /**
  17174. * Returns the string "InstancedLinesMesh".
  17175. */
  17176. getClassName(): string;
  17177. }
  17178. }
  17179. declare module "babylonjs/Shaders/line.fragment" {
  17180. /** @hidden */
  17181. export var linePixelShader: {
  17182. name: string;
  17183. shader: string;
  17184. };
  17185. }
  17186. declare module "babylonjs/Shaders/line.vertex" {
  17187. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17188. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17189. /** @hidden */
  17190. export var lineVertexShader: {
  17191. name: string;
  17192. shader: string;
  17193. };
  17194. }
  17195. declare module "babylonjs/Rendering/edgesRenderer" {
  17196. import { Nullable } from "babylonjs/types";
  17197. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17199. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17200. import { IDisposable } from "babylonjs/scene";
  17201. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17202. import "babylonjs/Shaders/line.fragment";
  17203. import "babylonjs/Shaders/line.vertex";
  17204. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17205. import { SmartArray } from "babylonjs/Misc/smartArray";
  17206. module "babylonjs/scene" {
  17207. interface Scene {
  17208. /** @hidden */
  17209. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17210. }
  17211. }
  17212. module "babylonjs/Meshes/abstractMesh" {
  17213. interface AbstractMesh {
  17214. /**
  17215. * Gets the edgesRenderer associated with the mesh
  17216. */
  17217. edgesRenderer: Nullable<EdgesRenderer>;
  17218. }
  17219. }
  17220. module "babylonjs/Meshes/linesMesh" {
  17221. interface LinesMesh {
  17222. /**
  17223. * Enables the edge rendering mode on the mesh.
  17224. * This mode makes the mesh edges visible
  17225. * @param epsilon defines the maximal distance between two angles to detect a face
  17226. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17227. * @returns the currentAbstractMesh
  17228. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17229. */
  17230. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17231. }
  17232. }
  17233. module "babylonjs/Meshes/linesMesh" {
  17234. interface InstancedLinesMesh {
  17235. /**
  17236. * Enables the edge rendering mode on the mesh.
  17237. * This mode makes the mesh edges visible
  17238. * @param epsilon defines the maximal distance between two angles to detect a face
  17239. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17240. * @returns the current InstancedLinesMesh
  17241. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17242. */
  17243. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17244. }
  17245. }
  17246. /**
  17247. * Defines the minimum contract an Edges renderer should follow.
  17248. */
  17249. export interface IEdgesRenderer extends IDisposable {
  17250. /**
  17251. * Gets or sets a boolean indicating if the edgesRenderer is active
  17252. */
  17253. isEnabled: boolean;
  17254. /**
  17255. * Renders the edges of the attached mesh,
  17256. */
  17257. render(): void;
  17258. /**
  17259. * Checks wether or not the edges renderer is ready to render.
  17260. * @return true if ready, otherwise false.
  17261. */
  17262. isReady(): boolean;
  17263. /**
  17264. * List of instances to render in case the source mesh has instances
  17265. */
  17266. customInstances: SmartArray<Matrix>;
  17267. }
  17268. /**
  17269. * Defines the additional options of the edges renderer
  17270. */
  17271. export interface IEdgesRendererOptions {
  17272. /**
  17273. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17274. * If not defined, the default value is true
  17275. */
  17276. useAlternateEdgeFinder?: boolean;
  17277. /**
  17278. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17279. * If not defined, the default value is true.
  17280. * 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)
  17281. * This option is used only if useAlternateEdgeFinder = true
  17282. */
  17283. useFastVertexMerger?: boolean;
  17284. /**
  17285. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17286. * The default value is 1e-6
  17287. * This option is used only if useAlternateEdgeFinder = true
  17288. */
  17289. epsilonVertexMerge?: number;
  17290. /**
  17291. * 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
  17292. * 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.
  17293. * This option is used only if useAlternateEdgeFinder = true
  17294. */
  17295. applyTessellation?: boolean;
  17296. /**
  17297. * 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
  17298. * The default value is 1e-6
  17299. * This option is used only if useAlternateEdgeFinder = true
  17300. */
  17301. epsilonVertexAligned?: number;
  17302. }
  17303. /**
  17304. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17305. */
  17306. export class EdgesRenderer implements IEdgesRenderer {
  17307. /**
  17308. * Define the size of the edges with an orthographic camera
  17309. */
  17310. edgesWidthScalerForOrthographic: number;
  17311. /**
  17312. * Define the size of the edges with a perspective camera
  17313. */
  17314. edgesWidthScalerForPerspective: number;
  17315. protected _source: AbstractMesh;
  17316. protected _linesPositions: number[];
  17317. protected _linesNormals: number[];
  17318. protected _linesIndices: number[];
  17319. protected _epsilon: number;
  17320. protected _indicesCount: number;
  17321. protected _lineShader: ShaderMaterial;
  17322. protected _ib: DataBuffer;
  17323. protected _buffers: {
  17324. [key: string]: Nullable<VertexBuffer>;
  17325. };
  17326. protected _buffersForInstances: {
  17327. [key: string]: Nullable<VertexBuffer>;
  17328. };
  17329. protected _checkVerticesInsteadOfIndices: boolean;
  17330. protected _options: Nullable<IEdgesRendererOptions>;
  17331. private _meshRebuildObserver;
  17332. private _meshDisposeObserver;
  17333. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17334. isEnabled: boolean;
  17335. /**
  17336. * List of instances to render in case the source mesh has instances
  17337. */
  17338. customInstances: SmartArray<Matrix>;
  17339. private static GetShader;
  17340. /**
  17341. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17342. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17343. * @param source Mesh used to create edges
  17344. * @param epsilon sum of angles in adjacency to check for edge
  17345. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17346. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17347. * @param options The options to apply when generating the edges
  17348. */
  17349. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17350. protected _prepareRessources(): void;
  17351. /** @hidden */
  17352. _rebuild(): void;
  17353. /**
  17354. * Releases the required resources for the edges renderer
  17355. */
  17356. dispose(): void;
  17357. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17358. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17359. /**
  17360. * Checks if the pair of p0 and p1 is en edge
  17361. * @param faceIndex
  17362. * @param edge
  17363. * @param faceNormals
  17364. * @param p0
  17365. * @param p1
  17366. * @private
  17367. */
  17368. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17369. /**
  17370. * push line into the position, normal and index buffer
  17371. * @protected
  17372. */
  17373. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17374. /**
  17375. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17376. */
  17377. private _tessellateTriangle;
  17378. private _generateEdgesLinesAlternate;
  17379. /**
  17380. * Generates lines edges from adjacencjes
  17381. * @private
  17382. */
  17383. _generateEdgesLines(): void;
  17384. /**
  17385. * Checks wether or not the edges renderer is ready to render.
  17386. * @return true if ready, otherwise false.
  17387. */
  17388. isReady(): boolean;
  17389. /**
  17390. * Renders the edges of the attached mesh,
  17391. */
  17392. render(): void;
  17393. }
  17394. /**
  17395. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17396. */
  17397. export class LineEdgesRenderer extends EdgesRenderer {
  17398. /**
  17399. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17400. * @param source LineMesh used to generate edges
  17401. * @param epsilon not important (specified angle for edge detection)
  17402. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17403. */
  17404. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17405. /**
  17406. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17407. */
  17408. _generateEdgesLines(): void;
  17409. }
  17410. }
  17411. declare module "babylonjs/Rendering/renderingGroup" {
  17412. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17415. import { Nullable } from "babylonjs/types";
  17416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17417. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17418. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17419. import { Material } from "babylonjs/Materials/material";
  17420. import { Scene } from "babylonjs/scene";
  17421. /**
  17422. * This represents the object necessary to create a rendering group.
  17423. * This is exclusively used and created by the rendering manager.
  17424. * To modify the behavior, you use the available helpers in your scene or meshes.
  17425. * @hidden
  17426. */
  17427. export class RenderingGroup {
  17428. index: number;
  17429. private static _zeroVector;
  17430. private _scene;
  17431. private _opaqueSubMeshes;
  17432. private _transparentSubMeshes;
  17433. private _alphaTestSubMeshes;
  17434. private _depthOnlySubMeshes;
  17435. private _particleSystems;
  17436. private _spriteManagers;
  17437. private _opaqueSortCompareFn;
  17438. private _alphaTestSortCompareFn;
  17439. private _transparentSortCompareFn;
  17440. private _renderOpaque;
  17441. private _renderAlphaTest;
  17442. private _renderTransparent;
  17443. /** @hidden */
  17444. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17445. onBeforeTransparentRendering: () => void;
  17446. /**
  17447. * Set the opaque sort comparison function.
  17448. * If null the sub meshes will be render in the order they were created
  17449. */
  17450. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17451. /**
  17452. * Set the alpha test sort comparison function.
  17453. * If null the sub meshes will be render in the order they were created
  17454. */
  17455. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17456. /**
  17457. * Set the transparent sort comparison function.
  17458. * If null the sub meshes will be render in the order they were created
  17459. */
  17460. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17461. /**
  17462. * Creates a new rendering group.
  17463. * @param index The rendering group index
  17464. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17465. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17466. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17467. */
  17468. 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>);
  17469. /**
  17470. * Render all the sub meshes contained in the group.
  17471. * @param customRenderFunction Used to override the default render behaviour of the group.
  17472. * @returns true if rendered some submeshes.
  17473. */
  17474. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17475. /**
  17476. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17477. * @param subMeshes The submeshes to render
  17478. */
  17479. private renderOpaqueSorted;
  17480. /**
  17481. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17482. * @param subMeshes The submeshes to render
  17483. */
  17484. private renderAlphaTestSorted;
  17485. /**
  17486. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17487. * @param subMeshes The submeshes to render
  17488. */
  17489. private renderTransparentSorted;
  17490. /**
  17491. * Renders the submeshes in a specified order.
  17492. * @param subMeshes The submeshes to sort before render
  17493. * @param sortCompareFn The comparison function use to sort
  17494. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17495. * @param transparent Specifies to activate blending if true
  17496. */
  17497. private static renderSorted;
  17498. /**
  17499. * Renders the submeshes in the order they were dispatched (no sort applied).
  17500. * @param subMeshes The submeshes to render
  17501. */
  17502. private static renderUnsorted;
  17503. /**
  17504. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17505. * are rendered back to front if in the same alpha index.
  17506. *
  17507. * @param a The first submesh
  17508. * @param b The second submesh
  17509. * @returns The result of the comparison
  17510. */
  17511. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17512. /**
  17513. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17514. * are rendered back to front.
  17515. *
  17516. * @param a The first submesh
  17517. * @param b The second submesh
  17518. * @returns The result of the comparison
  17519. */
  17520. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17521. /**
  17522. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17523. * are rendered front to back (prevent overdraw).
  17524. *
  17525. * @param a The first submesh
  17526. * @param b The second submesh
  17527. * @returns The result of the comparison
  17528. */
  17529. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17530. /**
  17531. * Resets the different lists of submeshes to prepare a new frame.
  17532. */
  17533. prepare(): void;
  17534. dispose(): void;
  17535. /**
  17536. * Inserts the submesh in its correct queue depending on its material.
  17537. * @param subMesh The submesh to dispatch
  17538. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17539. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17540. */
  17541. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17542. dispatchSprites(spriteManager: ISpriteManager): void;
  17543. dispatchParticles(particleSystem: IParticleSystem): void;
  17544. private _renderParticles;
  17545. private _renderSprites;
  17546. }
  17547. }
  17548. declare module "babylonjs/Rendering/renderingManager" {
  17549. import { Nullable } from "babylonjs/types";
  17550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17551. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17552. import { SmartArray } from "babylonjs/Misc/smartArray";
  17553. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17554. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17555. import { Material } from "babylonjs/Materials/material";
  17556. import { Scene } from "babylonjs/scene";
  17557. import { Camera } from "babylonjs/Cameras/camera";
  17558. /**
  17559. * Interface describing the different options available in the rendering manager
  17560. * regarding Auto Clear between groups.
  17561. */
  17562. export interface IRenderingManagerAutoClearSetup {
  17563. /**
  17564. * Defines whether or not autoclear is enable.
  17565. */
  17566. autoClear: boolean;
  17567. /**
  17568. * Defines whether or not to autoclear the depth buffer.
  17569. */
  17570. depth: boolean;
  17571. /**
  17572. * Defines whether or not to autoclear the stencil buffer.
  17573. */
  17574. stencil: boolean;
  17575. }
  17576. /**
  17577. * This class is used by the onRenderingGroupObservable
  17578. */
  17579. export class RenderingGroupInfo {
  17580. /**
  17581. * The Scene that being rendered
  17582. */
  17583. scene: Scene;
  17584. /**
  17585. * The camera currently used for the rendering pass
  17586. */
  17587. camera: Nullable<Camera>;
  17588. /**
  17589. * The ID of the renderingGroup being processed
  17590. */
  17591. renderingGroupId: number;
  17592. }
  17593. /**
  17594. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17595. * It is enable to manage the different groups as well as the different necessary sort functions.
  17596. * This should not be used directly aside of the few static configurations
  17597. */
  17598. export class RenderingManager {
  17599. /**
  17600. * The max id used for rendering groups (not included)
  17601. */
  17602. static MAX_RENDERINGGROUPS: number;
  17603. /**
  17604. * The min id used for rendering groups (included)
  17605. */
  17606. static MIN_RENDERINGGROUPS: number;
  17607. /**
  17608. * Used to globally prevent autoclearing scenes.
  17609. */
  17610. static AUTOCLEAR: boolean;
  17611. /**
  17612. * @hidden
  17613. */
  17614. _useSceneAutoClearSetup: boolean;
  17615. private _scene;
  17616. private _renderingGroups;
  17617. private _depthStencilBufferAlreadyCleaned;
  17618. private _autoClearDepthStencil;
  17619. private _customOpaqueSortCompareFn;
  17620. private _customAlphaTestSortCompareFn;
  17621. private _customTransparentSortCompareFn;
  17622. private _renderingGroupInfo;
  17623. /**
  17624. * Instantiates a new rendering group for a particular scene
  17625. * @param scene Defines the scene the groups belongs to
  17626. */
  17627. constructor(scene: Scene);
  17628. private _clearDepthStencilBuffer;
  17629. /**
  17630. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17631. * @hidden
  17632. */
  17633. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17634. /**
  17635. * Resets the different information of the group to prepare a new frame
  17636. * @hidden
  17637. */
  17638. reset(): void;
  17639. /**
  17640. * Dispose and release the group and its associated resources.
  17641. * @hidden
  17642. */
  17643. dispose(): void;
  17644. /**
  17645. * Clear the info related to rendering groups preventing retention points during dispose.
  17646. */
  17647. freeRenderingGroups(): void;
  17648. private _prepareRenderingGroup;
  17649. /**
  17650. * Add a sprite manager to the rendering manager in order to render it this frame.
  17651. * @param spriteManager Define the sprite manager to render
  17652. */
  17653. dispatchSprites(spriteManager: ISpriteManager): void;
  17654. /**
  17655. * Add a particle system to the rendering manager in order to render it this frame.
  17656. * @param particleSystem Define the particle system to render
  17657. */
  17658. dispatchParticles(particleSystem: IParticleSystem): void;
  17659. /**
  17660. * Add a submesh to the manager in order to render it this frame
  17661. * @param subMesh The submesh to dispatch
  17662. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17663. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17664. */
  17665. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17666. /**
  17667. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17668. * This allowed control for front to back rendering or reversly depending of the special needs.
  17669. *
  17670. * @param renderingGroupId The rendering group id corresponding to its index
  17671. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17672. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17673. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17674. */
  17675. 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;
  17676. /**
  17677. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17678. *
  17679. * @param renderingGroupId The rendering group id corresponding to its index
  17680. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17681. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17682. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17683. */
  17684. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17685. /**
  17686. * Gets the current auto clear configuration for one rendering group of the rendering
  17687. * manager.
  17688. * @param index the rendering group index to get the information for
  17689. * @returns The auto clear setup for the requested rendering group
  17690. */
  17691. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17692. }
  17693. }
  17694. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17695. import { SmartArray } from "babylonjs/Misc/smartArray";
  17696. import { Nullable } from "babylonjs/types";
  17697. import { Scene } from "babylonjs/scene";
  17698. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17701. import { Mesh } from "babylonjs/Meshes/mesh";
  17702. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17703. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17704. import { Effect } from "babylonjs/Materials/effect";
  17705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17706. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17707. import "babylonjs/Shaders/shadowMap.fragment";
  17708. import "babylonjs/Shaders/shadowMap.vertex";
  17709. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17710. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17711. import { Observable } from "babylonjs/Misc/observable";
  17712. /**
  17713. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17714. */
  17715. export interface ICustomShaderOptions {
  17716. /**
  17717. * Gets or sets the custom shader name to use
  17718. */
  17719. shaderName: string;
  17720. /**
  17721. * The list of attribute names used in the shader
  17722. */
  17723. attributes?: string[];
  17724. /**
  17725. * The list of unifrom names used in the shader
  17726. */
  17727. uniforms?: string[];
  17728. /**
  17729. * The list of sampler names used in the shader
  17730. */
  17731. samplers?: string[];
  17732. /**
  17733. * The list of defines used in the shader
  17734. */
  17735. defines?: string[];
  17736. }
  17737. /**
  17738. * Interface to implement to create a shadow generator compatible with BJS.
  17739. */
  17740. export interface IShadowGenerator {
  17741. /**
  17742. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17743. * @returns The render target texture if present otherwise, null
  17744. */
  17745. getShadowMap(): Nullable<RenderTargetTexture>;
  17746. /**
  17747. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17748. * @param subMesh The submesh we want to render in the shadow map
  17749. * @param useInstances Defines wether will draw in the map using instances
  17750. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17751. * @returns true if ready otherwise, false
  17752. */
  17753. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17754. /**
  17755. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17756. * @param defines Defines of the material we want to update
  17757. * @param lightIndex Index of the light in the enabled light list of the material
  17758. */
  17759. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17760. /**
  17761. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17762. * defined in the generator but impacting the effect).
  17763. * It implies the unifroms available on the materials are the standard BJS ones.
  17764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17765. * @param effect The effect we are binfing the information for
  17766. */
  17767. bindShadowLight(lightIndex: string, effect: Effect): void;
  17768. /**
  17769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17770. * (eq to shadow prjection matrix * light transform matrix)
  17771. * @returns The transform matrix used to create the shadow map
  17772. */
  17773. getTransformMatrix(): Matrix;
  17774. /**
  17775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17776. * Cube and 2D textures for instance.
  17777. */
  17778. recreateShadowMap(): void;
  17779. /**
  17780. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17781. * @param onCompiled Callback triggered at the and of the effects compilation
  17782. * @param options Sets of optional options forcing the compilation with different modes
  17783. */
  17784. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17785. useInstances: boolean;
  17786. }>): void;
  17787. /**
  17788. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17789. * @param options Sets of optional options forcing the compilation with different modes
  17790. * @returns A promise that resolves when the compilation completes
  17791. */
  17792. forceCompilationAsync(options?: Partial<{
  17793. useInstances: boolean;
  17794. }>): Promise<void>;
  17795. /**
  17796. * Serializes the shadow generator setup to a json object.
  17797. * @returns The serialized JSON object
  17798. */
  17799. serialize(): any;
  17800. /**
  17801. * Disposes the Shadow map and related Textures and effects.
  17802. */
  17803. dispose(): void;
  17804. }
  17805. /**
  17806. * Default implementation IShadowGenerator.
  17807. * This is the main object responsible of generating shadows in the framework.
  17808. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17809. */
  17810. export class ShadowGenerator implements IShadowGenerator {
  17811. /**
  17812. * Name of the shadow generator class
  17813. */
  17814. static CLASSNAME: string;
  17815. /**
  17816. * Shadow generator mode None: no filtering applied.
  17817. */
  17818. static readonly FILTER_NONE: number;
  17819. /**
  17820. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17821. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17822. */
  17823. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17824. /**
  17825. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17826. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17827. */
  17828. static readonly FILTER_POISSONSAMPLING: number;
  17829. /**
  17830. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17831. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17832. */
  17833. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17834. /**
  17835. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17836. * edge artifacts on steep falloff.
  17837. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17838. */
  17839. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17840. /**
  17841. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17842. * edge artifacts on steep falloff.
  17843. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17844. */
  17845. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17846. /**
  17847. * Shadow generator mode PCF: Percentage Closer Filtering
  17848. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17849. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17850. */
  17851. static readonly FILTER_PCF: number;
  17852. /**
  17853. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17854. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17855. * Contact Hardening
  17856. */
  17857. static readonly FILTER_PCSS: number;
  17858. /**
  17859. * Reserved for PCF and PCSS
  17860. * Highest Quality.
  17861. *
  17862. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17863. *
  17864. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17865. */
  17866. static readonly QUALITY_HIGH: number;
  17867. /**
  17868. * Reserved for PCF and PCSS
  17869. * Good tradeoff for quality/perf cross devices
  17870. *
  17871. * Execute PCF on a 3*3 kernel.
  17872. *
  17873. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17874. */
  17875. static readonly QUALITY_MEDIUM: number;
  17876. /**
  17877. * Reserved for PCF and PCSS
  17878. * The lowest quality but the fastest.
  17879. *
  17880. * Execute PCF on a 1*1 kernel.
  17881. *
  17882. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17883. */
  17884. static readonly QUALITY_LOW: number;
  17885. /** Gets or sets the custom shader name to use */
  17886. customShaderOptions: ICustomShaderOptions;
  17887. /**
  17888. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17889. */
  17890. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17891. /**
  17892. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17893. */
  17894. onAfterShadowMapRenderObservable: Observable<Effect>;
  17895. /**
  17896. * Observable triggered before a mesh is rendered in the shadow map.
  17897. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17898. */
  17899. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17900. /**
  17901. * Observable triggered after a mesh is rendered in the shadow map.
  17902. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17903. */
  17904. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17905. protected _bias: number;
  17906. /**
  17907. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17908. */
  17909. get bias(): number;
  17910. /**
  17911. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17912. */
  17913. set bias(bias: number);
  17914. protected _normalBias: number;
  17915. /**
  17916. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17917. */
  17918. get normalBias(): number;
  17919. /**
  17920. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17921. */
  17922. set normalBias(normalBias: number);
  17923. protected _blurBoxOffset: number;
  17924. /**
  17925. * Gets the blur box offset: offset applied during the blur pass.
  17926. * Only useful if useKernelBlur = false
  17927. */
  17928. get blurBoxOffset(): number;
  17929. /**
  17930. * Sets the blur box offset: offset applied during the blur pass.
  17931. * Only useful if useKernelBlur = false
  17932. */
  17933. set blurBoxOffset(value: number);
  17934. protected _blurScale: number;
  17935. /**
  17936. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17937. * 2 means half of the size.
  17938. */
  17939. get blurScale(): number;
  17940. /**
  17941. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17942. * 2 means half of the size.
  17943. */
  17944. set blurScale(value: number);
  17945. protected _blurKernel: number;
  17946. /**
  17947. * Gets the blur kernel: kernel size of the blur pass.
  17948. * Only useful if useKernelBlur = true
  17949. */
  17950. get blurKernel(): number;
  17951. /**
  17952. * Sets the blur kernel: kernel size of the blur pass.
  17953. * Only useful if useKernelBlur = true
  17954. */
  17955. set blurKernel(value: number);
  17956. protected _useKernelBlur: boolean;
  17957. /**
  17958. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17959. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17960. */
  17961. get useKernelBlur(): boolean;
  17962. /**
  17963. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17964. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17965. */
  17966. set useKernelBlur(value: boolean);
  17967. protected _depthScale: number;
  17968. /**
  17969. * Gets the depth scale used in ESM mode.
  17970. */
  17971. get depthScale(): number;
  17972. /**
  17973. * Sets the depth scale used in ESM mode.
  17974. * This can override the scale stored on the light.
  17975. */
  17976. set depthScale(value: number);
  17977. protected _validateFilter(filter: number): number;
  17978. protected _filter: number;
  17979. /**
  17980. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17981. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17982. */
  17983. get filter(): number;
  17984. /**
  17985. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17986. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17987. */
  17988. set filter(value: number);
  17989. /**
  17990. * Gets if the current filter is set to Poisson Sampling.
  17991. */
  17992. get usePoissonSampling(): boolean;
  17993. /**
  17994. * Sets the current filter to Poisson Sampling.
  17995. */
  17996. set usePoissonSampling(value: boolean);
  17997. /**
  17998. * Gets if the current filter is set to ESM.
  17999. */
  18000. get useExponentialShadowMap(): boolean;
  18001. /**
  18002. * Sets the current filter is to ESM.
  18003. */
  18004. set useExponentialShadowMap(value: boolean);
  18005. /**
  18006. * Gets if the current filter is set to filtered ESM.
  18007. */
  18008. get useBlurExponentialShadowMap(): boolean;
  18009. /**
  18010. * Gets if the current filter is set to filtered ESM.
  18011. */
  18012. set useBlurExponentialShadowMap(value: boolean);
  18013. /**
  18014. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18015. * exponential to prevent steep falloff artifacts).
  18016. */
  18017. get useCloseExponentialShadowMap(): boolean;
  18018. /**
  18019. * Sets the current filter to "close ESM" (using the inverse of the
  18020. * exponential to prevent steep falloff artifacts).
  18021. */
  18022. set useCloseExponentialShadowMap(value: boolean);
  18023. /**
  18024. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18025. * exponential to prevent steep falloff artifacts).
  18026. */
  18027. get useBlurCloseExponentialShadowMap(): boolean;
  18028. /**
  18029. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18030. * exponential to prevent steep falloff artifacts).
  18031. */
  18032. set useBlurCloseExponentialShadowMap(value: boolean);
  18033. /**
  18034. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18035. */
  18036. get usePercentageCloserFiltering(): boolean;
  18037. /**
  18038. * Sets the current filter to "PCF" (percentage closer filtering).
  18039. */
  18040. set usePercentageCloserFiltering(value: boolean);
  18041. protected _filteringQuality: number;
  18042. /**
  18043. * Gets the PCF or PCSS Quality.
  18044. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18045. */
  18046. get filteringQuality(): number;
  18047. /**
  18048. * Sets the PCF or PCSS Quality.
  18049. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18050. */
  18051. set filteringQuality(filteringQuality: number);
  18052. /**
  18053. * Gets if the current filter is set to "PCSS" (contact hardening).
  18054. */
  18055. get useContactHardeningShadow(): boolean;
  18056. /**
  18057. * Sets the current filter to "PCSS" (contact hardening).
  18058. */
  18059. set useContactHardeningShadow(value: boolean);
  18060. protected _contactHardeningLightSizeUVRatio: number;
  18061. /**
  18062. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18063. * Using a ratio helps keeping shape stability independently of the map size.
  18064. *
  18065. * It does not account for the light projection as it was having too much
  18066. * instability during the light setup or during light position changes.
  18067. *
  18068. * Only valid if useContactHardeningShadow is true.
  18069. */
  18070. get contactHardeningLightSizeUVRatio(): number;
  18071. /**
  18072. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18073. * Using a ratio helps keeping shape stability independently of the map size.
  18074. *
  18075. * It does not account for the light projection as it was having too much
  18076. * instability during the light setup or during light position changes.
  18077. *
  18078. * Only valid if useContactHardeningShadow is true.
  18079. */
  18080. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18081. protected _darkness: number;
  18082. /** Gets or sets the actual darkness of a shadow */
  18083. get darkness(): number;
  18084. set darkness(value: number);
  18085. /**
  18086. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18087. * 0 means strongest and 1 would means no shadow.
  18088. * @returns the darkness.
  18089. */
  18090. getDarkness(): number;
  18091. /**
  18092. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18093. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18094. * @returns the shadow generator allowing fluent coding.
  18095. */
  18096. setDarkness(darkness: number): ShadowGenerator;
  18097. protected _transparencyShadow: boolean;
  18098. /** Gets or sets the ability to have transparent shadow */
  18099. get transparencyShadow(): boolean;
  18100. set transparencyShadow(value: boolean);
  18101. /**
  18102. * Sets the ability to have transparent shadow (boolean).
  18103. * @param transparent True if transparent else False
  18104. * @returns the shadow generator allowing fluent coding
  18105. */
  18106. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18107. /**
  18108. * Enables or disables shadows with varying strength based on the transparency
  18109. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18110. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18111. * mesh.visibility * alphaTexture.a
  18112. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18113. */
  18114. enableSoftTransparentShadow: boolean;
  18115. protected _shadowMap: Nullable<RenderTargetTexture>;
  18116. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18117. /**
  18118. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18119. * @returns The render target texture if present otherwise, null
  18120. */
  18121. getShadowMap(): Nullable<RenderTargetTexture>;
  18122. /**
  18123. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18124. * @returns The render target texture if the shadow map is present otherwise, null
  18125. */
  18126. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18127. /**
  18128. * Gets the class name of that object
  18129. * @returns "ShadowGenerator"
  18130. */
  18131. getClassName(): string;
  18132. /**
  18133. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18134. * @param mesh Mesh to add
  18135. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18136. * @returns the Shadow Generator itself
  18137. */
  18138. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18139. /**
  18140. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18141. * @param mesh Mesh to remove
  18142. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18143. * @returns the Shadow Generator itself
  18144. */
  18145. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18146. /**
  18147. * Controls the extent to which the shadows fade out at the edge of the frustum
  18148. */
  18149. frustumEdgeFalloff: number;
  18150. protected _light: IShadowLight;
  18151. /**
  18152. * Returns the associated light object.
  18153. * @returns the light generating the shadow
  18154. */
  18155. getLight(): IShadowLight;
  18156. /**
  18157. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18158. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18159. * It might on the other hand introduce peter panning.
  18160. */
  18161. forceBackFacesOnly: boolean;
  18162. protected _scene: Scene;
  18163. protected _lightDirection: Vector3;
  18164. protected _effect: Effect;
  18165. protected _viewMatrix: Matrix;
  18166. protected _projectionMatrix: Matrix;
  18167. protected _transformMatrix: Matrix;
  18168. protected _cachedPosition: Vector3;
  18169. protected _cachedDirection: Vector3;
  18170. protected _cachedDefines: string;
  18171. protected _currentRenderID: number;
  18172. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18173. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18174. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18175. protected _blurPostProcesses: PostProcess[];
  18176. protected _mapSize: number;
  18177. protected _currentFaceIndex: number;
  18178. protected _currentFaceIndexCache: number;
  18179. protected _textureType: number;
  18180. protected _defaultTextureMatrix: Matrix;
  18181. protected _storedUniqueId: Nullable<number>;
  18182. /** @hidden */
  18183. static _SceneComponentInitialization: (scene: Scene) => void;
  18184. /**
  18185. * Creates a ShadowGenerator object.
  18186. * A ShadowGenerator is the required tool to use the shadows.
  18187. * Each light casting shadows needs to use its own ShadowGenerator.
  18188. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18189. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18190. * @param light The light object generating the shadows.
  18191. * @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.
  18192. */
  18193. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18194. protected _initializeGenerator(): void;
  18195. protected _createTargetRenderTexture(): void;
  18196. protected _initializeShadowMap(): void;
  18197. protected _initializeBlurRTTAndPostProcesses(): void;
  18198. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18199. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18200. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18201. protected _applyFilterValues(): void;
  18202. /**
  18203. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18204. * @param onCompiled Callback triggered at the and of the effects compilation
  18205. * @param options Sets of optional options forcing the compilation with different modes
  18206. */
  18207. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18208. useInstances: boolean;
  18209. }>): void;
  18210. /**
  18211. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18212. * @param options Sets of optional options forcing the compilation with different modes
  18213. * @returns A promise that resolves when the compilation completes
  18214. */
  18215. forceCompilationAsync(options?: Partial<{
  18216. useInstances: boolean;
  18217. }>): Promise<void>;
  18218. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18219. private _prepareShadowDefines;
  18220. /**
  18221. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18222. * @param subMesh The submesh we want to render in the shadow map
  18223. * @param useInstances Defines wether will draw in the map using instances
  18224. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18225. * @returns true if ready otherwise, false
  18226. */
  18227. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18228. /**
  18229. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18230. * @param defines Defines of the material we want to update
  18231. * @param lightIndex Index of the light in the enabled light list of the material
  18232. */
  18233. prepareDefines(defines: any, lightIndex: number): void;
  18234. /**
  18235. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18236. * defined in the generator but impacting the effect).
  18237. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18238. * @param effect The effect we are binfing the information for
  18239. */
  18240. bindShadowLight(lightIndex: string, effect: Effect): void;
  18241. /**
  18242. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18243. * (eq to shadow prjection matrix * light transform matrix)
  18244. * @returns The transform matrix used to create the shadow map
  18245. */
  18246. getTransformMatrix(): Matrix;
  18247. /**
  18248. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18249. * Cube and 2D textures for instance.
  18250. */
  18251. recreateShadowMap(): void;
  18252. protected _disposeBlurPostProcesses(): void;
  18253. protected _disposeRTTandPostProcesses(): void;
  18254. /**
  18255. * Disposes the ShadowGenerator.
  18256. * Returns nothing.
  18257. */
  18258. dispose(): void;
  18259. /**
  18260. * Serializes the shadow generator setup to a json object.
  18261. * @returns The serialized JSON object
  18262. */
  18263. serialize(): any;
  18264. /**
  18265. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18266. * @param parsedShadowGenerator The JSON object to parse
  18267. * @param scene The scene to create the shadow map for
  18268. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18269. * @returns The parsed shadow generator
  18270. */
  18271. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18272. }
  18273. }
  18274. declare module "babylonjs/Lights/light" {
  18275. import { Nullable } from "babylonjs/types";
  18276. import { Scene } from "babylonjs/scene";
  18277. import { Vector3 } from "babylonjs/Maths/math.vector";
  18278. import { Color3 } from "babylonjs/Maths/math.color";
  18279. import { Node } from "babylonjs/node";
  18280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18281. import { Effect } from "babylonjs/Materials/effect";
  18282. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18283. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18284. /**
  18285. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18286. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18287. * 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.
  18288. */
  18289. export abstract class Light extends Node {
  18290. /**
  18291. * Falloff Default: light is falling off following the material specification:
  18292. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18293. */
  18294. static readonly FALLOFF_DEFAULT: number;
  18295. /**
  18296. * Falloff Physical: light is falling off following the inverse squared distance law.
  18297. */
  18298. static readonly FALLOFF_PHYSICAL: number;
  18299. /**
  18300. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18301. * to enhance interoperability with other engines.
  18302. */
  18303. static readonly FALLOFF_GLTF: number;
  18304. /**
  18305. * Falloff Standard: light is falling off like in the standard material
  18306. * to enhance interoperability with other materials.
  18307. */
  18308. static readonly FALLOFF_STANDARD: number;
  18309. /**
  18310. * If every light affecting the material is in this lightmapMode,
  18311. * material.lightmapTexture adds or multiplies
  18312. * (depends on material.useLightmapAsShadowmap)
  18313. * after every other light calculations.
  18314. */
  18315. static readonly LIGHTMAP_DEFAULT: number;
  18316. /**
  18317. * material.lightmapTexture as only diffuse lighting from this light
  18318. * adds only specular lighting from this light
  18319. * adds dynamic shadows
  18320. */
  18321. static readonly LIGHTMAP_SPECULAR: number;
  18322. /**
  18323. * material.lightmapTexture as only lighting
  18324. * no light calculation from this light
  18325. * only adds dynamic shadows from this light
  18326. */
  18327. static readonly LIGHTMAP_SHADOWSONLY: number;
  18328. /**
  18329. * Each light type uses the default quantity according to its type:
  18330. * point/spot lights use luminous intensity
  18331. * directional lights use illuminance
  18332. */
  18333. static readonly INTENSITYMODE_AUTOMATIC: number;
  18334. /**
  18335. * lumen (lm)
  18336. */
  18337. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18338. /**
  18339. * candela (lm/sr)
  18340. */
  18341. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18342. /**
  18343. * lux (lm/m^2)
  18344. */
  18345. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18346. /**
  18347. * nit (cd/m^2)
  18348. */
  18349. static readonly INTENSITYMODE_LUMINANCE: number;
  18350. /**
  18351. * Light type const id of the point light.
  18352. */
  18353. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18354. /**
  18355. * Light type const id of the directional light.
  18356. */
  18357. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18358. /**
  18359. * Light type const id of the spot light.
  18360. */
  18361. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18362. /**
  18363. * Light type const id of the hemispheric light.
  18364. */
  18365. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18366. /**
  18367. * Diffuse gives the basic color to an object.
  18368. */
  18369. diffuse: Color3;
  18370. /**
  18371. * Specular produces a highlight color on an object.
  18372. * Note: This is note affecting PBR materials.
  18373. */
  18374. specular: Color3;
  18375. /**
  18376. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18377. * falling off base on range or angle.
  18378. * This can be set to any values in Light.FALLOFF_x.
  18379. *
  18380. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18381. * other types of materials.
  18382. */
  18383. falloffType: number;
  18384. /**
  18385. * Strength of the light.
  18386. * Note: By default it is define in the framework own unit.
  18387. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18388. */
  18389. intensity: number;
  18390. private _range;
  18391. protected _inverseSquaredRange: number;
  18392. /**
  18393. * Defines how far from the source the light is impacting in scene units.
  18394. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18395. */
  18396. get range(): number;
  18397. /**
  18398. * Defines how far from the source the light is impacting in scene units.
  18399. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18400. */
  18401. set range(value: number);
  18402. /**
  18403. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18404. * of light.
  18405. */
  18406. private _photometricScale;
  18407. private _intensityMode;
  18408. /**
  18409. * Gets the photometric scale used to interpret the intensity.
  18410. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18411. */
  18412. get intensityMode(): number;
  18413. /**
  18414. * Sets the photometric scale used to interpret the intensity.
  18415. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18416. */
  18417. set intensityMode(value: number);
  18418. private _radius;
  18419. /**
  18420. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18421. */
  18422. get radius(): number;
  18423. /**
  18424. * sets the light radius used by PBR Materials to simulate soft area lights.
  18425. */
  18426. set radius(value: number);
  18427. private _renderPriority;
  18428. /**
  18429. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18430. * exceeding the number allowed of the materials.
  18431. */
  18432. renderPriority: number;
  18433. private _shadowEnabled;
  18434. /**
  18435. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18436. * the current shadow generator.
  18437. */
  18438. get shadowEnabled(): boolean;
  18439. /**
  18440. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18441. * the current shadow generator.
  18442. */
  18443. set shadowEnabled(value: boolean);
  18444. private _includedOnlyMeshes;
  18445. /**
  18446. * Gets the only meshes impacted by this light.
  18447. */
  18448. get includedOnlyMeshes(): AbstractMesh[];
  18449. /**
  18450. * Sets the only meshes impacted by this light.
  18451. */
  18452. set includedOnlyMeshes(value: AbstractMesh[]);
  18453. private _excludedMeshes;
  18454. /**
  18455. * Gets the meshes not impacted by this light.
  18456. */
  18457. get excludedMeshes(): AbstractMesh[];
  18458. /**
  18459. * Sets the meshes not impacted by this light.
  18460. */
  18461. set excludedMeshes(value: AbstractMesh[]);
  18462. private _excludeWithLayerMask;
  18463. /**
  18464. * Gets the layer id use to find what meshes are not impacted by the light.
  18465. * Inactive if 0
  18466. */
  18467. get excludeWithLayerMask(): number;
  18468. /**
  18469. * Sets the layer id use to find what meshes are not impacted by the light.
  18470. * Inactive if 0
  18471. */
  18472. set excludeWithLayerMask(value: number);
  18473. private _includeOnlyWithLayerMask;
  18474. /**
  18475. * Gets the layer id use to find what meshes are impacted by the light.
  18476. * Inactive if 0
  18477. */
  18478. get includeOnlyWithLayerMask(): number;
  18479. /**
  18480. * Sets the layer id use to find what meshes are impacted by the light.
  18481. * Inactive if 0
  18482. */
  18483. set includeOnlyWithLayerMask(value: number);
  18484. private _lightmapMode;
  18485. /**
  18486. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18487. */
  18488. get lightmapMode(): number;
  18489. /**
  18490. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18491. */
  18492. set lightmapMode(value: number);
  18493. /**
  18494. * Shadow generator associted to the light.
  18495. * @hidden Internal use only.
  18496. */
  18497. _shadowGenerator: Nullable<IShadowGenerator>;
  18498. /**
  18499. * @hidden Internal use only.
  18500. */
  18501. _excludedMeshesIds: string[];
  18502. /**
  18503. * @hidden Internal use only.
  18504. */
  18505. _includedOnlyMeshesIds: string[];
  18506. /**
  18507. * The current light unifom buffer.
  18508. * @hidden Internal use only.
  18509. */
  18510. _uniformBuffer: UniformBuffer;
  18511. /** @hidden */
  18512. _renderId: number;
  18513. /**
  18514. * Creates a Light object in the scene.
  18515. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18516. * @param name The firendly name of the light
  18517. * @param scene The scene the light belongs too
  18518. */
  18519. constructor(name: string, scene: Scene);
  18520. protected abstract _buildUniformLayout(): void;
  18521. /**
  18522. * Sets the passed Effect "effect" with the Light information.
  18523. * @param effect The effect to update
  18524. * @param lightIndex The index of the light in the effect to update
  18525. * @returns The light
  18526. */
  18527. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18528. /**
  18529. * Sets the passed Effect "effect" with the Light textures.
  18530. * @param effect The effect to update
  18531. * @param lightIndex The index of the light in the effect to update
  18532. * @returns The light
  18533. */
  18534. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18535. /**
  18536. * Binds the lights information from the scene to the effect for the given mesh.
  18537. * @param lightIndex Light index
  18538. * @param scene The scene where the light belongs to
  18539. * @param effect The effect we are binding the data to
  18540. * @param useSpecular Defines if specular is supported
  18541. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18542. */
  18543. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18544. /**
  18545. * Sets the passed Effect "effect" with the Light information.
  18546. * @param effect The effect to update
  18547. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18548. * @returns The light
  18549. */
  18550. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18551. /**
  18552. * Returns the string "Light".
  18553. * @returns the class name
  18554. */
  18555. getClassName(): string;
  18556. /** @hidden */
  18557. readonly _isLight: boolean;
  18558. /**
  18559. * Converts the light information to a readable string for debug purpose.
  18560. * @param fullDetails Supports for multiple levels of logging within scene loading
  18561. * @returns the human readable light info
  18562. */
  18563. toString(fullDetails?: boolean): string;
  18564. /** @hidden */
  18565. protected _syncParentEnabledState(): void;
  18566. /**
  18567. * Set the enabled state of this node.
  18568. * @param value - the new enabled state
  18569. */
  18570. setEnabled(value: boolean): void;
  18571. /**
  18572. * Returns the Light associated shadow generator if any.
  18573. * @return the associated shadow generator.
  18574. */
  18575. getShadowGenerator(): Nullable<IShadowGenerator>;
  18576. /**
  18577. * Returns a Vector3, the absolute light position in the World.
  18578. * @returns the world space position of the light
  18579. */
  18580. getAbsolutePosition(): Vector3;
  18581. /**
  18582. * Specifies if the light will affect the passed mesh.
  18583. * @param mesh The mesh to test against the light
  18584. * @return true the mesh is affected otherwise, false.
  18585. */
  18586. canAffectMesh(mesh: AbstractMesh): boolean;
  18587. /**
  18588. * Sort function to order lights for rendering.
  18589. * @param a First Light object to compare to second.
  18590. * @param b Second Light object to compare first.
  18591. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18592. */
  18593. static CompareLightsPriority(a: Light, b: Light): number;
  18594. /**
  18595. * Releases resources associated with this node.
  18596. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18597. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18598. */
  18599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18600. /**
  18601. * Returns the light type ID (integer).
  18602. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18603. */
  18604. getTypeID(): number;
  18605. /**
  18606. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18607. * @returns the scaled intensity in intensity mode unit
  18608. */
  18609. getScaledIntensity(): number;
  18610. /**
  18611. * Returns a new Light object, named "name", from the current one.
  18612. * @param name The name of the cloned light
  18613. * @param newParent The parent of this light, if it has one
  18614. * @returns the new created light
  18615. */
  18616. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18617. /**
  18618. * Serializes the current light into a Serialization object.
  18619. * @returns the serialized object.
  18620. */
  18621. serialize(): any;
  18622. /**
  18623. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18624. * This new light is named "name" and added to the passed scene.
  18625. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18626. * @param name The friendly name of the light
  18627. * @param scene The scene the new light will belong to
  18628. * @returns the constructor function
  18629. */
  18630. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18631. /**
  18632. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18633. * @param parsedLight The JSON representation of the light
  18634. * @param scene The scene to create the parsed light in
  18635. * @returns the created light after parsing
  18636. */
  18637. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18638. private _hookArrayForExcluded;
  18639. private _hookArrayForIncludedOnly;
  18640. private _resyncMeshes;
  18641. /**
  18642. * Forces the meshes to update their light related information in their rendering used effects
  18643. * @hidden Internal Use Only
  18644. */
  18645. _markMeshesAsLightDirty(): void;
  18646. /**
  18647. * Recomputes the cached photometric scale if needed.
  18648. */
  18649. private _computePhotometricScale;
  18650. /**
  18651. * Returns the Photometric Scale according to the light type and intensity mode.
  18652. */
  18653. private _getPhotometricScale;
  18654. /**
  18655. * Reorder the light in the scene according to their defined priority.
  18656. * @hidden Internal Use Only
  18657. */
  18658. _reorderLightsInScene(): void;
  18659. /**
  18660. * Prepares the list of defines specific to the light type.
  18661. * @param defines the list of defines
  18662. * @param lightIndex defines the index of the light for the effect
  18663. */
  18664. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18665. }
  18666. }
  18667. declare module "babylonjs/Cameras/targetCamera" {
  18668. import { Nullable } from "babylonjs/types";
  18669. import { Camera } from "babylonjs/Cameras/camera";
  18670. import { Scene } from "babylonjs/scene";
  18671. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18672. /**
  18673. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18674. * This is the base of the follow, arc rotate cameras and Free camera
  18675. * @see https://doc.babylonjs.com/features/cameras
  18676. */
  18677. export class TargetCamera extends Camera {
  18678. private static _RigCamTransformMatrix;
  18679. private static _TargetTransformMatrix;
  18680. private static _TargetFocalPoint;
  18681. private _tmpUpVector;
  18682. private _tmpTargetVector;
  18683. /**
  18684. * Define the current direction the camera is moving to
  18685. */
  18686. cameraDirection: Vector3;
  18687. /**
  18688. * Define the current rotation the camera is rotating to
  18689. */
  18690. cameraRotation: Vector2;
  18691. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18692. ignoreParentScaling: boolean;
  18693. /**
  18694. * When set, the up vector of the camera will be updated by the rotation of the camera
  18695. */
  18696. updateUpVectorFromRotation: boolean;
  18697. private _tmpQuaternion;
  18698. /**
  18699. * Define the current rotation of the camera
  18700. */
  18701. rotation: Vector3;
  18702. /**
  18703. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18704. */
  18705. rotationQuaternion: Quaternion;
  18706. /**
  18707. * Define the current speed of the camera
  18708. */
  18709. speed: number;
  18710. /**
  18711. * Add constraint to the camera to prevent it to move freely in all directions and
  18712. * around all axis.
  18713. */
  18714. noRotationConstraint: boolean;
  18715. /**
  18716. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18717. * panning
  18718. */
  18719. invertRotation: boolean;
  18720. /**
  18721. * Speed multiplier for inverse camera panning
  18722. */
  18723. inverseRotationSpeed: number;
  18724. /**
  18725. * Define the current target of the camera as an object or a position.
  18726. */
  18727. lockedTarget: any;
  18728. /** @hidden */
  18729. _currentTarget: Vector3;
  18730. /** @hidden */
  18731. _initialFocalDistance: number;
  18732. /** @hidden */
  18733. _viewMatrix: Matrix;
  18734. /** @hidden */
  18735. _camMatrix: Matrix;
  18736. /** @hidden */
  18737. _cameraTransformMatrix: Matrix;
  18738. /** @hidden */
  18739. _cameraRotationMatrix: Matrix;
  18740. /** @hidden */
  18741. _referencePoint: Vector3;
  18742. /** @hidden */
  18743. _transformedReferencePoint: Vector3;
  18744. /** @hidden */
  18745. _reset: () => void;
  18746. private _defaultUp;
  18747. /**
  18748. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18749. * This is the base of the follow, arc rotate cameras and Free camera
  18750. * @see https://doc.babylonjs.com/features/cameras
  18751. * @param name Defines the name of the camera in the scene
  18752. * @param position Defines the start position of the camera in the scene
  18753. * @param scene Defines the scene the camera belongs to
  18754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18755. */
  18756. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18757. /**
  18758. * Gets the position in front of the camera at a given distance.
  18759. * @param distance The distance from the camera we want the position to be
  18760. * @returns the position
  18761. */
  18762. getFrontPosition(distance: number): Vector3;
  18763. /** @hidden */
  18764. _getLockedTargetPosition(): Nullable<Vector3>;
  18765. private _storedPosition;
  18766. private _storedRotation;
  18767. private _storedRotationQuaternion;
  18768. /**
  18769. * Store current camera state of the camera (fov, position, rotation, etc..)
  18770. * @returns the camera
  18771. */
  18772. storeState(): Camera;
  18773. /**
  18774. * Restored camera state. You must call storeState() first
  18775. * @returns whether it was successful or not
  18776. * @hidden
  18777. */
  18778. _restoreStateValues(): boolean;
  18779. /** @hidden */
  18780. _initCache(): void;
  18781. /** @hidden */
  18782. _updateCache(ignoreParentClass?: boolean): void;
  18783. /** @hidden */
  18784. _isSynchronizedViewMatrix(): boolean;
  18785. /** @hidden */
  18786. _computeLocalCameraSpeed(): number;
  18787. /**
  18788. * Defines the target the camera should look at.
  18789. * @param target Defines the new target as a Vector or a mesh
  18790. */
  18791. setTarget(target: Vector3): void;
  18792. /**
  18793. * Return the current target position of the camera. This value is expressed in local space.
  18794. * @returns the target position
  18795. */
  18796. getTarget(): Vector3;
  18797. /** @hidden */
  18798. _decideIfNeedsToMove(): boolean;
  18799. /** @hidden */
  18800. _updatePosition(): void;
  18801. /** @hidden */
  18802. _checkInputs(): void;
  18803. protected _updateCameraRotationMatrix(): void;
  18804. /**
  18805. * 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)
  18806. * @returns the current camera
  18807. */
  18808. private _rotateUpVectorWithCameraRotationMatrix;
  18809. private _cachedRotationZ;
  18810. private _cachedQuaternionRotationZ;
  18811. /** @hidden */
  18812. _getViewMatrix(): Matrix;
  18813. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18814. /**
  18815. * @hidden
  18816. */
  18817. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18818. /**
  18819. * @hidden
  18820. */
  18821. _updateRigCameras(): void;
  18822. private _getRigCamPositionAndTarget;
  18823. /**
  18824. * Gets the current object class name.
  18825. * @return the class name
  18826. */
  18827. getClassName(): string;
  18828. }
  18829. }
  18830. declare module "babylonjs/Events/keyboardEvents" {
  18831. /**
  18832. * Gather the list of keyboard event types as constants.
  18833. */
  18834. export class KeyboardEventTypes {
  18835. /**
  18836. * The keydown event is fired when a key becomes active (pressed).
  18837. */
  18838. static readonly KEYDOWN: number;
  18839. /**
  18840. * The keyup event is fired when a key has been released.
  18841. */
  18842. static readonly KEYUP: number;
  18843. }
  18844. /**
  18845. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18846. */
  18847. export class KeyboardInfo {
  18848. /**
  18849. * Defines the type of event (KeyboardEventTypes)
  18850. */
  18851. type: number;
  18852. /**
  18853. * Defines the related dom event
  18854. */
  18855. event: KeyboardEvent;
  18856. /**
  18857. * Instantiates a new keyboard info.
  18858. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18859. * @param type Defines the type of event (KeyboardEventTypes)
  18860. * @param event Defines the related dom event
  18861. */
  18862. constructor(
  18863. /**
  18864. * Defines the type of event (KeyboardEventTypes)
  18865. */
  18866. type: number,
  18867. /**
  18868. * Defines the related dom event
  18869. */
  18870. event: KeyboardEvent);
  18871. }
  18872. /**
  18873. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18874. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18875. */
  18876. export class KeyboardInfoPre extends KeyboardInfo {
  18877. /**
  18878. * Defines the type of event (KeyboardEventTypes)
  18879. */
  18880. type: number;
  18881. /**
  18882. * Defines the related dom event
  18883. */
  18884. event: KeyboardEvent;
  18885. /**
  18886. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18887. */
  18888. skipOnPointerObservable: boolean;
  18889. /**
  18890. * Instantiates a new keyboard pre info.
  18891. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18892. * @param type Defines the type of event (KeyboardEventTypes)
  18893. * @param event Defines the related dom event
  18894. */
  18895. constructor(
  18896. /**
  18897. * Defines the type of event (KeyboardEventTypes)
  18898. */
  18899. type: number,
  18900. /**
  18901. * Defines the related dom event
  18902. */
  18903. event: KeyboardEvent);
  18904. }
  18905. }
  18906. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18907. import { Nullable } from "babylonjs/types";
  18908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18909. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18910. /**
  18911. * Manage the keyboard inputs to control the movement of a free camera.
  18912. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18913. */
  18914. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18915. /**
  18916. * Defines the camera the input is attached to.
  18917. */
  18918. camera: FreeCamera;
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18921. */
  18922. keysUp: number[];
  18923. /**
  18924. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18925. */
  18926. keysUpward: number[];
  18927. /**
  18928. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18929. */
  18930. keysDown: number[];
  18931. /**
  18932. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18933. */
  18934. keysDownward: number[];
  18935. /**
  18936. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18937. */
  18938. keysLeft: number[];
  18939. /**
  18940. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18941. */
  18942. keysRight: number[];
  18943. private _keys;
  18944. private _onCanvasBlurObserver;
  18945. private _onKeyboardObserver;
  18946. private _engine;
  18947. private _scene;
  18948. /**
  18949. * Attach the input controls to a specific dom element to get the input from.
  18950. * @param element Defines the element the controls should be listened from
  18951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18952. */
  18953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18954. /**
  18955. * Detach the current controls from the specified dom element.
  18956. * @param element Defines the element to stop listening the inputs from
  18957. */
  18958. detachControl(element: Nullable<HTMLElement>): void;
  18959. /**
  18960. * Update the current camera state depending on the inputs that have been used this frame.
  18961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18962. */
  18963. checkInputs(): void;
  18964. /**
  18965. * Gets the class name of the current intput.
  18966. * @returns the class name
  18967. */
  18968. getClassName(): string;
  18969. /** @hidden */
  18970. _onLostFocus(): void;
  18971. /**
  18972. * Get the friendly name associated with the input class.
  18973. * @returns the input friendly name
  18974. */
  18975. getSimpleName(): string;
  18976. }
  18977. }
  18978. declare module "babylonjs/Events/pointerEvents" {
  18979. import { Nullable } from "babylonjs/types";
  18980. import { Vector2 } from "babylonjs/Maths/math.vector";
  18981. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18982. import { Ray } from "babylonjs/Culling/ray";
  18983. /**
  18984. * Gather the list of pointer event types as constants.
  18985. */
  18986. export class PointerEventTypes {
  18987. /**
  18988. * 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.
  18989. */
  18990. static readonly POINTERDOWN: number;
  18991. /**
  18992. * The pointerup event is fired when a pointer is no longer active.
  18993. */
  18994. static readonly POINTERUP: number;
  18995. /**
  18996. * The pointermove event is fired when a pointer changes coordinates.
  18997. */
  18998. static readonly POINTERMOVE: number;
  18999. /**
  19000. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19001. */
  19002. static readonly POINTERWHEEL: number;
  19003. /**
  19004. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19005. */
  19006. static readonly POINTERPICK: number;
  19007. /**
  19008. * The pointertap event is fired when a the object has been touched and released without drag.
  19009. */
  19010. static readonly POINTERTAP: number;
  19011. /**
  19012. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19013. */
  19014. static readonly POINTERDOUBLETAP: number;
  19015. }
  19016. /**
  19017. * Base class of pointer info types.
  19018. */
  19019. export class PointerInfoBase {
  19020. /**
  19021. * Defines the type of event (PointerEventTypes)
  19022. */
  19023. type: number;
  19024. /**
  19025. * Defines the related dom event
  19026. */
  19027. event: PointerEvent | MouseWheelEvent;
  19028. /**
  19029. * Instantiates the base class of pointers info.
  19030. * @param type Defines the type of event (PointerEventTypes)
  19031. * @param event Defines the related dom event
  19032. */
  19033. constructor(
  19034. /**
  19035. * Defines the type of event (PointerEventTypes)
  19036. */
  19037. type: number,
  19038. /**
  19039. * Defines the related dom event
  19040. */
  19041. event: PointerEvent | MouseWheelEvent);
  19042. }
  19043. /**
  19044. * This class is used to store pointer related info for the onPrePointerObservable event.
  19045. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19046. */
  19047. export class PointerInfoPre extends PointerInfoBase {
  19048. /**
  19049. * Ray from a pointer if availible (eg. 6dof controller)
  19050. */
  19051. ray: Nullable<Ray>;
  19052. /**
  19053. * Defines the local position of the pointer on the canvas.
  19054. */
  19055. localPosition: Vector2;
  19056. /**
  19057. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19058. */
  19059. skipOnPointerObservable: boolean;
  19060. /**
  19061. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19062. * @param type Defines the type of event (PointerEventTypes)
  19063. * @param event Defines the related dom event
  19064. * @param localX Defines the local x coordinates of the pointer when the event occured
  19065. * @param localY Defines the local y coordinates of the pointer when the event occured
  19066. */
  19067. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19068. }
  19069. /**
  19070. * This type contains all the data related to a pointer event in Babylon.js.
  19071. * 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.
  19072. */
  19073. export class PointerInfo extends PointerInfoBase {
  19074. /**
  19075. * Defines the picking info associated to the info (if any)\
  19076. */
  19077. pickInfo: Nullable<PickingInfo>;
  19078. /**
  19079. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19080. * @param type Defines the type of event (PointerEventTypes)
  19081. * @param event Defines the related dom event
  19082. * @param pickInfo Defines the picking info associated to the info (if any)\
  19083. */
  19084. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19085. /**
  19086. * Defines the picking info associated to the info (if any)\
  19087. */
  19088. pickInfo: Nullable<PickingInfo>);
  19089. }
  19090. /**
  19091. * Data relating to a touch event on the screen.
  19092. */
  19093. export interface PointerTouch {
  19094. /**
  19095. * X coordinate of touch.
  19096. */
  19097. x: number;
  19098. /**
  19099. * Y coordinate of touch.
  19100. */
  19101. y: number;
  19102. /**
  19103. * Id of touch. Unique for each finger.
  19104. */
  19105. pointerId: number;
  19106. /**
  19107. * Event type passed from DOM.
  19108. */
  19109. type: any;
  19110. }
  19111. }
  19112. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19113. import { Observable } from "babylonjs/Misc/observable";
  19114. import { Nullable } from "babylonjs/types";
  19115. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19116. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19117. /**
  19118. * Manage the mouse inputs to control the movement of a free camera.
  19119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19120. */
  19121. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19122. /**
  19123. * Define if touch is enabled in the mouse input
  19124. */
  19125. touchEnabled: boolean;
  19126. /**
  19127. * Defines the camera the input is attached to.
  19128. */
  19129. camera: FreeCamera;
  19130. /**
  19131. * Defines the buttons associated with the input to handle camera move.
  19132. */
  19133. buttons: number[];
  19134. /**
  19135. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19136. */
  19137. angularSensibility: number;
  19138. private _pointerInput;
  19139. private _onMouseMove;
  19140. private _observer;
  19141. private previousPosition;
  19142. /**
  19143. * Observable for when a pointer move event occurs containing the move offset
  19144. */
  19145. onPointerMovedObservable: Observable<{
  19146. offsetX: number;
  19147. offsetY: number;
  19148. }>;
  19149. /**
  19150. * @hidden
  19151. * If the camera should be rotated automatically based on pointer movement
  19152. */
  19153. _allowCameraRotation: boolean;
  19154. /**
  19155. * Manage the mouse inputs to control the movement of a free camera.
  19156. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19157. * @param touchEnabled Defines if touch is enabled or not
  19158. */
  19159. constructor(
  19160. /**
  19161. * Define if touch is enabled in the mouse input
  19162. */
  19163. touchEnabled?: boolean);
  19164. /**
  19165. * Attach the input controls to a specific dom element to get the input from.
  19166. * @param element Defines the element the controls should be listened from
  19167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19168. */
  19169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19170. /**
  19171. * Called on JS contextmenu event.
  19172. * Override this method to provide functionality.
  19173. */
  19174. protected onContextMenu(evt: PointerEvent): void;
  19175. /**
  19176. * Detach the current controls from the specified dom element.
  19177. * @param element Defines the element to stop listening the inputs from
  19178. */
  19179. detachControl(element: Nullable<HTMLElement>): void;
  19180. /**
  19181. * Gets the class name of the current intput.
  19182. * @returns the class name
  19183. */
  19184. getClassName(): string;
  19185. /**
  19186. * Get the friendly name associated with the input class.
  19187. * @returns the input friendly name
  19188. */
  19189. getSimpleName(): string;
  19190. }
  19191. }
  19192. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19193. import { Nullable } from "babylonjs/types";
  19194. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19195. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19196. /**
  19197. * Manage the touch inputs to control the movement of a free camera.
  19198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19199. */
  19200. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19201. /**
  19202. * Defines the camera the input is attached to.
  19203. */
  19204. camera: FreeCamera;
  19205. /**
  19206. * Defines the touch sensibility for rotation.
  19207. * The higher the faster.
  19208. */
  19209. touchAngularSensibility: number;
  19210. /**
  19211. * Defines the touch sensibility for move.
  19212. * The higher the faster.
  19213. */
  19214. touchMoveSensibility: number;
  19215. private _offsetX;
  19216. private _offsetY;
  19217. private _pointerPressed;
  19218. private _pointerInput;
  19219. private _observer;
  19220. private _onLostFocus;
  19221. /**
  19222. * Attach the input controls to a specific dom element to get the input from.
  19223. * @param element Defines the element the controls should be listened from
  19224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19225. */
  19226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19227. /**
  19228. * Detach the current controls from the specified dom element.
  19229. * @param element Defines the element to stop listening the inputs from
  19230. */
  19231. detachControl(element: Nullable<HTMLElement>): void;
  19232. /**
  19233. * Update the current camera state depending on the inputs that have been used this frame.
  19234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19235. */
  19236. checkInputs(): void;
  19237. /**
  19238. * Gets the class name of the current intput.
  19239. * @returns the class name
  19240. */
  19241. getClassName(): string;
  19242. /**
  19243. * Get the friendly name associated with the input class.
  19244. * @returns the input friendly name
  19245. */
  19246. getSimpleName(): string;
  19247. }
  19248. }
  19249. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19250. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19251. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19252. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19253. import { Nullable } from "babylonjs/types";
  19254. /**
  19255. * Default Inputs manager for the FreeCamera.
  19256. * It groups all the default supported inputs for ease of use.
  19257. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19258. */
  19259. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19260. /**
  19261. * @hidden
  19262. */
  19263. _mouseInput: Nullable<FreeCameraMouseInput>;
  19264. /**
  19265. * Instantiates a new FreeCameraInputsManager.
  19266. * @param camera Defines the camera the inputs belong to
  19267. */
  19268. constructor(camera: FreeCamera);
  19269. /**
  19270. * Add keyboard input support to the input manager.
  19271. * @returns the current input manager
  19272. */
  19273. addKeyboard(): FreeCameraInputsManager;
  19274. /**
  19275. * Add mouse input support to the input manager.
  19276. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19277. * @returns the current input manager
  19278. */
  19279. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19280. /**
  19281. * Removes the mouse input support from the manager
  19282. * @returns the current input manager
  19283. */
  19284. removeMouse(): FreeCameraInputsManager;
  19285. /**
  19286. * Add touch input support to the input manager.
  19287. * @returns the current input manager
  19288. */
  19289. addTouch(): FreeCameraInputsManager;
  19290. /**
  19291. * Remove all attached input methods from a camera
  19292. */
  19293. clear(): void;
  19294. }
  19295. }
  19296. declare module "babylonjs/Cameras/freeCamera" {
  19297. import { Vector3 } from "babylonjs/Maths/math.vector";
  19298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19299. import { Scene } from "babylonjs/scene";
  19300. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19301. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19302. /**
  19303. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19304. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19305. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19306. */
  19307. export class FreeCamera extends TargetCamera {
  19308. /**
  19309. * Define the collision ellipsoid of the camera.
  19310. * This is helpful to simulate a camera body like the player body around the camera
  19311. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19312. */
  19313. ellipsoid: Vector3;
  19314. /**
  19315. * Define an offset for the position of the ellipsoid around the camera.
  19316. * This can be helpful to determine the center of the body near the gravity center of the body
  19317. * instead of its head.
  19318. */
  19319. ellipsoidOffset: Vector3;
  19320. /**
  19321. * Enable or disable collisions of the camera with the rest of the scene objects.
  19322. */
  19323. checkCollisions: boolean;
  19324. /**
  19325. * Enable or disable gravity on the camera.
  19326. */
  19327. applyGravity: boolean;
  19328. /**
  19329. * Define the input manager associated to the camera.
  19330. */
  19331. inputs: FreeCameraInputsManager;
  19332. /**
  19333. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19334. * Higher values reduce sensitivity.
  19335. */
  19336. get angularSensibility(): number;
  19337. /**
  19338. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19339. * Higher values reduce sensitivity.
  19340. */
  19341. set angularSensibility(value: number);
  19342. /**
  19343. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19344. */
  19345. get keysUp(): number[];
  19346. set keysUp(value: number[]);
  19347. /**
  19348. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19349. */
  19350. get keysUpward(): number[];
  19351. set keysUpward(value: number[]);
  19352. /**
  19353. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19354. */
  19355. get keysDown(): number[];
  19356. set keysDown(value: number[]);
  19357. /**
  19358. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19359. */
  19360. get keysDownward(): number[];
  19361. set keysDownward(value: number[]);
  19362. /**
  19363. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19364. */
  19365. get keysLeft(): number[];
  19366. set keysLeft(value: number[]);
  19367. /**
  19368. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19369. */
  19370. get keysRight(): number[];
  19371. set keysRight(value: number[]);
  19372. /**
  19373. * Event raised when the camera collide with a mesh in the scene.
  19374. */
  19375. onCollide: (collidedMesh: AbstractMesh) => void;
  19376. private _collider;
  19377. private _needMoveForGravity;
  19378. private _oldPosition;
  19379. private _diffPosition;
  19380. private _newPosition;
  19381. /** @hidden */
  19382. _localDirection: Vector3;
  19383. /** @hidden */
  19384. _transformedDirection: Vector3;
  19385. /**
  19386. * Instantiates a Free Camera.
  19387. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19388. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19389. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19390. * @param name Define the name of the camera in the scene
  19391. * @param position Define the start position of the camera in the scene
  19392. * @param scene Define the scene the camera belongs to
  19393. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19394. */
  19395. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19396. /**
  19397. * Attached controls to the current camera.
  19398. * @param element Defines the element the controls should be listened from
  19399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19400. */
  19401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19402. /**
  19403. * Detach the current controls from the camera.
  19404. * The camera will stop reacting to inputs.
  19405. * @param element Defines the element to stop listening the inputs from
  19406. */
  19407. detachControl(element: HTMLElement): void;
  19408. private _collisionMask;
  19409. /**
  19410. * Define a collision mask to limit the list of object the camera can collide with
  19411. */
  19412. get collisionMask(): number;
  19413. set collisionMask(mask: number);
  19414. /** @hidden */
  19415. _collideWithWorld(displacement: Vector3): void;
  19416. private _onCollisionPositionChange;
  19417. /** @hidden */
  19418. _checkInputs(): void;
  19419. /** @hidden */
  19420. _decideIfNeedsToMove(): boolean;
  19421. /** @hidden */
  19422. _updatePosition(): void;
  19423. /**
  19424. * Destroy the camera and release the current resources hold by it.
  19425. */
  19426. dispose(): void;
  19427. /**
  19428. * Gets the current object class name.
  19429. * @return the class name
  19430. */
  19431. getClassName(): string;
  19432. }
  19433. }
  19434. declare module "babylonjs/Gamepads/gamepad" {
  19435. import { Observable } from "babylonjs/Misc/observable";
  19436. /**
  19437. * Represents a gamepad control stick position
  19438. */
  19439. export class StickValues {
  19440. /**
  19441. * The x component of the control stick
  19442. */
  19443. x: number;
  19444. /**
  19445. * The y component of the control stick
  19446. */
  19447. y: number;
  19448. /**
  19449. * Initializes the gamepad x and y control stick values
  19450. * @param x The x component of the gamepad control stick value
  19451. * @param y The y component of the gamepad control stick value
  19452. */
  19453. constructor(
  19454. /**
  19455. * The x component of the control stick
  19456. */
  19457. x: number,
  19458. /**
  19459. * The y component of the control stick
  19460. */
  19461. y: number);
  19462. }
  19463. /**
  19464. * An interface which manages callbacks for gamepad button changes
  19465. */
  19466. export interface GamepadButtonChanges {
  19467. /**
  19468. * Called when a gamepad has been changed
  19469. */
  19470. changed: boolean;
  19471. /**
  19472. * Called when a gamepad press event has been triggered
  19473. */
  19474. pressChanged: boolean;
  19475. /**
  19476. * Called when a touch event has been triggered
  19477. */
  19478. touchChanged: boolean;
  19479. /**
  19480. * Called when a value has changed
  19481. */
  19482. valueChanged: boolean;
  19483. }
  19484. /**
  19485. * Represents a gamepad
  19486. */
  19487. export class Gamepad {
  19488. /**
  19489. * The id of the gamepad
  19490. */
  19491. id: string;
  19492. /**
  19493. * The index of the gamepad
  19494. */
  19495. index: number;
  19496. /**
  19497. * The browser gamepad
  19498. */
  19499. browserGamepad: any;
  19500. /**
  19501. * Specifies what type of gamepad this represents
  19502. */
  19503. type: number;
  19504. private _leftStick;
  19505. private _rightStick;
  19506. /** @hidden */
  19507. _isConnected: boolean;
  19508. private _leftStickAxisX;
  19509. private _leftStickAxisY;
  19510. private _rightStickAxisX;
  19511. private _rightStickAxisY;
  19512. /**
  19513. * Triggered when the left control stick has been changed
  19514. */
  19515. private _onleftstickchanged;
  19516. /**
  19517. * Triggered when the right control stick has been changed
  19518. */
  19519. private _onrightstickchanged;
  19520. /**
  19521. * Represents a gamepad controller
  19522. */
  19523. static GAMEPAD: number;
  19524. /**
  19525. * Represents a generic controller
  19526. */
  19527. static GENERIC: number;
  19528. /**
  19529. * Represents an XBox controller
  19530. */
  19531. static XBOX: number;
  19532. /**
  19533. * Represents a pose-enabled controller
  19534. */
  19535. static POSE_ENABLED: number;
  19536. /**
  19537. * Represents an Dual Shock controller
  19538. */
  19539. static DUALSHOCK: number;
  19540. /**
  19541. * Specifies whether the left control stick should be Y-inverted
  19542. */
  19543. protected _invertLeftStickY: boolean;
  19544. /**
  19545. * Specifies if the gamepad has been connected
  19546. */
  19547. get isConnected(): boolean;
  19548. /**
  19549. * Initializes the gamepad
  19550. * @param id The id of the gamepad
  19551. * @param index The index of the gamepad
  19552. * @param browserGamepad The browser gamepad
  19553. * @param leftStickX The x component of the left joystick
  19554. * @param leftStickY The y component of the left joystick
  19555. * @param rightStickX The x component of the right joystick
  19556. * @param rightStickY The y component of the right joystick
  19557. */
  19558. constructor(
  19559. /**
  19560. * The id of the gamepad
  19561. */
  19562. id: string,
  19563. /**
  19564. * The index of the gamepad
  19565. */
  19566. index: number,
  19567. /**
  19568. * The browser gamepad
  19569. */
  19570. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19571. /**
  19572. * Callback triggered when the left joystick has changed
  19573. * @param callback
  19574. */
  19575. onleftstickchanged(callback: (values: StickValues) => void): void;
  19576. /**
  19577. * Callback triggered when the right joystick has changed
  19578. * @param callback
  19579. */
  19580. onrightstickchanged(callback: (values: StickValues) => void): void;
  19581. /**
  19582. * Gets the left joystick
  19583. */
  19584. get leftStick(): StickValues;
  19585. /**
  19586. * Sets the left joystick values
  19587. */
  19588. set leftStick(newValues: StickValues);
  19589. /**
  19590. * Gets the right joystick
  19591. */
  19592. get rightStick(): StickValues;
  19593. /**
  19594. * Sets the right joystick value
  19595. */
  19596. set rightStick(newValues: StickValues);
  19597. /**
  19598. * Updates the gamepad joystick positions
  19599. */
  19600. update(): void;
  19601. /**
  19602. * Disposes the gamepad
  19603. */
  19604. dispose(): void;
  19605. }
  19606. /**
  19607. * Represents a generic gamepad
  19608. */
  19609. export class GenericPad extends Gamepad {
  19610. private _buttons;
  19611. private _onbuttondown;
  19612. private _onbuttonup;
  19613. /**
  19614. * Observable triggered when a button has been pressed
  19615. */
  19616. onButtonDownObservable: Observable<number>;
  19617. /**
  19618. * Observable triggered when a button has been released
  19619. */
  19620. onButtonUpObservable: Observable<number>;
  19621. /**
  19622. * Callback triggered when a button has been pressed
  19623. * @param callback Called when a button has been pressed
  19624. */
  19625. onbuttondown(callback: (buttonPressed: number) => void): void;
  19626. /**
  19627. * Callback triggered when a button has been released
  19628. * @param callback Called when a button has been released
  19629. */
  19630. onbuttonup(callback: (buttonReleased: number) => void): void;
  19631. /**
  19632. * Initializes the generic gamepad
  19633. * @param id The id of the generic gamepad
  19634. * @param index The index of the generic gamepad
  19635. * @param browserGamepad The browser gamepad
  19636. */
  19637. constructor(id: string, index: number, browserGamepad: any);
  19638. private _setButtonValue;
  19639. /**
  19640. * Updates the generic gamepad
  19641. */
  19642. update(): void;
  19643. /**
  19644. * Disposes the generic gamepad
  19645. */
  19646. dispose(): void;
  19647. }
  19648. }
  19649. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19650. import { Observable } from "babylonjs/Misc/observable";
  19651. import { Nullable } from "babylonjs/types";
  19652. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19653. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19655. import { Ray } from "babylonjs/Culling/ray";
  19656. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19657. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19658. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19659. /**
  19660. * Defines the types of pose enabled controllers that are supported
  19661. */
  19662. export enum PoseEnabledControllerType {
  19663. /**
  19664. * HTC Vive
  19665. */
  19666. VIVE = 0,
  19667. /**
  19668. * Oculus Rift
  19669. */
  19670. OCULUS = 1,
  19671. /**
  19672. * Windows mixed reality
  19673. */
  19674. WINDOWS = 2,
  19675. /**
  19676. * Samsung gear VR
  19677. */
  19678. GEAR_VR = 3,
  19679. /**
  19680. * Google Daydream
  19681. */
  19682. DAYDREAM = 4,
  19683. /**
  19684. * Generic
  19685. */
  19686. GENERIC = 5
  19687. }
  19688. /**
  19689. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19690. */
  19691. export interface MutableGamepadButton {
  19692. /**
  19693. * Value of the button/trigger
  19694. */
  19695. value: number;
  19696. /**
  19697. * If the button/trigger is currently touched
  19698. */
  19699. touched: boolean;
  19700. /**
  19701. * If the button/trigger is currently pressed
  19702. */
  19703. pressed: boolean;
  19704. }
  19705. /**
  19706. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19707. * @hidden
  19708. */
  19709. export interface ExtendedGamepadButton extends GamepadButton {
  19710. /**
  19711. * If the button/trigger is currently pressed
  19712. */
  19713. readonly pressed: boolean;
  19714. /**
  19715. * If the button/trigger is currently touched
  19716. */
  19717. readonly touched: boolean;
  19718. /**
  19719. * Value of the button/trigger
  19720. */
  19721. readonly value: number;
  19722. }
  19723. /** @hidden */
  19724. export interface _GamePadFactory {
  19725. /**
  19726. * Returns whether or not the current gamepad can be created for this type of controller.
  19727. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19728. * @returns true if it can be created, otherwise false
  19729. */
  19730. canCreate(gamepadInfo: any): boolean;
  19731. /**
  19732. * Creates a new instance of the Gamepad.
  19733. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19734. * @returns the new gamepad instance
  19735. */
  19736. create(gamepadInfo: any): Gamepad;
  19737. }
  19738. /**
  19739. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19740. */
  19741. export class PoseEnabledControllerHelper {
  19742. /** @hidden */
  19743. static _ControllerFactories: _GamePadFactory[];
  19744. /** @hidden */
  19745. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19746. /**
  19747. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19748. * @param vrGamepad the gamepad to initialized
  19749. * @returns a vr controller of the type the gamepad identified as
  19750. */
  19751. static InitiateController(vrGamepad: any): Gamepad;
  19752. }
  19753. /**
  19754. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19755. */
  19756. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19757. /**
  19758. * If the controller is used in a webXR session
  19759. */
  19760. isXR: boolean;
  19761. private _deviceRoomPosition;
  19762. private _deviceRoomRotationQuaternion;
  19763. /**
  19764. * The device position in babylon space
  19765. */
  19766. devicePosition: Vector3;
  19767. /**
  19768. * The device rotation in babylon space
  19769. */
  19770. deviceRotationQuaternion: Quaternion;
  19771. /**
  19772. * The scale factor of the device in babylon space
  19773. */
  19774. deviceScaleFactor: number;
  19775. /**
  19776. * (Likely devicePosition should be used instead) The device position in its room space
  19777. */
  19778. position: Vector3;
  19779. /**
  19780. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19781. */
  19782. rotationQuaternion: Quaternion;
  19783. /**
  19784. * The type of controller (Eg. Windows mixed reality)
  19785. */
  19786. controllerType: PoseEnabledControllerType;
  19787. protected _calculatedPosition: Vector3;
  19788. private _calculatedRotation;
  19789. /**
  19790. * The raw pose from the device
  19791. */
  19792. rawPose: DevicePose;
  19793. private _trackPosition;
  19794. private _maxRotationDistFromHeadset;
  19795. private _draggedRoomRotation;
  19796. /**
  19797. * @hidden
  19798. */
  19799. _disableTrackPosition(fixedPosition: Vector3): void;
  19800. /**
  19801. * Internal, the mesh attached to the controller
  19802. * @hidden
  19803. */
  19804. _mesh: Nullable<AbstractMesh>;
  19805. private _poseControlledCamera;
  19806. private _leftHandSystemQuaternion;
  19807. /**
  19808. * Internal, matrix used to convert room space to babylon space
  19809. * @hidden
  19810. */
  19811. _deviceToWorld: Matrix;
  19812. /**
  19813. * Node to be used when casting a ray from the controller
  19814. * @hidden
  19815. */
  19816. _pointingPoseNode: Nullable<TransformNode>;
  19817. /**
  19818. * Name of the child mesh that can be used to cast a ray from the controller
  19819. */
  19820. static readonly POINTING_POSE: string;
  19821. /**
  19822. * Creates a new PoseEnabledController from a gamepad
  19823. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19824. */
  19825. constructor(browserGamepad: any);
  19826. private _workingMatrix;
  19827. /**
  19828. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19829. */
  19830. update(): void;
  19831. /**
  19832. * Updates only the pose device and mesh without doing any button event checking
  19833. */
  19834. protected _updatePoseAndMesh(): void;
  19835. /**
  19836. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19837. * @param poseData raw pose fromthe device
  19838. */
  19839. updateFromDevice(poseData: DevicePose): void;
  19840. /**
  19841. * @hidden
  19842. */
  19843. _meshAttachedObservable: Observable<AbstractMesh>;
  19844. /**
  19845. * Attaches a mesh to the controller
  19846. * @param mesh the mesh to be attached
  19847. */
  19848. attachToMesh(mesh: AbstractMesh): void;
  19849. /**
  19850. * Attaches the controllers mesh to a camera
  19851. * @param camera the camera the mesh should be attached to
  19852. */
  19853. attachToPoseControlledCamera(camera: TargetCamera): void;
  19854. /**
  19855. * Disposes of the controller
  19856. */
  19857. dispose(): void;
  19858. /**
  19859. * The mesh that is attached to the controller
  19860. */
  19861. get mesh(): Nullable<AbstractMesh>;
  19862. /**
  19863. * Gets the ray of the controller in the direction the controller is pointing
  19864. * @param length the length the resulting ray should be
  19865. * @returns a ray in the direction the controller is pointing
  19866. */
  19867. getForwardRay(length?: number): Ray;
  19868. }
  19869. }
  19870. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19871. import { Observable } from "babylonjs/Misc/observable";
  19872. import { Scene } from "babylonjs/scene";
  19873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19874. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19875. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19876. import { Nullable } from "babylonjs/types";
  19877. /**
  19878. * Defines the WebVRController object that represents controllers tracked in 3D space
  19879. */
  19880. export abstract class WebVRController extends PoseEnabledController {
  19881. /**
  19882. * Internal, the default controller model for the controller
  19883. */
  19884. protected _defaultModel: Nullable<AbstractMesh>;
  19885. /**
  19886. * Fired when the trigger state has changed
  19887. */
  19888. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19889. /**
  19890. * Fired when the main button state has changed
  19891. */
  19892. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19893. /**
  19894. * Fired when the secondary button state has changed
  19895. */
  19896. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19897. /**
  19898. * Fired when the pad state has changed
  19899. */
  19900. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19901. /**
  19902. * Fired when controllers stick values have changed
  19903. */
  19904. onPadValuesChangedObservable: Observable<StickValues>;
  19905. /**
  19906. * Array of button availible on the controller
  19907. */
  19908. protected _buttons: Array<MutableGamepadButton>;
  19909. private _onButtonStateChange;
  19910. /**
  19911. * Fired when a controller button's state has changed
  19912. * @param callback the callback containing the button that was modified
  19913. */
  19914. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19915. /**
  19916. * X and Y axis corresponding to the controllers joystick
  19917. */
  19918. pad: StickValues;
  19919. /**
  19920. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19921. */
  19922. hand: string;
  19923. /**
  19924. * The default controller model for the controller
  19925. */
  19926. get defaultModel(): Nullable<AbstractMesh>;
  19927. /**
  19928. * Creates a new WebVRController from a gamepad
  19929. * @param vrGamepad the gamepad that the WebVRController should be created from
  19930. */
  19931. constructor(vrGamepad: any);
  19932. /**
  19933. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19934. */
  19935. update(): void;
  19936. /**
  19937. * Function to be called when a button is modified
  19938. */
  19939. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19940. /**
  19941. * Loads a mesh and attaches it to the controller
  19942. * @param scene the scene the mesh should be added to
  19943. * @param meshLoaded callback for when the mesh has been loaded
  19944. */
  19945. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19946. private _setButtonValue;
  19947. private _changes;
  19948. private _checkChanges;
  19949. /**
  19950. * Disposes of th webVRCOntroller
  19951. */
  19952. dispose(): void;
  19953. }
  19954. }
  19955. declare module "babylonjs/Lights/hemisphericLight" {
  19956. import { Nullable } from "babylonjs/types";
  19957. import { Scene } from "babylonjs/scene";
  19958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19959. import { Color3 } from "babylonjs/Maths/math.color";
  19960. import { Effect } from "babylonjs/Materials/effect";
  19961. import { Light } from "babylonjs/Lights/light";
  19962. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19963. /**
  19964. * The HemisphericLight simulates the ambient environment light,
  19965. * so the passed direction is the light reflection direction, not the incoming direction.
  19966. */
  19967. export class HemisphericLight extends Light {
  19968. /**
  19969. * The groundColor is the light in the opposite direction to the one specified during creation.
  19970. * 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.
  19971. */
  19972. groundColor: Color3;
  19973. /**
  19974. * The light reflection direction, not the incoming direction.
  19975. */
  19976. direction: Vector3;
  19977. /**
  19978. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19979. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19980. * The HemisphericLight can't cast shadows.
  19981. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19982. * @param name The friendly name of the light
  19983. * @param direction The direction of the light reflection
  19984. * @param scene The scene the light belongs to
  19985. */
  19986. constructor(name: string, direction: Vector3, scene: Scene);
  19987. protected _buildUniformLayout(): void;
  19988. /**
  19989. * Returns the string "HemisphericLight".
  19990. * @return The class name
  19991. */
  19992. getClassName(): string;
  19993. /**
  19994. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19995. * Returns the updated direction.
  19996. * @param target The target the direction should point to
  19997. * @return The computed direction
  19998. */
  19999. setDirectionToTarget(target: Vector3): Vector3;
  20000. /**
  20001. * Returns the shadow generator associated to the light.
  20002. * @returns Always null for hemispheric lights because it does not support shadows.
  20003. */
  20004. getShadowGenerator(): Nullable<IShadowGenerator>;
  20005. /**
  20006. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20007. * @param effect The effect to update
  20008. * @param lightIndex The index of the light in the effect to update
  20009. * @returns The hemispheric light
  20010. */
  20011. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20012. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20013. /**
  20014. * Computes the world matrix of the node
  20015. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20016. * @param useWasUpdatedFlag defines a reserved property
  20017. * @returns the world matrix
  20018. */
  20019. computeWorldMatrix(): Matrix;
  20020. /**
  20021. * Returns the integer 3.
  20022. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20023. */
  20024. getTypeID(): number;
  20025. /**
  20026. * Prepares the list of defines specific to the light type.
  20027. * @param defines the list of defines
  20028. * @param lightIndex defines the index of the light for the effect
  20029. */
  20030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20031. }
  20032. }
  20033. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20034. /** @hidden */
  20035. export var vrMultiviewToSingleviewPixelShader: {
  20036. name: string;
  20037. shader: string;
  20038. };
  20039. }
  20040. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20042. import { Scene } from "babylonjs/scene";
  20043. /**
  20044. * Renders to multiple views with a single draw call
  20045. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20046. */
  20047. export class MultiviewRenderTarget extends RenderTargetTexture {
  20048. /**
  20049. * Creates a multiview render target
  20050. * @param scene scene used with the render target
  20051. * @param size the size of the render target (used for each view)
  20052. */
  20053. constructor(scene: Scene, size?: number | {
  20054. width: number;
  20055. height: number;
  20056. } | {
  20057. ratio: number;
  20058. });
  20059. /**
  20060. * @hidden
  20061. * @param faceIndex the face index, if its a cube texture
  20062. */
  20063. _bindFrameBuffer(faceIndex?: number): void;
  20064. /**
  20065. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20066. * @returns the view count
  20067. */
  20068. getViewCount(): number;
  20069. }
  20070. }
  20071. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20072. import { Camera } from "babylonjs/Cameras/camera";
  20073. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20074. import { Nullable } from "babylonjs/types";
  20075. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20076. import { Matrix } from "babylonjs/Maths/math.vector";
  20077. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20078. module "babylonjs/Engines/engine" {
  20079. interface Engine {
  20080. /**
  20081. * Creates a new multiview render target
  20082. * @param width defines the width of the texture
  20083. * @param height defines the height of the texture
  20084. * @returns the created multiview texture
  20085. */
  20086. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20087. /**
  20088. * Binds a multiview framebuffer to be drawn to
  20089. * @param multiviewTexture texture to bind
  20090. */
  20091. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20092. }
  20093. }
  20094. module "babylonjs/Cameras/camera" {
  20095. interface Camera {
  20096. /**
  20097. * @hidden
  20098. * 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)
  20099. */
  20100. _useMultiviewToSingleView: boolean;
  20101. /**
  20102. * @hidden
  20103. * 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)
  20104. */
  20105. _multiviewTexture: Nullable<RenderTargetTexture>;
  20106. /**
  20107. * @hidden
  20108. * ensures the multiview texture of the camera exists and has the specified width/height
  20109. * @param width height to set on the multiview texture
  20110. * @param height width to set on the multiview texture
  20111. */
  20112. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20113. }
  20114. }
  20115. module "babylonjs/scene" {
  20116. interface Scene {
  20117. /** @hidden */
  20118. _transformMatrixR: Matrix;
  20119. /** @hidden */
  20120. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20121. /** @hidden */
  20122. _createMultiviewUbo(): void;
  20123. /** @hidden */
  20124. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20125. /** @hidden */
  20126. _renderMultiviewToSingleView(camera: Camera): void;
  20127. }
  20128. }
  20129. }
  20130. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20131. import { Camera } from "babylonjs/Cameras/camera";
  20132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20133. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20134. import "babylonjs/Engines/Extensions/engine.multiview";
  20135. /**
  20136. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20137. * This will not be used for webXR as it supports displaying texture arrays directly
  20138. */
  20139. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20140. /**
  20141. * Initializes a VRMultiviewToSingleview
  20142. * @param name name of the post process
  20143. * @param camera camera to be applied to
  20144. * @param scaleFactor scaling factor to the size of the output texture
  20145. */
  20146. constructor(name: string, camera: Camera, scaleFactor: number);
  20147. }
  20148. }
  20149. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20150. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20151. import { Nullable } from "babylonjs/types";
  20152. import { Size } from "babylonjs/Maths/math.size";
  20153. import { Observable } from "babylonjs/Misc/observable";
  20154. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20155. /**
  20156. * Interface used to define additional presentation attributes
  20157. */
  20158. export interface IVRPresentationAttributes {
  20159. /**
  20160. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20161. */
  20162. highRefreshRate: boolean;
  20163. /**
  20164. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20165. */
  20166. foveationLevel: number;
  20167. }
  20168. module "babylonjs/Engines/engine" {
  20169. interface Engine {
  20170. /** @hidden */
  20171. _vrDisplay: any;
  20172. /** @hidden */
  20173. _vrSupported: boolean;
  20174. /** @hidden */
  20175. _oldSize: Size;
  20176. /** @hidden */
  20177. _oldHardwareScaleFactor: number;
  20178. /** @hidden */
  20179. _vrExclusivePointerMode: boolean;
  20180. /** @hidden */
  20181. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20182. /** @hidden */
  20183. _onVRDisplayPointerRestricted: () => void;
  20184. /** @hidden */
  20185. _onVRDisplayPointerUnrestricted: () => void;
  20186. /** @hidden */
  20187. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20188. /** @hidden */
  20189. _onVrDisplayDisconnect: Nullable<() => void>;
  20190. /** @hidden */
  20191. _onVrDisplayPresentChange: Nullable<() => void>;
  20192. /**
  20193. * Observable signaled when VR display mode changes
  20194. */
  20195. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20196. /**
  20197. * Observable signaled when VR request present is complete
  20198. */
  20199. onVRRequestPresentComplete: Observable<boolean>;
  20200. /**
  20201. * Observable signaled when VR request present starts
  20202. */
  20203. onVRRequestPresentStart: Observable<Engine>;
  20204. /**
  20205. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20206. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20207. */
  20208. isInVRExclusivePointerMode: boolean;
  20209. /**
  20210. * Gets a boolean indicating if a webVR device was detected
  20211. * @returns true if a webVR device was detected
  20212. */
  20213. isVRDevicePresent(): boolean;
  20214. /**
  20215. * Gets the current webVR device
  20216. * @returns the current webVR device (or null)
  20217. */
  20218. getVRDevice(): any;
  20219. /**
  20220. * Initializes a webVR display and starts listening to display change events
  20221. * The onVRDisplayChangedObservable will be notified upon these changes
  20222. * @returns A promise containing a VRDisplay and if vr is supported
  20223. */
  20224. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20225. /** @hidden */
  20226. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20227. /**
  20228. * Gets or sets the presentation attributes used to configure VR rendering
  20229. */
  20230. vrPresentationAttributes?: IVRPresentationAttributes;
  20231. /**
  20232. * Call this function to switch to webVR mode
  20233. * Will do nothing if webVR is not supported or if there is no webVR device
  20234. * @param options the webvr options provided to the camera. mainly used for multiview
  20235. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20236. */
  20237. enableVR(options: WebVROptions): void;
  20238. /** @hidden */
  20239. _onVRFullScreenTriggered(): void;
  20240. }
  20241. }
  20242. }
  20243. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20244. import { Nullable } from "babylonjs/types";
  20245. import { Observable } from "babylonjs/Misc/observable";
  20246. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20247. import { Scene } from "babylonjs/scene";
  20248. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20249. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20250. import { Node } from "babylonjs/node";
  20251. import { Ray } from "babylonjs/Culling/ray";
  20252. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20253. import "babylonjs/Engines/Extensions/engine.webVR";
  20254. /**
  20255. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20256. * IMPORTANT!! The data is right-hand data.
  20257. * @export
  20258. * @interface DevicePose
  20259. */
  20260. export interface DevicePose {
  20261. /**
  20262. * The position of the device, values in array are [x,y,z].
  20263. */
  20264. readonly position: Nullable<Float32Array>;
  20265. /**
  20266. * The linearVelocity of the device, values in array are [x,y,z].
  20267. */
  20268. readonly linearVelocity: Nullable<Float32Array>;
  20269. /**
  20270. * The linearAcceleration of the device, values in array are [x,y,z].
  20271. */
  20272. readonly linearAcceleration: Nullable<Float32Array>;
  20273. /**
  20274. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20275. */
  20276. readonly orientation: Nullable<Float32Array>;
  20277. /**
  20278. * The angularVelocity of the device, values in array are [x,y,z].
  20279. */
  20280. readonly angularVelocity: Nullable<Float32Array>;
  20281. /**
  20282. * The angularAcceleration of the device, values in array are [x,y,z].
  20283. */
  20284. readonly angularAcceleration: Nullable<Float32Array>;
  20285. }
  20286. /**
  20287. * Interface representing a pose controlled object in Babylon.
  20288. * A pose controlled object has both regular pose values as well as pose values
  20289. * from an external device such as a VR head mounted display
  20290. */
  20291. export interface PoseControlled {
  20292. /**
  20293. * The position of the object in babylon space.
  20294. */
  20295. position: Vector3;
  20296. /**
  20297. * The rotation quaternion of the object in babylon space.
  20298. */
  20299. rotationQuaternion: Quaternion;
  20300. /**
  20301. * The position of the device in babylon space.
  20302. */
  20303. devicePosition?: Vector3;
  20304. /**
  20305. * The rotation quaternion of the device in babylon space.
  20306. */
  20307. deviceRotationQuaternion: Quaternion;
  20308. /**
  20309. * The raw pose coming from the device.
  20310. */
  20311. rawPose: Nullable<DevicePose>;
  20312. /**
  20313. * The scale of the device to be used when translating from device space to babylon space.
  20314. */
  20315. deviceScaleFactor: number;
  20316. /**
  20317. * Updates the poseControlled values based on the input device pose.
  20318. * @param poseData the pose data to update the object with
  20319. */
  20320. updateFromDevice(poseData: DevicePose): void;
  20321. }
  20322. /**
  20323. * Set of options to customize the webVRCamera
  20324. */
  20325. export interface WebVROptions {
  20326. /**
  20327. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20328. */
  20329. trackPosition?: boolean;
  20330. /**
  20331. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20332. */
  20333. positionScale?: number;
  20334. /**
  20335. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20336. */
  20337. displayName?: string;
  20338. /**
  20339. * Should the native controller meshes be initialized. (default: true)
  20340. */
  20341. controllerMeshes?: boolean;
  20342. /**
  20343. * Creating a default HemiLight only on controllers. (default: true)
  20344. */
  20345. defaultLightingOnControllers?: boolean;
  20346. /**
  20347. * If you don't want to use the default VR button of the helper. (default: false)
  20348. */
  20349. useCustomVRButton?: boolean;
  20350. /**
  20351. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20352. */
  20353. customVRButton?: HTMLButtonElement;
  20354. /**
  20355. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20356. */
  20357. rayLength?: number;
  20358. /**
  20359. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20360. */
  20361. defaultHeight?: number;
  20362. /**
  20363. * If multiview should be used if availible (default: false)
  20364. */
  20365. useMultiview?: boolean;
  20366. }
  20367. /**
  20368. * This represents a WebVR camera.
  20369. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20370. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20371. */
  20372. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20373. private webVROptions;
  20374. /**
  20375. * @hidden
  20376. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20377. */
  20378. _vrDevice: any;
  20379. /**
  20380. * The rawPose of the vrDevice.
  20381. */
  20382. rawPose: Nullable<DevicePose>;
  20383. private _onVREnabled;
  20384. private _specsVersion;
  20385. private _attached;
  20386. private _frameData;
  20387. protected _descendants: Array<Node>;
  20388. private _deviceRoomPosition;
  20389. /** @hidden */
  20390. _deviceRoomRotationQuaternion: Quaternion;
  20391. private _standingMatrix;
  20392. /**
  20393. * Represents device position in babylon space.
  20394. */
  20395. devicePosition: Vector3;
  20396. /**
  20397. * Represents device rotation in babylon space.
  20398. */
  20399. deviceRotationQuaternion: Quaternion;
  20400. /**
  20401. * The scale of the device to be used when translating from device space to babylon space.
  20402. */
  20403. deviceScaleFactor: number;
  20404. private _deviceToWorld;
  20405. private _worldToDevice;
  20406. /**
  20407. * References to the webVR controllers for the vrDevice.
  20408. */
  20409. controllers: Array<WebVRController>;
  20410. /**
  20411. * Emits an event when a controller is attached.
  20412. */
  20413. onControllersAttachedObservable: Observable<WebVRController[]>;
  20414. /**
  20415. * Emits an event when a controller's mesh has been loaded;
  20416. */
  20417. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20418. /**
  20419. * Emits an event when the HMD's pose has been updated.
  20420. */
  20421. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20422. private _poseSet;
  20423. /**
  20424. * If the rig cameras be used as parent instead of this camera.
  20425. */
  20426. rigParenting: boolean;
  20427. private _lightOnControllers;
  20428. private _defaultHeight?;
  20429. /**
  20430. * Instantiates a WebVRFreeCamera.
  20431. * @param name The name of the WebVRFreeCamera
  20432. * @param position The starting anchor position for the camera
  20433. * @param scene The scene the camera belongs to
  20434. * @param webVROptions a set of customizable options for the webVRCamera
  20435. */
  20436. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20437. /**
  20438. * Gets the device distance from the ground in meters.
  20439. * @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.
  20440. */
  20441. deviceDistanceToRoomGround(): number;
  20442. /**
  20443. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20444. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20445. */
  20446. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20447. /**
  20448. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20449. * @returns A promise with a boolean set to if the standing matrix is supported.
  20450. */
  20451. useStandingMatrixAsync(): Promise<boolean>;
  20452. /**
  20453. * Disposes the camera
  20454. */
  20455. dispose(): void;
  20456. /**
  20457. * Gets a vrController by name.
  20458. * @param name The name of the controller to retreive
  20459. * @returns the controller matching the name specified or null if not found
  20460. */
  20461. getControllerByName(name: string): Nullable<WebVRController>;
  20462. private _leftController;
  20463. /**
  20464. * The controller corresponding to the users left hand.
  20465. */
  20466. get leftController(): Nullable<WebVRController>;
  20467. private _rightController;
  20468. /**
  20469. * The controller corresponding to the users right hand.
  20470. */
  20471. get rightController(): Nullable<WebVRController>;
  20472. /**
  20473. * Casts a ray forward from the vrCamera's gaze.
  20474. * @param length Length of the ray (default: 100)
  20475. * @returns the ray corresponding to the gaze
  20476. */
  20477. getForwardRay(length?: number): Ray;
  20478. /**
  20479. * @hidden
  20480. * Updates the camera based on device's frame data
  20481. */
  20482. _checkInputs(): void;
  20483. /**
  20484. * Updates the poseControlled values based on the input device pose.
  20485. * @param poseData Pose coming from the device
  20486. */
  20487. updateFromDevice(poseData: DevicePose): void;
  20488. private _htmlElementAttached;
  20489. private _detachIfAttached;
  20490. /**
  20491. * WebVR's attach control will start broadcasting frames to the device.
  20492. * Note that in certain browsers (chrome for example) this function must be called
  20493. * within a user-interaction callback. Example:
  20494. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20495. *
  20496. * @param element html element to attach the vrDevice to
  20497. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20498. */
  20499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20500. /**
  20501. * Detaches the camera from the html element and disables VR
  20502. *
  20503. * @param element html element to detach from
  20504. */
  20505. detachControl(element: HTMLElement): void;
  20506. /**
  20507. * @returns the name of this class
  20508. */
  20509. getClassName(): string;
  20510. /**
  20511. * Calls resetPose on the vrDisplay
  20512. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20513. */
  20514. resetToCurrentRotation(): void;
  20515. /**
  20516. * @hidden
  20517. * Updates the rig cameras (left and right eye)
  20518. */
  20519. _updateRigCameras(): void;
  20520. private _workingVector;
  20521. private _oneVector;
  20522. private _workingMatrix;
  20523. private updateCacheCalled;
  20524. private _correctPositionIfNotTrackPosition;
  20525. /**
  20526. * @hidden
  20527. * Updates the cached values of the camera
  20528. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20529. */
  20530. _updateCache(ignoreParentClass?: boolean): void;
  20531. /**
  20532. * @hidden
  20533. * Get current device position in babylon world
  20534. */
  20535. _computeDevicePosition(): void;
  20536. /**
  20537. * Updates the current device position and rotation in the babylon world
  20538. */
  20539. update(): void;
  20540. /**
  20541. * @hidden
  20542. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20543. * @returns an identity matrix
  20544. */
  20545. _getViewMatrix(): Matrix;
  20546. private _tmpMatrix;
  20547. /**
  20548. * This function is called by the two RIG cameras.
  20549. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20550. * @hidden
  20551. */
  20552. _getWebVRViewMatrix(): Matrix;
  20553. /** @hidden */
  20554. _getWebVRProjectionMatrix(): Matrix;
  20555. private _onGamepadConnectedObserver;
  20556. private _onGamepadDisconnectedObserver;
  20557. private _updateCacheWhenTrackingDisabledObserver;
  20558. /**
  20559. * Initializes the controllers and their meshes
  20560. */
  20561. initControllers(): void;
  20562. }
  20563. }
  20564. declare module "babylonjs/Materials/materialHelper" {
  20565. import { Nullable } from "babylonjs/types";
  20566. import { Scene } from "babylonjs/scene";
  20567. import { Engine } from "babylonjs/Engines/engine";
  20568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20569. import { Light } from "babylonjs/Lights/light";
  20570. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20571. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20573. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20574. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20575. /**
  20576. * "Static Class" containing the most commonly used helper while dealing with material for
  20577. * rendering purpose.
  20578. *
  20579. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20580. *
  20581. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20582. */
  20583. export class MaterialHelper {
  20584. /**
  20585. * Bind the current view position to an effect.
  20586. * @param effect The effect to be bound
  20587. * @param scene The scene the eyes position is used from
  20588. * @param variableName name of the shader variable that will hold the eye position
  20589. */
  20590. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20591. /**
  20592. * Helps preparing the defines values about the UVs in used in the effect.
  20593. * UVs are shared as much as we can accross channels in the shaders.
  20594. * @param texture The texture we are preparing the UVs for
  20595. * @param defines The defines to update
  20596. * @param key The channel key "diffuse", "specular"... used in the shader
  20597. */
  20598. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20599. /**
  20600. * Binds a texture matrix value to its corrsponding uniform
  20601. * @param texture The texture to bind the matrix for
  20602. * @param uniformBuffer The uniform buffer receivin the data
  20603. * @param key The channel key "diffuse", "specular"... used in the shader
  20604. */
  20605. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20606. /**
  20607. * Gets the current status of the fog (should it be enabled?)
  20608. * @param mesh defines the mesh to evaluate for fog support
  20609. * @param scene defines the hosting scene
  20610. * @returns true if fog must be enabled
  20611. */
  20612. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20613. /**
  20614. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20615. * @param mesh defines the current mesh
  20616. * @param scene defines the current scene
  20617. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20618. * @param pointsCloud defines if point cloud rendering has to be turned on
  20619. * @param fogEnabled defines if fog has to be turned on
  20620. * @param alphaTest defines if alpha testing has to be turned on
  20621. * @param defines defines the current list of defines
  20622. */
  20623. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20624. /**
  20625. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20626. * @param scene defines the current scene
  20627. * @param engine defines the current engine
  20628. * @param defines specifies the list of active defines
  20629. * @param useInstances defines if instances have to be turned on
  20630. * @param useClipPlane defines if clip plane have to be turned on
  20631. * @param useInstances defines if instances have to be turned on
  20632. * @param useThinInstances defines if thin instances have to be turned on
  20633. */
  20634. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20635. /**
  20636. * Prepares the defines for bones
  20637. * @param mesh The mesh containing the geometry data we will draw
  20638. * @param defines The defines to update
  20639. */
  20640. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20641. /**
  20642. * Prepares the defines for morph targets
  20643. * @param mesh The mesh containing the geometry data we will draw
  20644. * @param defines The defines to update
  20645. */
  20646. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20647. /**
  20648. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20649. * @param mesh The mesh containing the geometry data we will draw
  20650. * @param defines The defines to update
  20651. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20652. * @param useBones Precise whether bones should be used or not (override mesh info)
  20653. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20654. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20655. * @returns false if defines are considered not dirty and have not been checked
  20656. */
  20657. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20658. /**
  20659. * Prepares the defines related to multiview
  20660. * @param scene The scene we are intending to draw
  20661. * @param defines The defines to update
  20662. */
  20663. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20664. /**
  20665. * Prepares the defines related to the prepass
  20666. * @param scene The scene we are intending to draw
  20667. * @param defines The defines to update
  20668. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20669. */
  20670. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20671. /**
  20672. * Prepares the defines related to the light information passed in parameter
  20673. * @param scene The scene we are intending to draw
  20674. * @param mesh The mesh the effect is compiling for
  20675. * @param light The light the effect is compiling for
  20676. * @param lightIndex The index of the light
  20677. * @param defines The defines to update
  20678. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20679. * @param state Defines the current state regarding what is needed (normals, etc...)
  20680. */
  20681. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20682. needNormals: boolean;
  20683. needRebuild: boolean;
  20684. shadowEnabled: boolean;
  20685. specularEnabled: boolean;
  20686. lightmapMode: boolean;
  20687. }): void;
  20688. /**
  20689. * Prepares the defines related to the light information passed in parameter
  20690. * @param scene The scene we are intending to draw
  20691. * @param mesh The mesh the effect is compiling for
  20692. * @param defines The defines to update
  20693. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20694. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20695. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20696. * @returns true if normals will be required for the rest of the effect
  20697. */
  20698. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20699. /**
  20700. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20701. * @param lightIndex defines the light index
  20702. * @param uniformsList The uniform list
  20703. * @param samplersList The sampler list
  20704. * @param projectedLightTexture defines if projected texture must be used
  20705. * @param uniformBuffersList defines an optional list of uniform buffers
  20706. */
  20707. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20708. /**
  20709. * Prepares the uniforms and samplers list to be used in the effect
  20710. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20711. * @param samplersList The sampler list
  20712. * @param defines The defines helping in the list generation
  20713. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20714. */
  20715. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20716. /**
  20717. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20718. * @param defines The defines to update while falling back
  20719. * @param fallbacks The authorized effect fallbacks
  20720. * @param maxSimultaneousLights The maximum number of lights allowed
  20721. * @param rank the current rank of the Effect
  20722. * @returns The newly affected rank
  20723. */
  20724. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20725. private static _TmpMorphInfluencers;
  20726. /**
  20727. * Prepares the list of attributes required for morph targets according to the effect defines.
  20728. * @param attribs The current list of supported attribs
  20729. * @param mesh The mesh to prepare the morph targets attributes for
  20730. * @param influencers The number of influencers
  20731. */
  20732. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20733. /**
  20734. * Prepares the list of attributes required for morph targets according to the effect defines.
  20735. * @param attribs The current list of supported attribs
  20736. * @param mesh The mesh to prepare the morph targets attributes for
  20737. * @param defines The current Defines of the effect
  20738. */
  20739. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20740. /**
  20741. * Prepares the list of attributes required for bones according to the effect defines.
  20742. * @param attribs The current list of supported attribs
  20743. * @param mesh The mesh to prepare the bones attributes for
  20744. * @param defines The current Defines of the effect
  20745. * @param fallbacks The current efffect fallback strategy
  20746. */
  20747. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20748. /**
  20749. * Check and prepare the list of attributes required for instances according to the effect defines.
  20750. * @param attribs The current list of supported attribs
  20751. * @param defines The current MaterialDefines of the effect
  20752. */
  20753. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20754. /**
  20755. * Add the list of attributes required for instances to the attribs array.
  20756. * @param attribs The current list of supported attribs
  20757. */
  20758. static PushAttributesForInstances(attribs: string[]): void;
  20759. /**
  20760. * Binds the light information to the effect.
  20761. * @param light The light containing the generator
  20762. * @param effect The effect we are binding the data to
  20763. * @param lightIndex The light index in the effect used to render
  20764. */
  20765. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20766. /**
  20767. * Binds the lights information from the scene to the effect for the given mesh.
  20768. * @param light Light to bind
  20769. * @param lightIndex Light index
  20770. * @param scene The scene where the light belongs to
  20771. * @param effect The effect we are binding the data to
  20772. * @param useSpecular Defines if specular is supported
  20773. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20774. */
  20775. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20776. /**
  20777. * Binds the lights information from the scene to the effect for the given mesh.
  20778. * @param scene The scene the lights belongs to
  20779. * @param mesh The mesh we are binding the information to render
  20780. * @param effect The effect we are binding the data to
  20781. * @param defines The generated defines for the effect
  20782. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20783. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20784. */
  20785. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20786. private static _tempFogColor;
  20787. /**
  20788. * Binds the fog information from the scene to the effect for the given mesh.
  20789. * @param scene The scene the lights belongs to
  20790. * @param mesh The mesh we are binding the information to render
  20791. * @param effect The effect we are binding the data to
  20792. * @param linearSpace Defines if the fog effect is applied in linear space
  20793. */
  20794. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20795. /**
  20796. * Binds the bones information from the mesh to the effect.
  20797. * @param mesh The mesh we are binding the information to render
  20798. * @param effect The effect we are binding the data to
  20799. */
  20800. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20801. /**
  20802. * Binds the morph targets information from the mesh to the effect.
  20803. * @param abstractMesh The mesh we are binding the information to render
  20804. * @param effect The effect we are binding the data to
  20805. */
  20806. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20807. /**
  20808. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20809. * @param defines The generated defines used in the effect
  20810. * @param effect The effect we are binding the data to
  20811. * @param scene The scene we are willing to render with logarithmic scale for
  20812. */
  20813. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20814. /**
  20815. * Binds the clip plane information from the scene to the effect.
  20816. * @param scene The scene the clip plane information are extracted from
  20817. * @param effect The effect we are binding the data to
  20818. */
  20819. static BindClipPlane(effect: Effect, scene: Scene): void;
  20820. }
  20821. }
  20822. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20824. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20825. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20826. import { Nullable } from "babylonjs/types";
  20827. import { Effect } from "babylonjs/Materials/effect";
  20828. import { Matrix } from "babylonjs/Maths/math.vector";
  20829. import { Scene } from "babylonjs/scene";
  20830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20832. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20833. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20834. import { Observable } from "babylonjs/Misc/observable";
  20835. /**
  20836. * Block used to expose an input value
  20837. */
  20838. export class InputBlock extends NodeMaterialBlock {
  20839. private _mode;
  20840. private _associatedVariableName;
  20841. private _storedValue;
  20842. private _valueCallback;
  20843. private _type;
  20844. private _animationType;
  20845. /** Gets or set a value used to limit the range of float values */
  20846. min: number;
  20847. /** Gets or set a value used to limit the range of float values */
  20848. max: number;
  20849. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20850. isBoolean: boolean;
  20851. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20852. matrixMode: number;
  20853. /** @hidden */
  20854. _systemValue: Nullable<NodeMaterialSystemValues>;
  20855. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20856. visibleInInspector: boolean;
  20857. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20858. isConstant: boolean;
  20859. /** Gets or sets the group to use to display this block in the Inspector */
  20860. groupInInspector: string;
  20861. /** Gets an observable raised when the value is changed */
  20862. onValueChangedObservable: Observable<InputBlock>;
  20863. /**
  20864. * Gets or sets the connection point type (default is float)
  20865. */
  20866. get type(): NodeMaterialBlockConnectionPointTypes;
  20867. /**
  20868. * Creates a new InputBlock
  20869. * @param name defines the block name
  20870. * @param target defines the target of that block (Vertex by default)
  20871. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20872. */
  20873. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20874. /**
  20875. * Validates if a name is a reserve word.
  20876. * @param newName the new name to be given to the node.
  20877. * @returns false if the name is a reserve word, else true.
  20878. */
  20879. validateBlockName(newName: string): boolean;
  20880. /**
  20881. * Gets the output component
  20882. */
  20883. get output(): NodeMaterialConnectionPoint;
  20884. /**
  20885. * Set the source of this connection point to a vertex attribute
  20886. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20887. * @returns the current connection point
  20888. */
  20889. setAsAttribute(attributeName?: string): InputBlock;
  20890. /**
  20891. * Set the source of this connection point to a system value
  20892. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20893. * @returns the current connection point
  20894. */
  20895. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20896. /**
  20897. * Gets or sets the value of that point.
  20898. * Please note that this value will be ignored if valueCallback is defined
  20899. */
  20900. get value(): any;
  20901. set value(value: any);
  20902. /**
  20903. * Gets or sets a callback used to get the value of that point.
  20904. * Please note that setting this value will force the connection point to ignore the value property
  20905. */
  20906. get valueCallback(): () => any;
  20907. set valueCallback(value: () => any);
  20908. /**
  20909. * Gets or sets the associated variable name in the shader
  20910. */
  20911. get associatedVariableName(): string;
  20912. set associatedVariableName(value: string);
  20913. /** Gets or sets the type of animation applied to the input */
  20914. get animationType(): AnimatedInputBlockTypes;
  20915. set animationType(value: AnimatedInputBlockTypes);
  20916. /**
  20917. * Gets a boolean indicating that this connection point not defined yet
  20918. */
  20919. get isUndefined(): boolean;
  20920. /**
  20921. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20922. * In this case the connection point name must be the name of the uniform to use.
  20923. * Can only be set on inputs
  20924. */
  20925. get isUniform(): boolean;
  20926. set isUniform(value: boolean);
  20927. /**
  20928. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20929. * In this case the connection point name must be the name of the attribute to use
  20930. * Can only be set on inputs
  20931. */
  20932. get isAttribute(): boolean;
  20933. set isAttribute(value: boolean);
  20934. /**
  20935. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20936. * Can only be set on exit points
  20937. */
  20938. get isVarying(): boolean;
  20939. set isVarying(value: boolean);
  20940. /**
  20941. * Gets a boolean indicating that the current connection point is a system value
  20942. */
  20943. get isSystemValue(): boolean;
  20944. /**
  20945. * Gets or sets the current well known value or null if not defined as a system value
  20946. */
  20947. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20948. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20949. /**
  20950. * Gets the current class name
  20951. * @returns the class name
  20952. */
  20953. getClassName(): string;
  20954. /**
  20955. * Animate the input if animationType !== None
  20956. * @param scene defines the rendering scene
  20957. */
  20958. animate(scene: Scene): void;
  20959. private _emitDefine;
  20960. initialize(state: NodeMaterialBuildState): void;
  20961. /**
  20962. * Set the input block to its default value (based on its type)
  20963. */
  20964. setDefaultValue(): void;
  20965. private _emitConstant;
  20966. /** @hidden */
  20967. get _noContextSwitch(): boolean;
  20968. private _emit;
  20969. /** @hidden */
  20970. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20971. /** @hidden */
  20972. _transmit(effect: Effect, scene: Scene): void;
  20973. protected _buildBlock(state: NodeMaterialBuildState): void;
  20974. protected _dumpPropertiesCode(): string;
  20975. dispose(): void;
  20976. serialize(): any;
  20977. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20978. }
  20979. }
  20980. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20981. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20982. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20983. import { Nullable } from "babylonjs/types";
  20984. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20985. import { Observable } from "babylonjs/Misc/observable";
  20986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20987. /**
  20988. * Enum used to define the compatibility state between two connection points
  20989. */
  20990. export enum NodeMaterialConnectionPointCompatibilityStates {
  20991. /** Points are compatibles */
  20992. Compatible = 0,
  20993. /** Points are incompatible because of their types */
  20994. TypeIncompatible = 1,
  20995. /** Points are incompatible because of their targets (vertex vs fragment) */
  20996. TargetIncompatible = 2
  20997. }
  20998. /**
  20999. * Defines the direction of a connection point
  21000. */
  21001. export enum NodeMaterialConnectionPointDirection {
  21002. /** Input */
  21003. Input = 0,
  21004. /** Output */
  21005. Output = 1
  21006. }
  21007. /**
  21008. * Defines a connection point for a block
  21009. */
  21010. export class NodeMaterialConnectionPoint {
  21011. /** @hidden */
  21012. _ownerBlock: NodeMaterialBlock;
  21013. /** @hidden */
  21014. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21015. private _endpoints;
  21016. private _associatedVariableName;
  21017. private _direction;
  21018. /** @hidden */
  21019. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21020. /** @hidden */
  21021. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21022. private _type;
  21023. /** @hidden */
  21024. _enforceAssociatedVariableName: boolean;
  21025. /** Gets the direction of the point */
  21026. get direction(): NodeMaterialConnectionPointDirection;
  21027. /** Indicates that this connection point needs dual validation before being connected to another point */
  21028. needDualDirectionValidation: boolean;
  21029. /**
  21030. * Gets or sets the additional types supported by this connection point
  21031. */
  21032. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21033. /**
  21034. * Gets or sets the additional types excluded by this connection point
  21035. */
  21036. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21037. /**
  21038. * Observable triggered when this point is connected
  21039. */
  21040. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21041. /**
  21042. * Gets or sets the associated variable name in the shader
  21043. */
  21044. get associatedVariableName(): string;
  21045. set associatedVariableName(value: string);
  21046. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21047. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21048. /**
  21049. * Gets or sets the connection point type (default is float)
  21050. */
  21051. get type(): NodeMaterialBlockConnectionPointTypes;
  21052. set type(value: NodeMaterialBlockConnectionPointTypes);
  21053. /**
  21054. * Gets or sets the connection point name
  21055. */
  21056. name: string;
  21057. /**
  21058. * Gets or sets the connection point name
  21059. */
  21060. displayName: string;
  21061. /**
  21062. * Gets or sets a boolean indicating that this connection point can be omitted
  21063. */
  21064. isOptional: boolean;
  21065. /**
  21066. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21067. */
  21068. isExposedOnFrame: boolean;
  21069. /**
  21070. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21071. */
  21072. define: string;
  21073. /** @hidden */
  21074. _prioritizeVertex: boolean;
  21075. private _target;
  21076. /** Gets or sets the target of that connection point */
  21077. get target(): NodeMaterialBlockTargets;
  21078. set target(value: NodeMaterialBlockTargets);
  21079. /**
  21080. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21081. */
  21082. get isConnected(): boolean;
  21083. /**
  21084. * Gets a boolean indicating that the current point is connected to an input block
  21085. */
  21086. get isConnectedToInputBlock(): boolean;
  21087. /**
  21088. * Gets a the connected input block (if any)
  21089. */
  21090. get connectInputBlock(): Nullable<InputBlock>;
  21091. /** Get the other side of the connection (if any) */
  21092. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21093. /** Get the block that owns this connection point */
  21094. get ownerBlock(): NodeMaterialBlock;
  21095. /** Get the block connected on the other side of this connection (if any) */
  21096. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21097. /** Get the block connected on the endpoints of this connection (if any) */
  21098. get connectedBlocks(): Array<NodeMaterialBlock>;
  21099. /** Gets the list of connected endpoints */
  21100. get endpoints(): NodeMaterialConnectionPoint[];
  21101. /** Gets a boolean indicating if that output point is connected to at least one input */
  21102. get hasEndpoints(): boolean;
  21103. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21104. get isConnectedInVertexShader(): boolean;
  21105. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21106. get isConnectedInFragmentShader(): boolean;
  21107. /**
  21108. * Creates a block suitable to be used as an input for this input point.
  21109. * If null is returned, a block based on the point type will be created.
  21110. * @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
  21111. */
  21112. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21113. /**
  21114. * Creates a new connection point
  21115. * @param name defines the connection point name
  21116. * @param ownerBlock defines the block hosting this connection point
  21117. * @param direction defines the direction of the connection point
  21118. */
  21119. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21120. /**
  21121. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21122. * @returns the class name
  21123. */
  21124. getClassName(): string;
  21125. /**
  21126. * Gets a boolean indicating if the current point can be connected to another point
  21127. * @param connectionPoint defines the other connection point
  21128. * @returns a boolean
  21129. */
  21130. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21131. /**
  21132. * Gets a number indicating if the current point can be connected to another point
  21133. * @param connectionPoint defines the other connection point
  21134. * @returns a number defining the compatibility state
  21135. */
  21136. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21137. /**
  21138. * Connect this point to another connection point
  21139. * @param connectionPoint defines the other connection point
  21140. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21141. * @returns the current connection point
  21142. */
  21143. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21144. /**
  21145. * Disconnect this point from one of his endpoint
  21146. * @param endpoint defines the other connection point
  21147. * @returns the current connection point
  21148. */
  21149. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21150. /**
  21151. * Serializes this point in a JSON representation
  21152. * @param isInput defines if the connection point is an input (default is true)
  21153. * @returns the serialized point object
  21154. */
  21155. serialize(isInput?: boolean): any;
  21156. /**
  21157. * Release resources
  21158. */
  21159. dispose(): void;
  21160. }
  21161. }
  21162. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21163. /**
  21164. * Enum used to define the material modes
  21165. */
  21166. export enum NodeMaterialModes {
  21167. /** Regular material */
  21168. Material = 0,
  21169. /** For post process */
  21170. PostProcess = 1,
  21171. /** For particle system */
  21172. Particle = 2
  21173. }
  21174. }
  21175. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21178. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21181. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21182. import { Effect } from "babylonjs/Materials/effect";
  21183. import { Mesh } from "babylonjs/Meshes/mesh";
  21184. import { Nullable } from "babylonjs/types";
  21185. import { Texture } from "babylonjs/Materials/Textures/texture";
  21186. import { Scene } from "babylonjs/scene";
  21187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21188. /**
  21189. * Block used to read a texture from a sampler
  21190. */
  21191. export class TextureBlock extends NodeMaterialBlock {
  21192. private _defineName;
  21193. private _linearDefineName;
  21194. private _gammaDefineName;
  21195. private _tempTextureRead;
  21196. private _samplerName;
  21197. private _transformedUVName;
  21198. private _textureTransformName;
  21199. private _textureInfoName;
  21200. private _mainUVName;
  21201. private _mainUVDefineName;
  21202. private _fragmentOnly;
  21203. /**
  21204. * Gets or sets the texture associated with the node
  21205. */
  21206. texture: Nullable<Texture>;
  21207. /**
  21208. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21209. */
  21210. convertToGammaSpace: boolean;
  21211. /**
  21212. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21213. */
  21214. convertToLinearSpace: boolean;
  21215. /**
  21216. * Create a new TextureBlock
  21217. * @param name defines the block name
  21218. */
  21219. constructor(name: string, fragmentOnly?: boolean);
  21220. /**
  21221. * Gets the current class name
  21222. * @returns the class name
  21223. */
  21224. getClassName(): string;
  21225. /**
  21226. * Gets the uv input component
  21227. */
  21228. get uv(): NodeMaterialConnectionPoint;
  21229. /**
  21230. * Gets the rgba output component
  21231. */
  21232. get rgba(): NodeMaterialConnectionPoint;
  21233. /**
  21234. * Gets the rgb output component
  21235. */
  21236. get rgb(): NodeMaterialConnectionPoint;
  21237. /**
  21238. * Gets the r output component
  21239. */
  21240. get r(): NodeMaterialConnectionPoint;
  21241. /**
  21242. * Gets the g output component
  21243. */
  21244. get g(): NodeMaterialConnectionPoint;
  21245. /**
  21246. * Gets the b output component
  21247. */
  21248. get b(): NodeMaterialConnectionPoint;
  21249. /**
  21250. * Gets the a output component
  21251. */
  21252. get a(): NodeMaterialConnectionPoint;
  21253. get target(): NodeMaterialBlockTargets;
  21254. autoConfigure(material: NodeMaterial): void;
  21255. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21257. isReady(): boolean;
  21258. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21259. private get _isMixed();
  21260. private _injectVertexCode;
  21261. private _writeTextureRead;
  21262. private _writeOutput;
  21263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21264. protected _dumpPropertiesCode(): string;
  21265. serialize(): any;
  21266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21267. }
  21268. }
  21269. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21270. /** @hidden */
  21271. export var reflectionFunction: {
  21272. name: string;
  21273. shader: string;
  21274. };
  21275. }
  21276. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21282. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21283. import { Effect } from "babylonjs/Materials/effect";
  21284. import { Mesh } from "babylonjs/Meshes/mesh";
  21285. import { Nullable } from "babylonjs/types";
  21286. import { Scene } from "babylonjs/scene";
  21287. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21288. /**
  21289. * Base block used to read a reflection texture from a sampler
  21290. */
  21291. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21292. /** @hidden */
  21293. _define3DName: string;
  21294. /** @hidden */
  21295. _defineCubicName: string;
  21296. /** @hidden */
  21297. _defineExplicitName: string;
  21298. /** @hidden */
  21299. _defineProjectionName: string;
  21300. /** @hidden */
  21301. _defineLocalCubicName: string;
  21302. /** @hidden */
  21303. _defineSphericalName: string;
  21304. /** @hidden */
  21305. _definePlanarName: string;
  21306. /** @hidden */
  21307. _defineEquirectangularName: string;
  21308. /** @hidden */
  21309. _defineMirroredEquirectangularFixedName: string;
  21310. /** @hidden */
  21311. _defineEquirectangularFixedName: string;
  21312. /** @hidden */
  21313. _defineSkyboxName: string;
  21314. /** @hidden */
  21315. _defineOppositeZ: string;
  21316. /** @hidden */
  21317. _cubeSamplerName: string;
  21318. /** @hidden */
  21319. _2DSamplerName: string;
  21320. protected _positionUVWName: string;
  21321. protected _directionWName: string;
  21322. protected _reflectionVectorName: string;
  21323. /** @hidden */
  21324. _reflectionCoordsName: string;
  21325. /** @hidden */
  21326. _reflectionMatrixName: string;
  21327. protected _reflectionColorName: string;
  21328. /**
  21329. * Gets or sets the texture associated with the node
  21330. */
  21331. texture: Nullable<BaseTexture>;
  21332. /**
  21333. * Create a new ReflectionTextureBaseBlock
  21334. * @param name defines the block name
  21335. */
  21336. constructor(name: string);
  21337. /**
  21338. * Gets the current class name
  21339. * @returns the class name
  21340. */
  21341. getClassName(): string;
  21342. /**
  21343. * Gets the world position input component
  21344. */
  21345. abstract get position(): NodeMaterialConnectionPoint;
  21346. /**
  21347. * Gets the world position input component
  21348. */
  21349. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the world normal input component
  21352. */
  21353. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the world input component
  21356. */
  21357. abstract get world(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the camera (or eye) position component
  21360. */
  21361. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Gets the view input component
  21364. */
  21365. abstract get view(): NodeMaterialConnectionPoint;
  21366. protected _getTexture(): Nullable<BaseTexture>;
  21367. autoConfigure(material: NodeMaterial): void;
  21368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21369. isReady(): boolean;
  21370. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21371. /**
  21372. * Gets the code to inject in the vertex shader
  21373. * @param state current state of the node material building
  21374. * @returns the shader code
  21375. */
  21376. handleVertexSide(state: NodeMaterialBuildState): string;
  21377. /**
  21378. * Handles the inits for the fragment code path
  21379. * @param state node material build state
  21380. */
  21381. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21382. /**
  21383. * Generates the reflection coords code for the fragment code path
  21384. * @param worldNormalVarName name of the world normal variable
  21385. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21386. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21387. * @returns the shader code
  21388. */
  21389. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21390. /**
  21391. * Generates the reflection color code for the fragment code path
  21392. * @param lodVarName name of the lod variable
  21393. * @param swizzleLookupTexture swizzle to use for the final color variable
  21394. * @returns the shader code
  21395. */
  21396. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21397. /**
  21398. * Generates the code corresponding to the connected output points
  21399. * @param state node material build state
  21400. * @param varName name of the variable to output
  21401. * @returns the shader code
  21402. */
  21403. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21404. protected _buildBlock(state: NodeMaterialBuildState): this;
  21405. protected _dumpPropertiesCode(): string;
  21406. serialize(): any;
  21407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21408. }
  21409. }
  21410. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21412. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21413. import { Nullable } from "babylonjs/types";
  21414. /**
  21415. * Defines a connection point to be used for points with a custom object type
  21416. */
  21417. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21418. private _blockType;
  21419. private _blockName;
  21420. private _nameForCheking?;
  21421. /**
  21422. * Creates a new connection point
  21423. * @param name defines the connection point name
  21424. * @param ownerBlock defines the block hosting this connection point
  21425. * @param direction defines the direction of the connection point
  21426. */
  21427. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21428. /**
  21429. * Gets a number indicating if the current point can be connected to another point
  21430. * @param connectionPoint defines the other connection point
  21431. * @returns a number defining the compatibility state
  21432. */
  21433. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21434. /**
  21435. * Creates a block suitable to be used as an input for this input point.
  21436. * If null is returned, a block based on the point type will be created.
  21437. * @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
  21438. */
  21439. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21440. }
  21441. }
  21442. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21443. /**
  21444. * Enum defining the type of properties that can be edited in the property pages in the NME
  21445. */
  21446. export enum PropertyTypeForEdition {
  21447. /** property is a boolean */
  21448. Boolean = 0,
  21449. /** property is a float */
  21450. Float = 1,
  21451. /** property is a Vector2 */
  21452. Vector2 = 2,
  21453. /** property is a list of values */
  21454. List = 3
  21455. }
  21456. /**
  21457. * Interface that defines an option in a variable of type list
  21458. */
  21459. export interface IEditablePropertyListOption {
  21460. /** label of the option */
  21461. "label": string;
  21462. /** value of the option */
  21463. "value": number;
  21464. }
  21465. /**
  21466. * Interface that defines the options available for an editable property
  21467. */
  21468. export interface IEditablePropertyOption {
  21469. /** min value */
  21470. "min"?: number;
  21471. /** max value */
  21472. "max"?: number;
  21473. /** notifiers: indicates which actions to take when the property is changed */
  21474. "notifiers"?: {
  21475. /** the material should be rebuilt */
  21476. "rebuild"?: boolean;
  21477. /** the preview should be updated */
  21478. "update"?: boolean;
  21479. };
  21480. /** list of the options for a variable of type list */
  21481. "options"?: IEditablePropertyListOption[];
  21482. }
  21483. /**
  21484. * Interface that describes an editable property
  21485. */
  21486. export interface IPropertyDescriptionForEdition {
  21487. /** name of the property */
  21488. "propertyName": string;
  21489. /** display name of the property */
  21490. "displayName": string;
  21491. /** type of the property */
  21492. "type": PropertyTypeForEdition;
  21493. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21494. "groupName": string;
  21495. /** options for the property */
  21496. "options": IEditablePropertyOption;
  21497. }
  21498. /**
  21499. * Decorator that flags a property in a node material block as being editable
  21500. */
  21501. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21502. }
  21503. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21506. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21508. import { Nullable } from "babylonjs/types";
  21509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21510. import { Mesh } from "babylonjs/Meshes/mesh";
  21511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21512. import { Effect } from "babylonjs/Materials/effect";
  21513. import { Scene } from "babylonjs/scene";
  21514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21515. /**
  21516. * Block used to implement the refraction part of the sub surface module of the PBR material
  21517. */
  21518. export class RefractionBlock extends NodeMaterialBlock {
  21519. /** @hidden */
  21520. _define3DName: string;
  21521. /** @hidden */
  21522. _refractionMatrixName: string;
  21523. /** @hidden */
  21524. _defineLODRefractionAlpha: string;
  21525. /** @hidden */
  21526. _defineLinearSpecularRefraction: string;
  21527. /** @hidden */
  21528. _defineOppositeZ: string;
  21529. /** @hidden */
  21530. _cubeSamplerName: string;
  21531. /** @hidden */
  21532. _2DSamplerName: string;
  21533. /** @hidden */
  21534. _vRefractionMicrosurfaceInfosName: string;
  21535. /** @hidden */
  21536. _vRefractionInfosName: string;
  21537. private _scene;
  21538. /**
  21539. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21540. * Materials half opaque for instance using refraction could benefit from this control.
  21541. */
  21542. linkRefractionWithTransparency: boolean;
  21543. /**
  21544. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21545. */
  21546. invertRefractionY: boolean;
  21547. /**
  21548. * Gets or sets the texture associated with the node
  21549. */
  21550. texture: Nullable<BaseTexture>;
  21551. /**
  21552. * Create a new RefractionBlock
  21553. * @param name defines the block name
  21554. */
  21555. constructor(name: string);
  21556. /**
  21557. * Gets the current class name
  21558. * @returns the class name
  21559. */
  21560. getClassName(): string;
  21561. /**
  21562. * Gets the intensity input component
  21563. */
  21564. get intensity(): NodeMaterialConnectionPoint;
  21565. /**
  21566. * Gets the index of refraction input component
  21567. */
  21568. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21569. /**
  21570. * Gets the tint at distance input component
  21571. */
  21572. get tintAtDistance(): NodeMaterialConnectionPoint;
  21573. /**
  21574. * Gets the view input component
  21575. */
  21576. get view(): NodeMaterialConnectionPoint;
  21577. /**
  21578. * Gets the refraction object output component
  21579. */
  21580. get refraction(): NodeMaterialConnectionPoint;
  21581. /**
  21582. * Returns true if the block has a texture
  21583. */
  21584. get hasTexture(): boolean;
  21585. protected _getTexture(): Nullable<BaseTexture>;
  21586. autoConfigure(material: NodeMaterial): void;
  21587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21588. isReady(): boolean;
  21589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21590. /**
  21591. * Gets the main code of the block (fragment side)
  21592. * @param state current state of the node material building
  21593. * @returns the shader code
  21594. */
  21595. getCode(state: NodeMaterialBuildState): string;
  21596. protected _buildBlock(state: NodeMaterialBuildState): this;
  21597. protected _dumpPropertiesCode(): string;
  21598. serialize(): any;
  21599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21600. }
  21601. }
  21602. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21605. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21608. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21610. import { Nullable } from "babylonjs/types";
  21611. import { Scene } from "babylonjs/scene";
  21612. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21613. /**
  21614. * Base block used as input for post process
  21615. */
  21616. export class CurrentScreenBlock extends NodeMaterialBlock {
  21617. private _samplerName;
  21618. private _linearDefineName;
  21619. private _gammaDefineName;
  21620. private _mainUVName;
  21621. private _tempTextureRead;
  21622. /**
  21623. * Gets or sets the texture associated with the node
  21624. */
  21625. texture: Nullable<BaseTexture>;
  21626. /**
  21627. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21628. */
  21629. convertToGammaSpace: boolean;
  21630. /**
  21631. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21632. */
  21633. convertToLinearSpace: boolean;
  21634. /**
  21635. * Create a new CurrentScreenBlock
  21636. * @param name defines the block name
  21637. */
  21638. constructor(name: string);
  21639. /**
  21640. * Gets the current class name
  21641. * @returns the class name
  21642. */
  21643. getClassName(): string;
  21644. /**
  21645. * Gets the uv input component
  21646. */
  21647. get uv(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the rgba output component
  21650. */
  21651. get rgba(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the rgb output component
  21654. */
  21655. get rgb(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the r output component
  21658. */
  21659. get r(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the g output component
  21662. */
  21663. get g(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the b output component
  21666. */
  21667. get b(): NodeMaterialConnectionPoint;
  21668. /**
  21669. * Gets the a output component
  21670. */
  21671. get a(): NodeMaterialConnectionPoint;
  21672. /**
  21673. * Initialize the block and prepare the context for build
  21674. * @param state defines the state that will be used for the build
  21675. */
  21676. initialize(state: NodeMaterialBuildState): void;
  21677. get target(): NodeMaterialBlockTargets;
  21678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21679. isReady(): boolean;
  21680. private _injectVertexCode;
  21681. private _writeTextureRead;
  21682. private _writeOutput;
  21683. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21684. serialize(): any;
  21685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21686. }
  21687. }
  21688. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21693. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21695. import { Nullable } from "babylonjs/types";
  21696. import { Scene } from "babylonjs/scene";
  21697. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21698. /**
  21699. * Base block used for the particle texture
  21700. */
  21701. export class ParticleTextureBlock extends NodeMaterialBlock {
  21702. private _samplerName;
  21703. private _linearDefineName;
  21704. private _gammaDefineName;
  21705. private _tempTextureRead;
  21706. /**
  21707. * Gets or sets the texture associated with the node
  21708. */
  21709. texture: Nullable<BaseTexture>;
  21710. /**
  21711. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21712. */
  21713. convertToGammaSpace: boolean;
  21714. /**
  21715. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21716. */
  21717. convertToLinearSpace: boolean;
  21718. /**
  21719. * Create a new ParticleTextureBlock
  21720. * @param name defines the block name
  21721. */
  21722. constructor(name: string);
  21723. /**
  21724. * Gets the current class name
  21725. * @returns the class name
  21726. */
  21727. getClassName(): string;
  21728. /**
  21729. * Gets the uv input component
  21730. */
  21731. get uv(): NodeMaterialConnectionPoint;
  21732. /**
  21733. * Gets the rgba output component
  21734. */
  21735. get rgba(): NodeMaterialConnectionPoint;
  21736. /**
  21737. * Gets the rgb output component
  21738. */
  21739. get rgb(): NodeMaterialConnectionPoint;
  21740. /**
  21741. * Gets the r output component
  21742. */
  21743. get r(): NodeMaterialConnectionPoint;
  21744. /**
  21745. * Gets the g output component
  21746. */
  21747. get g(): NodeMaterialConnectionPoint;
  21748. /**
  21749. * Gets the b output component
  21750. */
  21751. get b(): NodeMaterialConnectionPoint;
  21752. /**
  21753. * Gets the a output component
  21754. */
  21755. get a(): NodeMaterialConnectionPoint;
  21756. /**
  21757. * Initialize the block and prepare the context for build
  21758. * @param state defines the state that will be used for the build
  21759. */
  21760. initialize(state: NodeMaterialBuildState): void;
  21761. autoConfigure(material: NodeMaterial): void;
  21762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21763. isReady(): boolean;
  21764. private _writeOutput;
  21765. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21766. serialize(): any;
  21767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21768. }
  21769. }
  21770. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21773. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21774. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21775. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21776. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21777. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21778. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21779. import { Scene } from "babylonjs/scene";
  21780. /**
  21781. * Class used to store shared data between 2 NodeMaterialBuildState
  21782. */
  21783. export class NodeMaterialBuildStateSharedData {
  21784. /**
  21785. * Gets the list of emitted varyings
  21786. */
  21787. temps: string[];
  21788. /**
  21789. * Gets the list of emitted varyings
  21790. */
  21791. varyings: string[];
  21792. /**
  21793. * Gets the varying declaration string
  21794. */
  21795. varyingDeclaration: string;
  21796. /**
  21797. * Input blocks
  21798. */
  21799. inputBlocks: InputBlock[];
  21800. /**
  21801. * Input blocks
  21802. */
  21803. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21804. /**
  21805. * Bindable blocks (Blocks that need to set data to the effect)
  21806. */
  21807. bindableBlocks: NodeMaterialBlock[];
  21808. /**
  21809. * List of blocks that can provide a compilation fallback
  21810. */
  21811. blocksWithFallbacks: NodeMaterialBlock[];
  21812. /**
  21813. * List of blocks that can provide a define update
  21814. */
  21815. blocksWithDefines: NodeMaterialBlock[];
  21816. /**
  21817. * List of blocks that can provide a repeatable content
  21818. */
  21819. repeatableContentBlocks: NodeMaterialBlock[];
  21820. /**
  21821. * List of blocks that can provide a dynamic list of uniforms
  21822. */
  21823. dynamicUniformBlocks: NodeMaterialBlock[];
  21824. /**
  21825. * List of blocks that can block the isReady function for the material
  21826. */
  21827. blockingBlocks: NodeMaterialBlock[];
  21828. /**
  21829. * Gets the list of animated inputs
  21830. */
  21831. animatedInputs: InputBlock[];
  21832. /**
  21833. * Build Id used to avoid multiple recompilations
  21834. */
  21835. buildId: number;
  21836. /** List of emitted variables */
  21837. variableNames: {
  21838. [key: string]: number;
  21839. };
  21840. /** List of emitted defines */
  21841. defineNames: {
  21842. [key: string]: number;
  21843. };
  21844. /** Should emit comments? */
  21845. emitComments: boolean;
  21846. /** Emit build activity */
  21847. verbose: boolean;
  21848. /** Gets or sets the hosting scene */
  21849. scene: Scene;
  21850. /**
  21851. * Gets the compilation hints emitted at compilation time
  21852. */
  21853. hints: {
  21854. needWorldViewMatrix: boolean;
  21855. needWorldViewProjectionMatrix: boolean;
  21856. needAlphaBlending: boolean;
  21857. needAlphaTesting: boolean;
  21858. };
  21859. /**
  21860. * List of compilation checks
  21861. */
  21862. checks: {
  21863. emitVertex: boolean;
  21864. emitFragment: boolean;
  21865. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21866. };
  21867. /**
  21868. * Is vertex program allowed to be empty?
  21869. */
  21870. allowEmptyVertexProgram: boolean;
  21871. /** Creates a new shared data */
  21872. constructor();
  21873. /**
  21874. * Emits console errors and exceptions if there is a failing check
  21875. */
  21876. emitErrors(): void;
  21877. }
  21878. }
  21879. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21880. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21881. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21882. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21883. /**
  21884. * Class used to store node based material build state
  21885. */
  21886. export class NodeMaterialBuildState {
  21887. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21888. supportUniformBuffers: boolean;
  21889. /**
  21890. * Gets the list of emitted attributes
  21891. */
  21892. attributes: string[];
  21893. /**
  21894. * Gets the list of emitted uniforms
  21895. */
  21896. uniforms: string[];
  21897. /**
  21898. * Gets the list of emitted constants
  21899. */
  21900. constants: string[];
  21901. /**
  21902. * Gets the list of emitted samplers
  21903. */
  21904. samplers: string[];
  21905. /**
  21906. * Gets the list of emitted functions
  21907. */
  21908. functions: {
  21909. [key: string]: string;
  21910. };
  21911. /**
  21912. * Gets the list of emitted extensions
  21913. */
  21914. extensions: {
  21915. [key: string]: string;
  21916. };
  21917. /**
  21918. * Gets the target of the compilation state
  21919. */
  21920. target: NodeMaterialBlockTargets;
  21921. /**
  21922. * Gets the list of emitted counters
  21923. */
  21924. counters: {
  21925. [key: string]: number;
  21926. };
  21927. /**
  21928. * Shared data between multiple NodeMaterialBuildState instances
  21929. */
  21930. sharedData: NodeMaterialBuildStateSharedData;
  21931. /** @hidden */
  21932. _vertexState: NodeMaterialBuildState;
  21933. /** @hidden */
  21934. _attributeDeclaration: string;
  21935. /** @hidden */
  21936. _uniformDeclaration: string;
  21937. /** @hidden */
  21938. _constantDeclaration: string;
  21939. /** @hidden */
  21940. _samplerDeclaration: string;
  21941. /** @hidden */
  21942. _varyingTransfer: string;
  21943. /** @hidden */
  21944. _injectAtEnd: string;
  21945. private _repeatableContentAnchorIndex;
  21946. /** @hidden */
  21947. _builtCompilationString: string;
  21948. /**
  21949. * Gets the emitted compilation strings
  21950. */
  21951. compilationString: string;
  21952. /**
  21953. * Finalize the compilation strings
  21954. * @param state defines the current compilation state
  21955. */
  21956. finalize(state: NodeMaterialBuildState): void;
  21957. /** @hidden */
  21958. get _repeatableContentAnchor(): string;
  21959. /** @hidden */
  21960. _getFreeVariableName(prefix: string): string;
  21961. /** @hidden */
  21962. _getFreeDefineName(prefix: string): string;
  21963. /** @hidden */
  21964. _excludeVariableName(name: string): void;
  21965. /** @hidden */
  21966. _emit2DSampler(name: string): void;
  21967. /** @hidden */
  21968. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21969. /** @hidden */
  21970. _emitExtension(name: string, extension: string, define?: string): void;
  21971. /** @hidden */
  21972. _emitFunction(name: string, code: string, comments: string): void;
  21973. /** @hidden */
  21974. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21975. replaceStrings?: {
  21976. search: RegExp;
  21977. replace: string;
  21978. }[];
  21979. repeatKey?: string;
  21980. }): string;
  21981. /** @hidden */
  21982. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21983. repeatKey?: string;
  21984. removeAttributes?: boolean;
  21985. removeUniforms?: boolean;
  21986. removeVaryings?: boolean;
  21987. removeIfDef?: boolean;
  21988. replaceStrings?: {
  21989. search: RegExp;
  21990. replace: string;
  21991. }[];
  21992. }, storeKey?: string): void;
  21993. /** @hidden */
  21994. _registerTempVariable(name: string): boolean;
  21995. /** @hidden */
  21996. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21997. /** @hidden */
  21998. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21999. /** @hidden */
  22000. _emitFloat(value: number): string;
  22001. }
  22002. }
  22003. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22004. /**
  22005. * Helper class used to generate session unique ID
  22006. */
  22007. export class UniqueIdGenerator {
  22008. private static _UniqueIdCounter;
  22009. /**
  22010. * Gets an unique (relatively to the current scene) Id
  22011. */
  22012. static get UniqueId(): number;
  22013. }
  22014. }
  22015. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22016. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22018. import { Nullable } from "babylonjs/types";
  22019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22020. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22021. import { Effect } from "babylonjs/Materials/effect";
  22022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22023. import { Mesh } from "babylonjs/Meshes/mesh";
  22024. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22025. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22026. import { Scene } from "babylonjs/scene";
  22027. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22028. /**
  22029. * Defines a block that can be used inside a node based material
  22030. */
  22031. export class NodeMaterialBlock {
  22032. private _buildId;
  22033. private _buildTarget;
  22034. private _target;
  22035. private _isFinalMerger;
  22036. private _isInput;
  22037. private _name;
  22038. protected _isUnique: boolean;
  22039. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22040. inputsAreExclusive: boolean;
  22041. /** @hidden */
  22042. _codeVariableName: string;
  22043. /** @hidden */
  22044. _inputs: NodeMaterialConnectionPoint[];
  22045. /** @hidden */
  22046. _outputs: NodeMaterialConnectionPoint[];
  22047. /** @hidden */
  22048. _preparationId: number;
  22049. /**
  22050. * Gets the name of the block
  22051. */
  22052. get name(): string;
  22053. /**
  22054. * Sets the name of the block. Will check if the name is valid.
  22055. */
  22056. set name(newName: string);
  22057. /**
  22058. * Gets or sets the unique id of the node
  22059. */
  22060. uniqueId: number;
  22061. /**
  22062. * Gets or sets the comments associated with this block
  22063. */
  22064. comments: string;
  22065. /**
  22066. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22067. */
  22068. get isUnique(): boolean;
  22069. /**
  22070. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22071. */
  22072. get isFinalMerger(): boolean;
  22073. /**
  22074. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22075. */
  22076. get isInput(): boolean;
  22077. /**
  22078. * Gets or sets the build Id
  22079. */
  22080. get buildId(): number;
  22081. set buildId(value: number);
  22082. /**
  22083. * Gets or sets the target of the block
  22084. */
  22085. get target(): NodeMaterialBlockTargets;
  22086. set target(value: NodeMaterialBlockTargets);
  22087. /**
  22088. * Gets the list of input points
  22089. */
  22090. get inputs(): NodeMaterialConnectionPoint[];
  22091. /** Gets the list of output points */
  22092. get outputs(): NodeMaterialConnectionPoint[];
  22093. /**
  22094. * Find an input by its name
  22095. * @param name defines the name of the input to look for
  22096. * @returns the input or null if not found
  22097. */
  22098. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22099. /**
  22100. * Find an output by its name
  22101. * @param name defines the name of the outputto look for
  22102. * @returns the output or null if not found
  22103. */
  22104. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22105. /**
  22106. * Creates a new NodeMaterialBlock
  22107. * @param name defines the block name
  22108. * @param target defines the target of that block (Vertex by default)
  22109. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22110. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22111. */
  22112. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22113. /**
  22114. * Initialize the block and prepare the context for build
  22115. * @param state defines the state that will be used for the build
  22116. */
  22117. initialize(state: NodeMaterialBuildState): void;
  22118. /**
  22119. * Bind data to effect. Will only be called for blocks with isBindable === true
  22120. * @param effect defines the effect to bind data to
  22121. * @param nodeMaterial defines the hosting NodeMaterial
  22122. * @param mesh defines the mesh that will be rendered
  22123. * @param subMesh defines the submesh that will be rendered
  22124. */
  22125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22126. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22127. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22128. protected _writeFloat(value: number): string;
  22129. /**
  22130. * Gets the current class name e.g. "NodeMaterialBlock"
  22131. * @returns the class name
  22132. */
  22133. getClassName(): string;
  22134. /**
  22135. * Register a new input. Must be called inside a block constructor
  22136. * @param name defines the connection point name
  22137. * @param type defines the connection point type
  22138. * @param isOptional defines a boolean indicating that this input can be omitted
  22139. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22140. * @param point an already created connection point. If not provided, create a new one
  22141. * @returns the current block
  22142. */
  22143. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22144. /**
  22145. * Register a new output. Must be called inside a block constructor
  22146. * @param name defines the connection point name
  22147. * @param type defines the connection point type
  22148. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22149. * @param point an already created connection point. If not provided, create a new one
  22150. * @returns the current block
  22151. */
  22152. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22153. /**
  22154. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22155. * @param forOutput defines an optional connection point to check compatibility with
  22156. * @returns the first available input or null
  22157. */
  22158. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22159. /**
  22160. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22161. * @param forBlock defines an optional block to check compatibility with
  22162. * @returns the first available input or null
  22163. */
  22164. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22165. /**
  22166. * Gets the sibling of the given output
  22167. * @param current defines the current output
  22168. * @returns the next output in the list or null
  22169. */
  22170. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22171. /**
  22172. * Connect current block with another block
  22173. * @param other defines the block to connect with
  22174. * @param options define the various options to help pick the right connections
  22175. * @returns the current block
  22176. */
  22177. connectTo(other: NodeMaterialBlock, options?: {
  22178. input?: string;
  22179. output?: string;
  22180. outputSwizzle?: string;
  22181. }): this | undefined;
  22182. protected _buildBlock(state: NodeMaterialBuildState): void;
  22183. /**
  22184. * Add uniforms, samplers and uniform buffers at compilation time
  22185. * @param state defines the state to update
  22186. * @param nodeMaterial defines the node material requesting the update
  22187. * @param defines defines the material defines to update
  22188. * @param uniformBuffers defines the list of uniform buffer names
  22189. */
  22190. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22191. /**
  22192. * Add potential fallbacks if shader compilation fails
  22193. * @param mesh defines the mesh to be rendered
  22194. * @param fallbacks defines the current prioritized list of fallbacks
  22195. */
  22196. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22197. /**
  22198. * Initialize defines for shader compilation
  22199. * @param mesh defines the mesh to be rendered
  22200. * @param nodeMaterial defines the node material requesting the update
  22201. * @param defines defines the material defines to update
  22202. * @param useInstances specifies that instances should be used
  22203. */
  22204. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22205. /**
  22206. * Update defines for shader compilation
  22207. * @param mesh defines the mesh to be rendered
  22208. * @param nodeMaterial defines the node material requesting the update
  22209. * @param defines defines the material defines to update
  22210. * @param useInstances specifies that instances should be used
  22211. * @param subMesh defines which submesh to render
  22212. */
  22213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22214. /**
  22215. * Lets the block try to connect some inputs automatically
  22216. * @param material defines the hosting NodeMaterial
  22217. */
  22218. autoConfigure(material: NodeMaterial): void;
  22219. /**
  22220. * Function called when a block is declared as repeatable content generator
  22221. * @param vertexShaderState defines the current compilation state for the vertex shader
  22222. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22223. * @param mesh defines the mesh to be rendered
  22224. * @param defines defines the material defines to update
  22225. */
  22226. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22227. /**
  22228. * Checks if the block is ready
  22229. * @param mesh defines the mesh to be rendered
  22230. * @param nodeMaterial defines the node material requesting the update
  22231. * @param defines defines the material defines to update
  22232. * @param useInstances specifies that instances should be used
  22233. * @returns true if the block is ready
  22234. */
  22235. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22236. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22237. private _processBuild;
  22238. /**
  22239. * Validates the new name for the block node.
  22240. * @param newName the new name to be given to the node.
  22241. * @returns false if the name is a reserve word, else true.
  22242. */
  22243. validateBlockName(newName: string): boolean;
  22244. /**
  22245. * Compile the current node and generate the shader code
  22246. * @param state defines the current compilation state (uniforms, samplers, current string)
  22247. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22248. * @returns true if already built
  22249. */
  22250. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22251. protected _inputRename(name: string): string;
  22252. protected _outputRename(name: string): string;
  22253. protected _dumpPropertiesCode(): string;
  22254. /** @hidden */
  22255. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22256. /** @hidden */
  22257. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22258. /**
  22259. * Clone the current block to a new identical block
  22260. * @param scene defines the hosting scene
  22261. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22262. * @returns a copy of the current block
  22263. */
  22264. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22265. /**
  22266. * Serializes this block in a JSON representation
  22267. * @returns the serialized block object
  22268. */
  22269. serialize(): any;
  22270. /** @hidden */
  22271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22272. private _deserializePortDisplayNamesAndExposedOnFrame;
  22273. /**
  22274. * Release resources
  22275. */
  22276. dispose(): void;
  22277. }
  22278. }
  22279. declare module "babylonjs/Materials/pushMaterial" {
  22280. import { Nullable } from "babylonjs/types";
  22281. import { Scene } from "babylonjs/scene";
  22282. import { Matrix } from "babylonjs/Maths/math.vector";
  22283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22284. import { Mesh } from "babylonjs/Meshes/mesh";
  22285. import { Material } from "babylonjs/Materials/material";
  22286. import { Effect } from "babylonjs/Materials/effect";
  22287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22288. /**
  22289. * Base class of materials working in push mode in babylon JS
  22290. * @hidden
  22291. */
  22292. export class PushMaterial extends Material {
  22293. protected _activeEffect: Effect;
  22294. protected _normalMatrix: Matrix;
  22295. constructor(name: string, scene: Scene);
  22296. getEffect(): Effect;
  22297. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22298. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22299. /**
  22300. * Binds the given world matrix to the active effect
  22301. *
  22302. * @param world the matrix to bind
  22303. */
  22304. bindOnlyWorldMatrix(world: Matrix): void;
  22305. /**
  22306. * Binds the given normal matrix to the active effect
  22307. *
  22308. * @param normalMatrix the matrix to bind
  22309. */
  22310. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22311. bind(world: Matrix, mesh?: Mesh): void;
  22312. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22313. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22314. }
  22315. }
  22316. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22318. /**
  22319. * Root class for all node material optimizers
  22320. */
  22321. export class NodeMaterialOptimizer {
  22322. /**
  22323. * Function used to optimize a NodeMaterial graph
  22324. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22325. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22326. */
  22327. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22328. }
  22329. }
  22330. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22334. import { Scene } from "babylonjs/scene";
  22335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22336. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22337. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22338. /**
  22339. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22340. */
  22341. export class TransformBlock extends NodeMaterialBlock {
  22342. /**
  22343. * Defines the value to use to complement W value to transform it to a Vector4
  22344. */
  22345. complementW: number;
  22346. /**
  22347. * Defines the value to use to complement z value to transform it to a Vector4
  22348. */
  22349. complementZ: number;
  22350. /**
  22351. * Creates a new TransformBlock
  22352. * @param name defines the block name
  22353. */
  22354. constructor(name: string);
  22355. /**
  22356. * Gets the current class name
  22357. * @returns the class name
  22358. */
  22359. getClassName(): string;
  22360. /**
  22361. * Gets the vector input
  22362. */
  22363. get vector(): NodeMaterialConnectionPoint;
  22364. /**
  22365. * Gets the output component
  22366. */
  22367. get output(): NodeMaterialConnectionPoint;
  22368. /**
  22369. * Gets the xyz output component
  22370. */
  22371. get xyz(): NodeMaterialConnectionPoint;
  22372. /**
  22373. * Gets the matrix transform input
  22374. */
  22375. get transform(): NodeMaterialConnectionPoint;
  22376. protected _buildBlock(state: NodeMaterialBuildState): this;
  22377. /**
  22378. * Update defines for shader compilation
  22379. * @param mesh defines the mesh to be rendered
  22380. * @param nodeMaterial defines the node material requesting the update
  22381. * @param defines defines the material defines to update
  22382. * @param useInstances specifies that instances should be used
  22383. * @param subMesh defines which submesh to render
  22384. */
  22385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22386. serialize(): any;
  22387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22388. protected _dumpPropertiesCode(): string;
  22389. }
  22390. }
  22391. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22395. /**
  22396. * Block used to output the vertex position
  22397. */
  22398. export class VertexOutputBlock extends NodeMaterialBlock {
  22399. /**
  22400. * Creates a new VertexOutputBlock
  22401. * @param name defines the block name
  22402. */
  22403. constructor(name: string);
  22404. /**
  22405. * Gets the current class name
  22406. * @returns the class name
  22407. */
  22408. getClassName(): string;
  22409. /**
  22410. * Gets the vector input component
  22411. */
  22412. get vector(): NodeMaterialConnectionPoint;
  22413. protected _buildBlock(state: NodeMaterialBuildState): this;
  22414. }
  22415. }
  22416. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22420. /**
  22421. * Block used to output the final color
  22422. */
  22423. export class FragmentOutputBlock extends NodeMaterialBlock {
  22424. /**
  22425. * Create a new FragmentOutputBlock
  22426. * @param name defines the block name
  22427. */
  22428. constructor(name: string);
  22429. /**
  22430. * Gets the current class name
  22431. * @returns the class name
  22432. */
  22433. getClassName(): string;
  22434. /**
  22435. * Gets the rgba input component
  22436. */
  22437. get rgba(): NodeMaterialConnectionPoint;
  22438. /**
  22439. * Gets the rgb input component
  22440. */
  22441. get rgb(): NodeMaterialConnectionPoint;
  22442. /**
  22443. * Gets the a input component
  22444. */
  22445. get a(): NodeMaterialConnectionPoint;
  22446. protected _buildBlock(state: NodeMaterialBuildState): this;
  22447. }
  22448. }
  22449. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22453. /**
  22454. * Block used for the particle ramp gradient section
  22455. */
  22456. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22457. /**
  22458. * Create a new ParticleRampGradientBlock
  22459. * @param name defines the block name
  22460. */
  22461. constructor(name: string);
  22462. /**
  22463. * Gets the current class name
  22464. * @returns the class name
  22465. */
  22466. getClassName(): string;
  22467. /**
  22468. * Gets the color input component
  22469. */
  22470. get color(): NodeMaterialConnectionPoint;
  22471. /**
  22472. * Gets the rampColor output component
  22473. */
  22474. get rampColor(): NodeMaterialConnectionPoint;
  22475. /**
  22476. * Initialize the block and prepare the context for build
  22477. * @param state defines the state that will be used for the build
  22478. */
  22479. initialize(state: NodeMaterialBuildState): void;
  22480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22481. }
  22482. }
  22483. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22487. /**
  22488. * Block used for the particle blend multiply section
  22489. */
  22490. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22491. /**
  22492. * Create a new ParticleBlendMultiplyBlock
  22493. * @param name defines the block name
  22494. */
  22495. constructor(name: string);
  22496. /**
  22497. * Gets the current class name
  22498. * @returns the class name
  22499. */
  22500. getClassName(): string;
  22501. /**
  22502. * Gets the color input component
  22503. */
  22504. get color(): NodeMaterialConnectionPoint;
  22505. /**
  22506. * Gets the alphaTexture input component
  22507. */
  22508. get alphaTexture(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the alphaColor input component
  22511. */
  22512. get alphaColor(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the blendColor output component
  22515. */
  22516. get blendColor(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Initialize the block and prepare the context for build
  22519. * @param state defines the state that will be used for the build
  22520. */
  22521. initialize(state: NodeMaterialBuildState): void;
  22522. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22523. }
  22524. }
  22525. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22529. /**
  22530. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22531. */
  22532. export class VectorMergerBlock extends NodeMaterialBlock {
  22533. /**
  22534. * Create a new VectorMergerBlock
  22535. * @param name defines the block name
  22536. */
  22537. constructor(name: string);
  22538. /**
  22539. * Gets the current class name
  22540. * @returns the class name
  22541. */
  22542. getClassName(): string;
  22543. /**
  22544. * Gets the xyz component (input)
  22545. */
  22546. get xyzIn(): NodeMaterialConnectionPoint;
  22547. /**
  22548. * Gets the xy component (input)
  22549. */
  22550. get xyIn(): NodeMaterialConnectionPoint;
  22551. /**
  22552. * Gets the x component (input)
  22553. */
  22554. get x(): NodeMaterialConnectionPoint;
  22555. /**
  22556. * Gets the y component (input)
  22557. */
  22558. get y(): NodeMaterialConnectionPoint;
  22559. /**
  22560. * Gets the z component (input)
  22561. */
  22562. get z(): NodeMaterialConnectionPoint;
  22563. /**
  22564. * Gets the w component (input)
  22565. */
  22566. get w(): NodeMaterialConnectionPoint;
  22567. /**
  22568. * Gets the xyzw component (output)
  22569. */
  22570. get xyzw(): NodeMaterialConnectionPoint;
  22571. /**
  22572. * Gets the xyz component (output)
  22573. */
  22574. get xyzOut(): NodeMaterialConnectionPoint;
  22575. /**
  22576. * Gets the xy component (output)
  22577. */
  22578. get xyOut(): NodeMaterialConnectionPoint;
  22579. /**
  22580. * Gets the xy component (output)
  22581. * @deprecated Please use xyOut instead.
  22582. */
  22583. get xy(): NodeMaterialConnectionPoint;
  22584. /**
  22585. * Gets the xyz component (output)
  22586. * @deprecated Please use xyzOut instead.
  22587. */
  22588. get xyz(): NodeMaterialConnectionPoint;
  22589. protected _buildBlock(state: NodeMaterialBuildState): this;
  22590. }
  22591. }
  22592. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22596. import { Vector2 } from "babylonjs/Maths/math.vector";
  22597. import { Scene } from "babylonjs/scene";
  22598. /**
  22599. * Block used to remap a float from a range to a new one
  22600. */
  22601. export class RemapBlock extends NodeMaterialBlock {
  22602. /**
  22603. * Gets or sets the source range
  22604. */
  22605. sourceRange: Vector2;
  22606. /**
  22607. * Gets or sets the target range
  22608. */
  22609. targetRange: Vector2;
  22610. /**
  22611. * Creates a new RemapBlock
  22612. * @param name defines the block name
  22613. */
  22614. constructor(name: string);
  22615. /**
  22616. * Gets the current class name
  22617. * @returns the class name
  22618. */
  22619. getClassName(): string;
  22620. /**
  22621. * Gets the input component
  22622. */
  22623. get input(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the source min input component
  22626. */
  22627. get sourceMin(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the source max input component
  22630. */
  22631. get sourceMax(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the target min input component
  22634. */
  22635. get targetMin(): NodeMaterialConnectionPoint;
  22636. /**
  22637. * Gets the target max input component
  22638. */
  22639. get targetMax(): NodeMaterialConnectionPoint;
  22640. /**
  22641. * Gets the output component
  22642. */
  22643. get output(): NodeMaterialConnectionPoint;
  22644. protected _buildBlock(state: NodeMaterialBuildState): this;
  22645. protected _dumpPropertiesCode(): string;
  22646. serialize(): any;
  22647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22648. }
  22649. }
  22650. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22654. /**
  22655. * Block used to multiply 2 values
  22656. */
  22657. export class MultiplyBlock extends NodeMaterialBlock {
  22658. /**
  22659. * Creates a new MultiplyBlock
  22660. * @param name defines the block name
  22661. */
  22662. constructor(name: string);
  22663. /**
  22664. * Gets the current class name
  22665. * @returns the class name
  22666. */
  22667. getClassName(): string;
  22668. /**
  22669. * Gets the left operand input component
  22670. */
  22671. get left(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the right operand input component
  22674. */
  22675. get right(): NodeMaterialConnectionPoint;
  22676. /**
  22677. * Gets the output component
  22678. */
  22679. get output(): NodeMaterialConnectionPoint;
  22680. protected _buildBlock(state: NodeMaterialBuildState): this;
  22681. }
  22682. }
  22683. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22687. /**
  22688. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22689. */
  22690. export class ColorSplitterBlock extends NodeMaterialBlock {
  22691. /**
  22692. * Create a new ColorSplitterBlock
  22693. * @param name defines the block name
  22694. */
  22695. constructor(name: string);
  22696. /**
  22697. * Gets the current class name
  22698. * @returns the class name
  22699. */
  22700. getClassName(): string;
  22701. /**
  22702. * Gets the rgba component (input)
  22703. */
  22704. get rgba(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Gets the rgb component (input)
  22707. */
  22708. get rgbIn(): NodeMaterialConnectionPoint;
  22709. /**
  22710. * Gets the rgb component (output)
  22711. */
  22712. get rgbOut(): NodeMaterialConnectionPoint;
  22713. /**
  22714. * Gets the r component (output)
  22715. */
  22716. get r(): NodeMaterialConnectionPoint;
  22717. /**
  22718. * Gets the g component (output)
  22719. */
  22720. get g(): NodeMaterialConnectionPoint;
  22721. /**
  22722. * Gets the b component (output)
  22723. */
  22724. get b(): NodeMaterialConnectionPoint;
  22725. /**
  22726. * Gets the a component (output)
  22727. */
  22728. get a(): NodeMaterialConnectionPoint;
  22729. protected _inputRename(name: string): string;
  22730. protected _outputRename(name: string): string;
  22731. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22732. }
  22733. }
  22734. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22736. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22737. import { Scene } from "babylonjs/scene";
  22738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22739. import { Matrix } from "babylonjs/Maths/math.vector";
  22740. import { Mesh } from "babylonjs/Meshes/mesh";
  22741. import { Engine } from "babylonjs/Engines/engine";
  22742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22743. import { Observable } from "babylonjs/Misc/observable";
  22744. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22745. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22746. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22747. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22748. import { Nullable } from "babylonjs/types";
  22749. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22750. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22751. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22752. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22753. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22754. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22755. import { Effect } from "babylonjs/Materials/effect";
  22756. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22757. import { Camera } from "babylonjs/Cameras/camera";
  22758. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22759. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22760. /**
  22761. * Interface used to configure the node material editor
  22762. */
  22763. export interface INodeMaterialEditorOptions {
  22764. /** Define the URl to load node editor script */
  22765. editorURL?: string;
  22766. }
  22767. /** @hidden */
  22768. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22769. NORMAL: boolean;
  22770. TANGENT: boolean;
  22771. UV1: boolean;
  22772. /** BONES */
  22773. NUM_BONE_INFLUENCERS: number;
  22774. BonesPerMesh: number;
  22775. BONETEXTURE: boolean;
  22776. /** MORPH TARGETS */
  22777. MORPHTARGETS: boolean;
  22778. MORPHTARGETS_NORMAL: boolean;
  22779. MORPHTARGETS_TANGENT: boolean;
  22780. MORPHTARGETS_UV: boolean;
  22781. NUM_MORPH_INFLUENCERS: number;
  22782. /** IMAGE PROCESSING */
  22783. IMAGEPROCESSING: boolean;
  22784. VIGNETTE: boolean;
  22785. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22786. VIGNETTEBLENDMODEOPAQUE: boolean;
  22787. TONEMAPPING: boolean;
  22788. TONEMAPPING_ACES: boolean;
  22789. CONTRAST: boolean;
  22790. EXPOSURE: boolean;
  22791. COLORCURVES: boolean;
  22792. COLORGRADING: boolean;
  22793. COLORGRADING3D: boolean;
  22794. SAMPLER3DGREENDEPTH: boolean;
  22795. SAMPLER3DBGRMAP: boolean;
  22796. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22797. /** MISC. */
  22798. BUMPDIRECTUV: number;
  22799. constructor();
  22800. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22801. }
  22802. /**
  22803. * Class used to configure NodeMaterial
  22804. */
  22805. export interface INodeMaterialOptions {
  22806. /**
  22807. * Defines if blocks should emit comments
  22808. */
  22809. emitComments: boolean;
  22810. }
  22811. /**
  22812. * Class used to create a node based material built by assembling shader blocks
  22813. */
  22814. export class NodeMaterial extends PushMaterial {
  22815. private static _BuildIdGenerator;
  22816. private _options;
  22817. private _vertexCompilationState;
  22818. private _fragmentCompilationState;
  22819. private _sharedData;
  22820. private _buildId;
  22821. private _buildWasSuccessful;
  22822. private _cachedWorldViewMatrix;
  22823. private _cachedWorldViewProjectionMatrix;
  22824. private _optimizers;
  22825. private _animationFrame;
  22826. /** Define the Url to load node editor script */
  22827. static EditorURL: string;
  22828. /** Define the Url to load snippets */
  22829. static SnippetUrl: string;
  22830. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22831. static IgnoreTexturesAtLoadTime: boolean;
  22832. private BJSNODEMATERIALEDITOR;
  22833. /** Get the inspector from bundle or global */
  22834. private _getGlobalNodeMaterialEditor;
  22835. /**
  22836. * Snippet ID if the material was created from the snippet server
  22837. */
  22838. snippetId: string;
  22839. /**
  22840. * Gets or sets data used by visual editor
  22841. * @see https://nme.babylonjs.com
  22842. */
  22843. editorData: any;
  22844. /**
  22845. * 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)
  22846. */
  22847. ignoreAlpha: boolean;
  22848. /**
  22849. * Defines the maximum number of lights that can be used in the material
  22850. */
  22851. maxSimultaneousLights: number;
  22852. /**
  22853. * Observable raised when the material is built
  22854. */
  22855. onBuildObservable: Observable<NodeMaterial>;
  22856. /**
  22857. * Gets or sets the root nodes of the material vertex shader
  22858. */
  22859. _vertexOutputNodes: NodeMaterialBlock[];
  22860. /**
  22861. * Gets or sets the root nodes of the material fragment (pixel) shader
  22862. */
  22863. _fragmentOutputNodes: NodeMaterialBlock[];
  22864. /** Gets or sets options to control the node material overall behavior */
  22865. get options(): INodeMaterialOptions;
  22866. set options(options: INodeMaterialOptions);
  22867. /**
  22868. * Default configuration related to image processing available in the standard Material.
  22869. */
  22870. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22871. /**
  22872. * Gets the image processing configuration used either in this material.
  22873. */
  22874. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22875. /**
  22876. * Sets the Default image processing configuration used either in the this material.
  22877. *
  22878. * If sets to null, the scene one is in use.
  22879. */
  22880. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22881. /**
  22882. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22883. */
  22884. attachedBlocks: NodeMaterialBlock[];
  22885. /**
  22886. * Specifies the mode of the node material
  22887. * @hidden
  22888. */
  22889. _mode: NodeMaterialModes;
  22890. /**
  22891. * Gets the mode property
  22892. */
  22893. get mode(): NodeMaterialModes;
  22894. /**
  22895. * Create a new node based material
  22896. * @param name defines the material name
  22897. * @param scene defines the hosting scene
  22898. * @param options defines creation option
  22899. */
  22900. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22901. /**
  22902. * Gets the current class name of the material e.g. "NodeMaterial"
  22903. * @returns the class name
  22904. */
  22905. getClassName(): string;
  22906. /**
  22907. * Keep track of the image processing observer to allow dispose and replace.
  22908. */
  22909. private _imageProcessingObserver;
  22910. /**
  22911. * Attaches a new image processing configuration to the Standard Material.
  22912. * @param configuration
  22913. */
  22914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22915. /**
  22916. * Get a block by its name
  22917. * @param name defines the name of the block to retrieve
  22918. * @returns the required block or null if not found
  22919. */
  22920. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22921. /**
  22922. * Get a block by its name
  22923. * @param predicate defines the predicate used to find the good candidate
  22924. * @returns the required block or null if not found
  22925. */
  22926. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22927. /**
  22928. * Get an input block by its name
  22929. * @param predicate defines the predicate used to find the good candidate
  22930. * @returns the required input block or null if not found
  22931. */
  22932. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22933. /**
  22934. * Gets the list of input blocks attached to this material
  22935. * @returns an array of InputBlocks
  22936. */
  22937. getInputBlocks(): InputBlock[];
  22938. /**
  22939. * Adds a new optimizer to the list of optimizers
  22940. * @param optimizer defines the optimizers to add
  22941. * @returns the current material
  22942. */
  22943. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22944. /**
  22945. * Remove an optimizer from the list of optimizers
  22946. * @param optimizer defines the optimizers to remove
  22947. * @returns the current material
  22948. */
  22949. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22950. /**
  22951. * Add a new block to the list of output nodes
  22952. * @param node defines the node to add
  22953. * @returns the current material
  22954. */
  22955. addOutputNode(node: NodeMaterialBlock): this;
  22956. /**
  22957. * Remove a block from the list of root nodes
  22958. * @param node defines the node to remove
  22959. * @returns the current material
  22960. */
  22961. removeOutputNode(node: NodeMaterialBlock): this;
  22962. private _addVertexOutputNode;
  22963. private _removeVertexOutputNode;
  22964. private _addFragmentOutputNode;
  22965. private _removeFragmentOutputNode;
  22966. /**
  22967. * Specifies if the material will require alpha blending
  22968. * @returns a boolean specifying if alpha blending is needed
  22969. */
  22970. needAlphaBlending(): boolean;
  22971. /**
  22972. * Specifies if this material should be rendered in alpha test mode
  22973. * @returns a boolean specifying if an alpha test is needed.
  22974. */
  22975. needAlphaTesting(): boolean;
  22976. private _initializeBlock;
  22977. private _resetDualBlocks;
  22978. /**
  22979. * Remove a block from the current node material
  22980. * @param block defines the block to remove
  22981. */
  22982. removeBlock(block: NodeMaterialBlock): void;
  22983. /**
  22984. * Build the material and generates the inner effect
  22985. * @param verbose defines if the build should log activity
  22986. */
  22987. build(verbose?: boolean): void;
  22988. /**
  22989. * Runs an otpimization phase to try to improve the shader code
  22990. */
  22991. optimize(): void;
  22992. private _prepareDefinesForAttributes;
  22993. /**
  22994. * Create a post process from the material
  22995. * @param camera The camera to apply the render pass to.
  22996. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22998. * @param engine The engine which the post process will be applied. (default: current engine)
  22999. * @param reusable If the post process can be reused on the same frame. (default: false)
  23000. * @param textureType Type of textures used when performing the post process. (default: 0)
  23001. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23002. * @returns the post process created
  23003. */
  23004. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23005. /**
  23006. * Create the post process effect from the material
  23007. * @param postProcess The post process to create the effect for
  23008. */
  23009. createEffectForPostProcess(postProcess: PostProcess): void;
  23010. private _createEffectOrPostProcess;
  23011. private _createEffectForParticles;
  23012. /**
  23013. * Create the effect to be used as the custom effect for a particle system
  23014. * @param particleSystem Particle system to create the effect for
  23015. * @param onCompiled defines a function to call when the effect creation is successful
  23016. * @param onError defines a function to call when the effect creation has failed
  23017. */
  23018. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23019. private _processDefines;
  23020. /**
  23021. * Get if the submesh is ready to be used and all its information available.
  23022. * Child classes can use it to update shaders
  23023. * @param mesh defines the mesh to check
  23024. * @param subMesh defines which submesh to check
  23025. * @param useInstances specifies that instances should be used
  23026. * @returns a boolean indicating that the submesh is ready or not
  23027. */
  23028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23029. /**
  23030. * Get a string representing the shaders built by the current node graph
  23031. */
  23032. get compiledShaders(): string;
  23033. /**
  23034. * Binds the world matrix to the material
  23035. * @param world defines the world transformation matrix
  23036. */
  23037. bindOnlyWorldMatrix(world: Matrix): void;
  23038. /**
  23039. * Binds the submesh to this material by preparing the effect and shader to draw
  23040. * @param world defines the world transformation matrix
  23041. * @param mesh defines the mesh containing the submesh
  23042. * @param subMesh defines the submesh to bind the material to
  23043. */
  23044. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23045. /**
  23046. * Gets the active textures from the material
  23047. * @returns an array of textures
  23048. */
  23049. getActiveTextures(): BaseTexture[];
  23050. /**
  23051. * Gets the list of texture blocks
  23052. * @returns an array of texture blocks
  23053. */
  23054. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23055. /**
  23056. * Specifies if the material uses a texture
  23057. * @param texture defines the texture to check against the material
  23058. * @returns a boolean specifying if the material uses the texture
  23059. */
  23060. hasTexture(texture: BaseTexture): boolean;
  23061. /**
  23062. * Disposes the material
  23063. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23064. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23065. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23066. */
  23067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23068. /** Creates the node editor window. */
  23069. private _createNodeEditor;
  23070. /**
  23071. * Launch the node material editor
  23072. * @param config Define the configuration of the editor
  23073. * @return a promise fulfilled when the node editor is visible
  23074. */
  23075. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23076. /**
  23077. * Clear the current material
  23078. */
  23079. clear(): void;
  23080. /**
  23081. * Clear the current material and set it to a default state
  23082. */
  23083. setToDefault(): void;
  23084. /**
  23085. * Clear the current material and set it to a default state for post process
  23086. */
  23087. setToDefaultPostProcess(): void;
  23088. /**
  23089. * Clear the current material and set it to a default state for particle
  23090. */
  23091. setToDefaultParticle(): void;
  23092. /**
  23093. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23094. * @param url defines the url to load from
  23095. * @returns a promise that will fullfil when the material is fully loaded
  23096. */
  23097. loadAsync(url: string): Promise<void>;
  23098. private _gatherBlocks;
  23099. /**
  23100. * Generate a string containing the code declaration required to create an equivalent of this material
  23101. * @returns a string
  23102. */
  23103. generateCode(): string;
  23104. /**
  23105. * Serializes this material in a JSON representation
  23106. * @returns the serialized material object
  23107. */
  23108. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23109. private _restoreConnections;
  23110. /**
  23111. * Clear the current graph and load a new one from a serialization object
  23112. * @param source defines the JSON representation of the material
  23113. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23114. * @param merge defines whether or not the source must be merged or replace the current content
  23115. */
  23116. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23117. /**
  23118. * Makes a duplicate of the current material.
  23119. * @param name - name to use for the new material.
  23120. */
  23121. clone(name: string): NodeMaterial;
  23122. /**
  23123. * Creates a node material from parsed material data
  23124. * @param source defines the JSON representation of the material
  23125. * @param scene defines the hosting scene
  23126. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23127. * @returns a new node material
  23128. */
  23129. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23130. /**
  23131. * Creates a node material from a snippet saved in a remote file
  23132. * @param name defines the name of the material to create
  23133. * @param url defines the url to load from
  23134. * @param scene defines the hosting scene
  23135. * @returns a promise that will resolve to the new node material
  23136. */
  23137. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23138. /**
  23139. * Creates a node material from a snippet saved by the node material editor
  23140. * @param snippetId defines the snippet to load
  23141. * @param scene defines the hosting scene
  23142. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23143. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23144. * @returns a promise that will resolve to the new node material
  23145. */
  23146. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23147. /**
  23148. * Creates a new node material set to default basic configuration
  23149. * @param name defines the name of the material
  23150. * @param scene defines the hosting scene
  23151. * @returns a new NodeMaterial
  23152. */
  23153. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23154. }
  23155. }
  23156. declare module "babylonjs/PostProcesses/postProcess" {
  23157. import { Nullable } from "babylonjs/types";
  23158. import { SmartArray } from "babylonjs/Misc/smartArray";
  23159. import { Observable } from "babylonjs/Misc/observable";
  23160. import { Vector2 } from "babylonjs/Maths/math.vector";
  23161. import { Camera } from "babylonjs/Cameras/camera";
  23162. import { Effect } from "babylonjs/Materials/effect";
  23163. import "babylonjs/Shaders/postprocess.vertex";
  23164. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23165. import { Engine } from "babylonjs/Engines/engine";
  23166. import { Color4 } from "babylonjs/Maths/math.color";
  23167. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23168. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23169. import { Scene } from "babylonjs/scene";
  23170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23171. /**
  23172. * Size options for a post process
  23173. */
  23174. export type PostProcessOptions = {
  23175. width: number;
  23176. height: number;
  23177. };
  23178. /**
  23179. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23180. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23181. */
  23182. export class PostProcess {
  23183. /** Name of the PostProcess. */
  23184. name: string;
  23185. /**
  23186. * Gets or sets the unique id of the post process
  23187. */
  23188. uniqueId: number;
  23189. /**
  23190. * Width of the texture to apply the post process on
  23191. */
  23192. width: number;
  23193. /**
  23194. * Height of the texture to apply the post process on
  23195. */
  23196. height: number;
  23197. /**
  23198. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23199. */
  23200. nodeMaterialSource: Nullable<NodeMaterial>;
  23201. /**
  23202. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23203. * @hidden
  23204. */
  23205. _outputTexture: Nullable<InternalTexture>;
  23206. /**
  23207. * Sampling mode used by the shader
  23208. * See https://doc.babylonjs.com/classes/3.1/texture
  23209. */
  23210. renderTargetSamplingMode: number;
  23211. /**
  23212. * Clear color to use when screen clearing
  23213. */
  23214. clearColor: Color4;
  23215. /**
  23216. * If the buffer needs to be cleared before applying the post process. (default: true)
  23217. * Should be set to false if shader will overwrite all previous pixels.
  23218. */
  23219. autoClear: boolean;
  23220. /**
  23221. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23222. */
  23223. alphaMode: number;
  23224. /**
  23225. * Sets the setAlphaBlendConstants of the babylon engine
  23226. */
  23227. alphaConstants: Color4;
  23228. /**
  23229. * Animations to be used for the post processing
  23230. */
  23231. animations: import("babylonjs/Animations/animation").Animation[];
  23232. /**
  23233. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23234. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23235. */
  23236. enablePixelPerfectMode: boolean;
  23237. /**
  23238. * Force the postprocess to be applied without taking in account viewport
  23239. */
  23240. forceFullscreenViewport: boolean;
  23241. /**
  23242. * List of inspectable custom properties (used by the Inspector)
  23243. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23244. */
  23245. inspectableCustomProperties: IInspectable[];
  23246. /**
  23247. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23248. *
  23249. * | Value | Type | Description |
  23250. * | ----- | ----------------------------------- | ----------- |
  23251. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23252. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23253. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23254. *
  23255. */
  23256. scaleMode: number;
  23257. /**
  23258. * Force textures to be a power of two (default: false)
  23259. */
  23260. alwaysForcePOT: boolean;
  23261. private _samples;
  23262. /**
  23263. * Number of sample textures (default: 1)
  23264. */
  23265. get samples(): number;
  23266. set samples(n: number);
  23267. /**
  23268. * Modify the scale of the post process to be the same as the viewport (default: false)
  23269. */
  23270. adaptScaleToCurrentViewport: boolean;
  23271. private _camera;
  23272. protected _scene: Scene;
  23273. private _engine;
  23274. private _options;
  23275. private _reusable;
  23276. private _textureType;
  23277. private _textureFormat;
  23278. /**
  23279. * Smart array of input and output textures for the post process.
  23280. * @hidden
  23281. */
  23282. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23283. /**
  23284. * The index in _textures that corresponds to the output texture.
  23285. * @hidden
  23286. */
  23287. _currentRenderTextureInd: number;
  23288. private _effect;
  23289. private _samplers;
  23290. private _fragmentUrl;
  23291. private _vertexUrl;
  23292. private _parameters;
  23293. private _scaleRatio;
  23294. protected _indexParameters: any;
  23295. private _shareOutputWithPostProcess;
  23296. private _texelSize;
  23297. private _forcedOutputTexture;
  23298. /**
  23299. * Returns the fragment url or shader name used in the post process.
  23300. * @returns the fragment url or name in the shader store.
  23301. */
  23302. getEffectName(): string;
  23303. /**
  23304. * An event triggered when the postprocess is activated.
  23305. */
  23306. onActivateObservable: Observable<Camera>;
  23307. private _onActivateObserver;
  23308. /**
  23309. * A function that is added to the onActivateObservable
  23310. */
  23311. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23312. /**
  23313. * An event triggered when the postprocess changes its size.
  23314. */
  23315. onSizeChangedObservable: Observable<PostProcess>;
  23316. private _onSizeChangedObserver;
  23317. /**
  23318. * A function that is added to the onSizeChangedObservable
  23319. */
  23320. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23321. /**
  23322. * An event triggered when the postprocess applies its effect.
  23323. */
  23324. onApplyObservable: Observable<Effect>;
  23325. private _onApplyObserver;
  23326. /**
  23327. * A function that is added to the onApplyObservable
  23328. */
  23329. set onApply(callback: (effect: Effect) => void);
  23330. /**
  23331. * An event triggered before rendering the postprocess
  23332. */
  23333. onBeforeRenderObservable: Observable<Effect>;
  23334. private _onBeforeRenderObserver;
  23335. /**
  23336. * A function that is added to the onBeforeRenderObservable
  23337. */
  23338. set onBeforeRender(callback: (effect: Effect) => void);
  23339. /**
  23340. * An event triggered after rendering the postprocess
  23341. */
  23342. onAfterRenderObservable: Observable<Effect>;
  23343. private _onAfterRenderObserver;
  23344. /**
  23345. * A function that is added to the onAfterRenderObservable
  23346. */
  23347. set onAfterRender(callback: (efect: Effect) => void);
  23348. /**
  23349. * 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
  23350. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23351. */
  23352. get inputTexture(): InternalTexture;
  23353. set inputTexture(value: InternalTexture);
  23354. /**
  23355. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23356. * the only way to unset it is to use this function to restore its internal state
  23357. */
  23358. restoreDefaultInputTexture(): void;
  23359. /**
  23360. * Gets the camera which post process is applied to.
  23361. * @returns The camera the post process is applied to.
  23362. */
  23363. getCamera(): Camera;
  23364. /**
  23365. * Gets the texel size of the postprocess.
  23366. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23367. */
  23368. get texelSize(): Vector2;
  23369. /**
  23370. * Creates a new instance PostProcess
  23371. * @param name The name of the PostProcess.
  23372. * @param fragmentUrl The url of the fragment shader to be used.
  23373. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23374. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23375. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23376. * @param camera The camera to apply the render pass to.
  23377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23378. * @param engine The engine which the post process will be applied. (default: current engine)
  23379. * @param reusable If the post process can be reused on the same frame. (default: false)
  23380. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23381. * @param textureType Type of textures used when performing the post process. (default: 0)
  23382. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23383. * @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
  23384. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23385. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23386. */
  23387. constructor(
  23388. /** Name of the PostProcess. */
  23389. 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);
  23390. /**
  23391. * Gets a string idenfifying the name of the class
  23392. * @returns "PostProcess" string
  23393. */
  23394. getClassName(): string;
  23395. /**
  23396. * Gets the engine which this post process belongs to.
  23397. * @returns The engine the post process was enabled with.
  23398. */
  23399. getEngine(): Engine;
  23400. /**
  23401. * The effect that is created when initializing the post process.
  23402. * @returns The created effect corresponding the the postprocess.
  23403. */
  23404. getEffect(): Effect;
  23405. /**
  23406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23407. * @param postProcess The post process to share the output with.
  23408. * @returns This post process.
  23409. */
  23410. shareOutputWith(postProcess: PostProcess): PostProcess;
  23411. /**
  23412. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23413. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23414. */
  23415. useOwnOutput(): void;
  23416. /**
  23417. * Updates the effect with the current post process compile time values and recompiles the shader.
  23418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23421. * @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
  23422. * @param onCompiled Called when the shader has been compiled.
  23423. * @param onError Called if there is an error when compiling a shader.
  23424. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23425. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23426. */
  23427. 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;
  23428. /**
  23429. * The post process is reusable if it can be used multiple times within one frame.
  23430. * @returns If the post process is reusable
  23431. */
  23432. isReusable(): boolean;
  23433. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23434. markTextureDirty(): void;
  23435. /**
  23436. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23437. * 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.
  23438. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23439. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23440. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23441. * @returns The target texture that was bound to be written to.
  23442. */
  23443. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23444. /**
  23445. * If the post process is supported.
  23446. */
  23447. get isSupported(): boolean;
  23448. /**
  23449. * The aspect ratio of the output texture.
  23450. */
  23451. get aspectRatio(): number;
  23452. /**
  23453. * Get a value indicating if the post-process is ready to be used
  23454. * @returns true if the post-process is ready (shader is compiled)
  23455. */
  23456. isReady(): boolean;
  23457. /**
  23458. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23459. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23460. */
  23461. apply(): Nullable<Effect>;
  23462. private _disposeTextures;
  23463. /**
  23464. * Disposes the post process.
  23465. * @param camera The camera to dispose the post process on.
  23466. */
  23467. dispose(camera?: Camera): void;
  23468. }
  23469. }
  23470. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23471. /** @hidden */
  23472. export var kernelBlurVaryingDeclaration: {
  23473. name: string;
  23474. shader: string;
  23475. };
  23476. }
  23477. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23478. /** @hidden */
  23479. export var kernelBlurFragment: {
  23480. name: string;
  23481. shader: string;
  23482. };
  23483. }
  23484. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23485. /** @hidden */
  23486. export var kernelBlurFragment2: {
  23487. name: string;
  23488. shader: string;
  23489. };
  23490. }
  23491. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23492. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23493. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23494. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23495. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23496. /** @hidden */
  23497. export var kernelBlurPixelShader: {
  23498. name: string;
  23499. shader: string;
  23500. };
  23501. }
  23502. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23503. /** @hidden */
  23504. export var kernelBlurVertex: {
  23505. name: string;
  23506. shader: string;
  23507. };
  23508. }
  23509. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23510. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23511. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23512. /** @hidden */
  23513. export var kernelBlurVertexShader: {
  23514. name: string;
  23515. shader: string;
  23516. };
  23517. }
  23518. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23519. import { Vector2 } from "babylonjs/Maths/math.vector";
  23520. import { Nullable } from "babylonjs/types";
  23521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23522. import { Camera } from "babylonjs/Cameras/camera";
  23523. import { Effect } from "babylonjs/Materials/effect";
  23524. import { Engine } from "babylonjs/Engines/engine";
  23525. import "babylonjs/Shaders/kernelBlur.fragment";
  23526. import "babylonjs/Shaders/kernelBlur.vertex";
  23527. /**
  23528. * The Blur Post Process which blurs an image based on a kernel and direction.
  23529. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23530. */
  23531. export class BlurPostProcess extends PostProcess {
  23532. /** The direction in which to blur the image. */
  23533. direction: Vector2;
  23534. private blockCompilation;
  23535. protected _kernel: number;
  23536. protected _idealKernel: number;
  23537. protected _packedFloat: boolean;
  23538. private _staticDefines;
  23539. /**
  23540. * Sets the length in pixels of the blur sample region
  23541. */
  23542. set kernel(v: number);
  23543. /**
  23544. * Gets the length in pixels of the blur sample region
  23545. */
  23546. get kernel(): number;
  23547. /**
  23548. * Sets wether or not the blur needs to unpack/repack floats
  23549. */
  23550. set packedFloat(v: boolean);
  23551. /**
  23552. * Gets wether or not the blur is unpacking/repacking floats
  23553. */
  23554. get packedFloat(): boolean;
  23555. /**
  23556. * Creates a new instance BlurPostProcess
  23557. * @param name The name of the effect.
  23558. * @param direction The direction in which to blur the image.
  23559. * @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.
  23560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23561. * @param camera The camera to apply the render pass to.
  23562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23563. * @param engine The engine which the post process will be applied. (default: current engine)
  23564. * @param reusable If the post process can be reused on the same frame. (default: false)
  23565. * @param textureType Type of textures used when performing the post process. (default: 0)
  23566. * @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)
  23567. */
  23568. constructor(name: string,
  23569. /** The direction in which to blur the image. */
  23570. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23571. /**
  23572. * Updates the effect with the current post process compile time values and recompiles the shader.
  23573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23576. * @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
  23577. * @param onCompiled Called when the shader has been compiled.
  23578. * @param onError Called if there is an error when compiling a shader.
  23579. */
  23580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23581. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23582. /**
  23583. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23584. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23585. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23586. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23587. * The gaps between physical kernels are compensated for in the weighting of the samples
  23588. * @param idealKernel Ideal blur kernel.
  23589. * @return Nearest best kernel.
  23590. */
  23591. protected _nearestBestKernel(idealKernel: number): number;
  23592. /**
  23593. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23594. * @param x The point on the Gaussian distribution to sample.
  23595. * @return the value of the Gaussian function at x.
  23596. */
  23597. protected _gaussianWeight(x: number): number;
  23598. /**
  23599. * Generates a string that can be used as a floating point number in GLSL.
  23600. * @param x Value to print.
  23601. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23602. * @return GLSL float string.
  23603. */
  23604. protected _glslFloat(x: number, decimalFigures?: number): string;
  23605. }
  23606. }
  23607. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23608. import { Scene } from "babylonjs/scene";
  23609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23610. import { Plane } from "babylonjs/Maths/math.plane";
  23611. /**
  23612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23614. * You can then easily use it as a reflectionTexture on a flat surface.
  23615. * In case the surface is not a plane, please consider relying on reflection probes.
  23616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23617. */
  23618. export class MirrorTexture extends RenderTargetTexture {
  23619. private scene;
  23620. /**
  23621. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23622. * 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.
  23623. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23624. */
  23625. mirrorPlane: Plane;
  23626. /**
  23627. * Define the blur ratio used to blur the reflection if needed.
  23628. */
  23629. set blurRatio(value: number);
  23630. get blurRatio(): number;
  23631. /**
  23632. * Define the adaptive blur kernel used to blur the reflection if needed.
  23633. * This will autocompute the closest best match for the `blurKernel`
  23634. */
  23635. set adaptiveBlurKernel(value: number);
  23636. /**
  23637. * Define the blur kernel used to blur the reflection if needed.
  23638. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23639. */
  23640. set blurKernel(value: number);
  23641. /**
  23642. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23643. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23644. */
  23645. set blurKernelX(value: number);
  23646. get blurKernelX(): number;
  23647. /**
  23648. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23649. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23650. */
  23651. set blurKernelY(value: number);
  23652. get blurKernelY(): number;
  23653. private _autoComputeBlurKernel;
  23654. protected _onRatioRescale(): void;
  23655. private _updateGammaSpace;
  23656. private _imageProcessingConfigChangeObserver;
  23657. private _transformMatrix;
  23658. private _mirrorMatrix;
  23659. private _savedViewMatrix;
  23660. private _blurX;
  23661. private _blurY;
  23662. private _adaptiveBlurKernel;
  23663. private _blurKernelX;
  23664. private _blurKernelY;
  23665. private _blurRatio;
  23666. /**
  23667. * Instantiates a Mirror Texture.
  23668. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23669. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23670. * You can then easily use it as a reflectionTexture on a flat surface.
  23671. * In case the surface is not a plane, please consider relying on reflection probes.
  23672. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23673. * @param name
  23674. * @param size
  23675. * @param scene
  23676. * @param generateMipMaps
  23677. * @param type
  23678. * @param samplingMode
  23679. * @param generateDepthBuffer
  23680. */
  23681. constructor(name: string, size: number | {
  23682. width: number;
  23683. height: number;
  23684. } | {
  23685. ratio: number;
  23686. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23687. private _preparePostProcesses;
  23688. /**
  23689. * Clone the mirror texture.
  23690. * @returns the cloned texture
  23691. */
  23692. clone(): MirrorTexture;
  23693. /**
  23694. * Serialize the texture to a JSON representation you could use in Parse later on
  23695. * @returns the serialized JSON representation
  23696. */
  23697. serialize(): any;
  23698. /**
  23699. * Dispose the texture and release its associated resources.
  23700. */
  23701. dispose(): void;
  23702. }
  23703. }
  23704. declare module "babylonjs/Materials/Textures/texture" {
  23705. import { Observable } from "babylonjs/Misc/observable";
  23706. import { Nullable } from "babylonjs/types";
  23707. import { Matrix } from "babylonjs/Maths/math.vector";
  23708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23709. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23710. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23711. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23712. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23713. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23714. import { Scene } from "babylonjs/scene";
  23715. /**
  23716. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23717. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23718. */
  23719. export class Texture extends BaseTexture {
  23720. /**
  23721. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23722. */
  23723. static SerializeBuffers: boolean;
  23724. /** @hidden */
  23725. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23726. /** @hidden */
  23727. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23728. /** @hidden */
  23729. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23730. /** nearest is mag = nearest and min = nearest and mip = linear */
  23731. static readonly NEAREST_SAMPLINGMODE: number;
  23732. /** nearest is mag = nearest and min = nearest and mip = linear */
  23733. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23734. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23735. static readonly BILINEAR_SAMPLINGMODE: number;
  23736. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23737. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23738. /** Trilinear is mag = linear and min = linear and mip = linear */
  23739. static readonly TRILINEAR_SAMPLINGMODE: number;
  23740. /** Trilinear is mag = linear and min = linear and mip = linear */
  23741. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23742. /** mag = nearest and min = nearest and mip = nearest */
  23743. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23744. /** mag = nearest and min = linear and mip = nearest */
  23745. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23746. /** mag = nearest and min = linear and mip = linear */
  23747. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23748. /** mag = nearest and min = linear and mip = none */
  23749. static readonly NEAREST_LINEAR: number;
  23750. /** mag = nearest and min = nearest and mip = none */
  23751. static readonly NEAREST_NEAREST: number;
  23752. /** mag = linear and min = nearest and mip = nearest */
  23753. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23754. /** mag = linear and min = nearest and mip = linear */
  23755. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23756. /** mag = linear and min = linear and mip = none */
  23757. static readonly LINEAR_LINEAR: number;
  23758. /** mag = linear and min = nearest and mip = none */
  23759. static readonly LINEAR_NEAREST: number;
  23760. /** Explicit coordinates mode */
  23761. static readonly EXPLICIT_MODE: number;
  23762. /** Spherical coordinates mode */
  23763. static readonly SPHERICAL_MODE: number;
  23764. /** Planar coordinates mode */
  23765. static readonly PLANAR_MODE: number;
  23766. /** Cubic coordinates mode */
  23767. static readonly CUBIC_MODE: number;
  23768. /** Projection coordinates mode */
  23769. static readonly PROJECTION_MODE: number;
  23770. /** Inverse Cubic coordinates mode */
  23771. static readonly SKYBOX_MODE: number;
  23772. /** Inverse Cubic coordinates mode */
  23773. static readonly INVCUBIC_MODE: number;
  23774. /** Equirectangular coordinates mode */
  23775. static readonly EQUIRECTANGULAR_MODE: number;
  23776. /** Equirectangular Fixed coordinates mode */
  23777. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23778. /** Equirectangular Fixed Mirrored coordinates mode */
  23779. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23780. /** Texture is not repeating outside of 0..1 UVs */
  23781. static readonly CLAMP_ADDRESSMODE: number;
  23782. /** Texture is repeating outside of 0..1 UVs */
  23783. static readonly WRAP_ADDRESSMODE: number;
  23784. /** Texture is repeating and mirrored */
  23785. static readonly MIRROR_ADDRESSMODE: number;
  23786. /**
  23787. * 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
  23788. */
  23789. static UseSerializedUrlIfAny: boolean;
  23790. /**
  23791. * Define the url of the texture.
  23792. */
  23793. url: Nullable<string>;
  23794. /**
  23795. * Define an offset on the texture to offset the u coordinates of the UVs
  23796. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23797. */
  23798. uOffset: number;
  23799. /**
  23800. * Define an offset on the texture to offset the v coordinates of the UVs
  23801. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23802. */
  23803. vOffset: number;
  23804. /**
  23805. * Define an offset on the texture to scale the u coordinates of the UVs
  23806. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23807. */
  23808. uScale: number;
  23809. /**
  23810. * Define an offset on the texture to scale the v coordinates of the UVs
  23811. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23812. */
  23813. vScale: number;
  23814. /**
  23815. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23816. * @see https://doc.babylonjs.com/how_to/more_materials
  23817. */
  23818. uAng: number;
  23819. /**
  23820. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23821. * @see https://doc.babylonjs.com/how_to/more_materials
  23822. */
  23823. vAng: number;
  23824. /**
  23825. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23826. * @see https://doc.babylonjs.com/how_to/more_materials
  23827. */
  23828. wAng: number;
  23829. /**
  23830. * Defines the center of rotation (U)
  23831. */
  23832. uRotationCenter: number;
  23833. /**
  23834. * Defines the center of rotation (V)
  23835. */
  23836. vRotationCenter: number;
  23837. /**
  23838. * Defines the center of rotation (W)
  23839. */
  23840. wRotationCenter: number;
  23841. /**
  23842. * Are mip maps generated for this texture or not.
  23843. */
  23844. get noMipmap(): boolean;
  23845. /**
  23846. * List of inspectable custom properties (used by the Inspector)
  23847. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23848. */
  23849. inspectableCustomProperties: Nullable<IInspectable[]>;
  23850. private _noMipmap;
  23851. /** @hidden */
  23852. _invertY: boolean;
  23853. private _rowGenerationMatrix;
  23854. private _cachedTextureMatrix;
  23855. private _projectionModeMatrix;
  23856. private _t0;
  23857. private _t1;
  23858. private _t2;
  23859. private _cachedUOffset;
  23860. private _cachedVOffset;
  23861. private _cachedUScale;
  23862. private _cachedVScale;
  23863. private _cachedUAng;
  23864. private _cachedVAng;
  23865. private _cachedWAng;
  23866. private _cachedProjectionMatrixId;
  23867. private _cachedCoordinatesMode;
  23868. /** @hidden */
  23869. protected _initialSamplingMode: number;
  23870. /** @hidden */
  23871. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23872. private _deleteBuffer;
  23873. protected _format: Nullable<number>;
  23874. private _delayedOnLoad;
  23875. private _delayedOnError;
  23876. private _mimeType?;
  23877. /**
  23878. * Observable triggered once the texture has been loaded.
  23879. */
  23880. onLoadObservable: Observable<Texture>;
  23881. protected _isBlocking: boolean;
  23882. /**
  23883. * Is the texture preventing material to render while loading.
  23884. * If false, a default texture will be used instead of the loading one during the preparation step.
  23885. */
  23886. set isBlocking(value: boolean);
  23887. get isBlocking(): boolean;
  23888. /**
  23889. * Get the current sampling mode associated with the texture.
  23890. */
  23891. get samplingMode(): number;
  23892. /**
  23893. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23894. */
  23895. get invertY(): boolean;
  23896. /**
  23897. * Instantiates a new texture.
  23898. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23899. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23900. * @param url defines the url of the picture to load as a texture
  23901. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23902. * @param noMipmap defines if the texture will require mip maps or not
  23903. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23904. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23905. * @param onLoad defines a callback triggered when the texture has been loaded
  23906. * @param onError defines a callback triggered when an error occurred during the loading session
  23907. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23908. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23909. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23910. * @param mimeType defines an optional mime type information
  23911. */
  23912. 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);
  23913. /**
  23914. * Update the url (and optional buffer) of this texture if url was null during construction.
  23915. * @param url the url of the texture
  23916. * @param buffer the buffer of the texture (defaults to null)
  23917. * @param onLoad callback called when the texture is loaded (defaults to null)
  23918. */
  23919. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23920. /**
  23921. * Finish the loading sequence of a texture flagged as delayed load.
  23922. * @hidden
  23923. */
  23924. delayLoad(): void;
  23925. private _prepareRowForTextureGeneration;
  23926. /**
  23927. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23928. * @returns the transform matrix of the texture.
  23929. */
  23930. getTextureMatrix(uBase?: number): Matrix;
  23931. /**
  23932. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23933. * @returns The reflection texture transform
  23934. */
  23935. getReflectionTextureMatrix(): Matrix;
  23936. /**
  23937. * Clones the texture.
  23938. * @returns the cloned texture
  23939. */
  23940. clone(): Texture;
  23941. /**
  23942. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23943. * @returns The JSON representation of the texture
  23944. */
  23945. serialize(): any;
  23946. /**
  23947. * Get the current class name of the texture useful for serialization or dynamic coding.
  23948. * @returns "Texture"
  23949. */
  23950. getClassName(): string;
  23951. /**
  23952. * Dispose the texture and release its associated resources.
  23953. */
  23954. dispose(): void;
  23955. /**
  23956. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23957. * @param parsedTexture Define the JSON representation of the texture
  23958. * @param scene Define the scene the parsed texture should be instantiated in
  23959. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23960. * @returns The parsed texture if successful
  23961. */
  23962. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23963. /**
  23964. * Creates a texture from its base 64 representation.
  23965. * @param data Define the base64 payload without the data: prefix
  23966. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23967. * @param scene Define the scene the texture should belong to
  23968. * @param noMipmap Forces the texture to not create mip map information if true
  23969. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23970. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23971. * @param onLoad define a callback triggered when the texture has been loaded
  23972. * @param onError define a callback triggered when an error occurred during the loading session
  23973. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23974. * @returns the created texture
  23975. */
  23976. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23977. /**
  23978. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23979. * @param data Define the base64 payload without the data: prefix
  23980. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23981. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23982. * @param scene Define the scene the texture should belong to
  23983. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23984. * @param noMipmap Forces the texture to not create mip map information if true
  23985. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23986. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23987. * @param onLoad define a callback triggered when the texture has been loaded
  23988. * @param onError define a callback triggered when an error occurred during the loading session
  23989. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23990. * @returns the created texture
  23991. */
  23992. 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;
  23993. }
  23994. }
  23995. declare module "babylonjs/PostProcesses/postProcessManager" {
  23996. import { Nullable } from "babylonjs/types";
  23997. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23998. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23999. import { Scene } from "babylonjs/scene";
  24000. /**
  24001. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24002. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24003. */
  24004. export class PostProcessManager {
  24005. private _scene;
  24006. private _indexBuffer;
  24007. private _vertexBuffers;
  24008. /**
  24009. * Creates a new instance PostProcess
  24010. * @param scene The scene that the post process is associated with.
  24011. */
  24012. constructor(scene: Scene);
  24013. private _prepareBuffers;
  24014. private _buildIndexBuffer;
  24015. /**
  24016. * Rebuilds the vertex buffers of the manager.
  24017. * @hidden
  24018. */
  24019. _rebuild(): void;
  24020. /**
  24021. * Prepares a frame to be run through a post process.
  24022. * @param sourceTexture The input texture to the post procesess. (default: null)
  24023. * @param postProcesses An array of post processes to be run. (default: null)
  24024. * @returns True if the post processes were able to be run.
  24025. * @hidden
  24026. */
  24027. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24028. /**
  24029. * Manually render a set of post processes to a texture.
  24030. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24031. * @param postProcesses An array of post processes to be run.
  24032. * @param targetTexture The target texture to render to.
  24033. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24034. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24035. * @param lodLevel defines which lod of the texture to render to
  24036. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24037. */
  24038. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24039. /**
  24040. * Finalize the result of the output of the postprocesses.
  24041. * @param doNotPresent If true the result will not be displayed to the screen.
  24042. * @param targetTexture The target texture to render to.
  24043. * @param faceIndex The index of the face to bind the target texture to.
  24044. * @param postProcesses The array of post processes to render.
  24045. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24046. * @hidden
  24047. */
  24048. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24049. /**
  24050. * Disposes of the post process manager.
  24051. */
  24052. dispose(): void;
  24053. }
  24054. }
  24055. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24056. import { Observable } from "babylonjs/Misc/observable";
  24057. import { SmartArray } from "babylonjs/Misc/smartArray";
  24058. import { Nullable, Immutable } from "babylonjs/types";
  24059. import { Camera } from "babylonjs/Cameras/camera";
  24060. import { Scene } from "babylonjs/scene";
  24061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24062. import { Color4 } from "babylonjs/Maths/math.color";
  24063. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24065. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24066. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24067. import { Texture } from "babylonjs/Materials/Textures/texture";
  24068. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24069. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24070. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24071. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24072. import { Engine } from "babylonjs/Engines/engine";
  24073. /**
  24074. * This Helps creating a texture that will be created from a camera in your scene.
  24075. * It is basically a dynamic texture that could be used to create special effects for instance.
  24076. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24077. */
  24078. export class RenderTargetTexture extends Texture {
  24079. isCube: boolean;
  24080. /**
  24081. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24082. */
  24083. static readonly REFRESHRATE_RENDER_ONCE: number;
  24084. /**
  24085. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24086. */
  24087. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24088. /**
  24089. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24090. * the central point of your effect and can save a lot of performances.
  24091. */
  24092. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24093. /**
  24094. * Use this predicate to dynamically define the list of mesh you want to render.
  24095. * If set, the renderList property will be overwritten.
  24096. */
  24097. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24098. private _renderList;
  24099. /**
  24100. * Use this list to define the list of mesh you want to render.
  24101. */
  24102. get renderList(): Nullable<Array<AbstractMesh>>;
  24103. set renderList(value: Nullable<Array<AbstractMesh>>);
  24104. /**
  24105. * Use this function to overload the renderList array at rendering time.
  24106. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24107. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24108. * the cube (if the RTT is a cube, else layerOrFace=0).
  24109. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24110. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24111. * hold dummy elements!
  24112. */
  24113. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24114. private _hookArray;
  24115. /**
  24116. * Define if particles should be rendered in your texture.
  24117. */
  24118. renderParticles: boolean;
  24119. /**
  24120. * Define if sprites should be rendered in your texture.
  24121. */
  24122. renderSprites: boolean;
  24123. /**
  24124. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24125. */
  24126. coordinatesMode: number;
  24127. /**
  24128. * Define the camera used to render the texture.
  24129. */
  24130. activeCamera: Nullable<Camera>;
  24131. /**
  24132. * Override the mesh isReady function with your own one.
  24133. */
  24134. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24135. /**
  24136. * Override the render function of the texture with your own one.
  24137. */
  24138. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24139. /**
  24140. * Define if camera post processes should be use while rendering the texture.
  24141. */
  24142. useCameraPostProcesses: boolean;
  24143. /**
  24144. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24145. */
  24146. ignoreCameraViewport: boolean;
  24147. private _postProcessManager;
  24148. private _postProcesses;
  24149. private _resizeObserver;
  24150. /**
  24151. * An event triggered when the texture is unbind.
  24152. */
  24153. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24154. /**
  24155. * An event triggered when the texture is unbind.
  24156. */
  24157. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24158. private _onAfterUnbindObserver;
  24159. /**
  24160. * Set a after unbind callback in the texture.
  24161. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24162. */
  24163. set onAfterUnbind(callback: () => void);
  24164. /**
  24165. * An event triggered before rendering the texture
  24166. */
  24167. onBeforeRenderObservable: Observable<number>;
  24168. private _onBeforeRenderObserver;
  24169. /**
  24170. * Set a before render callback in the texture.
  24171. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24172. */
  24173. set onBeforeRender(callback: (faceIndex: number) => void);
  24174. /**
  24175. * An event triggered after rendering the texture
  24176. */
  24177. onAfterRenderObservable: Observable<number>;
  24178. private _onAfterRenderObserver;
  24179. /**
  24180. * Set a after render callback in the texture.
  24181. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24182. */
  24183. set onAfterRender(callback: (faceIndex: number) => void);
  24184. /**
  24185. * An event triggered after the texture clear
  24186. */
  24187. onClearObservable: Observable<Engine>;
  24188. private _onClearObserver;
  24189. /**
  24190. * Set a clear callback in the texture.
  24191. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24192. */
  24193. set onClear(callback: (Engine: Engine) => void);
  24194. /**
  24195. * An event triggered when the texture is resized.
  24196. */
  24197. onResizeObservable: Observable<RenderTargetTexture>;
  24198. /**
  24199. * Define the clear color of the Render Target if it should be different from the scene.
  24200. */
  24201. clearColor: Color4;
  24202. protected _size: number | {
  24203. width: number;
  24204. height: number;
  24205. layers?: number;
  24206. };
  24207. protected _initialSizeParameter: number | {
  24208. width: number;
  24209. height: number;
  24210. } | {
  24211. ratio: number;
  24212. };
  24213. protected _sizeRatio: Nullable<number>;
  24214. /** @hidden */
  24215. _generateMipMaps: boolean;
  24216. protected _renderingManager: RenderingManager;
  24217. /** @hidden */
  24218. _waitingRenderList: string[];
  24219. protected _doNotChangeAspectRatio: boolean;
  24220. protected _currentRefreshId: number;
  24221. protected _refreshRate: number;
  24222. protected _textureMatrix: Matrix;
  24223. protected _samples: number;
  24224. protected _renderTargetOptions: RenderTargetCreationOptions;
  24225. /**
  24226. * Gets render target creation options that were used.
  24227. */
  24228. get renderTargetOptions(): RenderTargetCreationOptions;
  24229. protected _onRatioRescale(): void;
  24230. /**
  24231. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24232. * It must define where the camera used to render the texture is set
  24233. */
  24234. boundingBoxPosition: Vector3;
  24235. private _boundingBoxSize;
  24236. /**
  24237. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24238. * When defined, the cubemap will switch to local mode
  24239. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24240. * @example https://www.babylonjs-playground.com/#RNASML
  24241. */
  24242. set boundingBoxSize(value: Vector3);
  24243. get boundingBoxSize(): Vector3;
  24244. /**
  24245. * In case the RTT has been created with a depth texture, get the associated
  24246. * depth texture.
  24247. * Otherwise, return null.
  24248. */
  24249. get depthStencilTexture(): Nullable<InternalTexture>;
  24250. /**
  24251. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24252. * or used a shadow, depth texture...
  24253. * @param name The friendly name of the texture
  24254. * @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)
  24255. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24256. * @param generateMipMaps True if mip maps need to be generated after render.
  24257. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24258. * @param type The type of the buffer in the RTT (int, half float, float...)
  24259. * @param isCube True if a cube texture needs to be created
  24260. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24261. * @param generateDepthBuffer True to generate a depth buffer
  24262. * @param generateStencilBuffer True to generate a stencil buffer
  24263. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24264. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24265. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24266. */
  24267. constructor(name: string, size: number | {
  24268. width: number;
  24269. height: number;
  24270. layers?: number;
  24271. } | {
  24272. ratio: number;
  24273. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24274. /**
  24275. * Creates a depth stencil texture.
  24276. * This is only available in WebGL 2 or with the depth texture extension available.
  24277. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24278. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24279. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24280. */
  24281. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24282. private _processSizeParameter;
  24283. /**
  24284. * Define the number of samples to use in case of MSAA.
  24285. * It defaults to one meaning no MSAA has been enabled.
  24286. */
  24287. get samples(): number;
  24288. set samples(value: number);
  24289. /**
  24290. * Resets the refresh counter of the texture and start bak from scratch.
  24291. * Could be useful to regenerate the texture if it is setup to render only once.
  24292. */
  24293. resetRefreshCounter(): void;
  24294. /**
  24295. * Define the refresh rate of the texture or the rendering frequency.
  24296. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24297. */
  24298. get refreshRate(): number;
  24299. set refreshRate(value: number);
  24300. /**
  24301. * Adds a post process to the render target rendering passes.
  24302. * @param postProcess define the post process to add
  24303. */
  24304. addPostProcess(postProcess: PostProcess): void;
  24305. /**
  24306. * Clear all the post processes attached to the render target
  24307. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24308. */
  24309. clearPostProcesses(dispose?: boolean): void;
  24310. /**
  24311. * Remove one of the post process from the list of attached post processes to the texture
  24312. * @param postProcess define the post process to remove from the list
  24313. */
  24314. removePostProcess(postProcess: PostProcess): void;
  24315. /** @hidden */
  24316. _shouldRender(): boolean;
  24317. /**
  24318. * Gets the actual render size of the texture.
  24319. * @returns the width of the render size
  24320. */
  24321. getRenderSize(): number;
  24322. /**
  24323. * Gets the actual render width of the texture.
  24324. * @returns the width of the render size
  24325. */
  24326. getRenderWidth(): number;
  24327. /**
  24328. * Gets the actual render height of the texture.
  24329. * @returns the height of the render size
  24330. */
  24331. getRenderHeight(): number;
  24332. /**
  24333. * Gets the actual number of layers of the texture.
  24334. * @returns the number of layers
  24335. */
  24336. getRenderLayers(): number;
  24337. /**
  24338. * Get if the texture can be rescaled or not.
  24339. */
  24340. get canRescale(): boolean;
  24341. /**
  24342. * Resize the texture using a ratio.
  24343. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24344. */
  24345. scale(ratio: number): void;
  24346. /**
  24347. * Get the texture reflection matrix used to rotate/transform the reflection.
  24348. * @returns the reflection matrix
  24349. */
  24350. getReflectionTextureMatrix(): Matrix;
  24351. /**
  24352. * Resize the texture to a new desired size.
  24353. * Be carrefull as it will recreate all the data in the new texture.
  24354. * @param size Define the new size. It can be:
  24355. * - a number for squared texture,
  24356. * - an object containing { width: number, height: number }
  24357. * - or an object containing a ratio { ratio: number }
  24358. */
  24359. resize(size: number | {
  24360. width: number;
  24361. height: number;
  24362. } | {
  24363. ratio: number;
  24364. }): void;
  24365. private _defaultRenderListPrepared;
  24366. /**
  24367. * Renders all the objects from the render list into the texture.
  24368. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24369. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24370. */
  24371. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24372. private _bestReflectionRenderTargetDimension;
  24373. private _prepareRenderingManager;
  24374. /**
  24375. * @hidden
  24376. * @param faceIndex face index to bind to if this is a cubetexture
  24377. * @param layer defines the index of the texture to bind in the array
  24378. */
  24379. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24380. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24381. private renderToTarget;
  24382. /**
  24383. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24384. * This allowed control for front to back rendering or reversly depending of the special needs.
  24385. *
  24386. * @param renderingGroupId The rendering group id corresponding to its index
  24387. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24388. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24389. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24390. */
  24391. 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;
  24392. /**
  24393. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24394. *
  24395. * @param renderingGroupId The rendering group id corresponding to its index
  24396. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24397. */
  24398. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24399. /**
  24400. * Clones the texture.
  24401. * @returns the cloned texture
  24402. */
  24403. clone(): RenderTargetTexture;
  24404. /**
  24405. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24406. * @returns The JSON representation of the texture
  24407. */
  24408. serialize(): any;
  24409. /**
  24410. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24411. */
  24412. disposeFramebufferObjects(): void;
  24413. /**
  24414. * Dispose the texture and release its associated resources.
  24415. */
  24416. dispose(): void;
  24417. /** @hidden */
  24418. _rebuild(): void;
  24419. /**
  24420. * Clear the info related to rendering groups preventing retention point in material dispose.
  24421. */
  24422. freeRenderingGroups(): void;
  24423. /**
  24424. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24425. * @returns the view count
  24426. */
  24427. getViewCount(): number;
  24428. }
  24429. }
  24430. declare module "babylonjs/Misc/guid" {
  24431. /**
  24432. * Class used to manipulate GUIDs
  24433. */
  24434. export class GUID {
  24435. /**
  24436. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24437. * Be aware Math.random() could cause collisions, but:
  24438. * "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"
  24439. * @returns a pseudo random id
  24440. */
  24441. static RandomId(): string;
  24442. }
  24443. }
  24444. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24445. import { Nullable } from "babylonjs/types";
  24446. import { Scene } from "babylonjs/scene";
  24447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24448. import { Material } from "babylonjs/Materials/material";
  24449. import { Effect } from "babylonjs/Materials/effect";
  24450. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24451. /**
  24452. * Options to be used when creating a shadow depth material
  24453. */
  24454. export interface IIOptionShadowDepthMaterial {
  24455. /** Variables in the vertex shader code that need to have their names remapped.
  24456. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24457. * "var_name" should be either: worldPos or vNormalW
  24458. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24459. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24460. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24461. */
  24462. remappedVariables?: string[];
  24463. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24464. standalone?: boolean;
  24465. }
  24466. /**
  24467. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24468. */
  24469. export class ShadowDepthWrapper {
  24470. private _scene;
  24471. private _options?;
  24472. private _baseMaterial;
  24473. private _onEffectCreatedObserver;
  24474. private _subMeshToEffect;
  24475. private _subMeshToDepthEffect;
  24476. private _meshes;
  24477. /** @hidden */
  24478. _matriceNames: any;
  24479. /** Gets the standalone status of the wrapper */
  24480. get standalone(): boolean;
  24481. /** Gets the base material the wrapper is built upon */
  24482. get baseMaterial(): Material;
  24483. /**
  24484. * Instantiate a new shadow depth wrapper.
  24485. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24486. * generate the shadow depth map. For more information, please refer to the documentation:
  24487. * https://doc.babylonjs.com/babylon101/shadows
  24488. * @param baseMaterial Material to wrap
  24489. * @param scene Define the scene the material belongs to
  24490. * @param options Options used to create the wrapper
  24491. */
  24492. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24493. /**
  24494. * Gets the effect to use to generate the depth map
  24495. * @param subMesh subMesh to get the effect for
  24496. * @param shadowGenerator shadow generator to get the effect for
  24497. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24498. */
  24499. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24500. /**
  24501. * Specifies that the submesh is ready to be used for depth rendering
  24502. * @param subMesh submesh to check
  24503. * @param defines the list of defines to take into account when checking the effect
  24504. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24505. * @param useInstances specifies that instances should be used
  24506. * @returns a boolean indicating that the submesh is ready or not
  24507. */
  24508. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24509. /**
  24510. * Disposes the resources
  24511. */
  24512. dispose(): void;
  24513. private _makeEffect;
  24514. }
  24515. }
  24516. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24518. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24519. import { Nullable } from "babylonjs/types";
  24520. module "babylonjs/Engines/thinEngine" {
  24521. interface ThinEngine {
  24522. /**
  24523. * Unbind a list of render target textures from the webGL context
  24524. * This is used only when drawBuffer extension or webGL2 are active
  24525. * @param textures defines the render target textures to unbind
  24526. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24527. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24528. */
  24529. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24530. /**
  24531. * Create a multi render target texture
  24532. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24533. * @param size defines the size of the texture
  24534. * @param options defines the creation options
  24535. * @returns the cube texture as an InternalTexture
  24536. */
  24537. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24538. /**
  24539. * Update the sample count for a given multiple render target texture
  24540. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24541. * @param textures defines the textures to update
  24542. * @param samples defines the sample count to set
  24543. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24544. */
  24545. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24546. /**
  24547. * Select a subsets of attachments to draw to.
  24548. * @param attachments gl attachments
  24549. */
  24550. bindAttachments(attachments: number[]): void;
  24551. }
  24552. }
  24553. }
  24554. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24555. import { Scene } from "babylonjs/scene";
  24556. import { Engine } from "babylonjs/Engines/engine";
  24557. import { Texture } from "babylonjs/Materials/Textures/texture";
  24558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24559. import "babylonjs/Engines/Extensions/engine.multiRender";
  24560. /**
  24561. * Creation options of the multi render target texture.
  24562. */
  24563. export interface IMultiRenderTargetOptions {
  24564. /**
  24565. * Define if the texture needs to create mip maps after render.
  24566. */
  24567. generateMipMaps?: boolean;
  24568. /**
  24569. * Define the types of all the draw buffers we want to create
  24570. */
  24571. types?: number[];
  24572. /**
  24573. * Define the sampling modes of all the draw buffers we want to create
  24574. */
  24575. samplingModes?: number[];
  24576. /**
  24577. * Define if a depth buffer is required
  24578. */
  24579. generateDepthBuffer?: boolean;
  24580. /**
  24581. * Define if a stencil buffer is required
  24582. */
  24583. generateStencilBuffer?: boolean;
  24584. /**
  24585. * Define if a depth texture is required instead of a depth buffer
  24586. */
  24587. generateDepthTexture?: boolean;
  24588. /**
  24589. * Define the number of desired draw buffers
  24590. */
  24591. textureCount?: number;
  24592. /**
  24593. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24594. */
  24595. doNotChangeAspectRatio?: boolean;
  24596. /**
  24597. * Define the default type of the buffers we are creating
  24598. */
  24599. defaultType?: number;
  24600. }
  24601. /**
  24602. * A multi render target, like a render target provides the ability to render to a texture.
  24603. * Unlike the render target, it can render to several draw buffers in one draw.
  24604. * This is specially interesting in deferred rendering or for any effects requiring more than
  24605. * just one color from a single pass.
  24606. */
  24607. export class MultiRenderTarget extends RenderTargetTexture {
  24608. private _internalTextures;
  24609. private _textures;
  24610. private _multiRenderTargetOptions;
  24611. private _count;
  24612. /**
  24613. * Get if draw buffers are currently supported by the used hardware and browser.
  24614. */
  24615. get isSupported(): boolean;
  24616. /**
  24617. * Get the list of textures generated by the multi render target.
  24618. */
  24619. get textures(): Texture[];
  24620. /**
  24621. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24622. */
  24623. get count(): number;
  24624. /**
  24625. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24626. */
  24627. get depthTexture(): Texture;
  24628. /**
  24629. * Set the wrapping mode on U of all the textures we are rendering to.
  24630. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24631. */
  24632. set wrapU(wrap: number);
  24633. /**
  24634. * Set the wrapping mode on V of all the textures we are rendering to.
  24635. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24636. */
  24637. set wrapV(wrap: number);
  24638. /**
  24639. * Instantiate a new multi render target texture.
  24640. * A multi render target, like a render target provides the ability to render to a texture.
  24641. * Unlike the render target, it can render to several draw buffers in one draw.
  24642. * This is specially interesting in deferred rendering or for any effects requiring more than
  24643. * just one color from a single pass.
  24644. * @param name Define the name of the texture
  24645. * @param size Define the size of the buffers to render to
  24646. * @param count Define the number of target we are rendering into
  24647. * @param scene Define the scene the texture belongs to
  24648. * @param options Define the options used to create the multi render target
  24649. */
  24650. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24651. /** @hidden */
  24652. _rebuild(): void;
  24653. private _createInternalTextures;
  24654. private _createTextures;
  24655. /**
  24656. * Define the number of samples used if MSAA is enabled.
  24657. */
  24658. get samples(): number;
  24659. set samples(value: number);
  24660. /**
  24661. * Resize all the textures in the multi render target.
  24662. * Be carrefull as it will recreate all the data in the new texture.
  24663. * @param size Define the new size
  24664. */
  24665. resize(size: any): void;
  24666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24667. /**
  24668. * Dispose the render targets and their associated resources
  24669. */
  24670. dispose(): void;
  24671. /**
  24672. * Release all the underlying texture used as draw buffers.
  24673. */
  24674. releaseInternalTextures(): void;
  24675. }
  24676. }
  24677. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24678. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24679. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24680. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24681. /** @hidden */
  24682. export var imageProcessingPixelShader: {
  24683. name: string;
  24684. shader: string;
  24685. };
  24686. }
  24687. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24688. import { Nullable } from "babylonjs/types";
  24689. import { Color4 } from "babylonjs/Maths/math.color";
  24690. import { Camera } from "babylonjs/Cameras/camera";
  24691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24692. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24693. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24695. import { Engine } from "babylonjs/Engines/engine";
  24696. import "babylonjs/Shaders/imageProcessing.fragment";
  24697. import "babylonjs/Shaders/postprocess.vertex";
  24698. /**
  24699. * ImageProcessingPostProcess
  24700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24701. */
  24702. export class ImageProcessingPostProcess extends PostProcess {
  24703. /**
  24704. * Default configuration related to image processing available in the PBR Material.
  24705. */
  24706. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24707. /**
  24708. * Gets the image processing configuration used either in this material.
  24709. */
  24710. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24711. /**
  24712. * Sets the Default image processing configuration used either in the this material.
  24713. *
  24714. * If sets to null, the scene one is in use.
  24715. */
  24716. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24717. /**
  24718. * Keep track of the image processing observer to allow dispose and replace.
  24719. */
  24720. private _imageProcessingObserver;
  24721. /**
  24722. * Attaches a new image processing configuration to the PBR Material.
  24723. * @param configuration
  24724. */
  24725. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24726. /**
  24727. * If the post process is supported.
  24728. */
  24729. get isSupported(): boolean;
  24730. /**
  24731. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24732. */
  24733. get colorCurves(): Nullable<ColorCurves>;
  24734. /**
  24735. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24736. */
  24737. set colorCurves(value: Nullable<ColorCurves>);
  24738. /**
  24739. * Gets wether the color curves effect is enabled.
  24740. */
  24741. get colorCurvesEnabled(): boolean;
  24742. /**
  24743. * Sets wether the color curves effect is enabled.
  24744. */
  24745. set colorCurvesEnabled(value: boolean);
  24746. /**
  24747. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24748. */
  24749. get colorGradingTexture(): Nullable<BaseTexture>;
  24750. /**
  24751. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24752. */
  24753. set colorGradingTexture(value: Nullable<BaseTexture>);
  24754. /**
  24755. * Gets wether the color grading effect is enabled.
  24756. */
  24757. get colorGradingEnabled(): boolean;
  24758. /**
  24759. * Gets wether the color grading effect is enabled.
  24760. */
  24761. set colorGradingEnabled(value: boolean);
  24762. /**
  24763. * Gets exposure used in the effect.
  24764. */
  24765. get exposure(): number;
  24766. /**
  24767. * Sets exposure used in the effect.
  24768. */
  24769. set exposure(value: number);
  24770. /**
  24771. * Gets wether tonemapping is enabled or not.
  24772. */
  24773. get toneMappingEnabled(): boolean;
  24774. /**
  24775. * Sets wether tonemapping is enabled or not
  24776. */
  24777. set toneMappingEnabled(value: boolean);
  24778. /**
  24779. * Gets the type of tone mapping effect.
  24780. */
  24781. get toneMappingType(): number;
  24782. /**
  24783. * Sets the type of tone mapping effect.
  24784. */
  24785. set toneMappingType(value: number);
  24786. /**
  24787. * Gets contrast used in the effect.
  24788. */
  24789. get contrast(): number;
  24790. /**
  24791. * Sets contrast used in the effect.
  24792. */
  24793. set contrast(value: number);
  24794. /**
  24795. * Gets Vignette stretch size.
  24796. */
  24797. get vignetteStretch(): number;
  24798. /**
  24799. * Sets Vignette stretch size.
  24800. */
  24801. set vignetteStretch(value: number);
  24802. /**
  24803. * Gets Vignette centre X Offset.
  24804. */
  24805. get vignetteCentreX(): number;
  24806. /**
  24807. * Sets Vignette centre X Offset.
  24808. */
  24809. set vignetteCentreX(value: number);
  24810. /**
  24811. * Gets Vignette centre Y Offset.
  24812. */
  24813. get vignetteCentreY(): number;
  24814. /**
  24815. * Sets Vignette centre Y Offset.
  24816. */
  24817. set vignetteCentreY(value: number);
  24818. /**
  24819. * Gets Vignette weight or intensity of the vignette effect.
  24820. */
  24821. get vignetteWeight(): number;
  24822. /**
  24823. * Sets Vignette weight or intensity of the vignette effect.
  24824. */
  24825. set vignetteWeight(value: number);
  24826. /**
  24827. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24828. * if vignetteEnabled is set to true.
  24829. */
  24830. get vignetteColor(): Color4;
  24831. /**
  24832. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24833. * if vignetteEnabled is set to true.
  24834. */
  24835. set vignetteColor(value: Color4);
  24836. /**
  24837. * Gets Camera field of view used by the Vignette effect.
  24838. */
  24839. get vignetteCameraFov(): number;
  24840. /**
  24841. * Sets Camera field of view used by the Vignette effect.
  24842. */
  24843. set vignetteCameraFov(value: number);
  24844. /**
  24845. * Gets the vignette blend mode allowing different kind of effect.
  24846. */
  24847. get vignetteBlendMode(): number;
  24848. /**
  24849. * Sets the vignette blend mode allowing different kind of effect.
  24850. */
  24851. set vignetteBlendMode(value: number);
  24852. /**
  24853. * Gets wether the vignette effect is enabled.
  24854. */
  24855. get vignetteEnabled(): boolean;
  24856. /**
  24857. * Sets wether the vignette effect is enabled.
  24858. */
  24859. set vignetteEnabled(value: boolean);
  24860. private _fromLinearSpace;
  24861. /**
  24862. * Gets wether the input of the processing is in Gamma or Linear Space.
  24863. */
  24864. get fromLinearSpace(): boolean;
  24865. /**
  24866. * Sets wether the input of the processing is in Gamma or Linear Space.
  24867. */
  24868. set fromLinearSpace(value: boolean);
  24869. /**
  24870. * Defines cache preventing GC.
  24871. */
  24872. private _defines;
  24873. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24874. /**
  24875. * "ImageProcessingPostProcess"
  24876. * @returns "ImageProcessingPostProcess"
  24877. */
  24878. getClassName(): string;
  24879. /**
  24880. * @hidden
  24881. */
  24882. _updateParameters(): void;
  24883. dispose(camera?: Camera): void;
  24884. }
  24885. }
  24886. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  24887. /** @hidden */
  24888. export var fibonacci: {
  24889. name: string;
  24890. shader: string;
  24891. };
  24892. }
  24893. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  24894. /** @hidden */
  24895. export var subSurfaceScatteringFunctions: {
  24896. name: string;
  24897. shader: string;
  24898. };
  24899. }
  24900. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  24901. /** @hidden */
  24902. export var diffusionProfile: {
  24903. name: string;
  24904. shader: string;
  24905. };
  24906. }
  24907. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  24908. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  24909. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24910. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  24911. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  24912. /** @hidden */
  24913. export var subSurfaceScatteringPixelShader: {
  24914. name: string;
  24915. shader: string;
  24916. };
  24917. }
  24918. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  24919. import { Nullable } from "babylonjs/types";
  24920. import { Camera } from "babylonjs/Cameras/camera";
  24921. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24922. import { Engine } from "babylonjs/Engines/engine";
  24923. import { Scene } from "babylonjs/scene";
  24924. import "babylonjs/Shaders/imageProcessing.fragment";
  24925. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  24926. import "babylonjs/Shaders/postprocess.vertex";
  24927. /**
  24928. * Sub surface scattering post process
  24929. */
  24930. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24931. /** @hidden */
  24932. texelWidth: number;
  24933. /** @hidden */
  24934. texelHeight: number;
  24935. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24936. }
  24937. }
  24938. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24940. /**
  24941. * Interface for defining prepass effects in the prepass post-process pipeline
  24942. */
  24943. export interface PrePassEffectConfiguration {
  24944. /**
  24945. * Post process to attach for this effect
  24946. */
  24947. postProcess: PostProcess;
  24948. /**
  24949. * Is the effect enabled
  24950. */
  24951. enabled: boolean;
  24952. /**
  24953. * Disposes the effect configuration
  24954. */
  24955. dispose(): void;
  24956. /**
  24957. * Disposes the effect configuration
  24958. */
  24959. createPostProcess: () => PostProcess;
  24960. }
  24961. }
  24962. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  24963. import { Scene } from "babylonjs/scene";
  24964. import { Color3 } from "babylonjs/Maths/math.color";
  24965. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  24966. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24967. /**
  24968. * Contains all parameters needed for the prepass to perform
  24969. * screen space subsurface scattering
  24970. */
  24971. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24972. private _ssDiffusionS;
  24973. private _ssFilterRadii;
  24974. private _ssDiffusionD;
  24975. /**
  24976. * Post process to attach for screen space subsurface scattering
  24977. */
  24978. postProcess: SubSurfaceScatteringPostProcess;
  24979. /**
  24980. * Diffusion profile color for subsurface scattering
  24981. */
  24982. get ssDiffusionS(): number[];
  24983. /**
  24984. * Diffusion profile max color channel value for subsurface scattering
  24985. */
  24986. get ssDiffusionD(): number[];
  24987. /**
  24988. * Diffusion profile filter radius for subsurface scattering
  24989. */
  24990. get ssFilterRadii(): number[];
  24991. /**
  24992. * Is subsurface enabled
  24993. */
  24994. enabled: boolean;
  24995. /**
  24996. * Diffusion profile colors for subsurface scattering
  24997. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24998. * See ...
  24999. * Note that you can only store up to 5 of them
  25000. */
  25001. ssDiffusionProfileColors: Color3[];
  25002. /**
  25003. * Defines the ratio real world => scene units.
  25004. * Used for subsurface scattering
  25005. */
  25006. metersPerUnit: number;
  25007. private _scene;
  25008. /**
  25009. * Builds a subsurface configuration object
  25010. * @param scene The scene
  25011. */
  25012. constructor(scene: Scene);
  25013. /**
  25014. * Adds a new diffusion profile.
  25015. * Useful for more realistic subsurface scattering on diverse materials.
  25016. * @param color The color of the diffusion profile. Should be the average color of the material.
  25017. * @return The index of the diffusion profile for the material subsurface configuration
  25018. */
  25019. addDiffusionProfile(color: Color3): number;
  25020. /**
  25021. * Creates the sss post process
  25022. * @return The created post process
  25023. */
  25024. createPostProcess(): SubSurfaceScatteringPostProcess;
  25025. /**
  25026. * Deletes all diffusion profiles.
  25027. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25028. */
  25029. clearAllDiffusionProfiles(): void;
  25030. /**
  25031. * Disposes this object
  25032. */
  25033. dispose(): void;
  25034. /**
  25035. * @hidden
  25036. * https://zero-radiance.github.io/post/sampling-diffusion/
  25037. *
  25038. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25039. * ------------------------------------------------------------------------------------
  25040. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25041. * PDF[r, phi, s] = r * R[r, phi, s]
  25042. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25043. * ------------------------------------------------------------------------------------
  25044. * We importance sample the color channel with the widest scattering distance.
  25045. */
  25046. getDiffusionProfileParameters(color: Color3): number;
  25047. /**
  25048. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25049. * 'u' is the random number (the value of the CDF): [0, 1).
  25050. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25051. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25052. */
  25053. private _sampleBurleyDiffusionProfile;
  25054. }
  25055. }
  25056. declare module "babylonjs/Rendering/prePassRenderer" {
  25057. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25058. import { Scene } from "babylonjs/scene";
  25059. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25060. import { Effect } from "babylonjs/Materials/effect";
  25061. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25062. /**
  25063. * Renders a pre pass of the scene
  25064. * This means every mesh in the scene will be rendered to a render target texture
  25065. * And then this texture will be composited to the rendering canvas with post processes
  25066. * It is necessary for effects like subsurface scattering or deferred shading
  25067. */
  25068. export class PrePassRenderer {
  25069. /** @hidden */
  25070. static _SceneComponentInitialization: (scene: Scene) => void;
  25071. private _scene;
  25072. private _engine;
  25073. private _isDirty;
  25074. /**
  25075. * Number of textures in the multi render target texture where the scene is directly rendered
  25076. */
  25077. readonly mrtCount: number;
  25078. /**
  25079. * The render target where the scene is directly rendered
  25080. */
  25081. prePassRT: MultiRenderTarget;
  25082. private _mrtTypes;
  25083. private _multiRenderAttachments;
  25084. private _defaultAttachments;
  25085. private _clearAttachments;
  25086. private _postProcesses;
  25087. private readonly _clearColor;
  25088. /**
  25089. * Image processing post process for composition
  25090. */
  25091. imageProcessingPostProcess: ImageProcessingPostProcess;
  25092. /**
  25093. * Configuration for sub surface scattering post process
  25094. */
  25095. subSurfaceConfiguration: SubSurfaceConfiguration;
  25096. /**
  25097. * Should materials render their geometry on the MRT
  25098. */
  25099. materialsShouldRenderGeometry: boolean;
  25100. /**
  25101. * Should materials render the irradiance information on the MRT
  25102. */
  25103. materialsShouldRenderIrradiance: boolean;
  25104. private _enabled;
  25105. /**
  25106. * Indicates if the prepass is enabled
  25107. */
  25108. get enabled(): boolean;
  25109. /**
  25110. * How many samples are used for MSAA of the scene render target
  25111. */
  25112. get samples(): number;
  25113. set samples(n: number);
  25114. /**
  25115. * Instanciates a prepass renderer
  25116. * @param scene The scene
  25117. */
  25118. constructor(scene: Scene);
  25119. private _initializeAttachments;
  25120. private _createCompositionEffect;
  25121. /**
  25122. * Indicates if rendering a prepass is supported
  25123. */
  25124. get isSupported(): boolean;
  25125. /**
  25126. * Sets the proper output textures to draw in the engine.
  25127. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25128. */
  25129. bindAttachmentsForEffect(effect: Effect): void;
  25130. /**
  25131. * @hidden
  25132. */
  25133. _beforeCameraDraw(): void;
  25134. /**
  25135. * @hidden
  25136. */
  25137. _afterCameraDraw(): void;
  25138. private _checkRTSize;
  25139. private _bindFrameBuffer;
  25140. /**
  25141. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25142. */
  25143. clear(): void;
  25144. private _setState;
  25145. private _enable;
  25146. private _disable;
  25147. private _resetPostProcessChain;
  25148. private _bindPostProcessChain;
  25149. /**
  25150. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25151. */
  25152. markAsDirty(): void;
  25153. private _update;
  25154. /**
  25155. * Disposes the prepass renderer.
  25156. */
  25157. dispose(): void;
  25158. }
  25159. }
  25160. declare module "babylonjs/Materials/material" {
  25161. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25162. import { SmartArray } from "babylonjs/Misc/smartArray";
  25163. import { Observable } from "babylonjs/Misc/observable";
  25164. import { Nullable } from "babylonjs/types";
  25165. import { Scene } from "babylonjs/scene";
  25166. import { Matrix } from "babylonjs/Maths/math.vector";
  25167. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25169. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25170. import { Effect } from "babylonjs/Materials/effect";
  25171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25173. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25174. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25175. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25176. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25177. import { Mesh } from "babylonjs/Meshes/mesh";
  25178. import { Animation } from "babylonjs/Animations/animation";
  25179. /**
  25180. * Options for compiling materials.
  25181. */
  25182. export interface IMaterialCompilationOptions {
  25183. /**
  25184. * Defines whether clip planes are enabled.
  25185. */
  25186. clipPlane: boolean;
  25187. /**
  25188. * Defines whether instances are enabled.
  25189. */
  25190. useInstances: boolean;
  25191. }
  25192. /**
  25193. * Options passed when calling customShaderNameResolve
  25194. */
  25195. export interface ICustomShaderNameResolveOptions {
  25196. /**
  25197. * 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
  25198. */
  25199. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25200. }
  25201. /**
  25202. * Base class for the main features of a material in Babylon.js
  25203. */
  25204. export class Material implements IAnimatable {
  25205. /**
  25206. * Returns the triangle fill mode
  25207. */
  25208. static readonly TriangleFillMode: number;
  25209. /**
  25210. * Returns the wireframe mode
  25211. */
  25212. static readonly WireFrameFillMode: number;
  25213. /**
  25214. * Returns the point fill mode
  25215. */
  25216. static readonly PointFillMode: number;
  25217. /**
  25218. * Returns the point list draw mode
  25219. */
  25220. static readonly PointListDrawMode: number;
  25221. /**
  25222. * Returns the line list draw mode
  25223. */
  25224. static readonly LineListDrawMode: number;
  25225. /**
  25226. * Returns the line loop draw mode
  25227. */
  25228. static readonly LineLoopDrawMode: number;
  25229. /**
  25230. * Returns the line strip draw mode
  25231. */
  25232. static readonly LineStripDrawMode: number;
  25233. /**
  25234. * Returns the triangle strip draw mode
  25235. */
  25236. static readonly TriangleStripDrawMode: number;
  25237. /**
  25238. * Returns the triangle fan draw mode
  25239. */
  25240. static readonly TriangleFanDrawMode: number;
  25241. /**
  25242. * Stores the clock-wise side orientation
  25243. */
  25244. static readonly ClockWiseSideOrientation: number;
  25245. /**
  25246. * Stores the counter clock-wise side orientation
  25247. */
  25248. static readonly CounterClockWiseSideOrientation: number;
  25249. /**
  25250. * The dirty texture flag value
  25251. */
  25252. static readonly TextureDirtyFlag: number;
  25253. /**
  25254. * The dirty light flag value
  25255. */
  25256. static readonly LightDirtyFlag: number;
  25257. /**
  25258. * The dirty fresnel flag value
  25259. */
  25260. static readonly FresnelDirtyFlag: number;
  25261. /**
  25262. * The dirty attribute flag value
  25263. */
  25264. static readonly AttributesDirtyFlag: number;
  25265. /**
  25266. * The dirty misc flag value
  25267. */
  25268. static readonly MiscDirtyFlag: number;
  25269. /**
  25270. * The all dirty flag value
  25271. */
  25272. static readonly AllDirtyFlag: number;
  25273. /**
  25274. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25275. */
  25276. static readonly MATERIAL_OPAQUE: number;
  25277. /**
  25278. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25279. */
  25280. static readonly MATERIAL_ALPHATEST: number;
  25281. /**
  25282. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25283. */
  25284. static readonly MATERIAL_ALPHABLEND: number;
  25285. /**
  25286. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25287. * They are also discarded below the alpha cutoff threshold to improve performances.
  25288. */
  25289. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25290. /**
  25291. * The Whiteout method is used to blend normals.
  25292. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25293. */
  25294. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25295. /**
  25296. * The Reoriented Normal Mapping method is used to blend normals.
  25297. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25298. */
  25299. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25300. /**
  25301. * Custom callback helping to override the default shader used in the material.
  25302. */
  25303. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25304. /**
  25305. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25306. */
  25307. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25308. /**
  25309. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25310. * This means that the material can keep using a previous shader while a new one is being compiled.
  25311. * This is mostly used when shader parallel compilation is supported (true by default)
  25312. */
  25313. allowShaderHotSwapping: boolean;
  25314. /**
  25315. * The ID of the material
  25316. */
  25317. id: string;
  25318. /**
  25319. * Gets or sets the unique id of the material
  25320. */
  25321. uniqueId: number;
  25322. /**
  25323. * The name of the material
  25324. */
  25325. name: string;
  25326. /**
  25327. * Gets or sets user defined metadata
  25328. */
  25329. metadata: any;
  25330. /**
  25331. * For internal use only. Please do not use.
  25332. */
  25333. reservedDataStore: any;
  25334. /**
  25335. * Specifies if the ready state should be checked on each call
  25336. */
  25337. checkReadyOnEveryCall: boolean;
  25338. /**
  25339. * Specifies if the ready state should be checked once
  25340. */
  25341. checkReadyOnlyOnce: boolean;
  25342. /**
  25343. * The state of the material
  25344. */
  25345. state: string;
  25346. /**
  25347. * If the material can be rendered to several textures with MRT extension
  25348. */
  25349. get canRenderToMRT(): boolean;
  25350. /**
  25351. * The alpha value of the material
  25352. */
  25353. protected _alpha: number;
  25354. /**
  25355. * List of inspectable custom properties (used by the Inspector)
  25356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25357. */
  25358. inspectableCustomProperties: IInspectable[];
  25359. /**
  25360. * Sets the alpha value of the material
  25361. */
  25362. set alpha(value: number);
  25363. /**
  25364. * Gets the alpha value of the material
  25365. */
  25366. get alpha(): number;
  25367. /**
  25368. * Specifies if back face culling is enabled
  25369. */
  25370. protected _backFaceCulling: boolean;
  25371. /**
  25372. * Sets the back-face culling state
  25373. */
  25374. set backFaceCulling(value: boolean);
  25375. /**
  25376. * Gets the back-face culling state
  25377. */
  25378. get backFaceCulling(): boolean;
  25379. /**
  25380. * Stores the value for side orientation
  25381. */
  25382. sideOrientation: number;
  25383. /**
  25384. * Callback triggered when the material is compiled
  25385. */
  25386. onCompiled: Nullable<(effect: Effect) => void>;
  25387. /**
  25388. * Callback triggered when an error occurs
  25389. */
  25390. onError: Nullable<(effect: Effect, errors: string) => void>;
  25391. /**
  25392. * Callback triggered to get the render target textures
  25393. */
  25394. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25395. /**
  25396. * Gets a boolean indicating that current material needs to register RTT
  25397. */
  25398. get hasRenderTargetTextures(): boolean;
  25399. /**
  25400. * Specifies if the material should be serialized
  25401. */
  25402. doNotSerialize: boolean;
  25403. /**
  25404. * @hidden
  25405. */
  25406. _storeEffectOnSubMeshes: boolean;
  25407. /**
  25408. * Stores the animations for the material
  25409. */
  25410. animations: Nullable<Array<Animation>>;
  25411. /**
  25412. * An event triggered when the material is disposed
  25413. */
  25414. onDisposeObservable: Observable<Material>;
  25415. /**
  25416. * An observer which watches for dispose events
  25417. */
  25418. private _onDisposeObserver;
  25419. private _onUnBindObservable;
  25420. /**
  25421. * Called during a dispose event
  25422. */
  25423. set onDispose(callback: () => void);
  25424. private _onBindObservable;
  25425. /**
  25426. * An event triggered when the material is bound
  25427. */
  25428. get onBindObservable(): Observable<AbstractMesh>;
  25429. /**
  25430. * An observer which watches for bind events
  25431. */
  25432. private _onBindObserver;
  25433. /**
  25434. * Called during a bind event
  25435. */
  25436. set onBind(callback: (Mesh: AbstractMesh) => void);
  25437. /**
  25438. * An event triggered when the material is unbound
  25439. */
  25440. get onUnBindObservable(): Observable<Material>;
  25441. protected _onEffectCreatedObservable: Nullable<Observable<{
  25442. effect: Effect;
  25443. subMesh: Nullable<SubMesh>;
  25444. }>>;
  25445. /**
  25446. * An event triggered when the effect is (re)created
  25447. */
  25448. get onEffectCreatedObservable(): Observable<{
  25449. effect: Effect;
  25450. subMesh: Nullable<SubMesh>;
  25451. }>;
  25452. /**
  25453. * Stores the value of the alpha mode
  25454. */
  25455. private _alphaMode;
  25456. /**
  25457. * Sets the value of the alpha mode.
  25458. *
  25459. * | Value | Type | Description |
  25460. * | --- | --- | --- |
  25461. * | 0 | ALPHA_DISABLE | |
  25462. * | 1 | ALPHA_ADD | |
  25463. * | 2 | ALPHA_COMBINE | |
  25464. * | 3 | ALPHA_SUBTRACT | |
  25465. * | 4 | ALPHA_MULTIPLY | |
  25466. * | 5 | ALPHA_MAXIMIZED | |
  25467. * | 6 | ALPHA_ONEONE | |
  25468. * | 7 | ALPHA_PREMULTIPLIED | |
  25469. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25470. * | 9 | ALPHA_INTERPOLATE | |
  25471. * | 10 | ALPHA_SCREENMODE | |
  25472. *
  25473. */
  25474. set alphaMode(value: number);
  25475. /**
  25476. * Gets the value of the alpha mode
  25477. */
  25478. get alphaMode(): number;
  25479. /**
  25480. * Stores the state of the need depth pre-pass value
  25481. */
  25482. private _needDepthPrePass;
  25483. /**
  25484. * Sets the need depth pre-pass value
  25485. */
  25486. set needDepthPrePass(value: boolean);
  25487. /**
  25488. * Gets the depth pre-pass value
  25489. */
  25490. get needDepthPrePass(): boolean;
  25491. /**
  25492. * Specifies if depth writing should be disabled
  25493. */
  25494. disableDepthWrite: boolean;
  25495. /**
  25496. * Specifies if color writing should be disabled
  25497. */
  25498. disableColorWrite: boolean;
  25499. /**
  25500. * Specifies if depth writing should be forced
  25501. */
  25502. forceDepthWrite: boolean;
  25503. /**
  25504. * Specifies the depth function that should be used. 0 means the default engine function
  25505. */
  25506. depthFunction: number;
  25507. /**
  25508. * Specifies if there should be a separate pass for culling
  25509. */
  25510. separateCullingPass: boolean;
  25511. /**
  25512. * Stores the state specifing if fog should be enabled
  25513. */
  25514. private _fogEnabled;
  25515. /**
  25516. * Sets the state for enabling fog
  25517. */
  25518. set fogEnabled(value: boolean);
  25519. /**
  25520. * Gets the value of the fog enabled state
  25521. */
  25522. get fogEnabled(): boolean;
  25523. /**
  25524. * Stores the size of points
  25525. */
  25526. pointSize: number;
  25527. /**
  25528. * Stores the z offset value
  25529. */
  25530. zOffset: number;
  25531. get wireframe(): boolean;
  25532. /**
  25533. * Sets the state of wireframe mode
  25534. */
  25535. set wireframe(value: boolean);
  25536. /**
  25537. * Gets the value specifying if point clouds are enabled
  25538. */
  25539. get pointsCloud(): boolean;
  25540. /**
  25541. * Sets the state of point cloud mode
  25542. */
  25543. set pointsCloud(value: boolean);
  25544. /**
  25545. * Gets the material fill mode
  25546. */
  25547. get fillMode(): number;
  25548. /**
  25549. * Sets the material fill mode
  25550. */
  25551. set fillMode(value: number);
  25552. /**
  25553. * @hidden
  25554. * Stores the effects for the material
  25555. */
  25556. _effect: Nullable<Effect>;
  25557. /**
  25558. * Specifies if uniform buffers should be used
  25559. */
  25560. private _useUBO;
  25561. /**
  25562. * Stores a reference to the scene
  25563. */
  25564. private _scene;
  25565. /**
  25566. * Stores the fill mode state
  25567. */
  25568. private _fillMode;
  25569. /**
  25570. * Specifies if the depth write state should be cached
  25571. */
  25572. private _cachedDepthWriteState;
  25573. /**
  25574. * Specifies if the color write state should be cached
  25575. */
  25576. private _cachedColorWriteState;
  25577. /**
  25578. * Specifies if the depth function state should be cached
  25579. */
  25580. private _cachedDepthFunctionState;
  25581. /**
  25582. * Stores the uniform buffer
  25583. */
  25584. protected _uniformBuffer: UniformBuffer;
  25585. /** @hidden */
  25586. _indexInSceneMaterialArray: number;
  25587. /** @hidden */
  25588. meshMap: Nullable<{
  25589. [id: string]: AbstractMesh | undefined;
  25590. }>;
  25591. /**
  25592. * Creates a material instance
  25593. * @param name defines the name of the material
  25594. * @param scene defines the scene to reference
  25595. * @param doNotAdd specifies if the material should be added to the scene
  25596. */
  25597. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25598. /**
  25599. * Returns a string representation of the current material
  25600. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25601. * @returns a string with material information
  25602. */
  25603. toString(fullDetails?: boolean): string;
  25604. /**
  25605. * Gets the class name of the material
  25606. * @returns a string with the class name of the material
  25607. */
  25608. getClassName(): string;
  25609. /**
  25610. * Specifies if updates for the material been locked
  25611. */
  25612. get isFrozen(): boolean;
  25613. /**
  25614. * Locks updates for the material
  25615. */
  25616. freeze(): void;
  25617. /**
  25618. * Unlocks updates for the material
  25619. */
  25620. unfreeze(): void;
  25621. /**
  25622. * Specifies if the material is ready to be used
  25623. * @param mesh defines the mesh to check
  25624. * @param useInstances specifies if instances should be used
  25625. * @returns a boolean indicating if the material is ready to be used
  25626. */
  25627. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25628. /**
  25629. * Specifies that the submesh is ready to be used
  25630. * @param mesh defines the mesh to check
  25631. * @param subMesh defines which submesh to check
  25632. * @param useInstances specifies that instances should be used
  25633. * @returns a boolean indicating that the submesh is ready or not
  25634. */
  25635. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25636. /**
  25637. * Returns the material effect
  25638. * @returns the effect associated with the material
  25639. */
  25640. getEffect(): Nullable<Effect>;
  25641. /**
  25642. * Returns the current scene
  25643. * @returns a Scene
  25644. */
  25645. getScene(): Scene;
  25646. /**
  25647. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25648. */
  25649. protected _forceAlphaTest: boolean;
  25650. /**
  25651. * The transparency mode of the material.
  25652. */
  25653. protected _transparencyMode: Nullable<number>;
  25654. /**
  25655. * Gets the current transparency mode.
  25656. */
  25657. get transparencyMode(): Nullable<number>;
  25658. /**
  25659. * Sets the transparency mode of the material.
  25660. *
  25661. * | Value | Type | Description |
  25662. * | ----- | ----------------------------------- | ----------- |
  25663. * | 0 | OPAQUE | |
  25664. * | 1 | ALPHATEST | |
  25665. * | 2 | ALPHABLEND | |
  25666. * | 3 | ALPHATESTANDBLEND | |
  25667. *
  25668. */
  25669. set transparencyMode(value: Nullable<number>);
  25670. /**
  25671. * Returns true if alpha blending should be disabled.
  25672. */
  25673. protected get _disableAlphaBlending(): boolean;
  25674. /**
  25675. * Specifies whether or not this material should be rendered in alpha blend mode.
  25676. * @returns a boolean specifying if alpha blending is needed
  25677. */
  25678. needAlphaBlending(): boolean;
  25679. /**
  25680. * Specifies if the mesh will require alpha blending
  25681. * @param mesh defines the mesh to check
  25682. * @returns a boolean specifying if alpha blending is needed for the mesh
  25683. */
  25684. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25685. /**
  25686. * Specifies whether or not this material should be rendered in alpha test mode.
  25687. * @returns a boolean specifying if an alpha test is needed.
  25688. */
  25689. needAlphaTesting(): boolean;
  25690. /**
  25691. * Specifies if material alpha testing should be turned on for the mesh
  25692. * @param mesh defines the mesh to check
  25693. */
  25694. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25695. /**
  25696. * Gets the texture used for the alpha test
  25697. * @returns the texture to use for alpha testing
  25698. */
  25699. getAlphaTestTexture(): Nullable<BaseTexture>;
  25700. /**
  25701. * Marks the material to indicate that it needs to be re-calculated
  25702. */
  25703. markDirty(): void;
  25704. /** @hidden */
  25705. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25706. /**
  25707. * Binds the material to the mesh
  25708. * @param world defines the world transformation matrix
  25709. * @param mesh defines the mesh to bind the material to
  25710. */
  25711. bind(world: Matrix, mesh?: Mesh): void;
  25712. /**
  25713. * Binds the submesh to the material
  25714. * @param world defines the world transformation matrix
  25715. * @param mesh defines the mesh containing the submesh
  25716. * @param subMesh defines the submesh to bind the material to
  25717. */
  25718. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25719. /**
  25720. * Binds the world matrix to the material
  25721. * @param world defines the world transformation matrix
  25722. */
  25723. bindOnlyWorldMatrix(world: Matrix): void;
  25724. /**
  25725. * Binds the scene's uniform buffer to the effect.
  25726. * @param effect defines the effect to bind to the scene uniform buffer
  25727. * @param sceneUbo defines the uniform buffer storing scene data
  25728. */
  25729. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25730. /**
  25731. * Binds the view matrix to the effect
  25732. * @param effect defines the effect to bind the view matrix to
  25733. */
  25734. bindView(effect: Effect): void;
  25735. /**
  25736. * Binds the view projection matrix to the effect
  25737. * @param effect defines the effect to bind the view projection matrix to
  25738. */
  25739. bindViewProjection(effect: Effect): void;
  25740. /**
  25741. * Processes to execute after binding the material to a mesh
  25742. * @param mesh defines the rendered mesh
  25743. */
  25744. protected _afterBind(mesh?: Mesh): void;
  25745. /**
  25746. * Unbinds the material from the mesh
  25747. */
  25748. unbind(): void;
  25749. /**
  25750. * Gets the active textures from the material
  25751. * @returns an array of textures
  25752. */
  25753. getActiveTextures(): BaseTexture[];
  25754. /**
  25755. * Specifies if the material uses a texture
  25756. * @param texture defines the texture to check against the material
  25757. * @returns a boolean specifying if the material uses the texture
  25758. */
  25759. hasTexture(texture: BaseTexture): boolean;
  25760. /**
  25761. * Makes a duplicate of the material, and gives it a new name
  25762. * @param name defines the new name for the duplicated material
  25763. * @returns the cloned material
  25764. */
  25765. clone(name: string): Nullable<Material>;
  25766. /**
  25767. * Gets the meshes bound to the material
  25768. * @returns an array of meshes bound to the material
  25769. */
  25770. getBindedMeshes(): AbstractMesh[];
  25771. /**
  25772. * Force shader compilation
  25773. * @param mesh defines the mesh associated with this material
  25774. * @param onCompiled defines a function to execute once the material is compiled
  25775. * @param options defines the options to configure the compilation
  25776. * @param onError defines a function to execute if the material fails compiling
  25777. */
  25778. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25779. /**
  25780. * Force shader compilation
  25781. * @param mesh defines the mesh that will use this material
  25782. * @param options defines additional options for compiling the shaders
  25783. * @returns a promise that resolves when the compilation completes
  25784. */
  25785. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25786. private static readonly _AllDirtyCallBack;
  25787. private static readonly _ImageProcessingDirtyCallBack;
  25788. private static readonly _TextureDirtyCallBack;
  25789. private static readonly _FresnelDirtyCallBack;
  25790. private static readonly _MiscDirtyCallBack;
  25791. private static readonly _LightsDirtyCallBack;
  25792. private static readonly _AttributeDirtyCallBack;
  25793. private static _FresnelAndMiscDirtyCallBack;
  25794. private static _TextureAndMiscDirtyCallBack;
  25795. private static readonly _DirtyCallbackArray;
  25796. private static readonly _RunDirtyCallBacks;
  25797. /**
  25798. * Marks a define in the material to indicate that it needs to be re-computed
  25799. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25800. */
  25801. markAsDirty(flag: number): void;
  25802. /**
  25803. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25804. * @param func defines a function which checks material defines against the submeshes
  25805. */
  25806. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25807. /**
  25808. * Indicates that the scene should check if the rendering now needs a prepass
  25809. */
  25810. protected _markScenePrePassDirty(): void;
  25811. /**
  25812. * Indicates that we need to re-calculated for all submeshes
  25813. */
  25814. protected _markAllSubMeshesAsAllDirty(): void;
  25815. /**
  25816. * Indicates that image processing needs to be re-calculated for all submeshes
  25817. */
  25818. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25819. /**
  25820. * Indicates that textures need to be re-calculated for all submeshes
  25821. */
  25822. protected _markAllSubMeshesAsTexturesDirty(): void;
  25823. /**
  25824. * Indicates that fresnel needs to be re-calculated for all submeshes
  25825. */
  25826. protected _markAllSubMeshesAsFresnelDirty(): void;
  25827. /**
  25828. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25829. */
  25830. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25831. /**
  25832. * Indicates that lights need to be re-calculated for all submeshes
  25833. */
  25834. protected _markAllSubMeshesAsLightsDirty(): void;
  25835. /**
  25836. * Indicates that attributes need to be re-calculated for all submeshes
  25837. */
  25838. protected _markAllSubMeshesAsAttributesDirty(): void;
  25839. /**
  25840. * Indicates that misc needs to be re-calculated for all submeshes
  25841. */
  25842. protected _markAllSubMeshesAsMiscDirty(): void;
  25843. /**
  25844. * Indicates that textures and misc need to be re-calculated for all submeshes
  25845. */
  25846. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25847. /**
  25848. * Sets the required values to the prepass renderer.
  25849. * @param prePassRenderer defines the prepass renderer to setup.
  25850. * @returns true if the pre pass is needed.
  25851. */
  25852. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25853. /**
  25854. * Disposes the material
  25855. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25856. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25857. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25858. */
  25859. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25860. /** @hidden */
  25861. private releaseVertexArrayObject;
  25862. /**
  25863. * Serializes this material
  25864. * @returns the serialized material object
  25865. */
  25866. serialize(): any;
  25867. /**
  25868. * Creates a material from parsed material data
  25869. * @param parsedMaterial defines parsed material data
  25870. * @param scene defines the hosting scene
  25871. * @param rootUrl defines the root URL to use to load textures
  25872. * @returns a new material
  25873. */
  25874. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25875. }
  25876. }
  25877. declare module "babylonjs/Materials/multiMaterial" {
  25878. import { Nullable } from "babylonjs/types";
  25879. import { Scene } from "babylonjs/scene";
  25880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25883. import { Material } from "babylonjs/Materials/material";
  25884. /**
  25885. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25886. * separate meshes. This can be use to improve performances.
  25887. * @see https://doc.babylonjs.com/how_to/multi_materials
  25888. */
  25889. export class MultiMaterial extends Material {
  25890. private _subMaterials;
  25891. /**
  25892. * Gets or Sets the list of Materials used within the multi material.
  25893. * They need to be ordered according to the submeshes order in the associated mesh
  25894. */
  25895. get subMaterials(): Nullable<Material>[];
  25896. set subMaterials(value: Nullable<Material>[]);
  25897. /**
  25898. * Function used to align with Node.getChildren()
  25899. * @returns the list of Materials used within the multi material
  25900. */
  25901. getChildren(): Nullable<Material>[];
  25902. /**
  25903. * Instantiates a new Multi Material
  25904. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25905. * separate meshes. This can be use to improve performances.
  25906. * @see https://doc.babylonjs.com/how_to/multi_materials
  25907. * @param name Define the name in the scene
  25908. * @param scene Define the scene the material belongs to
  25909. */
  25910. constructor(name: string, scene: Scene);
  25911. private _hookArray;
  25912. /**
  25913. * Get one of the submaterial by its index in the submaterials array
  25914. * @param index The index to look the sub material at
  25915. * @returns The Material if the index has been defined
  25916. */
  25917. getSubMaterial(index: number): Nullable<Material>;
  25918. /**
  25919. * Get the list of active textures for the whole sub materials list.
  25920. * @returns All the textures that will be used during the rendering
  25921. */
  25922. getActiveTextures(): BaseTexture[];
  25923. /**
  25924. * Gets the current class name of the material e.g. "MultiMaterial"
  25925. * Mainly use in serialization.
  25926. * @returns the class name
  25927. */
  25928. getClassName(): string;
  25929. /**
  25930. * Checks if the material is ready to render the requested sub mesh
  25931. * @param mesh Define the mesh the submesh belongs to
  25932. * @param subMesh Define the sub mesh to look readyness for
  25933. * @param useInstances Define whether or not the material is used with instances
  25934. * @returns true if ready, otherwise false
  25935. */
  25936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25937. /**
  25938. * Clones the current material and its related sub materials
  25939. * @param name Define the name of the newly cloned material
  25940. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25941. * @returns the cloned material
  25942. */
  25943. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25944. /**
  25945. * Serializes the materials into a JSON representation.
  25946. * @returns the JSON representation
  25947. */
  25948. serialize(): any;
  25949. /**
  25950. * Dispose the material and release its associated resources
  25951. * @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)
  25952. * @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)
  25953. * @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)
  25954. */
  25955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25956. /**
  25957. * Creates a MultiMaterial from parsed MultiMaterial data.
  25958. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25959. * @param scene defines the hosting scene
  25960. * @returns a new MultiMaterial
  25961. */
  25962. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25963. }
  25964. }
  25965. declare module "babylonjs/Meshes/subMesh" {
  25966. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25967. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25968. import { Engine } from "babylonjs/Engines/engine";
  25969. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25970. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25971. import { Effect } from "babylonjs/Materials/effect";
  25972. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25973. import { Plane } from "babylonjs/Maths/math.plane";
  25974. import { Collider } from "babylonjs/Collisions/collider";
  25975. import { Material } from "babylonjs/Materials/material";
  25976. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25978. import { Mesh } from "babylonjs/Meshes/mesh";
  25979. import { Ray } from "babylonjs/Culling/ray";
  25980. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25981. /**
  25982. * Defines a subdivision inside a mesh
  25983. */
  25984. export class SubMesh implements ICullable {
  25985. /** the material index to use */
  25986. materialIndex: number;
  25987. /** vertex index start */
  25988. verticesStart: number;
  25989. /** vertices count */
  25990. verticesCount: number;
  25991. /** index start */
  25992. indexStart: number;
  25993. /** indices count */
  25994. indexCount: number;
  25995. /** @hidden */
  25996. _materialDefines: Nullable<MaterialDefines>;
  25997. /** @hidden */
  25998. _materialEffect: Nullable<Effect>;
  25999. /** @hidden */
  26000. _effectOverride: Nullable<Effect>;
  26001. /**
  26002. * Gets material defines used by the effect associated to the sub mesh
  26003. */
  26004. get materialDefines(): Nullable<MaterialDefines>;
  26005. /**
  26006. * Sets material defines used by the effect associated to the sub mesh
  26007. */
  26008. set materialDefines(defines: Nullable<MaterialDefines>);
  26009. /**
  26010. * Gets associated effect
  26011. */
  26012. get effect(): Nullable<Effect>;
  26013. /**
  26014. * Sets associated effect (effect used to render this submesh)
  26015. * @param effect defines the effect to associate with
  26016. * @param defines defines the set of defines used to compile this effect
  26017. */
  26018. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26019. /** @hidden */
  26020. _linesIndexCount: number;
  26021. private _mesh;
  26022. private _renderingMesh;
  26023. private _boundingInfo;
  26024. private _linesIndexBuffer;
  26025. /** @hidden */
  26026. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26027. /** @hidden */
  26028. _trianglePlanes: Plane[];
  26029. /** @hidden */
  26030. _lastColliderTransformMatrix: Nullable<Matrix>;
  26031. /** @hidden */
  26032. _renderId: number;
  26033. /** @hidden */
  26034. _alphaIndex: number;
  26035. /** @hidden */
  26036. _distanceToCamera: number;
  26037. /** @hidden */
  26038. _id: number;
  26039. private _currentMaterial;
  26040. /**
  26041. * Add a new submesh to a mesh
  26042. * @param materialIndex defines the material index to use
  26043. * @param verticesStart defines vertex index start
  26044. * @param verticesCount defines vertices count
  26045. * @param indexStart defines index start
  26046. * @param indexCount defines indices count
  26047. * @param mesh defines the parent mesh
  26048. * @param renderingMesh defines an optional rendering mesh
  26049. * @param createBoundingBox defines if bounding box should be created for this submesh
  26050. * @returns the new submesh
  26051. */
  26052. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26053. /**
  26054. * Creates a new submesh
  26055. * @param materialIndex defines the material index to use
  26056. * @param verticesStart defines vertex index start
  26057. * @param verticesCount defines vertices count
  26058. * @param indexStart defines index start
  26059. * @param indexCount defines indices count
  26060. * @param mesh defines the parent mesh
  26061. * @param renderingMesh defines an optional rendering mesh
  26062. * @param createBoundingBox defines if bounding box should be created for this submesh
  26063. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26064. */
  26065. constructor(
  26066. /** the material index to use */
  26067. materialIndex: number,
  26068. /** vertex index start */
  26069. verticesStart: number,
  26070. /** vertices count */
  26071. verticesCount: number,
  26072. /** index start */
  26073. indexStart: number,
  26074. /** indices count */
  26075. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26076. /**
  26077. * Returns true if this submesh covers the entire parent mesh
  26078. * @ignorenaming
  26079. */
  26080. get IsGlobal(): boolean;
  26081. /**
  26082. * Returns the submesh BoudingInfo object
  26083. * @returns current bounding info (or mesh's one if the submesh is global)
  26084. */
  26085. getBoundingInfo(): BoundingInfo;
  26086. /**
  26087. * Sets the submesh BoundingInfo
  26088. * @param boundingInfo defines the new bounding info to use
  26089. * @returns the SubMesh
  26090. */
  26091. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26092. /**
  26093. * Returns the mesh of the current submesh
  26094. * @return the parent mesh
  26095. */
  26096. getMesh(): AbstractMesh;
  26097. /**
  26098. * Returns the rendering mesh of the submesh
  26099. * @returns the rendering mesh (could be different from parent mesh)
  26100. */
  26101. getRenderingMesh(): Mesh;
  26102. /**
  26103. * Returns the replacement mesh of the submesh
  26104. * @returns the replacement mesh (could be different from parent mesh)
  26105. */
  26106. getReplacementMesh(): Nullable<AbstractMesh>;
  26107. /**
  26108. * Returns the effective mesh of the submesh
  26109. * @returns the effective mesh (could be different from parent mesh)
  26110. */
  26111. getEffectiveMesh(): AbstractMesh;
  26112. /**
  26113. * Returns the submesh material
  26114. * @returns null or the current material
  26115. */
  26116. getMaterial(): Nullable<Material>;
  26117. private _IsMultiMaterial;
  26118. /**
  26119. * Sets a new updated BoundingInfo object to the submesh
  26120. * @param data defines an optional position array to use to determine the bounding info
  26121. * @returns the SubMesh
  26122. */
  26123. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26124. /** @hidden */
  26125. _checkCollision(collider: Collider): boolean;
  26126. /**
  26127. * Updates the submesh BoundingInfo
  26128. * @param world defines the world matrix to use to update the bounding info
  26129. * @returns the submesh
  26130. */
  26131. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26132. /**
  26133. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26134. * @param frustumPlanes defines the frustum planes
  26135. * @returns true if the submesh is intersecting with the frustum
  26136. */
  26137. isInFrustum(frustumPlanes: Plane[]): boolean;
  26138. /**
  26139. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26140. * @param frustumPlanes defines the frustum planes
  26141. * @returns true if the submesh is inside the frustum
  26142. */
  26143. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26144. /**
  26145. * Renders the submesh
  26146. * @param enableAlphaMode defines if alpha needs to be used
  26147. * @returns the submesh
  26148. */
  26149. render(enableAlphaMode: boolean): SubMesh;
  26150. /**
  26151. * @hidden
  26152. */
  26153. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26154. /**
  26155. * Checks if the submesh intersects with a ray
  26156. * @param ray defines the ray to test
  26157. * @returns true is the passed ray intersects the submesh bounding box
  26158. */
  26159. canIntersects(ray: Ray): boolean;
  26160. /**
  26161. * Intersects current submesh with a ray
  26162. * @param ray defines the ray to test
  26163. * @param positions defines mesh's positions array
  26164. * @param indices defines mesh's indices array
  26165. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26166. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26167. * @returns intersection info or null if no intersection
  26168. */
  26169. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26170. /** @hidden */
  26171. private _intersectLines;
  26172. /** @hidden */
  26173. private _intersectUnIndexedLines;
  26174. /** @hidden */
  26175. private _intersectTriangles;
  26176. /** @hidden */
  26177. private _intersectUnIndexedTriangles;
  26178. /** @hidden */
  26179. _rebuild(): void;
  26180. /**
  26181. * Creates a new submesh from the passed mesh
  26182. * @param newMesh defines the new hosting mesh
  26183. * @param newRenderingMesh defines an optional rendering mesh
  26184. * @returns the new submesh
  26185. */
  26186. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26187. /**
  26188. * Release associated resources
  26189. */
  26190. dispose(): void;
  26191. /**
  26192. * Gets the class name
  26193. * @returns the string "SubMesh".
  26194. */
  26195. getClassName(): string;
  26196. /**
  26197. * Creates a new submesh from indices data
  26198. * @param materialIndex the index of the main mesh material
  26199. * @param startIndex the index where to start the copy in the mesh indices array
  26200. * @param indexCount the number of indices to copy then from the startIndex
  26201. * @param mesh the main mesh to create the submesh from
  26202. * @param renderingMesh the optional rendering mesh
  26203. * @returns a new submesh
  26204. */
  26205. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26206. }
  26207. }
  26208. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26209. /**
  26210. * Class used to represent data loading progression
  26211. */
  26212. export class SceneLoaderFlags {
  26213. private static _ForceFullSceneLoadingForIncremental;
  26214. private static _ShowLoadingScreen;
  26215. private static _CleanBoneMatrixWeights;
  26216. private static _loggingLevel;
  26217. /**
  26218. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26219. */
  26220. static get ForceFullSceneLoadingForIncremental(): boolean;
  26221. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26222. /**
  26223. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26224. */
  26225. static get ShowLoadingScreen(): boolean;
  26226. static set ShowLoadingScreen(value: boolean);
  26227. /**
  26228. * Defines the current logging level (while loading the scene)
  26229. * @ignorenaming
  26230. */
  26231. static get loggingLevel(): number;
  26232. static set loggingLevel(value: number);
  26233. /**
  26234. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26235. */
  26236. static get CleanBoneMatrixWeights(): boolean;
  26237. static set CleanBoneMatrixWeights(value: boolean);
  26238. }
  26239. }
  26240. declare module "babylonjs/Meshes/geometry" {
  26241. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26242. import { Scene } from "babylonjs/scene";
  26243. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26244. import { Engine } from "babylonjs/Engines/engine";
  26245. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26246. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26247. import { Effect } from "babylonjs/Materials/effect";
  26248. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26249. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26250. import { Mesh } from "babylonjs/Meshes/mesh";
  26251. /**
  26252. * Class used to store geometry data (vertex buffers + index buffer)
  26253. */
  26254. export class Geometry implements IGetSetVerticesData {
  26255. /**
  26256. * Gets or sets the ID of the geometry
  26257. */
  26258. id: string;
  26259. /**
  26260. * Gets or sets the unique ID of the geometry
  26261. */
  26262. uniqueId: number;
  26263. /**
  26264. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26265. */
  26266. delayLoadState: number;
  26267. /**
  26268. * Gets the file containing the data to load when running in delay load state
  26269. */
  26270. delayLoadingFile: Nullable<string>;
  26271. /**
  26272. * Callback called when the geometry is updated
  26273. */
  26274. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26275. private _scene;
  26276. private _engine;
  26277. private _meshes;
  26278. private _totalVertices;
  26279. /** @hidden */
  26280. _indices: IndicesArray;
  26281. /** @hidden */
  26282. _vertexBuffers: {
  26283. [key: string]: VertexBuffer;
  26284. };
  26285. private _isDisposed;
  26286. private _extend;
  26287. private _boundingBias;
  26288. /** @hidden */
  26289. _delayInfo: Array<string>;
  26290. private _indexBuffer;
  26291. private _indexBufferIsUpdatable;
  26292. /** @hidden */
  26293. _boundingInfo: Nullable<BoundingInfo>;
  26294. /** @hidden */
  26295. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26296. /** @hidden */
  26297. _softwareSkinningFrameId: number;
  26298. private _vertexArrayObjects;
  26299. private _updatable;
  26300. /** @hidden */
  26301. _positions: Nullable<Vector3[]>;
  26302. /**
  26303. * 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
  26304. */
  26305. get boundingBias(): Vector2;
  26306. /**
  26307. * 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
  26308. */
  26309. set boundingBias(value: Vector2);
  26310. /**
  26311. * Static function used to attach a new empty geometry to a mesh
  26312. * @param mesh defines the mesh to attach the geometry to
  26313. * @returns the new Geometry
  26314. */
  26315. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26316. /** Get the list of meshes using this geometry */
  26317. get meshes(): Mesh[];
  26318. /**
  26319. * 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
  26320. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26321. */
  26322. useBoundingInfoFromGeometry: boolean;
  26323. /**
  26324. * Creates a new geometry
  26325. * @param id defines the unique ID
  26326. * @param scene defines the hosting scene
  26327. * @param vertexData defines the VertexData used to get geometry data
  26328. * @param updatable defines if geometry must be updatable (false by default)
  26329. * @param mesh defines the mesh that will be associated with the geometry
  26330. */
  26331. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26332. /**
  26333. * Gets the current extend of the geometry
  26334. */
  26335. get extend(): {
  26336. minimum: Vector3;
  26337. maximum: Vector3;
  26338. };
  26339. /**
  26340. * Gets the hosting scene
  26341. * @returns the hosting Scene
  26342. */
  26343. getScene(): Scene;
  26344. /**
  26345. * Gets the hosting engine
  26346. * @returns the hosting Engine
  26347. */
  26348. getEngine(): Engine;
  26349. /**
  26350. * Defines if the geometry is ready to use
  26351. * @returns true if the geometry is ready to be used
  26352. */
  26353. isReady(): boolean;
  26354. /**
  26355. * Gets a value indicating that the geometry should not be serialized
  26356. */
  26357. get doNotSerialize(): boolean;
  26358. /** @hidden */
  26359. _rebuild(): void;
  26360. /**
  26361. * Affects all geometry data in one call
  26362. * @param vertexData defines the geometry data
  26363. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26364. */
  26365. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26366. /**
  26367. * Set specific vertex data
  26368. * @param kind defines the data kind (Position, normal, etc...)
  26369. * @param data defines the vertex data to use
  26370. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26371. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26372. */
  26373. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26374. /**
  26375. * Removes a specific vertex data
  26376. * @param kind defines the data kind (Position, normal, etc...)
  26377. */
  26378. removeVerticesData(kind: string): void;
  26379. /**
  26380. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26381. * @param buffer defines the vertex buffer to use
  26382. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26383. */
  26384. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26385. /**
  26386. * Update a specific vertex buffer
  26387. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26388. * It will do nothing if the buffer is not updatable
  26389. * @param kind defines the data kind (Position, normal, etc...)
  26390. * @param data defines the data to use
  26391. * @param offset defines the offset in the target buffer where to store the data
  26392. * @param useBytes set to true if the offset is in bytes
  26393. */
  26394. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26395. /**
  26396. * Update a specific vertex buffer
  26397. * This function will create a new buffer if the current one is not updatable
  26398. * @param kind defines the data kind (Position, normal, etc...)
  26399. * @param data defines the data to use
  26400. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26401. */
  26402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26403. private _updateBoundingInfo;
  26404. /** @hidden */
  26405. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26406. /**
  26407. * Gets total number of vertices
  26408. * @returns the total number of vertices
  26409. */
  26410. getTotalVertices(): number;
  26411. /**
  26412. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26413. * @param kind defines the data kind (Position, normal, etc...)
  26414. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26415. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26416. * @returns a float array containing vertex data
  26417. */
  26418. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26419. /**
  26420. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26421. * @param kind defines the data kind (Position, normal, etc...)
  26422. * @returns true if the vertex buffer with the specified kind is updatable
  26423. */
  26424. isVertexBufferUpdatable(kind: string): boolean;
  26425. /**
  26426. * Gets a specific vertex buffer
  26427. * @param kind defines the data kind (Position, normal, etc...)
  26428. * @returns a VertexBuffer
  26429. */
  26430. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26431. /**
  26432. * Returns all vertex buffers
  26433. * @return an object holding all vertex buffers indexed by kind
  26434. */
  26435. getVertexBuffers(): Nullable<{
  26436. [key: string]: VertexBuffer;
  26437. }>;
  26438. /**
  26439. * Gets a boolean indicating if specific vertex buffer is present
  26440. * @param kind defines the data kind (Position, normal, etc...)
  26441. * @returns true if data is present
  26442. */
  26443. isVerticesDataPresent(kind: string): boolean;
  26444. /**
  26445. * Gets a list of all attached data kinds (Position, normal, etc...)
  26446. * @returns a list of string containing all kinds
  26447. */
  26448. getVerticesDataKinds(): string[];
  26449. /**
  26450. * Update index buffer
  26451. * @param indices defines the indices to store in the index buffer
  26452. * @param offset defines the offset in the target buffer where to store the data
  26453. * @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)
  26454. */
  26455. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26456. /**
  26457. * Creates a new index buffer
  26458. * @param indices defines the indices to store in the index buffer
  26459. * @param totalVertices defines the total number of vertices (could be null)
  26460. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26461. */
  26462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26463. /**
  26464. * Return the total number of indices
  26465. * @returns the total number of indices
  26466. */
  26467. getTotalIndices(): number;
  26468. /**
  26469. * Gets the index buffer array
  26470. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26471. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26472. * @returns the index buffer array
  26473. */
  26474. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26475. /**
  26476. * Gets the index buffer
  26477. * @return the index buffer
  26478. */
  26479. getIndexBuffer(): Nullable<DataBuffer>;
  26480. /** @hidden */
  26481. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26482. /**
  26483. * Release the associated resources for a specific mesh
  26484. * @param mesh defines the source mesh
  26485. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26486. */
  26487. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26488. /**
  26489. * Apply current geometry to a given mesh
  26490. * @param mesh defines the mesh to apply geometry to
  26491. */
  26492. applyToMesh(mesh: Mesh): void;
  26493. private _updateExtend;
  26494. private _applyToMesh;
  26495. private notifyUpdate;
  26496. /**
  26497. * Load the geometry if it was flagged as delay loaded
  26498. * @param scene defines the hosting scene
  26499. * @param onLoaded defines a callback called when the geometry is loaded
  26500. */
  26501. load(scene: Scene, onLoaded?: () => void): void;
  26502. private _queueLoad;
  26503. /**
  26504. * Invert the geometry to move from a right handed system to a left handed one.
  26505. */
  26506. toLeftHanded(): void;
  26507. /** @hidden */
  26508. _resetPointsArrayCache(): void;
  26509. /** @hidden */
  26510. _generatePointsArray(): boolean;
  26511. /**
  26512. * Gets a value indicating if the geometry is disposed
  26513. * @returns true if the geometry was disposed
  26514. */
  26515. isDisposed(): boolean;
  26516. private _disposeVertexArrayObjects;
  26517. /**
  26518. * Free all associated resources
  26519. */
  26520. dispose(): void;
  26521. /**
  26522. * Clone the current geometry into a new geometry
  26523. * @param id defines the unique ID of the new geometry
  26524. * @returns a new geometry object
  26525. */
  26526. copy(id: string): Geometry;
  26527. /**
  26528. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26529. * @return a JSON representation of the current geometry data (without the vertices data)
  26530. */
  26531. serialize(): any;
  26532. private toNumberArray;
  26533. /**
  26534. * Serialize all vertices data into a JSON oject
  26535. * @returns a JSON representation of the current geometry data
  26536. */
  26537. serializeVerticeData(): any;
  26538. /**
  26539. * Extracts a clone of a mesh geometry
  26540. * @param mesh defines the source mesh
  26541. * @param id defines the unique ID of the new geometry object
  26542. * @returns the new geometry object
  26543. */
  26544. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26545. /**
  26546. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26547. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26548. * Be aware Math.random() could cause collisions, but:
  26549. * "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"
  26550. * @returns a string containing a new GUID
  26551. */
  26552. static RandomId(): string;
  26553. /** @hidden */
  26554. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26555. private static _CleanMatricesWeights;
  26556. /**
  26557. * Create a new geometry from persisted data (Using .babylon file format)
  26558. * @param parsedVertexData defines the persisted data
  26559. * @param scene defines the hosting scene
  26560. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26561. * @returns the new geometry object
  26562. */
  26563. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26564. }
  26565. }
  26566. declare module "babylonjs/Meshes/mesh.vertexData" {
  26567. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26568. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26569. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26570. import { Geometry } from "babylonjs/Meshes/geometry";
  26571. import { Mesh } from "babylonjs/Meshes/mesh";
  26572. /**
  26573. * Define an interface for all classes that will get and set the data on vertices
  26574. */
  26575. export interface IGetSetVerticesData {
  26576. /**
  26577. * Gets a boolean indicating if specific vertex data is present
  26578. * @param kind defines the vertex data kind to use
  26579. * @returns true is data kind is present
  26580. */
  26581. isVerticesDataPresent(kind: string): boolean;
  26582. /**
  26583. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26584. * @param kind defines the data kind (Position, normal, etc...)
  26585. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26586. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26587. * @returns a float array containing vertex data
  26588. */
  26589. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26590. /**
  26591. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26592. * @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.
  26593. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26594. * @returns the indices array or an empty array if the mesh has no geometry
  26595. */
  26596. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26597. /**
  26598. * Set specific vertex data
  26599. * @param kind defines the data kind (Position, normal, etc...)
  26600. * @param data defines the vertex data to use
  26601. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26602. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26603. */
  26604. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26605. /**
  26606. * Update a specific associated vertex buffer
  26607. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26608. * - VertexBuffer.PositionKind
  26609. * - VertexBuffer.UVKind
  26610. * - VertexBuffer.UV2Kind
  26611. * - VertexBuffer.UV3Kind
  26612. * - VertexBuffer.UV4Kind
  26613. * - VertexBuffer.UV5Kind
  26614. * - VertexBuffer.UV6Kind
  26615. * - VertexBuffer.ColorKind
  26616. * - VertexBuffer.MatricesIndicesKind
  26617. * - VertexBuffer.MatricesIndicesExtraKind
  26618. * - VertexBuffer.MatricesWeightsKind
  26619. * - VertexBuffer.MatricesWeightsExtraKind
  26620. * @param data defines the data source
  26621. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26622. * @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)
  26623. */
  26624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26625. /**
  26626. * Creates a new index buffer
  26627. * @param indices defines the indices to store in the index buffer
  26628. * @param totalVertices defines the total number of vertices (could be null)
  26629. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26630. */
  26631. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26632. }
  26633. /**
  26634. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26635. */
  26636. export class VertexData {
  26637. /**
  26638. * Mesh side orientation : usually the external or front surface
  26639. */
  26640. static readonly FRONTSIDE: number;
  26641. /**
  26642. * Mesh side orientation : usually the internal or back surface
  26643. */
  26644. static readonly BACKSIDE: number;
  26645. /**
  26646. * Mesh side orientation : both internal and external or front and back surfaces
  26647. */
  26648. static readonly DOUBLESIDE: number;
  26649. /**
  26650. * Mesh side orientation : by default, `FRONTSIDE`
  26651. */
  26652. static readonly DEFAULTSIDE: number;
  26653. /**
  26654. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26655. */
  26656. positions: Nullable<FloatArray>;
  26657. /**
  26658. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26659. */
  26660. normals: Nullable<FloatArray>;
  26661. /**
  26662. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26663. */
  26664. tangents: Nullable<FloatArray>;
  26665. /**
  26666. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26667. */
  26668. uvs: Nullable<FloatArray>;
  26669. /**
  26670. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26671. */
  26672. uvs2: Nullable<FloatArray>;
  26673. /**
  26674. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26675. */
  26676. uvs3: Nullable<FloatArray>;
  26677. /**
  26678. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26679. */
  26680. uvs4: Nullable<FloatArray>;
  26681. /**
  26682. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26683. */
  26684. uvs5: Nullable<FloatArray>;
  26685. /**
  26686. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26687. */
  26688. uvs6: Nullable<FloatArray>;
  26689. /**
  26690. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26691. */
  26692. colors: Nullable<FloatArray>;
  26693. /**
  26694. * 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).
  26695. */
  26696. matricesIndices: Nullable<FloatArray>;
  26697. /**
  26698. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26699. */
  26700. matricesWeights: Nullable<FloatArray>;
  26701. /**
  26702. * An array extending the number of possible indices
  26703. */
  26704. matricesIndicesExtra: Nullable<FloatArray>;
  26705. /**
  26706. * An array extending the number of possible weights when the number of indices is extended
  26707. */
  26708. matricesWeightsExtra: Nullable<FloatArray>;
  26709. /**
  26710. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26711. */
  26712. indices: Nullable<IndicesArray>;
  26713. /**
  26714. * Uses the passed data array to set the set the values for the specified kind of data
  26715. * @param data a linear array of floating numbers
  26716. * @param kind the type of data that is being set, eg positions, colors etc
  26717. */
  26718. set(data: FloatArray, kind: string): void;
  26719. /**
  26720. * Associates the vertexData to the passed Mesh.
  26721. * Sets it as updatable or not (default `false`)
  26722. * @param mesh the mesh the vertexData is applied to
  26723. * @param updatable when used and having the value true allows new data to update the vertexData
  26724. * @returns the VertexData
  26725. */
  26726. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26727. /**
  26728. * Associates the vertexData to the passed Geometry.
  26729. * Sets it as updatable or not (default `false`)
  26730. * @param geometry the geometry the vertexData is applied to
  26731. * @param updatable when used and having the value true allows new data to update the vertexData
  26732. * @returns VertexData
  26733. */
  26734. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26735. /**
  26736. * Updates the associated mesh
  26737. * @param mesh the mesh to be updated
  26738. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26739. * @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
  26740. * @returns VertexData
  26741. */
  26742. updateMesh(mesh: Mesh): VertexData;
  26743. /**
  26744. * Updates the associated geometry
  26745. * @param geometry the geometry to be updated
  26746. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26747. * @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
  26748. * @returns VertexData.
  26749. */
  26750. updateGeometry(geometry: Geometry): VertexData;
  26751. private _applyTo;
  26752. private _update;
  26753. /**
  26754. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26755. * @param matrix the transforming matrix
  26756. * @returns the VertexData
  26757. */
  26758. transform(matrix: Matrix): VertexData;
  26759. /**
  26760. * Merges the passed VertexData into the current one
  26761. * @param other the VertexData to be merged into the current one
  26762. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26763. * @returns the modified VertexData
  26764. */
  26765. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26766. private _mergeElement;
  26767. private _validate;
  26768. /**
  26769. * Serializes the VertexData
  26770. * @returns a serialized object
  26771. */
  26772. serialize(): any;
  26773. /**
  26774. * Extracts the vertexData from a mesh
  26775. * @param mesh the mesh from which to extract the VertexData
  26776. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26777. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26778. * @returns the object VertexData associated to the passed mesh
  26779. */
  26780. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26781. /**
  26782. * Extracts the vertexData from the geometry
  26783. * @param geometry the geometry from which to extract the VertexData
  26784. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26785. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26786. * @returns the object VertexData associated to the passed mesh
  26787. */
  26788. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26789. private static _ExtractFrom;
  26790. /**
  26791. * Creates the VertexData for a Ribbon
  26792. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26793. * * pathArray array of paths, each of which an array of successive Vector3
  26794. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26795. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26796. * * 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
  26797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26798. * * 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)
  26799. * * 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)
  26800. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26801. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26802. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26803. * @returns the VertexData of the ribbon
  26804. */
  26805. static CreateRibbon(options: {
  26806. pathArray: Vector3[][];
  26807. closeArray?: boolean;
  26808. closePath?: boolean;
  26809. offset?: number;
  26810. sideOrientation?: number;
  26811. frontUVs?: Vector4;
  26812. backUVs?: Vector4;
  26813. invertUV?: boolean;
  26814. uvs?: Vector2[];
  26815. colors?: Color4[];
  26816. }): VertexData;
  26817. /**
  26818. * Creates the VertexData for a box
  26819. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26820. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26821. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26822. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26823. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26824. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26825. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26827. * * 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)
  26828. * * 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)
  26829. * @returns the VertexData of the box
  26830. */
  26831. static CreateBox(options: {
  26832. size?: number;
  26833. width?: number;
  26834. height?: number;
  26835. depth?: number;
  26836. faceUV?: Vector4[];
  26837. faceColors?: Color4[];
  26838. sideOrientation?: number;
  26839. frontUVs?: Vector4;
  26840. backUVs?: Vector4;
  26841. }): VertexData;
  26842. /**
  26843. * Creates the VertexData for a tiled box
  26844. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26845. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26846. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26847. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26849. * @returns the VertexData of the box
  26850. */
  26851. static CreateTiledBox(options: {
  26852. pattern?: number;
  26853. width?: number;
  26854. height?: number;
  26855. depth?: number;
  26856. tileSize?: number;
  26857. tileWidth?: number;
  26858. tileHeight?: number;
  26859. alignHorizontal?: number;
  26860. alignVertical?: number;
  26861. faceUV?: Vector4[];
  26862. faceColors?: Color4[];
  26863. sideOrientation?: number;
  26864. }): VertexData;
  26865. /**
  26866. * Creates the VertexData for a tiled plane
  26867. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26868. * * pattern a limited pattern arrangement depending on the number
  26869. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26870. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26871. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26873. * * 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)
  26874. * * 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)
  26875. * @returns the VertexData of the tiled plane
  26876. */
  26877. static CreateTiledPlane(options: {
  26878. pattern?: number;
  26879. tileSize?: number;
  26880. tileWidth?: number;
  26881. tileHeight?: number;
  26882. size?: number;
  26883. width?: number;
  26884. height?: number;
  26885. alignHorizontal?: number;
  26886. alignVertical?: number;
  26887. sideOrientation?: number;
  26888. frontUVs?: Vector4;
  26889. backUVs?: Vector4;
  26890. }): VertexData;
  26891. /**
  26892. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26893. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26894. * * segments sets the number of horizontal strips optional, default 32
  26895. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26896. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26897. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26898. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26899. * * 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
  26900. * * 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
  26901. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26902. * * 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)
  26903. * * 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)
  26904. * @returns the VertexData of the ellipsoid
  26905. */
  26906. static CreateSphere(options: {
  26907. segments?: number;
  26908. diameter?: number;
  26909. diameterX?: number;
  26910. diameterY?: number;
  26911. diameterZ?: number;
  26912. arc?: number;
  26913. slice?: number;
  26914. sideOrientation?: number;
  26915. frontUVs?: Vector4;
  26916. backUVs?: Vector4;
  26917. }): VertexData;
  26918. /**
  26919. * Creates the VertexData for a cylinder, cone or prism
  26920. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26921. * * height sets the height (y direction) of the cylinder, optional, default 2
  26922. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26923. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26924. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26925. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26926. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26927. * * 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
  26928. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26929. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26930. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26931. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26933. * * 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)
  26934. * * 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)
  26935. * @returns the VertexData of the cylinder, cone or prism
  26936. */
  26937. static CreateCylinder(options: {
  26938. height?: number;
  26939. diameterTop?: number;
  26940. diameterBottom?: number;
  26941. diameter?: number;
  26942. tessellation?: number;
  26943. subdivisions?: number;
  26944. arc?: number;
  26945. faceColors?: Color4[];
  26946. faceUV?: Vector4[];
  26947. hasRings?: boolean;
  26948. enclose?: boolean;
  26949. sideOrientation?: number;
  26950. frontUVs?: Vector4;
  26951. backUVs?: Vector4;
  26952. }): VertexData;
  26953. /**
  26954. * Creates the VertexData for a torus
  26955. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26956. * * diameter the diameter of the torus, optional default 1
  26957. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26958. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26960. * * 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)
  26961. * * 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)
  26962. * @returns the VertexData of the torus
  26963. */
  26964. static CreateTorus(options: {
  26965. diameter?: number;
  26966. thickness?: number;
  26967. tessellation?: number;
  26968. sideOrientation?: number;
  26969. frontUVs?: Vector4;
  26970. backUVs?: Vector4;
  26971. }): VertexData;
  26972. /**
  26973. * Creates the VertexData of the LineSystem
  26974. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26975. * - lines an array of lines, each line being an array of successive Vector3
  26976. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26977. * @returns the VertexData of the LineSystem
  26978. */
  26979. static CreateLineSystem(options: {
  26980. lines: Vector3[][];
  26981. colors?: Nullable<Color4[][]>;
  26982. }): VertexData;
  26983. /**
  26984. * Create the VertexData for a DashedLines
  26985. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26986. * - points an array successive Vector3
  26987. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26988. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26989. * - dashNb the intended total number of dashes, optional, default 200
  26990. * @returns the VertexData for the DashedLines
  26991. */
  26992. static CreateDashedLines(options: {
  26993. points: Vector3[];
  26994. dashSize?: number;
  26995. gapSize?: number;
  26996. dashNb?: number;
  26997. }): VertexData;
  26998. /**
  26999. * Creates the VertexData for a Ground
  27000. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27001. * - width the width (x direction) of the ground, optional, default 1
  27002. * - height the height (z direction) of the ground, optional, default 1
  27003. * - subdivisions the number of subdivisions per side, optional, default 1
  27004. * @returns the VertexData of the Ground
  27005. */
  27006. static CreateGround(options: {
  27007. width?: number;
  27008. height?: number;
  27009. subdivisions?: number;
  27010. subdivisionsX?: number;
  27011. subdivisionsY?: number;
  27012. }): VertexData;
  27013. /**
  27014. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27015. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27016. * * xmin the ground minimum X coordinate, optional, default -1
  27017. * * zmin the ground minimum Z coordinate, optional, default -1
  27018. * * xmax the ground maximum X coordinate, optional, default 1
  27019. * * zmax the ground maximum Z coordinate, optional, default 1
  27020. * * 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}
  27021. * * 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}
  27022. * @returns the VertexData of the TiledGround
  27023. */
  27024. static CreateTiledGround(options: {
  27025. xmin: number;
  27026. zmin: number;
  27027. xmax: number;
  27028. zmax: number;
  27029. subdivisions?: {
  27030. w: number;
  27031. h: number;
  27032. };
  27033. precision?: {
  27034. w: number;
  27035. h: number;
  27036. };
  27037. }): VertexData;
  27038. /**
  27039. * Creates the VertexData of the Ground designed from a heightmap
  27040. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27041. * * width the width (x direction) of the ground
  27042. * * height the height (z direction) of the ground
  27043. * * subdivisions the number of subdivisions per side
  27044. * * minHeight the minimum altitude on the ground, optional, default 0
  27045. * * maxHeight the maximum altitude on the ground, optional default 1
  27046. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27047. * * buffer the array holding the image color data
  27048. * * bufferWidth the width of image
  27049. * * bufferHeight the height of image
  27050. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27051. * @returns the VertexData of the Ground designed from a heightmap
  27052. */
  27053. static CreateGroundFromHeightMap(options: {
  27054. width: number;
  27055. height: number;
  27056. subdivisions: number;
  27057. minHeight: number;
  27058. maxHeight: number;
  27059. colorFilter: Color3;
  27060. buffer: Uint8Array;
  27061. bufferWidth: number;
  27062. bufferHeight: number;
  27063. alphaFilter: number;
  27064. }): VertexData;
  27065. /**
  27066. * Creates the VertexData for a Plane
  27067. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27068. * * size sets the width and height of the plane to the value of size, optional default 1
  27069. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27070. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27072. * * 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)
  27073. * * 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)
  27074. * @returns the VertexData of the box
  27075. */
  27076. static CreatePlane(options: {
  27077. size?: number;
  27078. width?: number;
  27079. height?: number;
  27080. sideOrientation?: number;
  27081. frontUVs?: Vector4;
  27082. backUVs?: Vector4;
  27083. }): VertexData;
  27084. /**
  27085. * Creates the VertexData of the Disc or regular Polygon
  27086. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27087. * * radius the radius of the disc, optional default 0.5
  27088. * * tessellation the number of polygon sides, optional, default 64
  27089. * * 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
  27090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27091. * * 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)
  27092. * * 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)
  27093. * @returns the VertexData of the box
  27094. */
  27095. static CreateDisc(options: {
  27096. radius?: number;
  27097. tessellation?: number;
  27098. arc?: number;
  27099. sideOrientation?: number;
  27100. frontUVs?: Vector4;
  27101. backUVs?: Vector4;
  27102. }): VertexData;
  27103. /**
  27104. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27105. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27106. * @param polygon a mesh built from polygonTriangulation.build()
  27107. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27108. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27109. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27110. * @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)
  27111. * @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)
  27112. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27113. * @returns the VertexData of the Polygon
  27114. */
  27115. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27116. /**
  27117. * Creates the VertexData of the IcoSphere
  27118. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27119. * * radius the radius of the IcoSphere, optional default 1
  27120. * * radiusX allows stretching in the x direction, optional, default radius
  27121. * * radiusY allows stretching in the y direction, optional, default radius
  27122. * * radiusZ allows stretching in the z direction, optional, default radius
  27123. * * flat when true creates a flat shaded mesh, optional, default true
  27124. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27126. * * 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)
  27127. * * 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)
  27128. * @returns the VertexData of the IcoSphere
  27129. */
  27130. static CreateIcoSphere(options: {
  27131. radius?: number;
  27132. radiusX?: number;
  27133. radiusY?: number;
  27134. radiusZ?: number;
  27135. flat?: boolean;
  27136. subdivisions?: number;
  27137. sideOrientation?: number;
  27138. frontUVs?: Vector4;
  27139. backUVs?: Vector4;
  27140. }): VertexData;
  27141. /**
  27142. * Creates the VertexData for a Polyhedron
  27143. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27144. * * type provided types are:
  27145. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27146. * * 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)
  27147. * * size the size of the IcoSphere, optional default 1
  27148. * * sizeX allows stretching in the x direction, optional, default size
  27149. * * sizeY allows stretching in the y direction, optional, default size
  27150. * * sizeZ allows stretching in the z direction, optional, default size
  27151. * * 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
  27152. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27153. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27154. * * flat when true creates a flat shaded mesh, optional, default true
  27155. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27157. * * 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)
  27158. * * 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)
  27159. * @returns the VertexData of the Polyhedron
  27160. */
  27161. static CreatePolyhedron(options: {
  27162. type?: number;
  27163. size?: number;
  27164. sizeX?: number;
  27165. sizeY?: number;
  27166. sizeZ?: number;
  27167. custom?: any;
  27168. faceUV?: Vector4[];
  27169. faceColors?: Color4[];
  27170. flat?: boolean;
  27171. sideOrientation?: number;
  27172. frontUVs?: Vector4;
  27173. backUVs?: Vector4;
  27174. }): VertexData;
  27175. /**
  27176. * Creates the VertexData for a TorusKnot
  27177. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27178. * * radius the radius of the torus knot, optional, default 2
  27179. * * tube the thickness of the tube, optional, default 0.5
  27180. * * radialSegments the number of sides on each tube segments, optional, default 32
  27181. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27182. * * p the number of windings around the z axis, optional, default 2
  27183. * * q the number of windings around the x axis, optional, default 3
  27184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27185. * * 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)
  27186. * * 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)
  27187. * @returns the VertexData of the Torus Knot
  27188. */
  27189. static CreateTorusKnot(options: {
  27190. radius?: number;
  27191. tube?: number;
  27192. radialSegments?: number;
  27193. tubularSegments?: number;
  27194. p?: number;
  27195. q?: number;
  27196. sideOrientation?: number;
  27197. frontUVs?: Vector4;
  27198. backUVs?: Vector4;
  27199. }): VertexData;
  27200. /**
  27201. * Compute normals for given positions and indices
  27202. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27203. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27204. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27205. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27206. * * facetNormals : optional array of facet normals (vector3)
  27207. * * facetPositions : optional array of facet positions (vector3)
  27208. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27209. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27210. * * bInfo : optional bounding info, required for facetPartitioning computation
  27211. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27212. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27213. * * useRightHandedSystem: optional boolean to for right handed system computation
  27214. * * depthSort : optional boolean to enable the facet depth sort computation
  27215. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27216. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27217. */
  27218. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27219. facetNormals?: any;
  27220. facetPositions?: any;
  27221. facetPartitioning?: any;
  27222. ratio?: number;
  27223. bInfo?: any;
  27224. bbSize?: Vector3;
  27225. subDiv?: any;
  27226. useRightHandedSystem?: boolean;
  27227. depthSort?: boolean;
  27228. distanceTo?: Vector3;
  27229. depthSortedFacets?: any;
  27230. }): void;
  27231. /** @hidden */
  27232. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27233. /**
  27234. * Applies VertexData created from the imported parameters to the geometry
  27235. * @param parsedVertexData the parsed data from an imported file
  27236. * @param geometry the geometry to apply the VertexData to
  27237. */
  27238. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27239. }
  27240. }
  27241. declare module "babylonjs/Morph/morphTarget" {
  27242. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27243. import { Observable } from "babylonjs/Misc/observable";
  27244. import { Nullable, FloatArray } from "babylonjs/types";
  27245. import { Scene } from "babylonjs/scene";
  27246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27247. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27248. /**
  27249. * Defines a target to use with MorphTargetManager
  27250. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27251. */
  27252. export class MorphTarget implements IAnimatable {
  27253. /** defines the name of the target */
  27254. name: string;
  27255. /**
  27256. * Gets or sets the list of animations
  27257. */
  27258. animations: import("babylonjs/Animations/animation").Animation[];
  27259. private _scene;
  27260. private _positions;
  27261. private _normals;
  27262. private _tangents;
  27263. private _uvs;
  27264. private _influence;
  27265. private _uniqueId;
  27266. /**
  27267. * Observable raised when the influence changes
  27268. */
  27269. onInfluenceChanged: Observable<boolean>;
  27270. /** @hidden */
  27271. _onDataLayoutChanged: Observable<void>;
  27272. /**
  27273. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27274. */
  27275. get influence(): number;
  27276. set influence(influence: number);
  27277. /**
  27278. * Gets or sets the id of the morph Target
  27279. */
  27280. id: string;
  27281. private _animationPropertiesOverride;
  27282. /**
  27283. * Gets or sets the animation properties override
  27284. */
  27285. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27286. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27287. /**
  27288. * Creates a new MorphTarget
  27289. * @param name defines the name of the target
  27290. * @param influence defines the influence to use
  27291. * @param scene defines the scene the morphtarget belongs to
  27292. */
  27293. constructor(
  27294. /** defines the name of the target */
  27295. name: string, influence?: number, scene?: Nullable<Scene>);
  27296. /**
  27297. * Gets the unique ID of this manager
  27298. */
  27299. get uniqueId(): number;
  27300. /**
  27301. * Gets a boolean defining if the target contains position data
  27302. */
  27303. get hasPositions(): boolean;
  27304. /**
  27305. * Gets a boolean defining if the target contains normal data
  27306. */
  27307. get hasNormals(): boolean;
  27308. /**
  27309. * Gets a boolean defining if the target contains tangent data
  27310. */
  27311. get hasTangents(): boolean;
  27312. /**
  27313. * Gets a boolean defining if the target contains texture coordinates data
  27314. */
  27315. get hasUVs(): boolean;
  27316. /**
  27317. * Affects position data to this target
  27318. * @param data defines the position data to use
  27319. */
  27320. setPositions(data: Nullable<FloatArray>): void;
  27321. /**
  27322. * Gets the position data stored in this target
  27323. * @returns a FloatArray containing the position data (or null if not present)
  27324. */
  27325. getPositions(): Nullable<FloatArray>;
  27326. /**
  27327. * Affects normal data to this target
  27328. * @param data defines the normal data to use
  27329. */
  27330. setNormals(data: Nullable<FloatArray>): void;
  27331. /**
  27332. * Gets the normal data stored in this target
  27333. * @returns a FloatArray containing the normal data (or null if not present)
  27334. */
  27335. getNormals(): Nullable<FloatArray>;
  27336. /**
  27337. * Affects tangent data to this target
  27338. * @param data defines the tangent data to use
  27339. */
  27340. setTangents(data: Nullable<FloatArray>): void;
  27341. /**
  27342. * Gets the tangent data stored in this target
  27343. * @returns a FloatArray containing the tangent data (or null if not present)
  27344. */
  27345. getTangents(): Nullable<FloatArray>;
  27346. /**
  27347. * Affects texture coordinates data to this target
  27348. * @param data defines the texture coordinates data to use
  27349. */
  27350. setUVs(data: Nullable<FloatArray>): void;
  27351. /**
  27352. * Gets the texture coordinates data stored in this target
  27353. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27354. */
  27355. getUVs(): Nullable<FloatArray>;
  27356. /**
  27357. * Clone the current target
  27358. * @returns a new MorphTarget
  27359. */
  27360. clone(): MorphTarget;
  27361. /**
  27362. * Serializes the current target into a Serialization object
  27363. * @returns the serialized object
  27364. */
  27365. serialize(): any;
  27366. /**
  27367. * Returns the string "MorphTarget"
  27368. * @returns "MorphTarget"
  27369. */
  27370. getClassName(): string;
  27371. /**
  27372. * Creates a new target from serialized data
  27373. * @param serializationObject defines the serialized data to use
  27374. * @returns a new MorphTarget
  27375. */
  27376. static Parse(serializationObject: any): MorphTarget;
  27377. /**
  27378. * Creates a MorphTarget from mesh data
  27379. * @param mesh defines the source mesh
  27380. * @param name defines the name to use for the new target
  27381. * @param influence defines the influence to attach to the target
  27382. * @returns a new MorphTarget
  27383. */
  27384. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27385. }
  27386. }
  27387. declare module "babylonjs/Morph/morphTargetManager" {
  27388. import { Nullable } from "babylonjs/types";
  27389. import { Scene } from "babylonjs/scene";
  27390. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27391. /**
  27392. * This class is used to deform meshes using morphing between different targets
  27393. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27394. */
  27395. export class MorphTargetManager {
  27396. private _targets;
  27397. private _targetInfluenceChangedObservers;
  27398. private _targetDataLayoutChangedObservers;
  27399. private _activeTargets;
  27400. private _scene;
  27401. private _influences;
  27402. private _supportsNormals;
  27403. private _supportsTangents;
  27404. private _supportsUVs;
  27405. private _vertexCount;
  27406. private _uniqueId;
  27407. private _tempInfluences;
  27408. /**
  27409. * Gets or sets a boolean indicating if normals must be morphed
  27410. */
  27411. enableNormalMorphing: boolean;
  27412. /**
  27413. * Gets or sets a boolean indicating if tangents must be morphed
  27414. */
  27415. enableTangentMorphing: boolean;
  27416. /**
  27417. * Gets or sets a boolean indicating if UV must be morphed
  27418. */
  27419. enableUVMorphing: boolean;
  27420. /**
  27421. * Creates a new MorphTargetManager
  27422. * @param scene defines the current scene
  27423. */
  27424. constructor(scene?: Nullable<Scene>);
  27425. /**
  27426. * Gets the unique ID of this manager
  27427. */
  27428. get uniqueId(): number;
  27429. /**
  27430. * Gets the number of vertices handled by this manager
  27431. */
  27432. get vertexCount(): number;
  27433. /**
  27434. * Gets a boolean indicating if this manager supports morphing of normals
  27435. */
  27436. get supportsNormals(): boolean;
  27437. /**
  27438. * Gets a boolean indicating if this manager supports morphing of tangents
  27439. */
  27440. get supportsTangents(): boolean;
  27441. /**
  27442. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27443. */
  27444. get supportsUVs(): boolean;
  27445. /**
  27446. * Gets the number of targets stored in this manager
  27447. */
  27448. get numTargets(): number;
  27449. /**
  27450. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27451. */
  27452. get numInfluencers(): number;
  27453. /**
  27454. * Gets the list of influences (one per target)
  27455. */
  27456. get influences(): Float32Array;
  27457. /**
  27458. * Gets the active target at specified index. An active target is a target with an influence > 0
  27459. * @param index defines the index to check
  27460. * @returns the requested target
  27461. */
  27462. getActiveTarget(index: number): MorphTarget;
  27463. /**
  27464. * Gets the target at specified index
  27465. * @param index defines the index to check
  27466. * @returns the requested target
  27467. */
  27468. getTarget(index: number): MorphTarget;
  27469. /**
  27470. * Add a new target to this manager
  27471. * @param target defines the target to add
  27472. */
  27473. addTarget(target: MorphTarget): void;
  27474. /**
  27475. * Removes a target from the manager
  27476. * @param target defines the target to remove
  27477. */
  27478. removeTarget(target: MorphTarget): void;
  27479. /**
  27480. * Clone the current manager
  27481. * @returns a new MorphTargetManager
  27482. */
  27483. clone(): MorphTargetManager;
  27484. /**
  27485. * Serializes the current manager into a Serialization object
  27486. * @returns the serialized object
  27487. */
  27488. serialize(): any;
  27489. private _syncActiveTargets;
  27490. /**
  27491. * Syncrhonize the targets with all the meshes using this morph target manager
  27492. */
  27493. synchronize(): void;
  27494. /**
  27495. * Creates a new MorphTargetManager from serialized data
  27496. * @param serializationObject defines the serialized data
  27497. * @param scene defines the hosting scene
  27498. * @returns the new MorphTargetManager
  27499. */
  27500. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27501. }
  27502. }
  27503. declare module "babylonjs/Meshes/meshLODLevel" {
  27504. import { Mesh } from "babylonjs/Meshes/mesh";
  27505. import { Nullable } from "babylonjs/types";
  27506. /**
  27507. * Class used to represent a specific level of detail of a mesh
  27508. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27509. */
  27510. export class MeshLODLevel {
  27511. /** Defines the distance where this level should start being displayed */
  27512. distance: number;
  27513. /** Defines the mesh to use to render this level */
  27514. mesh: Nullable<Mesh>;
  27515. /**
  27516. * Creates a new LOD level
  27517. * @param distance defines the distance where this level should star being displayed
  27518. * @param mesh defines the mesh to use to render this level
  27519. */
  27520. constructor(
  27521. /** Defines the distance where this level should start being displayed */
  27522. distance: number,
  27523. /** Defines the mesh to use to render this level */
  27524. mesh: Nullable<Mesh>);
  27525. }
  27526. }
  27527. declare module "babylonjs/Misc/canvasGenerator" {
  27528. /**
  27529. * Helper class used to generate a canvas to manipulate images
  27530. */
  27531. export class CanvasGenerator {
  27532. /**
  27533. * Create a new canvas (or offscreen canvas depending on the context)
  27534. * @param width defines the expected width
  27535. * @param height defines the expected height
  27536. * @return a new canvas or offscreen canvas
  27537. */
  27538. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27539. }
  27540. }
  27541. declare module "babylonjs/Meshes/groundMesh" {
  27542. import { Scene } from "babylonjs/scene";
  27543. import { Vector3 } from "babylonjs/Maths/math.vector";
  27544. import { Mesh } from "babylonjs/Meshes/mesh";
  27545. /**
  27546. * Mesh representing the gorund
  27547. */
  27548. export class GroundMesh extends Mesh {
  27549. /** If octree should be generated */
  27550. generateOctree: boolean;
  27551. private _heightQuads;
  27552. /** @hidden */
  27553. _subdivisionsX: number;
  27554. /** @hidden */
  27555. _subdivisionsY: number;
  27556. /** @hidden */
  27557. _width: number;
  27558. /** @hidden */
  27559. _height: number;
  27560. /** @hidden */
  27561. _minX: number;
  27562. /** @hidden */
  27563. _maxX: number;
  27564. /** @hidden */
  27565. _minZ: number;
  27566. /** @hidden */
  27567. _maxZ: number;
  27568. constructor(name: string, scene: Scene);
  27569. /**
  27570. * "GroundMesh"
  27571. * @returns "GroundMesh"
  27572. */
  27573. getClassName(): string;
  27574. /**
  27575. * The minimum of x and y subdivisions
  27576. */
  27577. get subdivisions(): number;
  27578. /**
  27579. * X subdivisions
  27580. */
  27581. get subdivisionsX(): number;
  27582. /**
  27583. * Y subdivisions
  27584. */
  27585. get subdivisionsY(): number;
  27586. /**
  27587. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27588. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27589. * @param chunksCount the number of subdivisions for x and y
  27590. * @param octreeBlocksSize (Default: 32)
  27591. */
  27592. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27593. /**
  27594. * Returns a height (y) value in the Worl system :
  27595. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27596. * @param x x coordinate
  27597. * @param z z coordinate
  27598. * @returns the ground y position if (x, z) are outside the ground surface.
  27599. */
  27600. getHeightAtCoordinates(x: number, z: number): number;
  27601. /**
  27602. * Returns a normalized vector (Vector3) orthogonal to the ground
  27603. * at the ground coordinates (x, z) expressed in the World system.
  27604. * @param x x coordinate
  27605. * @param z z coordinate
  27606. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27607. */
  27608. getNormalAtCoordinates(x: number, z: number): Vector3;
  27609. /**
  27610. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27611. * at the ground coordinates (x, z) expressed in the World system.
  27612. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27613. * @param x x coordinate
  27614. * @param z z coordinate
  27615. * @param ref vector to store the result
  27616. * @returns the GroundMesh.
  27617. */
  27618. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27619. /**
  27620. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27621. * if the ground has been updated.
  27622. * This can be used in the render loop.
  27623. * @returns the GroundMesh.
  27624. */
  27625. updateCoordinateHeights(): GroundMesh;
  27626. private _getFacetAt;
  27627. private _initHeightQuads;
  27628. private _computeHeightQuads;
  27629. /**
  27630. * Serializes this ground mesh
  27631. * @param serializationObject object to write serialization to
  27632. */
  27633. serialize(serializationObject: any): void;
  27634. /**
  27635. * Parses a serialized ground mesh
  27636. * @param parsedMesh the serialized mesh
  27637. * @param scene the scene to create the ground mesh in
  27638. * @returns the created ground mesh
  27639. */
  27640. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27641. }
  27642. }
  27643. declare module "babylonjs/Physics/physicsJoint" {
  27644. import { Vector3 } from "babylonjs/Maths/math.vector";
  27645. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27646. /**
  27647. * Interface for Physics-Joint data
  27648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27649. */
  27650. export interface PhysicsJointData {
  27651. /**
  27652. * The main pivot of the joint
  27653. */
  27654. mainPivot?: Vector3;
  27655. /**
  27656. * The connected pivot of the joint
  27657. */
  27658. connectedPivot?: Vector3;
  27659. /**
  27660. * The main axis of the joint
  27661. */
  27662. mainAxis?: Vector3;
  27663. /**
  27664. * The connected axis of the joint
  27665. */
  27666. connectedAxis?: Vector3;
  27667. /**
  27668. * The collision of the joint
  27669. */
  27670. collision?: boolean;
  27671. /**
  27672. * Native Oimo/Cannon/Energy data
  27673. */
  27674. nativeParams?: any;
  27675. }
  27676. /**
  27677. * This is a holder class for the physics joint created by the physics plugin
  27678. * It holds a set of functions to control the underlying joint
  27679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27680. */
  27681. export class PhysicsJoint {
  27682. /**
  27683. * The type of the physics joint
  27684. */
  27685. type: number;
  27686. /**
  27687. * The data for the physics joint
  27688. */
  27689. jointData: PhysicsJointData;
  27690. private _physicsJoint;
  27691. protected _physicsPlugin: IPhysicsEnginePlugin;
  27692. /**
  27693. * Initializes the physics joint
  27694. * @param type The type of the physics joint
  27695. * @param jointData The data for the physics joint
  27696. */
  27697. constructor(
  27698. /**
  27699. * The type of the physics joint
  27700. */
  27701. type: number,
  27702. /**
  27703. * The data for the physics joint
  27704. */
  27705. jointData: PhysicsJointData);
  27706. /**
  27707. * Gets the physics joint
  27708. */
  27709. get physicsJoint(): any;
  27710. /**
  27711. * Sets the physics joint
  27712. */
  27713. set physicsJoint(newJoint: any);
  27714. /**
  27715. * Sets the physics plugin
  27716. */
  27717. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27718. /**
  27719. * Execute a function that is physics-plugin specific.
  27720. * @param {Function} func the function that will be executed.
  27721. * It accepts two parameters: the physics world and the physics joint
  27722. */
  27723. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27724. /**
  27725. * Distance-Joint type
  27726. */
  27727. static DistanceJoint: number;
  27728. /**
  27729. * Hinge-Joint type
  27730. */
  27731. static HingeJoint: number;
  27732. /**
  27733. * Ball-and-Socket joint type
  27734. */
  27735. static BallAndSocketJoint: number;
  27736. /**
  27737. * Wheel-Joint type
  27738. */
  27739. static WheelJoint: number;
  27740. /**
  27741. * Slider-Joint type
  27742. */
  27743. static SliderJoint: number;
  27744. /**
  27745. * Prismatic-Joint type
  27746. */
  27747. static PrismaticJoint: number;
  27748. /**
  27749. * Universal-Joint type
  27750. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27751. */
  27752. static UniversalJoint: number;
  27753. /**
  27754. * Hinge-Joint 2 type
  27755. */
  27756. static Hinge2Joint: number;
  27757. /**
  27758. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27759. */
  27760. static PointToPointJoint: number;
  27761. /**
  27762. * Spring-Joint type
  27763. */
  27764. static SpringJoint: number;
  27765. /**
  27766. * Lock-Joint type
  27767. */
  27768. static LockJoint: number;
  27769. }
  27770. /**
  27771. * A class representing a physics distance joint
  27772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27773. */
  27774. export class DistanceJoint extends PhysicsJoint {
  27775. /**
  27776. *
  27777. * @param jointData The data for the Distance-Joint
  27778. */
  27779. constructor(jointData: DistanceJointData);
  27780. /**
  27781. * Update the predefined distance.
  27782. * @param maxDistance The maximum preferred distance
  27783. * @param minDistance The minimum preferred distance
  27784. */
  27785. updateDistance(maxDistance: number, minDistance?: number): void;
  27786. }
  27787. /**
  27788. * Represents a Motor-Enabled Joint
  27789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27790. */
  27791. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27792. /**
  27793. * Initializes the Motor-Enabled Joint
  27794. * @param type The type of the joint
  27795. * @param jointData The physica joint data for the joint
  27796. */
  27797. constructor(type: number, jointData: PhysicsJointData);
  27798. /**
  27799. * Set the motor values.
  27800. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27801. * @param force the force to apply
  27802. * @param maxForce max force for this motor.
  27803. */
  27804. setMotor(force?: number, maxForce?: number): void;
  27805. /**
  27806. * Set the motor's limits.
  27807. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27808. * @param upperLimit The upper limit of the motor
  27809. * @param lowerLimit The lower limit of the motor
  27810. */
  27811. setLimit(upperLimit: number, lowerLimit?: number): void;
  27812. }
  27813. /**
  27814. * This class represents a single physics Hinge-Joint
  27815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27816. */
  27817. export class HingeJoint extends MotorEnabledJoint {
  27818. /**
  27819. * Initializes the Hinge-Joint
  27820. * @param jointData The joint data for the Hinge-Joint
  27821. */
  27822. constructor(jointData: PhysicsJointData);
  27823. /**
  27824. * Set the motor values.
  27825. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27826. * @param {number} force the force to apply
  27827. * @param {number} maxForce max force for this motor.
  27828. */
  27829. setMotor(force?: number, maxForce?: number): void;
  27830. /**
  27831. * Set the motor's limits.
  27832. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27833. * @param upperLimit The upper limit of the motor
  27834. * @param lowerLimit The lower limit of the motor
  27835. */
  27836. setLimit(upperLimit: number, lowerLimit?: number): void;
  27837. }
  27838. /**
  27839. * This class represents a dual hinge physics joint (same as wheel joint)
  27840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27841. */
  27842. export class Hinge2Joint extends MotorEnabledJoint {
  27843. /**
  27844. * Initializes the Hinge2-Joint
  27845. * @param jointData The joint data for the Hinge2-Joint
  27846. */
  27847. constructor(jointData: PhysicsJointData);
  27848. /**
  27849. * Set the motor values.
  27850. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27851. * @param {number} targetSpeed the speed the motor is to reach
  27852. * @param {number} maxForce max force for this motor.
  27853. * @param {motorIndex} the motor's index, 0 or 1.
  27854. */
  27855. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27856. /**
  27857. * Set the motor limits.
  27858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27859. * @param {number} upperLimit the upper limit
  27860. * @param {number} lowerLimit lower limit
  27861. * @param {motorIndex} the motor's index, 0 or 1.
  27862. */
  27863. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27864. }
  27865. /**
  27866. * Interface for a motor enabled joint
  27867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27868. */
  27869. export interface IMotorEnabledJoint {
  27870. /**
  27871. * Physics joint
  27872. */
  27873. physicsJoint: any;
  27874. /**
  27875. * Sets the motor of the motor-enabled joint
  27876. * @param force The force of the motor
  27877. * @param maxForce The maximum force of the motor
  27878. * @param motorIndex The index of the motor
  27879. */
  27880. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27881. /**
  27882. * Sets the limit of the motor
  27883. * @param upperLimit The upper limit of the motor
  27884. * @param lowerLimit The lower limit of the motor
  27885. * @param motorIndex The index of the motor
  27886. */
  27887. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27888. }
  27889. /**
  27890. * Joint data for a Distance-Joint
  27891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27892. */
  27893. export interface DistanceJointData extends PhysicsJointData {
  27894. /**
  27895. * Max distance the 2 joint objects can be apart
  27896. */
  27897. maxDistance: number;
  27898. }
  27899. /**
  27900. * Joint data from a spring joint
  27901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27902. */
  27903. export interface SpringJointData extends PhysicsJointData {
  27904. /**
  27905. * Length of the spring
  27906. */
  27907. length: number;
  27908. /**
  27909. * Stiffness of the spring
  27910. */
  27911. stiffness: number;
  27912. /**
  27913. * Damping of the spring
  27914. */
  27915. damping: number;
  27916. /** this callback will be called when applying the force to the impostors. */
  27917. forceApplicationCallback: () => void;
  27918. }
  27919. }
  27920. declare module "babylonjs/Physics/physicsRaycastResult" {
  27921. import { Vector3 } from "babylonjs/Maths/math.vector";
  27922. /**
  27923. * Holds the data for the raycast result
  27924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27925. */
  27926. export class PhysicsRaycastResult {
  27927. private _hasHit;
  27928. private _hitDistance;
  27929. private _hitNormalWorld;
  27930. private _hitPointWorld;
  27931. private _rayFromWorld;
  27932. private _rayToWorld;
  27933. /**
  27934. * Gets if there was a hit
  27935. */
  27936. get hasHit(): boolean;
  27937. /**
  27938. * Gets the distance from the hit
  27939. */
  27940. get hitDistance(): number;
  27941. /**
  27942. * Gets the hit normal/direction in the world
  27943. */
  27944. get hitNormalWorld(): Vector3;
  27945. /**
  27946. * Gets the hit point in the world
  27947. */
  27948. get hitPointWorld(): Vector3;
  27949. /**
  27950. * Gets the ray "start point" of the ray in the world
  27951. */
  27952. get rayFromWorld(): Vector3;
  27953. /**
  27954. * Gets the ray "end point" of the ray in the world
  27955. */
  27956. get rayToWorld(): Vector3;
  27957. /**
  27958. * Sets the hit data (normal & point in world space)
  27959. * @param hitNormalWorld defines the normal in world space
  27960. * @param hitPointWorld defines the point in world space
  27961. */
  27962. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27963. /**
  27964. * Sets the distance from the start point to the hit point
  27965. * @param distance
  27966. */
  27967. setHitDistance(distance: number): void;
  27968. /**
  27969. * Calculates the distance manually
  27970. */
  27971. calculateHitDistance(): void;
  27972. /**
  27973. * Resets all the values to default
  27974. * @param from The from point on world space
  27975. * @param to The to point on world space
  27976. */
  27977. reset(from?: Vector3, to?: Vector3): void;
  27978. }
  27979. /**
  27980. * Interface for the size containing width and height
  27981. */
  27982. interface IXYZ {
  27983. /**
  27984. * X
  27985. */
  27986. x: number;
  27987. /**
  27988. * Y
  27989. */
  27990. y: number;
  27991. /**
  27992. * Z
  27993. */
  27994. z: number;
  27995. }
  27996. }
  27997. declare module "babylonjs/Physics/IPhysicsEngine" {
  27998. import { Nullable } from "babylonjs/types";
  27999. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28001. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28002. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28003. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28004. /**
  28005. * Interface used to describe a physics joint
  28006. */
  28007. export interface PhysicsImpostorJoint {
  28008. /** Defines the main impostor to which the joint is linked */
  28009. mainImpostor: PhysicsImpostor;
  28010. /** Defines the impostor that is connected to the main impostor using this joint */
  28011. connectedImpostor: PhysicsImpostor;
  28012. /** Defines the joint itself */
  28013. joint: PhysicsJoint;
  28014. }
  28015. /** @hidden */
  28016. export interface IPhysicsEnginePlugin {
  28017. world: any;
  28018. name: string;
  28019. setGravity(gravity: Vector3): void;
  28020. setTimeStep(timeStep: number): void;
  28021. getTimeStep(): number;
  28022. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28023. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28024. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28025. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28026. removePhysicsBody(impostor: PhysicsImpostor): void;
  28027. generateJoint(joint: PhysicsImpostorJoint): void;
  28028. removeJoint(joint: PhysicsImpostorJoint): void;
  28029. isSupported(): boolean;
  28030. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28031. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28032. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28033. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28034. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28035. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28036. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28037. getBodyMass(impostor: PhysicsImpostor): number;
  28038. getBodyFriction(impostor: PhysicsImpostor): number;
  28039. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28040. getBodyRestitution(impostor: PhysicsImpostor): number;
  28041. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28042. getBodyPressure?(impostor: PhysicsImpostor): number;
  28043. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28044. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28045. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28046. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28047. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28048. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28049. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28050. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28051. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28052. sleepBody(impostor: PhysicsImpostor): void;
  28053. wakeUpBody(impostor: PhysicsImpostor): void;
  28054. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28055. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28056. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28058. getRadius(impostor: PhysicsImpostor): number;
  28059. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28060. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28061. dispose(): void;
  28062. }
  28063. /**
  28064. * Interface used to define a physics engine
  28065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28066. */
  28067. export interface IPhysicsEngine {
  28068. /**
  28069. * Gets the gravity vector used by the simulation
  28070. */
  28071. gravity: Vector3;
  28072. /**
  28073. * Sets the gravity vector used by the simulation
  28074. * @param gravity defines the gravity vector to use
  28075. */
  28076. setGravity(gravity: Vector3): void;
  28077. /**
  28078. * Set the time step of the physics engine.
  28079. * Default is 1/60.
  28080. * To slow it down, enter 1/600 for example.
  28081. * To speed it up, 1/30
  28082. * @param newTimeStep the new timestep to apply to this world.
  28083. */
  28084. setTimeStep(newTimeStep: number): void;
  28085. /**
  28086. * Get the time step of the physics engine.
  28087. * @returns the current time step
  28088. */
  28089. getTimeStep(): number;
  28090. /**
  28091. * Set the sub time step of the physics engine.
  28092. * Default is 0 meaning there is no sub steps
  28093. * To increase physics resolution precision, set a small value (like 1 ms)
  28094. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28095. */
  28096. setSubTimeStep(subTimeStep: number): void;
  28097. /**
  28098. * Get the sub time step of the physics engine.
  28099. * @returns the current sub time step
  28100. */
  28101. getSubTimeStep(): number;
  28102. /**
  28103. * Release all resources
  28104. */
  28105. dispose(): void;
  28106. /**
  28107. * Gets the name of the current physics plugin
  28108. * @returns the name of the plugin
  28109. */
  28110. getPhysicsPluginName(): string;
  28111. /**
  28112. * Adding a new impostor for the impostor tracking.
  28113. * This will be done by the impostor itself.
  28114. * @param impostor the impostor to add
  28115. */
  28116. addImpostor(impostor: PhysicsImpostor): void;
  28117. /**
  28118. * Remove an impostor from the engine.
  28119. * This impostor and its mesh will not longer be updated by the physics engine.
  28120. * @param impostor the impostor to remove
  28121. */
  28122. removeImpostor(impostor: PhysicsImpostor): void;
  28123. /**
  28124. * Add a joint to the physics engine
  28125. * @param mainImpostor defines the main impostor to which the joint is added.
  28126. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28127. * @param joint defines the joint that will connect both impostors.
  28128. */
  28129. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28130. /**
  28131. * Removes a joint from the simulation
  28132. * @param mainImpostor defines the impostor used with the joint
  28133. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28134. * @param joint defines the joint to remove
  28135. */
  28136. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28137. /**
  28138. * Gets the current plugin used to run the simulation
  28139. * @returns current plugin
  28140. */
  28141. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28142. /**
  28143. * Gets the list of physic impostors
  28144. * @returns an array of PhysicsImpostor
  28145. */
  28146. getImpostors(): Array<PhysicsImpostor>;
  28147. /**
  28148. * Gets the impostor for a physics enabled object
  28149. * @param object defines the object impersonated by the impostor
  28150. * @returns the PhysicsImpostor or null if not found
  28151. */
  28152. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28153. /**
  28154. * Gets the impostor for a physics body object
  28155. * @param body defines physics body used by the impostor
  28156. * @returns the PhysicsImpostor or null if not found
  28157. */
  28158. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28159. /**
  28160. * Does a raycast in the physics world
  28161. * @param from when should the ray start?
  28162. * @param to when should the ray end?
  28163. * @returns PhysicsRaycastResult
  28164. */
  28165. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28166. /**
  28167. * Called by the scene. No need to call it.
  28168. * @param delta defines the timespam between frames
  28169. */
  28170. _step(delta: number): void;
  28171. }
  28172. }
  28173. declare module "babylonjs/Physics/physicsImpostor" {
  28174. import { Nullable, IndicesArray } from "babylonjs/types";
  28175. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28176. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28178. import { Scene } from "babylonjs/scene";
  28179. import { Bone } from "babylonjs/Bones/bone";
  28180. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28181. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28182. import { Space } from "babylonjs/Maths/math.axis";
  28183. /**
  28184. * The interface for the physics imposter parameters
  28185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28186. */
  28187. export interface PhysicsImpostorParameters {
  28188. /**
  28189. * The mass of the physics imposter
  28190. */
  28191. mass: number;
  28192. /**
  28193. * The friction of the physics imposter
  28194. */
  28195. friction?: number;
  28196. /**
  28197. * The coefficient of restitution of the physics imposter
  28198. */
  28199. restitution?: number;
  28200. /**
  28201. * The native options of the physics imposter
  28202. */
  28203. nativeOptions?: any;
  28204. /**
  28205. * Specifies if the parent should be ignored
  28206. */
  28207. ignoreParent?: boolean;
  28208. /**
  28209. * Specifies if bi-directional transformations should be disabled
  28210. */
  28211. disableBidirectionalTransformation?: boolean;
  28212. /**
  28213. * The pressure inside the physics imposter, soft object only
  28214. */
  28215. pressure?: number;
  28216. /**
  28217. * The stiffness the physics imposter, soft object only
  28218. */
  28219. stiffness?: number;
  28220. /**
  28221. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28222. */
  28223. velocityIterations?: number;
  28224. /**
  28225. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28226. */
  28227. positionIterations?: number;
  28228. /**
  28229. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28230. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28231. * Add to fix multiple points
  28232. */
  28233. fixedPoints?: number;
  28234. /**
  28235. * The collision margin around a soft object
  28236. */
  28237. margin?: number;
  28238. /**
  28239. * The collision margin around a soft object
  28240. */
  28241. damping?: number;
  28242. /**
  28243. * The path for a rope based on an extrusion
  28244. */
  28245. path?: any;
  28246. /**
  28247. * The shape of an extrusion used for a rope based on an extrusion
  28248. */
  28249. shape?: any;
  28250. }
  28251. /**
  28252. * Interface for a physics-enabled object
  28253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28254. */
  28255. export interface IPhysicsEnabledObject {
  28256. /**
  28257. * The position of the physics-enabled object
  28258. */
  28259. position: Vector3;
  28260. /**
  28261. * The rotation of the physics-enabled object
  28262. */
  28263. rotationQuaternion: Nullable<Quaternion>;
  28264. /**
  28265. * The scale of the physics-enabled object
  28266. */
  28267. scaling: Vector3;
  28268. /**
  28269. * The rotation of the physics-enabled object
  28270. */
  28271. rotation?: Vector3;
  28272. /**
  28273. * The parent of the physics-enabled object
  28274. */
  28275. parent?: any;
  28276. /**
  28277. * The bounding info of the physics-enabled object
  28278. * @returns The bounding info of the physics-enabled object
  28279. */
  28280. getBoundingInfo(): BoundingInfo;
  28281. /**
  28282. * Computes the world matrix
  28283. * @param force Specifies if the world matrix should be computed by force
  28284. * @returns A world matrix
  28285. */
  28286. computeWorldMatrix(force: boolean): Matrix;
  28287. /**
  28288. * Gets the world matrix
  28289. * @returns A world matrix
  28290. */
  28291. getWorldMatrix?(): Matrix;
  28292. /**
  28293. * Gets the child meshes
  28294. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28295. * @returns An array of abstract meshes
  28296. */
  28297. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28298. /**
  28299. * Gets the vertex data
  28300. * @param kind The type of vertex data
  28301. * @returns A nullable array of numbers, or a float32 array
  28302. */
  28303. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28304. /**
  28305. * Gets the indices from the mesh
  28306. * @returns A nullable array of index arrays
  28307. */
  28308. getIndices?(): Nullable<IndicesArray>;
  28309. /**
  28310. * Gets the scene from the mesh
  28311. * @returns the indices array or null
  28312. */
  28313. getScene?(): Scene;
  28314. /**
  28315. * Gets the absolute position from the mesh
  28316. * @returns the absolute position
  28317. */
  28318. getAbsolutePosition(): Vector3;
  28319. /**
  28320. * Gets the absolute pivot point from the mesh
  28321. * @returns the absolute pivot point
  28322. */
  28323. getAbsolutePivotPoint(): Vector3;
  28324. /**
  28325. * Rotates the mesh
  28326. * @param axis The axis of rotation
  28327. * @param amount The amount of rotation
  28328. * @param space The space of the rotation
  28329. * @returns The rotation transform node
  28330. */
  28331. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28332. /**
  28333. * Translates the mesh
  28334. * @param axis The axis of translation
  28335. * @param distance The distance of translation
  28336. * @param space The space of the translation
  28337. * @returns The transform node
  28338. */
  28339. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28340. /**
  28341. * Sets the absolute position of the mesh
  28342. * @param absolutePosition The absolute position of the mesh
  28343. * @returns The transform node
  28344. */
  28345. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28346. /**
  28347. * Gets the class name of the mesh
  28348. * @returns The class name
  28349. */
  28350. getClassName(): string;
  28351. }
  28352. /**
  28353. * Represents a physics imposter
  28354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28355. */
  28356. export class PhysicsImpostor {
  28357. /**
  28358. * The physics-enabled object used as the physics imposter
  28359. */
  28360. object: IPhysicsEnabledObject;
  28361. /**
  28362. * The type of the physics imposter
  28363. */
  28364. type: number;
  28365. private _options;
  28366. private _scene?;
  28367. /**
  28368. * The default object size of the imposter
  28369. */
  28370. static DEFAULT_OBJECT_SIZE: Vector3;
  28371. /**
  28372. * The identity quaternion of the imposter
  28373. */
  28374. static IDENTITY_QUATERNION: Quaternion;
  28375. /** @hidden */
  28376. _pluginData: any;
  28377. private _physicsEngine;
  28378. private _physicsBody;
  28379. private _bodyUpdateRequired;
  28380. private _onBeforePhysicsStepCallbacks;
  28381. private _onAfterPhysicsStepCallbacks;
  28382. /** @hidden */
  28383. _onPhysicsCollideCallbacks: Array<{
  28384. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28385. otherImpostors: Array<PhysicsImpostor>;
  28386. }>;
  28387. private _deltaPosition;
  28388. private _deltaRotation;
  28389. private _deltaRotationConjugated;
  28390. /** @hidden */
  28391. _isFromLine: boolean;
  28392. private _parent;
  28393. private _isDisposed;
  28394. private static _tmpVecs;
  28395. private static _tmpQuat;
  28396. /**
  28397. * Specifies if the physics imposter is disposed
  28398. */
  28399. get isDisposed(): boolean;
  28400. /**
  28401. * Gets the mass of the physics imposter
  28402. */
  28403. get mass(): number;
  28404. set mass(value: number);
  28405. /**
  28406. * Gets the coefficient of friction
  28407. */
  28408. get friction(): number;
  28409. /**
  28410. * Sets the coefficient of friction
  28411. */
  28412. set friction(value: number);
  28413. /**
  28414. * Gets the coefficient of restitution
  28415. */
  28416. get restitution(): number;
  28417. /**
  28418. * Sets the coefficient of restitution
  28419. */
  28420. set restitution(value: number);
  28421. /**
  28422. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28423. */
  28424. get pressure(): number;
  28425. /**
  28426. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28427. */
  28428. set pressure(value: number);
  28429. /**
  28430. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28431. */
  28432. get stiffness(): number;
  28433. /**
  28434. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28435. */
  28436. set stiffness(value: number);
  28437. /**
  28438. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28439. */
  28440. get velocityIterations(): number;
  28441. /**
  28442. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28443. */
  28444. set velocityIterations(value: number);
  28445. /**
  28446. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28447. */
  28448. get positionIterations(): number;
  28449. /**
  28450. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28451. */
  28452. set positionIterations(value: number);
  28453. /**
  28454. * The unique id of the physics imposter
  28455. * set by the physics engine when adding this impostor to the array
  28456. */
  28457. uniqueId: number;
  28458. /**
  28459. * @hidden
  28460. */
  28461. soft: boolean;
  28462. /**
  28463. * @hidden
  28464. */
  28465. segments: number;
  28466. private _joints;
  28467. /**
  28468. * Initializes the physics imposter
  28469. * @param object The physics-enabled object used as the physics imposter
  28470. * @param type The type of the physics imposter
  28471. * @param _options The options for the physics imposter
  28472. * @param _scene The Babylon scene
  28473. */
  28474. constructor(
  28475. /**
  28476. * The physics-enabled object used as the physics imposter
  28477. */
  28478. object: IPhysicsEnabledObject,
  28479. /**
  28480. * The type of the physics imposter
  28481. */
  28482. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28483. /**
  28484. * This function will completly initialize this impostor.
  28485. * It will create a new body - but only if this mesh has no parent.
  28486. * If it has, this impostor will not be used other than to define the impostor
  28487. * of the child mesh.
  28488. * @hidden
  28489. */
  28490. _init(): void;
  28491. private _getPhysicsParent;
  28492. /**
  28493. * Should a new body be generated.
  28494. * @returns boolean specifying if body initialization is required
  28495. */
  28496. isBodyInitRequired(): boolean;
  28497. /**
  28498. * Sets the updated scaling
  28499. * @param updated Specifies if the scaling is updated
  28500. */
  28501. setScalingUpdated(): void;
  28502. /**
  28503. * Force a regeneration of this or the parent's impostor's body.
  28504. * Use under cautious - This will remove all joints already implemented.
  28505. */
  28506. forceUpdate(): void;
  28507. /**
  28508. * Gets the body that holds this impostor. Either its own, or its parent.
  28509. */
  28510. get physicsBody(): any;
  28511. /**
  28512. * Get the parent of the physics imposter
  28513. * @returns Physics imposter or null
  28514. */
  28515. get parent(): Nullable<PhysicsImpostor>;
  28516. /**
  28517. * Sets the parent of the physics imposter
  28518. */
  28519. set parent(value: Nullable<PhysicsImpostor>);
  28520. /**
  28521. * Set the physics body. Used mainly by the physics engine/plugin
  28522. */
  28523. set physicsBody(physicsBody: any);
  28524. /**
  28525. * Resets the update flags
  28526. */
  28527. resetUpdateFlags(): void;
  28528. /**
  28529. * Gets the object extend size
  28530. * @returns the object extend size
  28531. */
  28532. getObjectExtendSize(): Vector3;
  28533. /**
  28534. * Gets the object center
  28535. * @returns The object center
  28536. */
  28537. getObjectCenter(): Vector3;
  28538. /**
  28539. * Get a specific parameter from the options parameters
  28540. * @param paramName The object parameter name
  28541. * @returns The object parameter
  28542. */
  28543. getParam(paramName: string): any;
  28544. /**
  28545. * Sets a specific parameter in the options given to the physics plugin
  28546. * @param paramName The parameter name
  28547. * @param value The value of the parameter
  28548. */
  28549. setParam(paramName: string, value: number): void;
  28550. /**
  28551. * Specifically change the body's mass option. Won't recreate the physics body object
  28552. * @param mass The mass of the physics imposter
  28553. */
  28554. setMass(mass: number): void;
  28555. /**
  28556. * Gets the linear velocity
  28557. * @returns linear velocity or null
  28558. */
  28559. getLinearVelocity(): Nullable<Vector3>;
  28560. /**
  28561. * Sets the linear velocity
  28562. * @param velocity linear velocity or null
  28563. */
  28564. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28565. /**
  28566. * Gets the angular velocity
  28567. * @returns angular velocity or null
  28568. */
  28569. getAngularVelocity(): Nullable<Vector3>;
  28570. /**
  28571. * Sets the angular velocity
  28572. * @param velocity The velocity or null
  28573. */
  28574. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28575. /**
  28576. * Execute a function with the physics plugin native code
  28577. * Provide a function the will have two variables - the world object and the physics body object
  28578. * @param func The function to execute with the physics plugin native code
  28579. */
  28580. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28581. /**
  28582. * Register a function that will be executed before the physics world is stepping forward
  28583. * @param func The function to execute before the physics world is stepped forward
  28584. */
  28585. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28586. /**
  28587. * Unregister a function that will be executed before the physics world is stepping forward
  28588. * @param func The function to execute before the physics world is stepped forward
  28589. */
  28590. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28591. /**
  28592. * Register a function that will be executed after the physics step
  28593. * @param func The function to execute after physics step
  28594. */
  28595. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28596. /**
  28597. * Unregisters a function that will be executed after the physics step
  28598. * @param func The function to execute after physics step
  28599. */
  28600. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28601. /**
  28602. * register a function that will be executed when this impostor collides against a different body
  28603. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28604. * @param func Callback that is executed on collision
  28605. */
  28606. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28607. /**
  28608. * Unregisters the physics imposter on contact
  28609. * @param collideAgainst The physics object to collide against
  28610. * @param func Callback to execute on collision
  28611. */
  28612. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28613. private _tmpQuat;
  28614. private _tmpQuat2;
  28615. /**
  28616. * Get the parent rotation
  28617. * @returns The parent rotation
  28618. */
  28619. getParentsRotation(): Quaternion;
  28620. /**
  28621. * this function is executed by the physics engine.
  28622. */
  28623. beforeStep: () => void;
  28624. /**
  28625. * this function is executed by the physics engine
  28626. */
  28627. afterStep: () => void;
  28628. /**
  28629. * Legacy collision detection event support
  28630. */
  28631. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28632. /**
  28633. * event and body object due to cannon's event-based architecture.
  28634. */
  28635. onCollide: (e: {
  28636. body: any;
  28637. }) => void;
  28638. /**
  28639. * Apply a force
  28640. * @param force The force to apply
  28641. * @param contactPoint The contact point for the force
  28642. * @returns The physics imposter
  28643. */
  28644. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28645. /**
  28646. * Apply an impulse
  28647. * @param force The impulse force
  28648. * @param contactPoint The contact point for the impulse force
  28649. * @returns The physics imposter
  28650. */
  28651. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28652. /**
  28653. * A help function to create a joint
  28654. * @param otherImpostor A physics imposter used to create a joint
  28655. * @param jointType The type of joint
  28656. * @param jointData The data for the joint
  28657. * @returns The physics imposter
  28658. */
  28659. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28660. /**
  28661. * Add a joint to this impostor with a different impostor
  28662. * @param otherImpostor A physics imposter used to add a joint
  28663. * @param joint The joint to add
  28664. * @returns The physics imposter
  28665. */
  28666. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28667. /**
  28668. * Add an anchor to a cloth impostor
  28669. * @param otherImpostor rigid impostor to anchor to
  28670. * @param width ratio across width from 0 to 1
  28671. * @param height ratio up height from 0 to 1
  28672. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28673. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28674. * @returns impostor the soft imposter
  28675. */
  28676. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28677. /**
  28678. * Add a hook to a rope impostor
  28679. * @param otherImpostor rigid impostor to anchor to
  28680. * @param length ratio across rope from 0 to 1
  28681. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28682. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28683. * @returns impostor the rope imposter
  28684. */
  28685. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28686. /**
  28687. * Will keep this body still, in a sleep mode.
  28688. * @returns the physics imposter
  28689. */
  28690. sleep(): PhysicsImpostor;
  28691. /**
  28692. * Wake the body up.
  28693. * @returns The physics imposter
  28694. */
  28695. wakeUp(): PhysicsImpostor;
  28696. /**
  28697. * Clones the physics imposter
  28698. * @param newObject The physics imposter clones to this physics-enabled object
  28699. * @returns A nullable physics imposter
  28700. */
  28701. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28702. /**
  28703. * Disposes the physics imposter
  28704. */
  28705. dispose(): void;
  28706. /**
  28707. * Sets the delta position
  28708. * @param position The delta position amount
  28709. */
  28710. setDeltaPosition(position: Vector3): void;
  28711. /**
  28712. * Sets the delta rotation
  28713. * @param rotation The delta rotation amount
  28714. */
  28715. setDeltaRotation(rotation: Quaternion): void;
  28716. /**
  28717. * Gets the box size of the physics imposter and stores the result in the input parameter
  28718. * @param result Stores the box size
  28719. * @returns The physics imposter
  28720. */
  28721. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28722. /**
  28723. * Gets the radius of the physics imposter
  28724. * @returns Radius of the physics imposter
  28725. */
  28726. getRadius(): number;
  28727. /**
  28728. * Sync a bone with this impostor
  28729. * @param bone The bone to sync to the impostor.
  28730. * @param boneMesh The mesh that the bone is influencing.
  28731. * @param jointPivot The pivot of the joint / bone in local space.
  28732. * @param distToJoint Optional distance from the impostor to the joint.
  28733. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28734. */
  28735. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28736. /**
  28737. * Sync impostor to a bone
  28738. * @param bone The bone that the impostor will be synced to.
  28739. * @param boneMesh The mesh that the bone is influencing.
  28740. * @param jointPivot The pivot of the joint / bone in local space.
  28741. * @param distToJoint Optional distance from the impostor to the joint.
  28742. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28743. * @param boneAxis Optional vector3 axis the bone is aligned with
  28744. */
  28745. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28746. /**
  28747. * No-Imposter type
  28748. */
  28749. static NoImpostor: number;
  28750. /**
  28751. * Sphere-Imposter type
  28752. */
  28753. static SphereImpostor: number;
  28754. /**
  28755. * Box-Imposter type
  28756. */
  28757. static BoxImpostor: number;
  28758. /**
  28759. * Plane-Imposter type
  28760. */
  28761. static PlaneImpostor: number;
  28762. /**
  28763. * Mesh-imposter type
  28764. */
  28765. static MeshImpostor: number;
  28766. /**
  28767. * Capsule-Impostor type (Ammo.js plugin only)
  28768. */
  28769. static CapsuleImpostor: number;
  28770. /**
  28771. * Cylinder-Imposter type
  28772. */
  28773. static CylinderImpostor: number;
  28774. /**
  28775. * Particle-Imposter type
  28776. */
  28777. static ParticleImpostor: number;
  28778. /**
  28779. * Heightmap-Imposter type
  28780. */
  28781. static HeightmapImpostor: number;
  28782. /**
  28783. * ConvexHull-Impostor type (Ammo.js plugin only)
  28784. */
  28785. static ConvexHullImpostor: number;
  28786. /**
  28787. * Custom-Imposter type (Ammo.js plugin only)
  28788. */
  28789. static CustomImpostor: number;
  28790. /**
  28791. * Rope-Imposter type
  28792. */
  28793. static RopeImpostor: number;
  28794. /**
  28795. * Cloth-Imposter type
  28796. */
  28797. static ClothImpostor: number;
  28798. /**
  28799. * Softbody-Imposter type
  28800. */
  28801. static SoftbodyImpostor: number;
  28802. }
  28803. }
  28804. declare module "babylonjs/Meshes/mesh" {
  28805. import { Observable } from "babylonjs/Misc/observable";
  28806. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28807. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28808. import { Camera } from "babylonjs/Cameras/camera";
  28809. import { Scene } from "babylonjs/scene";
  28810. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28811. import { Color4 } from "babylonjs/Maths/math.color";
  28812. import { Engine } from "babylonjs/Engines/engine";
  28813. import { Node } from "babylonjs/node";
  28814. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28815. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28816. import { Buffer } from "babylonjs/Meshes/buffer";
  28817. import { Geometry } from "babylonjs/Meshes/geometry";
  28818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28819. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28820. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28821. import { Effect } from "babylonjs/Materials/effect";
  28822. import { Material } from "babylonjs/Materials/material";
  28823. import { Skeleton } from "babylonjs/Bones/skeleton";
  28824. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28825. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28826. import { Path3D } from "babylonjs/Maths/math.path";
  28827. import { Plane } from "babylonjs/Maths/math.plane";
  28828. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28829. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28830. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28831. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28832. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28833. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28834. /**
  28835. * @hidden
  28836. **/
  28837. export class _CreationDataStorage {
  28838. closePath?: boolean;
  28839. closeArray?: boolean;
  28840. idx: number[];
  28841. dashSize: number;
  28842. gapSize: number;
  28843. path3D: Path3D;
  28844. pathArray: Vector3[][];
  28845. arc: number;
  28846. radius: number;
  28847. cap: number;
  28848. tessellation: number;
  28849. }
  28850. /**
  28851. * @hidden
  28852. **/
  28853. class _InstanceDataStorage {
  28854. visibleInstances: any;
  28855. batchCache: _InstancesBatch;
  28856. instancesBufferSize: number;
  28857. instancesBuffer: Nullable<Buffer>;
  28858. instancesData: Float32Array;
  28859. overridenInstanceCount: number;
  28860. isFrozen: boolean;
  28861. previousBatch: Nullable<_InstancesBatch>;
  28862. hardwareInstancedRendering: boolean;
  28863. sideOrientation: number;
  28864. manualUpdate: boolean;
  28865. }
  28866. /**
  28867. * @hidden
  28868. **/
  28869. export class _InstancesBatch {
  28870. mustReturn: boolean;
  28871. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28872. renderSelf: boolean[];
  28873. hardwareInstancedRendering: boolean[];
  28874. }
  28875. /**
  28876. * @hidden
  28877. **/
  28878. class _ThinInstanceDataStorage {
  28879. instancesCount: number;
  28880. matrixBuffer: Nullable<Buffer>;
  28881. matrixBufferSize: number;
  28882. matrixData: Nullable<Float32Array>;
  28883. boundingVectors: Array<Vector3>;
  28884. }
  28885. /**
  28886. * Class used to represent renderable models
  28887. */
  28888. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28889. /**
  28890. * Mesh side orientation : usually the external or front surface
  28891. */
  28892. static readonly FRONTSIDE: number;
  28893. /**
  28894. * Mesh side orientation : usually the internal or back surface
  28895. */
  28896. static readonly BACKSIDE: number;
  28897. /**
  28898. * Mesh side orientation : both internal and external or front and back surfaces
  28899. */
  28900. static readonly DOUBLESIDE: number;
  28901. /**
  28902. * Mesh side orientation : by default, `FRONTSIDE`
  28903. */
  28904. static readonly DEFAULTSIDE: number;
  28905. /**
  28906. * Mesh cap setting : no cap
  28907. */
  28908. static readonly NO_CAP: number;
  28909. /**
  28910. * Mesh cap setting : one cap at the beginning of the mesh
  28911. */
  28912. static readonly CAP_START: number;
  28913. /**
  28914. * Mesh cap setting : one cap at the end of the mesh
  28915. */
  28916. static readonly CAP_END: number;
  28917. /**
  28918. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28919. */
  28920. static readonly CAP_ALL: number;
  28921. /**
  28922. * Mesh pattern setting : no flip or rotate
  28923. */
  28924. static readonly NO_FLIP: number;
  28925. /**
  28926. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28927. */
  28928. static readonly FLIP_TILE: number;
  28929. /**
  28930. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28931. */
  28932. static readonly ROTATE_TILE: number;
  28933. /**
  28934. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28935. */
  28936. static readonly FLIP_ROW: number;
  28937. /**
  28938. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28939. */
  28940. static readonly ROTATE_ROW: number;
  28941. /**
  28942. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28943. */
  28944. static readonly FLIP_N_ROTATE_TILE: number;
  28945. /**
  28946. * Mesh pattern setting : rotate pattern and rotate
  28947. */
  28948. static readonly FLIP_N_ROTATE_ROW: number;
  28949. /**
  28950. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28951. */
  28952. static readonly CENTER: number;
  28953. /**
  28954. * Mesh tile positioning : part tiles on left
  28955. */
  28956. static readonly LEFT: number;
  28957. /**
  28958. * Mesh tile positioning : part tiles on right
  28959. */
  28960. static readonly RIGHT: number;
  28961. /**
  28962. * Mesh tile positioning : part tiles on top
  28963. */
  28964. static readonly TOP: number;
  28965. /**
  28966. * Mesh tile positioning : part tiles on bottom
  28967. */
  28968. static readonly BOTTOM: number;
  28969. /**
  28970. * Gets the default side orientation.
  28971. * @param orientation the orientation to value to attempt to get
  28972. * @returns the default orientation
  28973. * @hidden
  28974. */
  28975. static _GetDefaultSideOrientation(orientation?: number): number;
  28976. private _internalMeshDataInfo;
  28977. get computeBonesUsingShaders(): boolean;
  28978. set computeBonesUsingShaders(value: boolean);
  28979. /**
  28980. * An event triggered before rendering the mesh
  28981. */
  28982. get onBeforeRenderObservable(): Observable<Mesh>;
  28983. /**
  28984. * An event triggered before binding the mesh
  28985. */
  28986. get onBeforeBindObservable(): Observable<Mesh>;
  28987. /**
  28988. * An event triggered after rendering the mesh
  28989. */
  28990. get onAfterRenderObservable(): Observable<Mesh>;
  28991. /**
  28992. * An event triggered before drawing the mesh
  28993. */
  28994. get onBeforeDrawObservable(): Observable<Mesh>;
  28995. private _onBeforeDrawObserver;
  28996. /**
  28997. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28998. */
  28999. set onBeforeDraw(callback: () => void);
  29000. get hasInstances(): boolean;
  29001. get hasThinInstances(): boolean;
  29002. /**
  29003. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29004. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29005. */
  29006. delayLoadState: number;
  29007. /**
  29008. * Gets the list of instances created from this mesh
  29009. * it is not supposed to be modified manually.
  29010. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29011. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29012. */
  29013. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29014. /**
  29015. * Gets the file containing delay loading data for this mesh
  29016. */
  29017. delayLoadingFile: string;
  29018. /** @hidden */
  29019. _binaryInfo: any;
  29020. /**
  29021. * User defined function used to change how LOD level selection is done
  29022. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29023. */
  29024. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29025. /**
  29026. * Gets or sets the morph target manager
  29027. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29028. */
  29029. get morphTargetManager(): Nullable<MorphTargetManager>;
  29030. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29031. /** @hidden */
  29032. _creationDataStorage: Nullable<_CreationDataStorage>;
  29033. /** @hidden */
  29034. _geometry: Nullable<Geometry>;
  29035. /** @hidden */
  29036. _delayInfo: Array<string>;
  29037. /** @hidden */
  29038. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29039. /** @hidden */
  29040. _instanceDataStorage: _InstanceDataStorage;
  29041. /** @hidden */
  29042. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29043. private _effectiveMaterial;
  29044. /** @hidden */
  29045. _shouldGenerateFlatShading: boolean;
  29046. /** @hidden */
  29047. _originalBuilderSideOrientation: number;
  29048. /**
  29049. * Use this property to change the original side orientation defined at construction time
  29050. */
  29051. overrideMaterialSideOrientation: Nullable<number>;
  29052. /**
  29053. * Gets the source mesh (the one used to clone this one from)
  29054. */
  29055. get source(): Nullable<Mesh>;
  29056. /**
  29057. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29058. */
  29059. get isUnIndexed(): boolean;
  29060. set isUnIndexed(value: boolean);
  29061. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29062. get worldMatrixInstancedBuffer(): Float32Array;
  29063. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29064. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29065. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29066. /**
  29067. * @constructor
  29068. * @param name The value used by scene.getMeshByName() to do a lookup.
  29069. * @param scene The scene to add this mesh to.
  29070. * @param parent The parent of this mesh, if it has one
  29071. * @param source An optional Mesh from which geometry is shared, cloned.
  29072. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29073. * When false, achieved by calling a clone(), also passing False.
  29074. * This will make creation of children, recursive.
  29075. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29076. */
  29077. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29078. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29079. doNotInstantiate: boolean;
  29080. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29081. /**
  29082. * Gets the class name
  29083. * @returns the string "Mesh".
  29084. */
  29085. getClassName(): string;
  29086. /** @hidden */
  29087. get _isMesh(): boolean;
  29088. /**
  29089. * Returns a description of this mesh
  29090. * @param fullDetails define if full details about this mesh must be used
  29091. * @returns a descriptive string representing this mesh
  29092. */
  29093. toString(fullDetails?: boolean): string;
  29094. /** @hidden */
  29095. _unBindEffect(): void;
  29096. /**
  29097. * Gets a boolean indicating if this mesh has LOD
  29098. */
  29099. get hasLODLevels(): boolean;
  29100. /**
  29101. * Gets the list of MeshLODLevel associated with the current mesh
  29102. * @returns an array of MeshLODLevel
  29103. */
  29104. getLODLevels(): MeshLODLevel[];
  29105. private _sortLODLevels;
  29106. /**
  29107. * Add a mesh as LOD level triggered at the given distance.
  29108. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29109. * @param distance The distance from the center of the object to show this level
  29110. * @param mesh The mesh to be added as LOD level (can be null)
  29111. * @return This mesh (for chaining)
  29112. */
  29113. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29114. /**
  29115. * Returns the LOD level mesh at the passed distance or null if not found.
  29116. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29117. * @param distance The distance from the center of the object to show this level
  29118. * @returns a Mesh or `null`
  29119. */
  29120. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29121. /**
  29122. * Remove a mesh from the LOD array
  29123. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29124. * @param mesh defines the mesh to be removed
  29125. * @return This mesh (for chaining)
  29126. */
  29127. removeLODLevel(mesh: Mesh): Mesh;
  29128. /**
  29129. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29130. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29131. * @param camera defines the camera to use to compute distance
  29132. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29133. * @return This mesh (for chaining)
  29134. */
  29135. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29136. /**
  29137. * Gets the mesh internal Geometry object
  29138. */
  29139. get geometry(): Nullable<Geometry>;
  29140. /**
  29141. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29142. * @returns the total number of vertices
  29143. */
  29144. getTotalVertices(): number;
  29145. /**
  29146. * Returns the content of an associated vertex buffer
  29147. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29148. * - VertexBuffer.PositionKind
  29149. * - VertexBuffer.UVKind
  29150. * - VertexBuffer.UV2Kind
  29151. * - VertexBuffer.UV3Kind
  29152. * - VertexBuffer.UV4Kind
  29153. * - VertexBuffer.UV5Kind
  29154. * - VertexBuffer.UV6Kind
  29155. * - VertexBuffer.ColorKind
  29156. * - VertexBuffer.MatricesIndicesKind
  29157. * - VertexBuffer.MatricesIndicesExtraKind
  29158. * - VertexBuffer.MatricesWeightsKind
  29159. * - VertexBuffer.MatricesWeightsExtraKind
  29160. * @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
  29161. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29162. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29163. */
  29164. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29165. /**
  29166. * Returns the mesh VertexBuffer object from the requested `kind`
  29167. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29168. * - VertexBuffer.PositionKind
  29169. * - VertexBuffer.NormalKind
  29170. * - VertexBuffer.UVKind
  29171. * - VertexBuffer.UV2Kind
  29172. * - VertexBuffer.UV3Kind
  29173. * - VertexBuffer.UV4Kind
  29174. * - VertexBuffer.UV5Kind
  29175. * - VertexBuffer.UV6Kind
  29176. * - VertexBuffer.ColorKind
  29177. * - VertexBuffer.MatricesIndicesKind
  29178. * - VertexBuffer.MatricesIndicesExtraKind
  29179. * - VertexBuffer.MatricesWeightsKind
  29180. * - VertexBuffer.MatricesWeightsExtraKind
  29181. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29182. */
  29183. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29184. /**
  29185. * Tests if a specific vertex buffer is associated with this mesh
  29186. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29187. * - VertexBuffer.PositionKind
  29188. * - VertexBuffer.NormalKind
  29189. * - VertexBuffer.UVKind
  29190. * - VertexBuffer.UV2Kind
  29191. * - VertexBuffer.UV3Kind
  29192. * - VertexBuffer.UV4Kind
  29193. * - VertexBuffer.UV5Kind
  29194. * - VertexBuffer.UV6Kind
  29195. * - VertexBuffer.ColorKind
  29196. * - VertexBuffer.MatricesIndicesKind
  29197. * - VertexBuffer.MatricesIndicesExtraKind
  29198. * - VertexBuffer.MatricesWeightsKind
  29199. * - VertexBuffer.MatricesWeightsExtraKind
  29200. * @returns a boolean
  29201. */
  29202. isVerticesDataPresent(kind: string): boolean;
  29203. /**
  29204. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29205. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29206. * - VertexBuffer.PositionKind
  29207. * - VertexBuffer.UVKind
  29208. * - VertexBuffer.UV2Kind
  29209. * - VertexBuffer.UV3Kind
  29210. * - VertexBuffer.UV4Kind
  29211. * - VertexBuffer.UV5Kind
  29212. * - VertexBuffer.UV6Kind
  29213. * - VertexBuffer.ColorKind
  29214. * - VertexBuffer.MatricesIndicesKind
  29215. * - VertexBuffer.MatricesIndicesExtraKind
  29216. * - VertexBuffer.MatricesWeightsKind
  29217. * - VertexBuffer.MatricesWeightsExtraKind
  29218. * @returns a boolean
  29219. */
  29220. isVertexBufferUpdatable(kind: string): boolean;
  29221. /**
  29222. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29223. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29224. * - VertexBuffer.PositionKind
  29225. * - VertexBuffer.NormalKind
  29226. * - VertexBuffer.UVKind
  29227. * - VertexBuffer.UV2Kind
  29228. * - VertexBuffer.UV3Kind
  29229. * - VertexBuffer.UV4Kind
  29230. * - VertexBuffer.UV5Kind
  29231. * - VertexBuffer.UV6Kind
  29232. * - VertexBuffer.ColorKind
  29233. * - VertexBuffer.MatricesIndicesKind
  29234. * - VertexBuffer.MatricesIndicesExtraKind
  29235. * - VertexBuffer.MatricesWeightsKind
  29236. * - VertexBuffer.MatricesWeightsExtraKind
  29237. * @returns an array of strings
  29238. */
  29239. getVerticesDataKinds(): string[];
  29240. /**
  29241. * Returns a positive integer : the total number of indices in this mesh geometry.
  29242. * @returns the numner of indices or zero if the mesh has no geometry.
  29243. */
  29244. getTotalIndices(): number;
  29245. /**
  29246. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29247. * @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.
  29248. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29249. * @returns the indices array or an empty array if the mesh has no geometry
  29250. */
  29251. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29252. get isBlocked(): boolean;
  29253. /**
  29254. * Determine if the current mesh is ready to be rendered
  29255. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29256. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29257. * @returns true if all associated assets are ready (material, textures, shaders)
  29258. */
  29259. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29260. /**
  29261. * 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.
  29262. */
  29263. get areNormalsFrozen(): boolean;
  29264. /**
  29265. * 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.
  29266. * @returns the current mesh
  29267. */
  29268. freezeNormals(): Mesh;
  29269. /**
  29270. * 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
  29271. * @returns the current mesh
  29272. */
  29273. unfreezeNormals(): Mesh;
  29274. /**
  29275. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29276. */
  29277. set overridenInstanceCount(count: number);
  29278. /** @hidden */
  29279. _preActivate(): Mesh;
  29280. /** @hidden */
  29281. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29282. /** @hidden */
  29283. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29284. protected _afterComputeWorldMatrix(): void;
  29285. /** @hidden */
  29286. _postActivate(): void;
  29287. /**
  29288. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29289. * This means the mesh underlying bounding box and sphere are recomputed.
  29290. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29291. * @returns the current mesh
  29292. */
  29293. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29294. /** @hidden */
  29295. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29296. /**
  29297. * This function will subdivide the mesh into multiple submeshes
  29298. * @param count defines the expected number of submeshes
  29299. */
  29300. subdivide(count: number): void;
  29301. /**
  29302. * Copy a FloatArray into a specific associated vertex buffer
  29303. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29304. * - VertexBuffer.PositionKind
  29305. * - VertexBuffer.UVKind
  29306. * - VertexBuffer.UV2Kind
  29307. * - VertexBuffer.UV3Kind
  29308. * - VertexBuffer.UV4Kind
  29309. * - VertexBuffer.UV5Kind
  29310. * - VertexBuffer.UV6Kind
  29311. * - VertexBuffer.ColorKind
  29312. * - VertexBuffer.MatricesIndicesKind
  29313. * - VertexBuffer.MatricesIndicesExtraKind
  29314. * - VertexBuffer.MatricesWeightsKind
  29315. * - VertexBuffer.MatricesWeightsExtraKind
  29316. * @param data defines the data source
  29317. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29318. * @param stride defines the data stride size (can be null)
  29319. * @returns the current mesh
  29320. */
  29321. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29322. /**
  29323. * Delete a vertex buffer associated with this mesh
  29324. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29325. * - VertexBuffer.PositionKind
  29326. * - VertexBuffer.UVKind
  29327. * - VertexBuffer.UV2Kind
  29328. * - VertexBuffer.UV3Kind
  29329. * - VertexBuffer.UV4Kind
  29330. * - VertexBuffer.UV5Kind
  29331. * - VertexBuffer.UV6Kind
  29332. * - VertexBuffer.ColorKind
  29333. * - VertexBuffer.MatricesIndicesKind
  29334. * - VertexBuffer.MatricesIndicesExtraKind
  29335. * - VertexBuffer.MatricesWeightsKind
  29336. * - VertexBuffer.MatricesWeightsExtraKind
  29337. */
  29338. removeVerticesData(kind: string): void;
  29339. /**
  29340. * Flags an associated vertex buffer as updatable
  29341. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29342. * - VertexBuffer.PositionKind
  29343. * - VertexBuffer.UVKind
  29344. * - VertexBuffer.UV2Kind
  29345. * - VertexBuffer.UV3Kind
  29346. * - VertexBuffer.UV4Kind
  29347. * - VertexBuffer.UV5Kind
  29348. * - VertexBuffer.UV6Kind
  29349. * - VertexBuffer.ColorKind
  29350. * - VertexBuffer.MatricesIndicesKind
  29351. * - VertexBuffer.MatricesIndicesExtraKind
  29352. * - VertexBuffer.MatricesWeightsKind
  29353. * - VertexBuffer.MatricesWeightsExtraKind
  29354. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29355. */
  29356. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29357. /**
  29358. * Sets the mesh global Vertex Buffer
  29359. * @param buffer defines the buffer to use
  29360. * @returns the current mesh
  29361. */
  29362. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29363. /**
  29364. * Update a specific associated vertex buffer
  29365. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29366. * - VertexBuffer.PositionKind
  29367. * - VertexBuffer.UVKind
  29368. * - VertexBuffer.UV2Kind
  29369. * - VertexBuffer.UV3Kind
  29370. * - VertexBuffer.UV4Kind
  29371. * - VertexBuffer.UV5Kind
  29372. * - VertexBuffer.UV6Kind
  29373. * - VertexBuffer.ColorKind
  29374. * - VertexBuffer.MatricesIndicesKind
  29375. * - VertexBuffer.MatricesIndicesExtraKind
  29376. * - VertexBuffer.MatricesWeightsKind
  29377. * - VertexBuffer.MatricesWeightsExtraKind
  29378. * @param data defines the data source
  29379. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29380. * @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)
  29381. * @returns the current mesh
  29382. */
  29383. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29384. /**
  29385. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29386. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29387. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29388. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29389. * @returns the current mesh
  29390. */
  29391. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29392. /**
  29393. * Creates a un-shared specific occurence of the geometry for the mesh.
  29394. * @returns the current mesh
  29395. */
  29396. makeGeometryUnique(): Mesh;
  29397. /**
  29398. * Set the index buffer of this mesh
  29399. * @param indices defines the source data
  29400. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29401. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29402. * @returns the current mesh
  29403. */
  29404. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29405. /**
  29406. * Update the current index buffer
  29407. * @param indices defines the source data
  29408. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29409. * @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)
  29410. * @returns the current mesh
  29411. */
  29412. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29413. /**
  29414. * Invert the geometry to move from a right handed system to a left handed one.
  29415. * @returns the current mesh
  29416. */
  29417. toLeftHanded(): Mesh;
  29418. /** @hidden */
  29419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29420. /** @hidden */
  29421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29422. /**
  29423. * Registers for this mesh a javascript function called just before the rendering process
  29424. * @param func defines the function to call before rendering this mesh
  29425. * @returns the current mesh
  29426. */
  29427. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29428. /**
  29429. * Disposes a previously registered javascript function called before the rendering
  29430. * @param func defines the function to remove
  29431. * @returns the current mesh
  29432. */
  29433. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29434. /**
  29435. * Registers for this mesh a javascript function called just after the rendering is complete
  29436. * @param func defines the function to call after rendering this mesh
  29437. * @returns the current mesh
  29438. */
  29439. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29440. /**
  29441. * Disposes a previously registered javascript function called after the rendering.
  29442. * @param func defines the function to remove
  29443. * @returns the current mesh
  29444. */
  29445. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29446. /** @hidden */
  29447. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29448. /** @hidden */
  29449. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29450. /** @hidden */
  29451. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29452. /** @hidden */
  29453. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29454. /** @hidden */
  29455. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29456. /** @hidden */
  29457. _rebuild(): void;
  29458. /** @hidden */
  29459. _freeze(): void;
  29460. /** @hidden */
  29461. _unFreeze(): void;
  29462. /**
  29463. * 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
  29464. * @param subMesh defines the subMesh to render
  29465. * @param enableAlphaMode defines if alpha mode can be changed
  29466. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29467. * @returns the current mesh
  29468. */
  29469. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29470. private _onBeforeDraw;
  29471. /**
  29472. * Renormalize the mesh and patch it up if there are no weights
  29473. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29474. * However in the case of zero weights then we set just a single influence to 1.
  29475. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29476. */
  29477. cleanMatrixWeights(): void;
  29478. private normalizeSkinFourWeights;
  29479. private normalizeSkinWeightsAndExtra;
  29480. /**
  29481. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29482. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29483. * the user know there was an issue with importing the mesh
  29484. * @returns a validation object with skinned, valid and report string
  29485. */
  29486. validateSkinning(): {
  29487. skinned: boolean;
  29488. valid: boolean;
  29489. report: string;
  29490. };
  29491. /** @hidden */
  29492. _checkDelayState(): Mesh;
  29493. private _queueLoad;
  29494. /**
  29495. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29496. * A mesh is in the frustum if its bounding box intersects the frustum
  29497. * @param frustumPlanes defines the frustum to test
  29498. * @returns true if the mesh is in the frustum planes
  29499. */
  29500. isInFrustum(frustumPlanes: Plane[]): boolean;
  29501. /**
  29502. * Sets the mesh material by the material or multiMaterial `id` property
  29503. * @param id is a string identifying the material or the multiMaterial
  29504. * @returns the current mesh
  29505. */
  29506. setMaterialByID(id: string): Mesh;
  29507. /**
  29508. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29509. * @returns an array of IAnimatable
  29510. */
  29511. getAnimatables(): IAnimatable[];
  29512. /**
  29513. * Modifies the mesh geometry according to the passed transformation matrix.
  29514. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29515. * The mesh normals are modified using the same transformation.
  29516. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29517. * @param transform defines the transform matrix to use
  29518. * @see https://doc.babylonjs.com/resources/baking_transformations
  29519. * @returns the current mesh
  29520. */
  29521. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29522. /**
  29523. * Modifies the mesh geometry according to its own current World Matrix.
  29524. * The mesh World Matrix is then reset.
  29525. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29526. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29527. * @see https://doc.babylonjs.com/resources/baking_transformations
  29528. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29529. * @returns the current mesh
  29530. */
  29531. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29532. /** @hidden */
  29533. get _positions(): Nullable<Vector3[]>;
  29534. /** @hidden */
  29535. _resetPointsArrayCache(): Mesh;
  29536. /** @hidden */
  29537. _generatePointsArray(): boolean;
  29538. /**
  29539. * Returns a new Mesh object generated from the current mesh properties.
  29540. * This method must not get confused with createInstance()
  29541. * @param name is a string, the name given to the new mesh
  29542. * @param newParent can be any Node object (default `null`)
  29543. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29544. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29545. * @returns a new mesh
  29546. */
  29547. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29548. /**
  29549. * Releases resources associated with this mesh.
  29550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29552. */
  29553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29554. /** @hidden */
  29555. _disposeInstanceSpecificData(): void;
  29556. /** @hidden */
  29557. _disposeThinInstanceSpecificData(): void;
  29558. /**
  29559. * Modifies the mesh geometry according to a displacement map.
  29560. * 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.
  29561. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29562. * @param url is a string, the URL from the image file is to be downloaded.
  29563. * @param minHeight is the lower limit of the displacement.
  29564. * @param maxHeight is the upper limit of the displacement.
  29565. * @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.
  29566. * @param uvOffset is an optional vector2 used to offset UV.
  29567. * @param uvScale is an optional vector2 used to scale UV.
  29568. * @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.
  29569. * @returns the Mesh.
  29570. */
  29571. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29572. /**
  29573. * Modifies the mesh geometry according to a displacementMap buffer.
  29574. * 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.
  29575. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29576. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29577. * @param heightMapWidth is the width of the buffer image.
  29578. * @param heightMapHeight is the height of the buffer image.
  29579. * @param minHeight is the lower limit of the displacement.
  29580. * @param maxHeight is the upper limit of the displacement.
  29581. * @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.
  29582. * @param uvOffset is an optional vector2 used to offset UV.
  29583. * @param uvScale is an optional vector2 used to scale UV.
  29584. * @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.
  29585. * @returns the Mesh.
  29586. */
  29587. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29588. /**
  29589. * Modify the mesh to get a flat shading rendering.
  29590. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29591. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29592. * @returns current mesh
  29593. */
  29594. convertToFlatShadedMesh(): Mesh;
  29595. /**
  29596. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29597. * In other words, more vertices, no more indices and a single bigger VBO.
  29598. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29599. * @returns current mesh
  29600. */
  29601. convertToUnIndexedMesh(): Mesh;
  29602. /**
  29603. * Inverses facet orientations.
  29604. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29605. * @param flipNormals will also inverts the normals
  29606. * @returns current mesh
  29607. */
  29608. flipFaces(flipNormals?: boolean): Mesh;
  29609. /**
  29610. * Increase the number of facets and hence vertices in a mesh
  29611. * Vertex normals are interpolated from existing vertex normals
  29612. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29613. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29614. */
  29615. increaseVertices(numberPerEdge: number): void;
  29616. /**
  29617. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29618. * This will undo any application of covertToFlatShadedMesh
  29619. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29620. */
  29621. forceSharedVertices(): void;
  29622. /** @hidden */
  29623. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29624. /** @hidden */
  29625. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29626. /**
  29627. * Creates a new InstancedMesh object from the mesh model.
  29628. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29629. * @param name defines the name of the new instance
  29630. * @returns a new InstancedMesh
  29631. */
  29632. createInstance(name: string): InstancedMesh;
  29633. /**
  29634. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29635. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29636. * @returns the current mesh
  29637. */
  29638. synchronizeInstances(): Mesh;
  29639. /**
  29640. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29641. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29642. * This should be used together with the simplification to avoid disappearing triangles.
  29643. * @param successCallback an optional success callback to be called after the optimization finished.
  29644. * @returns the current mesh
  29645. */
  29646. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29647. /**
  29648. * Serialize current mesh
  29649. * @param serializationObject defines the object which will receive the serialization data
  29650. */
  29651. serialize(serializationObject: any): void;
  29652. /** @hidden */
  29653. _syncGeometryWithMorphTargetManager(): void;
  29654. /** @hidden */
  29655. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29656. /**
  29657. * Returns a new Mesh object parsed from the source provided.
  29658. * @param parsedMesh is the source
  29659. * @param scene defines the hosting scene
  29660. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29661. * @returns a new Mesh
  29662. */
  29663. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29664. /**
  29665. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29667. * @param name defines the name of the mesh to create
  29668. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29669. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29670. * @param closePath creates a seam between the first and the last points of each path of the path array
  29671. * @param offset is taken in account only if the `pathArray` is containing a single path
  29672. * @param scene defines the hosting scene
  29673. * @param updatable defines if the mesh must be flagged as updatable
  29674. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29675. * @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)
  29676. * @returns a new Mesh
  29677. */
  29678. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29679. /**
  29680. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29681. * @param name defines the name of the mesh to create
  29682. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29683. * @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
  29684. * @param scene defines the hosting scene
  29685. * @param updatable defines if the mesh must be flagged as updatable
  29686. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29687. * @returns a new Mesh
  29688. */
  29689. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29690. /**
  29691. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29692. * @param name defines the name of the mesh to create
  29693. * @param size sets the size (float) of each box side (default 1)
  29694. * @param scene defines the hosting scene
  29695. * @param updatable defines if the mesh must be flagged as updatable
  29696. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29697. * @returns a new Mesh
  29698. */
  29699. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29700. /**
  29701. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29702. * @param name defines the name of the mesh to create
  29703. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29704. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29705. * @param scene defines the hosting scene
  29706. * @param updatable defines if the mesh must be flagged as updatable
  29707. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29708. * @returns a new Mesh
  29709. */
  29710. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29711. /**
  29712. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29713. * @param name defines the name of the mesh to create
  29714. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29715. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29716. * @param scene defines the hosting scene
  29717. * @returns a new Mesh
  29718. */
  29719. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29720. /**
  29721. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29722. * @param name defines the name of the mesh to create
  29723. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29724. * @param diameterTop set the top cap diameter (floats, default 1)
  29725. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29726. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29727. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29728. * @param scene defines the hosting scene
  29729. * @param updatable defines if the mesh must be flagged as updatable
  29730. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29731. * @returns a new Mesh
  29732. */
  29733. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29734. /**
  29735. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29736. * @param name defines the name of the mesh to create
  29737. * @param diameter sets the diameter size (float) of the torus (default 1)
  29738. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29739. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29740. * @param scene defines the hosting scene
  29741. * @param updatable defines if the mesh must be flagged as updatable
  29742. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29743. * @returns a new Mesh
  29744. */
  29745. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29746. /**
  29747. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29748. * @param name defines the name of the mesh to create
  29749. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29750. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29751. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29752. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29753. * @param p the number of windings on X axis (positive integers, default 2)
  29754. * @param q the number of windings on Y axis (positive integers, default 3)
  29755. * @param scene defines the hosting scene
  29756. * @param updatable defines if the mesh must be flagged as updatable
  29757. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29758. * @returns a new Mesh
  29759. */
  29760. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29761. /**
  29762. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29763. * @param name defines the name of the mesh to create
  29764. * @param points is an array successive Vector3
  29765. * @param scene defines the hosting scene
  29766. * @param updatable defines if the mesh must be flagged as updatable
  29767. * @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).
  29768. * @returns a new Mesh
  29769. */
  29770. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29771. /**
  29772. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29773. * @param name defines the name of the mesh to create
  29774. * @param points is an array successive Vector3
  29775. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29776. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29777. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29778. * @param scene defines the hosting scene
  29779. * @param updatable defines if the mesh must be flagged as updatable
  29780. * @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)
  29781. * @returns a new Mesh
  29782. */
  29783. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29784. /**
  29785. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29787. * 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.
  29788. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29789. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29790. * Remember you can only change the shape positions, not their number when updating a polygon.
  29791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29792. * @param name defines the name of the mesh to create
  29793. * @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
  29794. * @param scene defines the hosting scene
  29795. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29796. * @param updatable defines if the mesh must be flagged as updatable
  29797. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29798. * @param earcutInjection can be used to inject your own earcut reference
  29799. * @returns a new Mesh
  29800. */
  29801. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29802. /**
  29803. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29805. * @param name defines the name of the mesh to create
  29806. * @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
  29807. * @param depth defines the height of extrusion
  29808. * @param scene defines the hosting scene
  29809. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29810. * @param updatable defines if the mesh must be flagged as updatable
  29811. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29812. * @param earcutInjection can be used to inject your own earcut reference
  29813. * @returns a new Mesh
  29814. */
  29815. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29816. /**
  29817. * Creates an extruded shape mesh.
  29818. * 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
  29819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29821. * @param name defines the name of the mesh to create
  29822. * @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
  29823. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29824. * @param scale is the value to scale the shape
  29825. * @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
  29826. * @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
  29827. * @param scene defines the hosting scene
  29828. * @param updatable defines if the mesh must be flagged as updatable
  29829. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29830. * @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)
  29831. * @returns a new Mesh
  29832. */
  29833. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29834. /**
  29835. * Creates an custom extruded shape mesh.
  29836. * The custom extrusion is a parametric shape.
  29837. * It has no predefined shape. Its final shape will depend on the input parameters.
  29838. * Please consider using the same method from the MeshBuilder class instead
  29839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29840. * @param name defines the name of the mesh to create
  29841. * @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
  29842. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29843. * @param scaleFunction is a custom Javascript function called on each path point
  29844. * @param rotationFunction is a custom Javascript function called on each path point
  29845. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29846. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29847. * @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
  29848. * @param scene defines the hosting scene
  29849. * @param updatable defines if the mesh must be flagged as updatable
  29850. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29851. * @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)
  29852. * @returns a new Mesh
  29853. */
  29854. 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;
  29855. /**
  29856. * Creates lathe mesh.
  29857. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29858. * Please consider using the same method from the MeshBuilder class instead
  29859. * @param name defines the name of the mesh to create
  29860. * @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
  29861. * @param radius is the radius value of the lathe
  29862. * @param tessellation is the side number of the lathe.
  29863. * @param scene defines the hosting scene
  29864. * @param updatable defines if the mesh must be flagged as updatable
  29865. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29866. * @returns a new Mesh
  29867. */
  29868. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29869. /**
  29870. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29871. * @param name defines the name of the mesh to create
  29872. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29873. * @param scene defines the hosting scene
  29874. * @param updatable defines if the mesh must be flagged as updatable
  29875. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29876. * @returns a new Mesh
  29877. */
  29878. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29879. /**
  29880. * Creates a ground mesh.
  29881. * Please consider using the same method from the MeshBuilder class instead
  29882. * @param name defines the name of the mesh to create
  29883. * @param width set the width of the ground
  29884. * @param height set the height of the ground
  29885. * @param subdivisions sets the number of subdivisions per side
  29886. * @param scene defines the hosting scene
  29887. * @param updatable defines if the mesh must be flagged as updatable
  29888. * @returns a new Mesh
  29889. */
  29890. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29891. /**
  29892. * Creates a tiled ground mesh.
  29893. * Please consider using the same method from the MeshBuilder class instead
  29894. * @param name defines the name of the mesh to create
  29895. * @param xmin set the ground minimum X coordinate
  29896. * @param zmin set the ground minimum Y coordinate
  29897. * @param xmax set the ground maximum X coordinate
  29898. * @param zmax set the ground maximum Z coordinate
  29899. * @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
  29900. * @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
  29901. * @param scene defines the hosting scene
  29902. * @param updatable defines if the mesh must be flagged as updatable
  29903. * @returns a new Mesh
  29904. */
  29905. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29906. w: number;
  29907. h: number;
  29908. }, precision: {
  29909. w: number;
  29910. h: number;
  29911. }, scene: Scene, updatable?: boolean): Mesh;
  29912. /**
  29913. * Creates a ground mesh from a height map.
  29914. * Please consider using the same method from the MeshBuilder class instead
  29915. * @see https://doc.babylonjs.com/babylon101/height_map
  29916. * @param name defines the name of the mesh to create
  29917. * @param url sets the URL of the height map image resource
  29918. * @param width set the ground width size
  29919. * @param height set the ground height size
  29920. * @param subdivisions sets the number of subdivision per side
  29921. * @param minHeight is the minimum altitude on the ground
  29922. * @param maxHeight is the maximum altitude on the ground
  29923. * @param scene defines the hosting scene
  29924. * @param updatable defines if the mesh must be flagged as updatable
  29925. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29926. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29927. * @returns a new Mesh
  29928. */
  29929. 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;
  29930. /**
  29931. * Creates a tube mesh.
  29932. * The tube is a parametric shape.
  29933. * It has no predefined shape. Its final shape will depend on the input parameters.
  29934. * Please consider using the same method from the MeshBuilder class instead
  29935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29936. * @param name defines the name of the mesh to create
  29937. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29938. * @param radius sets the tube radius size
  29939. * @param tessellation is the number of sides on the tubular surface
  29940. * @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
  29941. * @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
  29942. * @param scene defines the hosting scene
  29943. * @param updatable defines if the mesh must be flagged as updatable
  29944. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29945. * @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)
  29946. * @returns a new Mesh
  29947. */
  29948. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29949. (i: number, distance: number): number;
  29950. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29951. /**
  29952. * Creates a polyhedron mesh.
  29953. * Please consider using the same method from the MeshBuilder class instead.
  29954. * * 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
  29955. * * The parameter `size` (positive float, default 1) sets the polygon size
  29956. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29957. * * 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`
  29958. * * 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
  29959. * * 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)`)
  29960. * * 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
  29961. * * 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
  29962. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29965. * @param name defines the name of the mesh to create
  29966. * @param options defines the options used to create the mesh
  29967. * @param scene defines the hosting scene
  29968. * @returns a new Mesh
  29969. */
  29970. static CreatePolyhedron(name: string, options: {
  29971. type?: number;
  29972. size?: number;
  29973. sizeX?: number;
  29974. sizeY?: number;
  29975. sizeZ?: number;
  29976. custom?: any;
  29977. faceUV?: Vector4[];
  29978. faceColors?: Color4[];
  29979. updatable?: boolean;
  29980. sideOrientation?: number;
  29981. }, scene: Scene): Mesh;
  29982. /**
  29983. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29984. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29985. * * 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`)
  29986. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29987. * * 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
  29988. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29991. * @param name defines the name of the mesh
  29992. * @param options defines the options used to create the mesh
  29993. * @param scene defines the hosting scene
  29994. * @returns a new Mesh
  29995. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29996. */
  29997. static CreateIcoSphere(name: string, options: {
  29998. radius?: number;
  29999. flat?: boolean;
  30000. subdivisions?: number;
  30001. sideOrientation?: number;
  30002. updatable?: boolean;
  30003. }, scene: Scene): Mesh;
  30004. /**
  30005. * Creates a decal mesh.
  30006. * Please consider using the same method from the MeshBuilder class instead.
  30007. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30008. * @param name defines the name of the mesh
  30009. * @param sourceMesh defines the mesh receiving the decal
  30010. * @param position sets the position of the decal in world coordinates
  30011. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30012. * @param size sets the decal scaling
  30013. * @param angle sets the angle to rotate the decal
  30014. * @returns a new Mesh
  30015. */
  30016. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30017. /**
  30018. * Prepare internal position array for software CPU skinning
  30019. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30020. */
  30021. setPositionsForCPUSkinning(): Float32Array;
  30022. /**
  30023. * Prepare internal normal array for software CPU skinning
  30024. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30025. */
  30026. setNormalsForCPUSkinning(): Float32Array;
  30027. /**
  30028. * Updates the vertex buffer by applying transformation from the bones
  30029. * @param skeleton defines the skeleton to apply to current mesh
  30030. * @returns the current mesh
  30031. */
  30032. applySkeleton(skeleton: Skeleton): Mesh;
  30033. /**
  30034. * 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
  30035. * @param meshes defines the list of meshes to scan
  30036. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30037. */
  30038. static MinMax(meshes: AbstractMesh[]): {
  30039. min: Vector3;
  30040. max: Vector3;
  30041. };
  30042. /**
  30043. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30044. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30045. * @returns a vector3
  30046. */
  30047. static Center(meshesOrMinMaxVector: {
  30048. min: Vector3;
  30049. max: Vector3;
  30050. } | AbstractMesh[]): Vector3;
  30051. /**
  30052. * Merge the array of meshes into a single mesh for performance reasons.
  30053. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30054. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30055. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30056. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30057. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30058. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30059. * @returns a new mesh
  30060. */
  30061. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30062. /** @hidden */
  30063. addInstance(instance: InstancedMesh): void;
  30064. /** @hidden */
  30065. removeInstance(instance: InstancedMesh): void;
  30066. }
  30067. }
  30068. declare module "babylonjs/Cameras/camera" {
  30069. import { SmartArray } from "babylonjs/Misc/smartArray";
  30070. import { Observable } from "babylonjs/Misc/observable";
  30071. import { Nullable } from "babylonjs/types";
  30072. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30073. import { Scene } from "babylonjs/scene";
  30074. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30075. import { Node } from "babylonjs/node";
  30076. import { Mesh } from "babylonjs/Meshes/mesh";
  30077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30078. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30079. import { Viewport } from "babylonjs/Maths/math.viewport";
  30080. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30082. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30083. import { Ray } from "babylonjs/Culling/ray";
  30084. /**
  30085. * This is the base class of all the camera used in the application.
  30086. * @see https://doc.babylonjs.com/features/cameras
  30087. */
  30088. export class Camera extends Node {
  30089. /** @hidden */
  30090. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30091. /**
  30092. * This is the default projection mode used by the cameras.
  30093. * It helps recreating a feeling of perspective and better appreciate depth.
  30094. * This is the best way to simulate real life cameras.
  30095. */
  30096. static readonly PERSPECTIVE_CAMERA: number;
  30097. /**
  30098. * This helps creating camera with an orthographic mode.
  30099. * 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.
  30100. */
  30101. static readonly ORTHOGRAPHIC_CAMERA: number;
  30102. /**
  30103. * This is the default FOV mode for perspective cameras.
  30104. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30105. */
  30106. static readonly FOVMODE_VERTICAL_FIXED: number;
  30107. /**
  30108. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30109. */
  30110. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30111. /**
  30112. * This specifies ther is no need for a camera rig.
  30113. * Basically only one eye is rendered corresponding to the camera.
  30114. */
  30115. static readonly RIG_MODE_NONE: number;
  30116. /**
  30117. * Simulates a camera Rig with one blue eye and one red eye.
  30118. * This can be use with 3d blue and red glasses.
  30119. */
  30120. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30121. /**
  30122. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30123. */
  30124. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30125. /**
  30126. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30127. */
  30128. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30129. /**
  30130. * Defines that both eyes of the camera will be rendered over under each other.
  30131. */
  30132. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30133. /**
  30134. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30135. */
  30136. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30137. /**
  30138. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30139. */
  30140. static readonly RIG_MODE_VR: number;
  30141. /**
  30142. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30143. */
  30144. static readonly RIG_MODE_WEBVR: number;
  30145. /**
  30146. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30147. */
  30148. static readonly RIG_MODE_CUSTOM: number;
  30149. /**
  30150. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30151. */
  30152. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30153. /**
  30154. * Define the input manager associated with the camera.
  30155. */
  30156. inputs: CameraInputsManager<Camera>;
  30157. /** @hidden */
  30158. _position: Vector3;
  30159. /**
  30160. * Define the current local position of the camera in the scene
  30161. */
  30162. get position(): Vector3;
  30163. set position(newPosition: Vector3);
  30164. /**
  30165. * The vector the camera should consider as up.
  30166. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30167. */
  30168. upVector: Vector3;
  30169. /**
  30170. * Define the current limit on the left side for an orthographic camera
  30171. * In scene unit
  30172. */
  30173. orthoLeft: Nullable<number>;
  30174. /**
  30175. * Define the current limit on the right side for an orthographic camera
  30176. * In scene unit
  30177. */
  30178. orthoRight: Nullable<number>;
  30179. /**
  30180. * Define the current limit on the bottom side for an orthographic camera
  30181. * In scene unit
  30182. */
  30183. orthoBottom: Nullable<number>;
  30184. /**
  30185. * Define the current limit on the top side for an orthographic camera
  30186. * In scene unit
  30187. */
  30188. orthoTop: Nullable<number>;
  30189. /**
  30190. * Field Of View is set in Radians. (default is 0.8)
  30191. */
  30192. fov: number;
  30193. /**
  30194. * Define the minimum distance the camera can see from.
  30195. * This is important to note that the depth buffer are not infinite and the closer it starts
  30196. * the more your scene might encounter depth fighting issue.
  30197. */
  30198. minZ: number;
  30199. /**
  30200. * Define the maximum distance the camera can see to.
  30201. * This is important to note that the depth buffer are not infinite and the further it end
  30202. * the more your scene might encounter depth fighting issue.
  30203. */
  30204. maxZ: number;
  30205. /**
  30206. * Define the default inertia of the camera.
  30207. * This helps giving a smooth feeling to the camera movement.
  30208. */
  30209. inertia: number;
  30210. /**
  30211. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30212. */
  30213. mode: number;
  30214. /**
  30215. * Define whether the camera is intermediate.
  30216. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30217. */
  30218. isIntermediate: boolean;
  30219. /**
  30220. * Define the viewport of the camera.
  30221. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30222. */
  30223. viewport: Viewport;
  30224. /**
  30225. * Restricts the camera to viewing objects with the same layerMask.
  30226. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30227. */
  30228. layerMask: number;
  30229. /**
  30230. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30231. */
  30232. fovMode: number;
  30233. /**
  30234. * Rig mode of the camera.
  30235. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30236. * This is normally controlled byt the camera themselves as internal use.
  30237. */
  30238. cameraRigMode: number;
  30239. /**
  30240. * Defines the distance between both "eyes" in case of a RIG
  30241. */
  30242. interaxialDistance: number;
  30243. /**
  30244. * Defines if stereoscopic rendering is done side by side or over under.
  30245. */
  30246. isStereoscopicSideBySide: boolean;
  30247. /**
  30248. * 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
  30249. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30250. * else in the scene. (Eg. security camera)
  30251. *
  30252. * 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)
  30253. */
  30254. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30255. /**
  30256. * When set, the camera will render to this render target instead of the default canvas
  30257. *
  30258. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30259. */
  30260. outputRenderTarget: Nullable<RenderTargetTexture>;
  30261. /**
  30262. * Observable triggered when the camera view matrix has changed.
  30263. */
  30264. onViewMatrixChangedObservable: Observable<Camera>;
  30265. /**
  30266. * Observable triggered when the camera Projection matrix has changed.
  30267. */
  30268. onProjectionMatrixChangedObservable: Observable<Camera>;
  30269. /**
  30270. * Observable triggered when the inputs have been processed.
  30271. */
  30272. onAfterCheckInputsObservable: Observable<Camera>;
  30273. /**
  30274. * Observable triggered when reset has been called and applied to the camera.
  30275. */
  30276. onRestoreStateObservable: Observable<Camera>;
  30277. /**
  30278. * Is this camera a part of a rig system?
  30279. */
  30280. isRigCamera: boolean;
  30281. /**
  30282. * If isRigCamera set to true this will be set with the parent camera.
  30283. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30284. */
  30285. rigParent?: Camera;
  30286. /** @hidden */
  30287. _cameraRigParams: any;
  30288. /** @hidden */
  30289. _rigCameras: Camera[];
  30290. /** @hidden */
  30291. _rigPostProcess: Nullable<PostProcess>;
  30292. protected _webvrViewMatrix: Matrix;
  30293. /** @hidden */
  30294. _skipRendering: boolean;
  30295. /** @hidden */
  30296. _projectionMatrix: Matrix;
  30297. /** @hidden */
  30298. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30299. /** @hidden */
  30300. _activeMeshes: SmartArray<AbstractMesh>;
  30301. protected _globalPosition: Vector3;
  30302. /** @hidden */
  30303. _computedViewMatrix: Matrix;
  30304. private _doNotComputeProjectionMatrix;
  30305. private _transformMatrix;
  30306. private _frustumPlanes;
  30307. private _refreshFrustumPlanes;
  30308. private _storedFov;
  30309. private _stateStored;
  30310. /**
  30311. * Instantiates a new camera object.
  30312. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30313. * @see https://doc.babylonjs.com/features/cameras
  30314. * @param name Defines the name of the camera in the scene
  30315. * @param position Defines the position of the camera
  30316. * @param scene Defines the scene the camera belongs too
  30317. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30318. */
  30319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30320. /**
  30321. * Store current camera state (fov, position, etc..)
  30322. * @returns the camera
  30323. */
  30324. storeState(): Camera;
  30325. /**
  30326. * Restores the camera state values if it has been stored. You must call storeState() first
  30327. */
  30328. protected _restoreStateValues(): boolean;
  30329. /**
  30330. * Restored camera state. You must call storeState() first.
  30331. * @returns true if restored and false otherwise
  30332. */
  30333. restoreState(): boolean;
  30334. /**
  30335. * Gets the class name of the camera.
  30336. * @returns the class name
  30337. */
  30338. getClassName(): string;
  30339. /** @hidden */
  30340. readonly _isCamera: boolean;
  30341. /**
  30342. * Gets a string representation of the camera useful for debug purpose.
  30343. * @param fullDetails Defines that a more verboe level of logging is required
  30344. * @returns the string representation
  30345. */
  30346. toString(fullDetails?: boolean): string;
  30347. /**
  30348. * Gets the current world space position of the camera.
  30349. */
  30350. get globalPosition(): Vector3;
  30351. /**
  30352. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30353. * @returns the active meshe list
  30354. */
  30355. getActiveMeshes(): SmartArray<AbstractMesh>;
  30356. /**
  30357. * Check whether a mesh is part of the current active mesh list of the camera
  30358. * @param mesh Defines the mesh to check
  30359. * @returns true if active, false otherwise
  30360. */
  30361. isActiveMesh(mesh: Mesh): boolean;
  30362. /**
  30363. * Is this camera ready to be used/rendered
  30364. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30365. * @return true if the camera is ready
  30366. */
  30367. isReady(completeCheck?: boolean): boolean;
  30368. /** @hidden */
  30369. _initCache(): void;
  30370. /** @hidden */
  30371. _updateCache(ignoreParentClass?: boolean): void;
  30372. /** @hidden */
  30373. _isSynchronized(): boolean;
  30374. /** @hidden */
  30375. _isSynchronizedViewMatrix(): boolean;
  30376. /** @hidden */
  30377. _isSynchronizedProjectionMatrix(): boolean;
  30378. /**
  30379. * Attach the input controls to a specific dom element to get the input from.
  30380. * @param element Defines the element the controls should be listened from
  30381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30382. */
  30383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30384. /**
  30385. * Detach the current controls from the specified dom element.
  30386. * @param element Defines the element to stop listening the inputs from
  30387. */
  30388. detachControl(element: HTMLElement): void;
  30389. /**
  30390. * Update the camera state according to the different inputs gathered during the frame.
  30391. */
  30392. update(): void;
  30393. /** @hidden */
  30394. _checkInputs(): void;
  30395. /** @hidden */
  30396. get rigCameras(): Camera[];
  30397. /**
  30398. * Gets the post process used by the rig cameras
  30399. */
  30400. get rigPostProcess(): Nullable<PostProcess>;
  30401. /**
  30402. * Internal, gets the first post proces.
  30403. * @returns the first post process to be run on this camera.
  30404. */
  30405. _getFirstPostProcess(): Nullable<PostProcess>;
  30406. private _cascadePostProcessesToRigCams;
  30407. /**
  30408. * Attach a post process to the camera.
  30409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30410. * @param postProcess The post process to attach to the camera
  30411. * @param insertAt The position of the post process in case several of them are in use in the scene
  30412. * @returns the position the post process has been inserted at
  30413. */
  30414. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30415. /**
  30416. * Detach a post process to the camera.
  30417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30418. * @param postProcess The post process to detach from the camera
  30419. */
  30420. detachPostProcess(postProcess: PostProcess): void;
  30421. /**
  30422. * Gets the current world matrix of the camera
  30423. */
  30424. getWorldMatrix(): Matrix;
  30425. /** @hidden */
  30426. _getViewMatrix(): Matrix;
  30427. /**
  30428. * Gets the current view matrix of the camera.
  30429. * @param force forces the camera to recompute the matrix without looking at the cached state
  30430. * @returns the view matrix
  30431. */
  30432. getViewMatrix(force?: boolean): Matrix;
  30433. /**
  30434. * Freeze the projection matrix.
  30435. * It will prevent the cache check of the camera projection compute and can speed up perf
  30436. * if no parameter of the camera are meant to change
  30437. * @param projection Defines manually a projection if necessary
  30438. */
  30439. freezeProjectionMatrix(projection?: Matrix): void;
  30440. /**
  30441. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30442. */
  30443. unfreezeProjectionMatrix(): void;
  30444. /**
  30445. * Gets the current projection matrix of the camera.
  30446. * @param force forces the camera to recompute the matrix without looking at the cached state
  30447. * @returns the projection matrix
  30448. */
  30449. getProjectionMatrix(force?: boolean): Matrix;
  30450. /**
  30451. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30452. * @returns a Matrix
  30453. */
  30454. getTransformationMatrix(): Matrix;
  30455. private _updateFrustumPlanes;
  30456. /**
  30457. * Checks if a cullable object (mesh...) is in the camera frustum
  30458. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30459. * @param target The object to check
  30460. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30461. * @returns true if the object is in frustum otherwise false
  30462. */
  30463. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30464. /**
  30465. * Checks if a cullable object (mesh...) is in the camera frustum
  30466. * Unlike isInFrustum this cheks the full bounding box
  30467. * @param target The object to check
  30468. * @returns true if the object is in frustum otherwise false
  30469. */
  30470. isCompletelyInFrustum(target: ICullable): boolean;
  30471. /**
  30472. * Gets a ray in the forward direction from the camera.
  30473. * @param length Defines the length of the ray to create
  30474. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30475. * @param origin Defines the start point of the ray which defaults to the camera position
  30476. * @returns the forward ray
  30477. */
  30478. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30479. /**
  30480. * Releases resources associated with this node.
  30481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30483. */
  30484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30485. /** @hidden */
  30486. _isLeftCamera: boolean;
  30487. /**
  30488. * Gets the left camera of a rig setup in case of Rigged Camera
  30489. */
  30490. get isLeftCamera(): boolean;
  30491. /** @hidden */
  30492. _isRightCamera: boolean;
  30493. /**
  30494. * Gets the right camera of a rig setup in case of Rigged Camera
  30495. */
  30496. get isRightCamera(): boolean;
  30497. /**
  30498. * Gets the left camera of a rig setup in case of Rigged Camera
  30499. */
  30500. get leftCamera(): Nullable<FreeCamera>;
  30501. /**
  30502. * Gets the right camera of a rig setup in case of Rigged Camera
  30503. */
  30504. get rightCamera(): Nullable<FreeCamera>;
  30505. /**
  30506. * Gets the left camera target of a rig setup in case of Rigged Camera
  30507. * @returns the target position
  30508. */
  30509. getLeftTarget(): Nullable<Vector3>;
  30510. /**
  30511. * Gets the right camera target of a rig setup in case of Rigged Camera
  30512. * @returns the target position
  30513. */
  30514. getRightTarget(): Nullable<Vector3>;
  30515. /**
  30516. * @hidden
  30517. */
  30518. setCameraRigMode(mode: number, rigParams: any): void;
  30519. /** @hidden */
  30520. static _setStereoscopicRigMode(camera: Camera): void;
  30521. /** @hidden */
  30522. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30523. /** @hidden */
  30524. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30525. /** @hidden */
  30526. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30527. /** @hidden */
  30528. _getVRProjectionMatrix(): Matrix;
  30529. protected _updateCameraRotationMatrix(): void;
  30530. protected _updateWebVRCameraRotationMatrix(): void;
  30531. /**
  30532. * This function MUST be overwritten by the different WebVR cameras available.
  30533. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30534. * @hidden
  30535. */
  30536. _getWebVRProjectionMatrix(): Matrix;
  30537. /**
  30538. * This function MUST be overwritten by the different WebVR cameras available.
  30539. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30540. * @hidden
  30541. */
  30542. _getWebVRViewMatrix(): Matrix;
  30543. /** @hidden */
  30544. setCameraRigParameter(name: string, value: any): void;
  30545. /**
  30546. * needs to be overridden by children so sub has required properties to be copied
  30547. * @hidden
  30548. */
  30549. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30550. /**
  30551. * May need to be overridden by children
  30552. * @hidden
  30553. */
  30554. _updateRigCameras(): void;
  30555. /** @hidden */
  30556. _setupInputs(): void;
  30557. /**
  30558. * Serialiaze the camera setup to a json represention
  30559. * @returns the JSON representation
  30560. */
  30561. serialize(): any;
  30562. /**
  30563. * Clones the current camera.
  30564. * @param name The cloned camera name
  30565. * @returns the cloned camera
  30566. */
  30567. clone(name: string): Camera;
  30568. /**
  30569. * Gets the direction of the camera relative to a given local axis.
  30570. * @param localAxis Defines the reference axis to provide a relative direction.
  30571. * @return the direction
  30572. */
  30573. getDirection(localAxis: Vector3): Vector3;
  30574. /**
  30575. * Returns the current camera absolute rotation
  30576. */
  30577. get absoluteRotation(): Quaternion;
  30578. /**
  30579. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30580. * @param localAxis Defines the reference axis to provide a relative direction.
  30581. * @param result Defines the vector to store the result in
  30582. */
  30583. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30584. /**
  30585. * Gets a camera constructor for a given camera type
  30586. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30587. * @param name The name of the camera the result will be able to instantiate
  30588. * @param scene The scene the result will construct the camera in
  30589. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30590. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30591. * @returns a factory method to construc the camera
  30592. */
  30593. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30594. /**
  30595. * Compute the world matrix of the camera.
  30596. * @returns the camera world matrix
  30597. */
  30598. computeWorldMatrix(): Matrix;
  30599. /**
  30600. * Parse a JSON and creates the camera from the parsed information
  30601. * @param parsedCamera The JSON to parse
  30602. * @param scene The scene to instantiate the camera in
  30603. * @returns the newly constructed camera
  30604. */
  30605. static Parse(parsedCamera: any, scene: Scene): Camera;
  30606. }
  30607. }
  30608. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30609. import { Nullable } from "babylonjs/types";
  30610. import { Scene } from "babylonjs/scene";
  30611. import { Vector4 } from "babylonjs/Maths/math.vector";
  30612. import { Mesh } from "babylonjs/Meshes/mesh";
  30613. /**
  30614. * Class containing static functions to help procedurally build meshes
  30615. */
  30616. export class DiscBuilder {
  30617. /**
  30618. * Creates a plane polygonal mesh. By default, this is a disc
  30619. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30620. * * 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
  30621. * * 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
  30622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30625. * @param name defines the name of the mesh
  30626. * @param options defines the options used to create the mesh
  30627. * @param scene defines the hosting scene
  30628. * @returns the plane polygonal mesh
  30629. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30630. */
  30631. static CreateDisc(name: string, options: {
  30632. radius?: number;
  30633. tessellation?: number;
  30634. arc?: number;
  30635. updatable?: boolean;
  30636. sideOrientation?: number;
  30637. frontUVs?: Vector4;
  30638. backUVs?: Vector4;
  30639. }, scene?: Nullable<Scene>): Mesh;
  30640. }
  30641. }
  30642. declare module "babylonjs/Materials/fresnelParameters" {
  30643. import { DeepImmutable } from "babylonjs/types";
  30644. import { Color3 } from "babylonjs/Maths/math.color";
  30645. /**
  30646. * Options to be used when creating a FresnelParameters.
  30647. */
  30648. export type IFresnelParametersCreationOptions = {
  30649. /**
  30650. * Define the color used on edges (grazing angle)
  30651. */
  30652. leftColor?: Color3;
  30653. /**
  30654. * Define the color used on center
  30655. */
  30656. rightColor?: Color3;
  30657. /**
  30658. * Define bias applied to computed fresnel term
  30659. */
  30660. bias?: number;
  30661. /**
  30662. * Defined the power exponent applied to fresnel term
  30663. */
  30664. power?: number;
  30665. /**
  30666. * Define if the fresnel effect is enable or not.
  30667. */
  30668. isEnabled?: boolean;
  30669. };
  30670. /**
  30671. * Serialized format for FresnelParameters.
  30672. */
  30673. export type IFresnelParametersSerialized = {
  30674. /**
  30675. * Define the color used on edges (grazing angle) [as an array]
  30676. */
  30677. leftColor: number[];
  30678. /**
  30679. * Define the color used on center [as an array]
  30680. */
  30681. rightColor: number[];
  30682. /**
  30683. * Define bias applied to computed fresnel term
  30684. */
  30685. bias: number;
  30686. /**
  30687. * Defined the power exponent applied to fresnel term
  30688. */
  30689. power?: number;
  30690. /**
  30691. * Define if the fresnel effect is enable or not.
  30692. */
  30693. isEnabled: boolean;
  30694. };
  30695. /**
  30696. * This represents all the required information to add a fresnel effect on a material:
  30697. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30698. */
  30699. export class FresnelParameters {
  30700. private _isEnabled;
  30701. /**
  30702. * Define if the fresnel effect is enable or not.
  30703. */
  30704. get isEnabled(): boolean;
  30705. set isEnabled(value: boolean);
  30706. /**
  30707. * Define the color used on edges (grazing angle)
  30708. */
  30709. leftColor: Color3;
  30710. /**
  30711. * Define the color used on center
  30712. */
  30713. rightColor: Color3;
  30714. /**
  30715. * Define bias applied to computed fresnel term
  30716. */
  30717. bias: number;
  30718. /**
  30719. * Defined the power exponent applied to fresnel term
  30720. */
  30721. power: number;
  30722. /**
  30723. * Creates a new FresnelParameters object.
  30724. *
  30725. * @param options provide your own settings to optionally to override defaults
  30726. */
  30727. constructor(options?: IFresnelParametersCreationOptions);
  30728. /**
  30729. * Clones the current fresnel and its valuues
  30730. * @returns a clone fresnel configuration
  30731. */
  30732. clone(): FresnelParameters;
  30733. /**
  30734. * Determines equality between FresnelParameters objects
  30735. * @param otherFresnelParameters defines the second operand
  30736. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30737. */
  30738. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30739. /**
  30740. * Serializes the current fresnel parameters to a JSON representation.
  30741. * @return the JSON serialization
  30742. */
  30743. serialize(): IFresnelParametersSerialized;
  30744. /**
  30745. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30746. * @param parsedFresnelParameters Define the JSON representation
  30747. * @returns the parsed parameters
  30748. */
  30749. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30750. }
  30751. }
  30752. declare module "babylonjs/Materials/materialFlags" {
  30753. /**
  30754. * This groups all the flags used to control the materials channel.
  30755. */
  30756. export class MaterialFlags {
  30757. private static _DiffuseTextureEnabled;
  30758. /**
  30759. * Are diffuse textures enabled in the application.
  30760. */
  30761. static get DiffuseTextureEnabled(): boolean;
  30762. static set DiffuseTextureEnabled(value: boolean);
  30763. private static _DetailTextureEnabled;
  30764. /**
  30765. * Are detail textures enabled in the application.
  30766. */
  30767. static get DetailTextureEnabled(): boolean;
  30768. static set DetailTextureEnabled(value: boolean);
  30769. private static _AmbientTextureEnabled;
  30770. /**
  30771. * Are ambient textures enabled in the application.
  30772. */
  30773. static get AmbientTextureEnabled(): boolean;
  30774. static set AmbientTextureEnabled(value: boolean);
  30775. private static _OpacityTextureEnabled;
  30776. /**
  30777. * Are opacity textures enabled in the application.
  30778. */
  30779. static get OpacityTextureEnabled(): boolean;
  30780. static set OpacityTextureEnabled(value: boolean);
  30781. private static _ReflectionTextureEnabled;
  30782. /**
  30783. * Are reflection textures enabled in the application.
  30784. */
  30785. static get ReflectionTextureEnabled(): boolean;
  30786. static set ReflectionTextureEnabled(value: boolean);
  30787. private static _EmissiveTextureEnabled;
  30788. /**
  30789. * Are emissive textures enabled in the application.
  30790. */
  30791. static get EmissiveTextureEnabled(): boolean;
  30792. static set EmissiveTextureEnabled(value: boolean);
  30793. private static _SpecularTextureEnabled;
  30794. /**
  30795. * Are specular textures enabled in the application.
  30796. */
  30797. static get SpecularTextureEnabled(): boolean;
  30798. static set SpecularTextureEnabled(value: boolean);
  30799. private static _BumpTextureEnabled;
  30800. /**
  30801. * Are bump textures enabled in the application.
  30802. */
  30803. static get BumpTextureEnabled(): boolean;
  30804. static set BumpTextureEnabled(value: boolean);
  30805. private static _LightmapTextureEnabled;
  30806. /**
  30807. * Are lightmap textures enabled in the application.
  30808. */
  30809. static get LightmapTextureEnabled(): boolean;
  30810. static set LightmapTextureEnabled(value: boolean);
  30811. private static _RefractionTextureEnabled;
  30812. /**
  30813. * Are refraction textures enabled in the application.
  30814. */
  30815. static get RefractionTextureEnabled(): boolean;
  30816. static set RefractionTextureEnabled(value: boolean);
  30817. private static _ColorGradingTextureEnabled;
  30818. /**
  30819. * Are color grading textures enabled in the application.
  30820. */
  30821. static get ColorGradingTextureEnabled(): boolean;
  30822. static set ColorGradingTextureEnabled(value: boolean);
  30823. private static _FresnelEnabled;
  30824. /**
  30825. * Are fresnels enabled in the application.
  30826. */
  30827. static get FresnelEnabled(): boolean;
  30828. static set FresnelEnabled(value: boolean);
  30829. private static _ClearCoatTextureEnabled;
  30830. /**
  30831. * Are clear coat textures enabled in the application.
  30832. */
  30833. static get ClearCoatTextureEnabled(): boolean;
  30834. static set ClearCoatTextureEnabled(value: boolean);
  30835. private static _ClearCoatBumpTextureEnabled;
  30836. /**
  30837. * Are clear coat bump textures enabled in the application.
  30838. */
  30839. static get ClearCoatBumpTextureEnabled(): boolean;
  30840. static set ClearCoatBumpTextureEnabled(value: boolean);
  30841. private static _ClearCoatTintTextureEnabled;
  30842. /**
  30843. * Are clear coat tint textures enabled in the application.
  30844. */
  30845. static get ClearCoatTintTextureEnabled(): boolean;
  30846. static set ClearCoatTintTextureEnabled(value: boolean);
  30847. private static _SheenTextureEnabled;
  30848. /**
  30849. * Are sheen textures enabled in the application.
  30850. */
  30851. static get SheenTextureEnabled(): boolean;
  30852. static set SheenTextureEnabled(value: boolean);
  30853. private static _AnisotropicTextureEnabled;
  30854. /**
  30855. * Are anisotropic textures enabled in the application.
  30856. */
  30857. static get AnisotropicTextureEnabled(): boolean;
  30858. static set AnisotropicTextureEnabled(value: boolean);
  30859. private static _ThicknessTextureEnabled;
  30860. /**
  30861. * Are thickness textures enabled in the application.
  30862. */
  30863. static get ThicknessTextureEnabled(): boolean;
  30864. static set ThicknessTextureEnabled(value: boolean);
  30865. }
  30866. }
  30867. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30868. /** @hidden */
  30869. export var defaultFragmentDeclaration: {
  30870. name: string;
  30871. shader: string;
  30872. };
  30873. }
  30874. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30875. /** @hidden */
  30876. export var defaultUboDeclaration: {
  30877. name: string;
  30878. shader: string;
  30879. };
  30880. }
  30881. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30882. /** @hidden */
  30883. export var prePassDeclaration: {
  30884. name: string;
  30885. shader: string;
  30886. };
  30887. }
  30888. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30889. /** @hidden */
  30890. export var lightFragmentDeclaration: {
  30891. name: string;
  30892. shader: string;
  30893. };
  30894. }
  30895. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30896. /** @hidden */
  30897. export var lightUboDeclaration: {
  30898. name: string;
  30899. shader: string;
  30900. };
  30901. }
  30902. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30903. /** @hidden */
  30904. export var lightsFragmentFunctions: {
  30905. name: string;
  30906. shader: string;
  30907. };
  30908. }
  30909. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30910. /** @hidden */
  30911. export var shadowsFragmentFunctions: {
  30912. name: string;
  30913. shader: string;
  30914. };
  30915. }
  30916. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30917. /** @hidden */
  30918. export var fresnelFunction: {
  30919. name: string;
  30920. shader: string;
  30921. };
  30922. }
  30923. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30924. /** @hidden */
  30925. export var bumpFragmentMainFunctions: {
  30926. name: string;
  30927. shader: string;
  30928. };
  30929. }
  30930. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30931. /** @hidden */
  30932. export var bumpFragmentFunctions: {
  30933. name: string;
  30934. shader: string;
  30935. };
  30936. }
  30937. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30938. /** @hidden */
  30939. export var logDepthDeclaration: {
  30940. name: string;
  30941. shader: string;
  30942. };
  30943. }
  30944. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30945. /** @hidden */
  30946. export var bumpFragment: {
  30947. name: string;
  30948. shader: string;
  30949. };
  30950. }
  30951. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30952. /** @hidden */
  30953. export var depthPrePass: {
  30954. name: string;
  30955. shader: string;
  30956. };
  30957. }
  30958. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30959. /** @hidden */
  30960. export var lightFragment: {
  30961. name: string;
  30962. shader: string;
  30963. };
  30964. }
  30965. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30966. /** @hidden */
  30967. export var logDepthFragment: {
  30968. name: string;
  30969. shader: string;
  30970. };
  30971. }
  30972. declare module "babylonjs/Shaders/default.fragment" {
  30973. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30974. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30975. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  30976. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30977. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30978. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30979. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30980. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30981. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30982. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30983. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30984. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30985. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30986. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30987. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30988. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30989. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30990. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30991. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30992. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30993. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30994. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30995. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30996. /** @hidden */
  30997. export var defaultPixelShader: {
  30998. name: string;
  30999. shader: string;
  31000. };
  31001. }
  31002. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31003. /** @hidden */
  31004. export var defaultVertexDeclaration: {
  31005. name: string;
  31006. shader: string;
  31007. };
  31008. }
  31009. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31010. /** @hidden */
  31011. export var bumpVertexDeclaration: {
  31012. name: string;
  31013. shader: string;
  31014. };
  31015. }
  31016. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31017. /** @hidden */
  31018. export var bumpVertex: {
  31019. name: string;
  31020. shader: string;
  31021. };
  31022. }
  31023. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31024. /** @hidden */
  31025. export var fogVertex: {
  31026. name: string;
  31027. shader: string;
  31028. };
  31029. }
  31030. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31031. /** @hidden */
  31032. export var shadowsVertex: {
  31033. name: string;
  31034. shader: string;
  31035. };
  31036. }
  31037. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31038. /** @hidden */
  31039. export var pointCloudVertex: {
  31040. name: string;
  31041. shader: string;
  31042. };
  31043. }
  31044. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31045. /** @hidden */
  31046. export var logDepthVertex: {
  31047. name: string;
  31048. shader: string;
  31049. };
  31050. }
  31051. declare module "babylonjs/Shaders/default.vertex" {
  31052. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31053. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31054. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31055. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31056. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31057. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31058. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31059. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31060. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31061. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31062. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31063. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31064. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31065. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31066. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31067. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31068. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31069. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31070. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31071. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31072. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31073. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31074. /** @hidden */
  31075. export var defaultVertexShader: {
  31076. name: string;
  31077. shader: string;
  31078. };
  31079. }
  31080. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31081. import { Nullable } from "babylonjs/types";
  31082. import { Scene } from "babylonjs/scene";
  31083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31084. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31085. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31086. /**
  31087. * @hidden
  31088. */
  31089. export interface IMaterialDetailMapDefines {
  31090. DETAIL: boolean;
  31091. DETAILDIRECTUV: number;
  31092. DETAIL_NORMALBLENDMETHOD: number;
  31093. /** @hidden */
  31094. _areTexturesDirty: boolean;
  31095. }
  31096. /**
  31097. * Define the code related to the detail map parameters of a material
  31098. *
  31099. * Inspired from:
  31100. * 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
  31101. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31102. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31103. */
  31104. export class DetailMapConfiguration {
  31105. private _texture;
  31106. /**
  31107. * The detail texture of the material.
  31108. */
  31109. texture: Nullable<BaseTexture>;
  31110. /**
  31111. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31112. * Bigger values mean stronger blending
  31113. */
  31114. diffuseBlendLevel: number;
  31115. /**
  31116. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31117. * Bigger values mean stronger blending. Only used with PBR materials
  31118. */
  31119. roughnessBlendLevel: number;
  31120. /**
  31121. * Defines how strong the bump effect from the detail map is
  31122. * Bigger values mean stronger effect
  31123. */
  31124. bumpLevel: number;
  31125. private _normalBlendMethod;
  31126. /**
  31127. * The method used to blend the bump and detail normals together
  31128. */
  31129. normalBlendMethod: number;
  31130. private _isEnabled;
  31131. /**
  31132. * Enable or disable the detail map on this material
  31133. */
  31134. isEnabled: boolean;
  31135. /** @hidden */
  31136. private _internalMarkAllSubMeshesAsTexturesDirty;
  31137. /** @hidden */
  31138. _markAllSubMeshesAsTexturesDirty(): void;
  31139. /**
  31140. * Instantiate a new detail map
  31141. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31142. */
  31143. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31144. /**
  31145. * Gets whether the submesh is ready to be used or not.
  31146. * @param defines the list of "defines" to update.
  31147. * @param scene defines the scene the material belongs to.
  31148. * @returns - boolean indicating that the submesh is ready or not.
  31149. */
  31150. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31151. /**
  31152. * Update the defines for detail map usage
  31153. * @param defines the list of "defines" to update.
  31154. * @param scene defines the scene the material belongs to.
  31155. */
  31156. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31157. /**
  31158. * Binds the material data.
  31159. * @param uniformBuffer defines the Uniform buffer to fill in.
  31160. * @param scene defines the scene the material belongs to.
  31161. * @param isFrozen defines whether the material is frozen or not.
  31162. */
  31163. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31164. /**
  31165. * Checks to see if a texture is used in the material.
  31166. * @param texture - Base texture to use.
  31167. * @returns - Boolean specifying if a texture is used in the material.
  31168. */
  31169. hasTexture(texture: BaseTexture): boolean;
  31170. /**
  31171. * Returns an array of the actively used textures.
  31172. * @param activeTextures Array of BaseTextures
  31173. */
  31174. getActiveTextures(activeTextures: BaseTexture[]): void;
  31175. /**
  31176. * Returns the animatable textures.
  31177. * @param animatables Array of animatable textures.
  31178. */
  31179. getAnimatables(animatables: IAnimatable[]): void;
  31180. /**
  31181. * Disposes the resources of the material.
  31182. * @param forceDisposeTextures - Forces the disposal of all textures.
  31183. */
  31184. dispose(forceDisposeTextures?: boolean): void;
  31185. /**
  31186. * Get the current class name useful for serialization or dynamic coding.
  31187. * @returns "DetailMap"
  31188. */
  31189. getClassName(): string;
  31190. /**
  31191. * Add the required uniforms to the current list.
  31192. * @param uniforms defines the current uniform list.
  31193. */
  31194. static AddUniforms(uniforms: string[]): void;
  31195. /**
  31196. * Add the required samplers to the current list.
  31197. * @param samplers defines the current sampler list.
  31198. */
  31199. static AddSamplers(samplers: string[]): void;
  31200. /**
  31201. * Add the required uniforms to the current buffer.
  31202. * @param uniformBuffer defines the current uniform buffer.
  31203. */
  31204. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31205. /**
  31206. * Makes a duplicate of the current instance into another one.
  31207. * @param detailMap define the instance where to copy the info
  31208. */
  31209. copyTo(detailMap: DetailMapConfiguration): void;
  31210. /**
  31211. * Serializes this detail map instance
  31212. * @returns - An object with the serialized instance.
  31213. */
  31214. serialize(): any;
  31215. /**
  31216. * Parses a detail map setting from a serialized object.
  31217. * @param source - Serialized object.
  31218. * @param scene Defines the scene we are parsing for
  31219. * @param rootUrl Defines the rootUrl to load from
  31220. */
  31221. parse(source: any, scene: Scene, rootUrl: string): void;
  31222. }
  31223. }
  31224. declare module "babylonjs/Materials/standardMaterial" {
  31225. import { SmartArray } from "babylonjs/Misc/smartArray";
  31226. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31227. import { Nullable } from "babylonjs/types";
  31228. import { Scene } from "babylonjs/scene";
  31229. import { Matrix } from "babylonjs/Maths/math.vector";
  31230. import { Color3 } from "babylonjs/Maths/math.color";
  31231. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31233. import { Mesh } from "babylonjs/Meshes/mesh";
  31234. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31235. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31236. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31237. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31238. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31241. import "babylonjs/Shaders/default.fragment";
  31242. import "babylonjs/Shaders/default.vertex";
  31243. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31244. /** @hidden */
  31245. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31246. MAINUV1: boolean;
  31247. MAINUV2: boolean;
  31248. DIFFUSE: boolean;
  31249. DIFFUSEDIRECTUV: number;
  31250. DETAIL: boolean;
  31251. DETAILDIRECTUV: number;
  31252. DETAIL_NORMALBLENDMETHOD: number;
  31253. AMBIENT: boolean;
  31254. AMBIENTDIRECTUV: number;
  31255. OPACITY: boolean;
  31256. OPACITYDIRECTUV: number;
  31257. OPACITYRGB: boolean;
  31258. REFLECTION: boolean;
  31259. EMISSIVE: boolean;
  31260. EMISSIVEDIRECTUV: number;
  31261. SPECULAR: boolean;
  31262. SPECULARDIRECTUV: number;
  31263. BUMP: boolean;
  31264. BUMPDIRECTUV: number;
  31265. PARALLAX: boolean;
  31266. PARALLAXOCCLUSION: boolean;
  31267. SPECULAROVERALPHA: boolean;
  31268. CLIPPLANE: boolean;
  31269. CLIPPLANE2: boolean;
  31270. CLIPPLANE3: boolean;
  31271. CLIPPLANE4: boolean;
  31272. CLIPPLANE5: boolean;
  31273. CLIPPLANE6: boolean;
  31274. ALPHATEST: boolean;
  31275. DEPTHPREPASS: boolean;
  31276. ALPHAFROMDIFFUSE: boolean;
  31277. POINTSIZE: boolean;
  31278. FOG: boolean;
  31279. SPECULARTERM: boolean;
  31280. DIFFUSEFRESNEL: boolean;
  31281. OPACITYFRESNEL: boolean;
  31282. REFLECTIONFRESNEL: boolean;
  31283. REFRACTIONFRESNEL: boolean;
  31284. EMISSIVEFRESNEL: boolean;
  31285. FRESNEL: boolean;
  31286. NORMAL: boolean;
  31287. UV1: boolean;
  31288. UV2: boolean;
  31289. VERTEXCOLOR: boolean;
  31290. VERTEXALPHA: boolean;
  31291. NUM_BONE_INFLUENCERS: number;
  31292. BonesPerMesh: number;
  31293. BONETEXTURE: boolean;
  31294. INSTANCES: boolean;
  31295. THIN_INSTANCES: boolean;
  31296. GLOSSINESS: boolean;
  31297. ROUGHNESS: boolean;
  31298. EMISSIVEASILLUMINATION: boolean;
  31299. LINKEMISSIVEWITHDIFFUSE: boolean;
  31300. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31301. LIGHTMAP: boolean;
  31302. LIGHTMAPDIRECTUV: number;
  31303. OBJECTSPACE_NORMALMAP: boolean;
  31304. USELIGHTMAPASSHADOWMAP: boolean;
  31305. REFLECTIONMAP_3D: boolean;
  31306. REFLECTIONMAP_SPHERICAL: boolean;
  31307. REFLECTIONMAP_PLANAR: boolean;
  31308. REFLECTIONMAP_CUBIC: boolean;
  31309. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31310. REFLECTIONMAP_PROJECTION: boolean;
  31311. REFLECTIONMAP_SKYBOX: boolean;
  31312. REFLECTIONMAP_EXPLICIT: boolean;
  31313. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31314. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31315. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31316. INVERTCUBICMAP: boolean;
  31317. LOGARITHMICDEPTH: boolean;
  31318. REFRACTION: boolean;
  31319. REFRACTIONMAP_3D: boolean;
  31320. REFLECTIONOVERALPHA: boolean;
  31321. TWOSIDEDLIGHTING: boolean;
  31322. SHADOWFLOAT: boolean;
  31323. MORPHTARGETS: boolean;
  31324. MORPHTARGETS_NORMAL: boolean;
  31325. MORPHTARGETS_TANGENT: boolean;
  31326. MORPHTARGETS_UV: boolean;
  31327. NUM_MORPH_INFLUENCERS: number;
  31328. NONUNIFORMSCALING: boolean;
  31329. PREMULTIPLYALPHA: boolean;
  31330. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31331. ALPHABLEND: boolean;
  31332. PREPASS: boolean;
  31333. SCENE_MRT_COUNT: number;
  31334. RGBDLIGHTMAP: boolean;
  31335. RGBDREFLECTION: boolean;
  31336. RGBDREFRACTION: boolean;
  31337. IMAGEPROCESSING: boolean;
  31338. VIGNETTE: boolean;
  31339. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31340. VIGNETTEBLENDMODEOPAQUE: boolean;
  31341. TONEMAPPING: boolean;
  31342. TONEMAPPING_ACES: boolean;
  31343. CONTRAST: boolean;
  31344. COLORCURVES: boolean;
  31345. COLORGRADING: boolean;
  31346. COLORGRADING3D: boolean;
  31347. SAMPLER3DGREENDEPTH: boolean;
  31348. SAMPLER3DBGRMAP: boolean;
  31349. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31350. MULTIVIEW: boolean;
  31351. /**
  31352. * If the reflection texture on this material is in linear color space
  31353. * @hidden
  31354. */
  31355. IS_REFLECTION_LINEAR: boolean;
  31356. /**
  31357. * If the refraction texture on this material is in linear color space
  31358. * @hidden
  31359. */
  31360. IS_REFRACTION_LINEAR: boolean;
  31361. EXPOSURE: boolean;
  31362. constructor();
  31363. setReflectionMode(modeToEnable: string): void;
  31364. }
  31365. /**
  31366. * This is the default material used in Babylon. It is the best trade off between quality
  31367. * and performances.
  31368. * @see https://doc.babylonjs.com/babylon101/materials
  31369. */
  31370. export class StandardMaterial extends PushMaterial {
  31371. private _diffuseTexture;
  31372. /**
  31373. * The basic texture of the material as viewed under a light.
  31374. */
  31375. diffuseTexture: Nullable<BaseTexture>;
  31376. private _ambientTexture;
  31377. /**
  31378. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31379. */
  31380. ambientTexture: Nullable<BaseTexture>;
  31381. private _opacityTexture;
  31382. /**
  31383. * Define the transparency of the material from a texture.
  31384. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31385. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31386. */
  31387. opacityTexture: Nullable<BaseTexture>;
  31388. private _reflectionTexture;
  31389. /**
  31390. * Define the texture used to display the reflection.
  31391. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31392. */
  31393. reflectionTexture: Nullable<BaseTexture>;
  31394. private _emissiveTexture;
  31395. /**
  31396. * Define texture of the material as if self lit.
  31397. * This will be mixed in the final result even in the absence of light.
  31398. */
  31399. emissiveTexture: Nullable<BaseTexture>;
  31400. private _specularTexture;
  31401. /**
  31402. * Define how the color and intensity of the highlight given by the light in the material.
  31403. */
  31404. specularTexture: Nullable<BaseTexture>;
  31405. private _bumpTexture;
  31406. /**
  31407. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31408. * 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.
  31409. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31410. */
  31411. bumpTexture: Nullable<BaseTexture>;
  31412. private _lightmapTexture;
  31413. /**
  31414. * Complex lighting can be computationally expensive to compute at runtime.
  31415. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31416. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31417. */
  31418. lightmapTexture: Nullable<BaseTexture>;
  31419. private _refractionTexture;
  31420. /**
  31421. * Define the texture used to display the refraction.
  31422. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31423. */
  31424. refractionTexture: Nullable<BaseTexture>;
  31425. /**
  31426. * The color of the material lit by the environmental background lighting.
  31427. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31428. */
  31429. ambientColor: Color3;
  31430. /**
  31431. * The basic color of the material as viewed under a light.
  31432. */
  31433. diffuseColor: Color3;
  31434. /**
  31435. * Define how the color and intensity of the highlight given by the light in the material.
  31436. */
  31437. specularColor: Color3;
  31438. /**
  31439. * Define the color of the material as if self lit.
  31440. * This will be mixed in the final result even in the absence of light.
  31441. */
  31442. emissiveColor: Color3;
  31443. /**
  31444. * Defines how sharp are the highlights in the material.
  31445. * The bigger the value the sharper giving a more glossy feeling to the result.
  31446. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31447. */
  31448. specularPower: number;
  31449. private _useAlphaFromDiffuseTexture;
  31450. /**
  31451. * Does the transparency come from the diffuse texture alpha channel.
  31452. */
  31453. useAlphaFromDiffuseTexture: boolean;
  31454. private _useEmissiveAsIllumination;
  31455. /**
  31456. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31457. */
  31458. useEmissiveAsIllumination: boolean;
  31459. private _linkEmissiveWithDiffuse;
  31460. /**
  31461. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31462. * the emissive level when the final color is close to one.
  31463. */
  31464. linkEmissiveWithDiffuse: boolean;
  31465. private _useSpecularOverAlpha;
  31466. /**
  31467. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31468. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31469. */
  31470. useSpecularOverAlpha: boolean;
  31471. private _useReflectionOverAlpha;
  31472. /**
  31473. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31474. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31475. */
  31476. useReflectionOverAlpha: boolean;
  31477. private _disableLighting;
  31478. /**
  31479. * Does lights from the scene impacts this material.
  31480. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31481. */
  31482. disableLighting: boolean;
  31483. private _useObjectSpaceNormalMap;
  31484. /**
  31485. * Allows using an object space normal map (instead of tangent space).
  31486. */
  31487. useObjectSpaceNormalMap: boolean;
  31488. private _useParallax;
  31489. /**
  31490. * Is parallax enabled or not.
  31491. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31492. */
  31493. useParallax: boolean;
  31494. private _useParallaxOcclusion;
  31495. /**
  31496. * Is parallax occlusion enabled or not.
  31497. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31498. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31499. */
  31500. useParallaxOcclusion: boolean;
  31501. /**
  31502. * 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.
  31503. */
  31504. parallaxScaleBias: number;
  31505. private _roughness;
  31506. /**
  31507. * Helps to define how blurry the reflections should appears in the material.
  31508. */
  31509. roughness: number;
  31510. /**
  31511. * In case of refraction, define the value of the index of refraction.
  31512. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31513. */
  31514. indexOfRefraction: number;
  31515. /**
  31516. * Invert the refraction texture alongside the y axis.
  31517. * It can be useful with procedural textures or probe for instance.
  31518. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31519. */
  31520. invertRefractionY: boolean;
  31521. /**
  31522. * Defines the alpha limits in alpha test mode.
  31523. */
  31524. alphaCutOff: number;
  31525. private _useLightmapAsShadowmap;
  31526. /**
  31527. * In case of light mapping, define whether the map contains light or shadow informations.
  31528. */
  31529. useLightmapAsShadowmap: boolean;
  31530. private _diffuseFresnelParameters;
  31531. /**
  31532. * Define the diffuse fresnel parameters of the material.
  31533. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31534. */
  31535. diffuseFresnelParameters: FresnelParameters;
  31536. private _opacityFresnelParameters;
  31537. /**
  31538. * Define the opacity fresnel parameters of the material.
  31539. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31540. */
  31541. opacityFresnelParameters: FresnelParameters;
  31542. private _reflectionFresnelParameters;
  31543. /**
  31544. * Define the reflection fresnel parameters of the material.
  31545. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31546. */
  31547. reflectionFresnelParameters: FresnelParameters;
  31548. private _refractionFresnelParameters;
  31549. /**
  31550. * Define the refraction fresnel parameters of the material.
  31551. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31552. */
  31553. refractionFresnelParameters: FresnelParameters;
  31554. private _emissiveFresnelParameters;
  31555. /**
  31556. * Define the emissive fresnel parameters of the material.
  31557. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31558. */
  31559. emissiveFresnelParameters: FresnelParameters;
  31560. private _useReflectionFresnelFromSpecular;
  31561. /**
  31562. * If true automatically deducts the fresnels values from the material specularity.
  31563. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31564. */
  31565. useReflectionFresnelFromSpecular: boolean;
  31566. private _useGlossinessFromSpecularMapAlpha;
  31567. /**
  31568. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31569. */
  31570. useGlossinessFromSpecularMapAlpha: boolean;
  31571. private _maxSimultaneousLights;
  31572. /**
  31573. * Defines the maximum number of lights that can be used in the material
  31574. */
  31575. maxSimultaneousLights: number;
  31576. private _invertNormalMapX;
  31577. /**
  31578. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31579. */
  31580. invertNormalMapX: boolean;
  31581. private _invertNormalMapY;
  31582. /**
  31583. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31584. */
  31585. invertNormalMapY: boolean;
  31586. private _twoSidedLighting;
  31587. /**
  31588. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31589. */
  31590. twoSidedLighting: boolean;
  31591. /**
  31592. * Default configuration related to image processing available in the standard Material.
  31593. */
  31594. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31595. /**
  31596. * Gets the image processing configuration used either in this material.
  31597. */
  31598. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31599. /**
  31600. * Sets the Default image processing configuration used either in the this material.
  31601. *
  31602. * If sets to null, the scene one is in use.
  31603. */
  31604. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31605. /**
  31606. * Keep track of the image processing observer to allow dispose and replace.
  31607. */
  31608. private _imageProcessingObserver;
  31609. /**
  31610. * Attaches a new image processing configuration to the Standard Material.
  31611. * @param configuration
  31612. */
  31613. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31614. /**
  31615. * Gets wether the color curves effect is enabled.
  31616. */
  31617. get cameraColorCurvesEnabled(): boolean;
  31618. /**
  31619. * Sets wether the color curves effect is enabled.
  31620. */
  31621. set cameraColorCurvesEnabled(value: boolean);
  31622. /**
  31623. * Gets wether the color grading effect is enabled.
  31624. */
  31625. get cameraColorGradingEnabled(): boolean;
  31626. /**
  31627. * Gets wether the color grading effect is enabled.
  31628. */
  31629. set cameraColorGradingEnabled(value: boolean);
  31630. /**
  31631. * Gets wether tonemapping is enabled or not.
  31632. */
  31633. get cameraToneMappingEnabled(): boolean;
  31634. /**
  31635. * Sets wether tonemapping is enabled or not
  31636. */
  31637. set cameraToneMappingEnabled(value: boolean);
  31638. /**
  31639. * The camera exposure used on this material.
  31640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31641. * This corresponds to a photographic exposure.
  31642. */
  31643. get cameraExposure(): number;
  31644. /**
  31645. * The camera exposure used on this material.
  31646. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31647. * This corresponds to a photographic exposure.
  31648. */
  31649. set cameraExposure(value: number);
  31650. /**
  31651. * Gets The camera contrast used on this material.
  31652. */
  31653. get cameraContrast(): number;
  31654. /**
  31655. * Sets The camera contrast used on this material.
  31656. */
  31657. set cameraContrast(value: number);
  31658. /**
  31659. * Gets the Color Grading 2D Lookup Texture.
  31660. */
  31661. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31662. /**
  31663. * Sets the Color Grading 2D Lookup Texture.
  31664. */
  31665. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31666. /**
  31667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31669. * 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;
  31670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31671. */
  31672. get cameraColorCurves(): Nullable<ColorCurves>;
  31673. /**
  31674. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31676. * 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;
  31677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31678. */
  31679. set cameraColorCurves(value: Nullable<ColorCurves>);
  31680. /**
  31681. * Can this material render to several textures at once
  31682. */
  31683. get canRenderToMRT(): boolean;
  31684. /**
  31685. * Defines the detail map parameters for the material.
  31686. */
  31687. readonly detailMap: DetailMapConfiguration;
  31688. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31689. protected _worldViewProjectionMatrix: Matrix;
  31690. protected _globalAmbientColor: Color3;
  31691. protected _useLogarithmicDepth: boolean;
  31692. protected _rebuildInParallel: boolean;
  31693. /**
  31694. * Instantiates a new standard material.
  31695. * This is the default material used in Babylon. It is the best trade off between quality
  31696. * and performances.
  31697. * @see https://doc.babylonjs.com/babylon101/materials
  31698. * @param name Define the name of the material in the scene
  31699. * @param scene Define the scene the material belong to
  31700. */
  31701. constructor(name: string, scene: Scene);
  31702. /**
  31703. * Gets a boolean indicating that current material needs to register RTT
  31704. */
  31705. get hasRenderTargetTextures(): boolean;
  31706. /**
  31707. * Gets the current class name of the material e.g. "StandardMaterial"
  31708. * Mainly use in serialization.
  31709. * @returns the class name
  31710. */
  31711. getClassName(): string;
  31712. /**
  31713. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31714. * You can try switching to logarithmic depth.
  31715. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31716. */
  31717. get useLogarithmicDepth(): boolean;
  31718. set useLogarithmicDepth(value: boolean);
  31719. /**
  31720. * Specifies if the material will require alpha blending
  31721. * @returns a boolean specifying if alpha blending is needed
  31722. */
  31723. needAlphaBlending(): boolean;
  31724. /**
  31725. * Specifies if this material should be rendered in alpha test mode
  31726. * @returns a boolean specifying if an alpha test is needed.
  31727. */
  31728. needAlphaTesting(): boolean;
  31729. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31730. /**
  31731. * Get the texture used for alpha test purpose.
  31732. * @returns the diffuse texture in case of the standard material.
  31733. */
  31734. getAlphaTestTexture(): Nullable<BaseTexture>;
  31735. /**
  31736. * Get if the submesh is ready to be used and all its information available.
  31737. * Child classes can use it to update shaders
  31738. * @param mesh defines the mesh to check
  31739. * @param subMesh defines which submesh to check
  31740. * @param useInstances specifies that instances should be used
  31741. * @returns a boolean indicating that the submesh is ready or not
  31742. */
  31743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31744. /**
  31745. * Builds the material UBO layouts.
  31746. * Used internally during the effect preparation.
  31747. */
  31748. buildUniformLayout(): void;
  31749. /**
  31750. * Unbinds the material from the mesh
  31751. */
  31752. unbind(): void;
  31753. /**
  31754. * Binds the submesh to this material by preparing the effect and shader to draw
  31755. * @param world defines the world transformation matrix
  31756. * @param mesh defines the mesh containing the submesh
  31757. * @param subMesh defines the submesh to bind the material to
  31758. */
  31759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31760. /**
  31761. * Get the list of animatables in the material.
  31762. * @returns the list of animatables object used in the material
  31763. */
  31764. getAnimatables(): IAnimatable[];
  31765. /**
  31766. * Gets the active textures from the material
  31767. * @returns an array of textures
  31768. */
  31769. getActiveTextures(): BaseTexture[];
  31770. /**
  31771. * Specifies if the material uses a texture
  31772. * @param texture defines the texture to check against the material
  31773. * @returns a boolean specifying if the material uses the texture
  31774. */
  31775. hasTexture(texture: BaseTexture): boolean;
  31776. /**
  31777. * Disposes the material
  31778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31780. */
  31781. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31782. /**
  31783. * Makes a duplicate of the material, and gives it a new name
  31784. * @param name defines the new name for the duplicated material
  31785. * @returns the cloned material
  31786. */
  31787. clone(name: string): StandardMaterial;
  31788. /**
  31789. * Serializes this material in a JSON representation
  31790. * @returns the serialized material object
  31791. */
  31792. serialize(): any;
  31793. /**
  31794. * Creates a standard material from parsed material data
  31795. * @param source defines the JSON representation of the material
  31796. * @param scene defines the hosting scene
  31797. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31798. * @returns a new standard material
  31799. */
  31800. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31801. /**
  31802. * Are diffuse textures enabled in the application.
  31803. */
  31804. static get DiffuseTextureEnabled(): boolean;
  31805. static set DiffuseTextureEnabled(value: boolean);
  31806. /**
  31807. * Are detail textures enabled in the application.
  31808. */
  31809. static get DetailTextureEnabled(): boolean;
  31810. static set DetailTextureEnabled(value: boolean);
  31811. /**
  31812. * Are ambient textures enabled in the application.
  31813. */
  31814. static get AmbientTextureEnabled(): boolean;
  31815. static set AmbientTextureEnabled(value: boolean);
  31816. /**
  31817. * Are opacity textures enabled in the application.
  31818. */
  31819. static get OpacityTextureEnabled(): boolean;
  31820. static set OpacityTextureEnabled(value: boolean);
  31821. /**
  31822. * Are reflection textures enabled in the application.
  31823. */
  31824. static get ReflectionTextureEnabled(): boolean;
  31825. static set ReflectionTextureEnabled(value: boolean);
  31826. /**
  31827. * Are emissive textures enabled in the application.
  31828. */
  31829. static get EmissiveTextureEnabled(): boolean;
  31830. static set EmissiveTextureEnabled(value: boolean);
  31831. /**
  31832. * Are specular textures enabled in the application.
  31833. */
  31834. static get SpecularTextureEnabled(): boolean;
  31835. static set SpecularTextureEnabled(value: boolean);
  31836. /**
  31837. * Are bump textures enabled in the application.
  31838. */
  31839. static get BumpTextureEnabled(): boolean;
  31840. static set BumpTextureEnabled(value: boolean);
  31841. /**
  31842. * Are lightmap textures enabled in the application.
  31843. */
  31844. static get LightmapTextureEnabled(): boolean;
  31845. static set LightmapTextureEnabled(value: boolean);
  31846. /**
  31847. * Are refraction textures enabled in the application.
  31848. */
  31849. static get RefractionTextureEnabled(): boolean;
  31850. static set RefractionTextureEnabled(value: boolean);
  31851. /**
  31852. * Are color grading textures enabled in the application.
  31853. */
  31854. static get ColorGradingTextureEnabled(): boolean;
  31855. static set ColorGradingTextureEnabled(value: boolean);
  31856. /**
  31857. * Are fresnels enabled in the application.
  31858. */
  31859. static get FresnelEnabled(): boolean;
  31860. static set FresnelEnabled(value: boolean);
  31861. }
  31862. }
  31863. declare module "babylonjs/Particles/solidParticleSystem" {
  31864. import { Nullable } from "babylonjs/types";
  31865. import { Mesh } from "babylonjs/Meshes/mesh";
  31866. import { Scene, IDisposable } from "babylonjs/scene";
  31867. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31868. import { Material } from "babylonjs/Materials/material";
  31869. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31870. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31871. /**
  31872. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31873. *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.
  31874. * The SPS is also a particle system. It provides some methods to manage the particles.
  31875. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31876. *
  31877. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31878. */
  31879. export class SolidParticleSystem implements IDisposable {
  31880. /**
  31881. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31882. * Example : var p = SPS.particles[i];
  31883. */
  31884. particles: SolidParticle[];
  31885. /**
  31886. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31887. */
  31888. nbParticles: number;
  31889. /**
  31890. * If the particles must ever face the camera (default false). Useful for planar particles.
  31891. */
  31892. billboard: boolean;
  31893. /**
  31894. * Recompute normals when adding a shape
  31895. */
  31896. recomputeNormals: boolean;
  31897. /**
  31898. * This a counter ofr your own usage. It's not set by any SPS functions.
  31899. */
  31900. counter: number;
  31901. /**
  31902. * The SPS name. This name is also given to the underlying mesh.
  31903. */
  31904. name: string;
  31905. /**
  31906. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31907. */
  31908. mesh: Mesh;
  31909. /**
  31910. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31911. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31912. */
  31913. vars: any;
  31914. /**
  31915. * This array is populated when the SPS is set as 'pickable'.
  31916. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31917. * Each element of this array is an object `{idx: int, faceId: int}`.
  31918. * `idx` is the picked particle index in the `SPS.particles` array
  31919. * `faceId` is the picked face index counted within this particle.
  31920. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31921. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31922. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31923. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31924. */
  31925. pickedParticles: {
  31926. idx: number;
  31927. faceId: number;
  31928. }[];
  31929. /**
  31930. * This array is populated when the SPS is set as 'pickable'
  31931. * Each key of this array is a submesh index.
  31932. * Each element of this array is a second array defined like this :
  31933. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31934. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31935. * `idx` is the picked particle index in the `SPS.particles` array
  31936. * `faceId` is the picked face index counted within this particle.
  31937. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31938. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31939. */
  31940. pickedBySubMesh: {
  31941. idx: number;
  31942. faceId: number;
  31943. }[][];
  31944. /**
  31945. * This array is populated when `enableDepthSort` is set to true.
  31946. * Each element of this array is an instance of the class DepthSortedParticle.
  31947. */
  31948. depthSortedParticles: DepthSortedParticle[];
  31949. /**
  31950. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31951. * @hidden
  31952. */
  31953. _bSphereOnly: boolean;
  31954. /**
  31955. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31956. * @hidden
  31957. */
  31958. _bSphereRadiusFactor: number;
  31959. private _scene;
  31960. private _positions;
  31961. private _indices;
  31962. private _normals;
  31963. private _colors;
  31964. private _uvs;
  31965. private _indices32;
  31966. private _positions32;
  31967. private _normals32;
  31968. private _fixedNormal32;
  31969. private _colors32;
  31970. private _uvs32;
  31971. private _index;
  31972. private _updatable;
  31973. private _pickable;
  31974. private _isVisibilityBoxLocked;
  31975. private _alwaysVisible;
  31976. private _depthSort;
  31977. private _expandable;
  31978. private _shapeCounter;
  31979. private _copy;
  31980. private _color;
  31981. private _computeParticleColor;
  31982. private _computeParticleTexture;
  31983. private _computeParticleRotation;
  31984. private _computeParticleVertex;
  31985. private _computeBoundingBox;
  31986. private _depthSortParticles;
  31987. private _camera;
  31988. private _mustUnrotateFixedNormals;
  31989. private _particlesIntersect;
  31990. private _needs32Bits;
  31991. private _isNotBuilt;
  31992. private _lastParticleId;
  31993. private _idxOfId;
  31994. private _multimaterialEnabled;
  31995. private _useModelMaterial;
  31996. private _indicesByMaterial;
  31997. private _materialIndexes;
  31998. private _depthSortFunction;
  31999. private _materialSortFunction;
  32000. private _materials;
  32001. private _multimaterial;
  32002. private _materialIndexesById;
  32003. private _defaultMaterial;
  32004. private _autoUpdateSubMeshes;
  32005. private _tmpVertex;
  32006. /**
  32007. * Creates a SPS (Solid Particle System) object.
  32008. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32009. * @param scene (Scene) is the scene in which the SPS is added.
  32010. * @param options defines the options of the sps e.g.
  32011. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32012. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32013. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32014. * * 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.
  32015. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32016. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32017. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32018. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32019. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32020. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32021. */
  32022. constructor(name: string, scene: Scene, options?: {
  32023. updatable?: boolean;
  32024. isPickable?: boolean;
  32025. enableDepthSort?: boolean;
  32026. particleIntersection?: boolean;
  32027. boundingSphereOnly?: boolean;
  32028. bSphereRadiusFactor?: number;
  32029. expandable?: boolean;
  32030. useModelMaterial?: boolean;
  32031. enableMultiMaterial?: boolean;
  32032. });
  32033. /**
  32034. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32035. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32036. * @returns the created mesh
  32037. */
  32038. buildMesh(): Mesh;
  32039. /**
  32040. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32041. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32042. * Thus the particles generated from `digest()` have their property `position` set yet.
  32043. * @param mesh ( Mesh ) is the mesh to be digested
  32044. * @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
  32045. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32046. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32047. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32048. * @returns the current SPS
  32049. */
  32050. digest(mesh: Mesh, options?: {
  32051. facetNb?: number;
  32052. number?: number;
  32053. delta?: number;
  32054. storage?: [];
  32055. }): SolidParticleSystem;
  32056. /**
  32057. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32058. * @hidden
  32059. */
  32060. private _unrotateFixedNormals;
  32061. /**
  32062. * Resets the temporary working copy particle
  32063. * @hidden
  32064. */
  32065. private _resetCopy;
  32066. /**
  32067. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32068. * @param p the current index in the positions array to be updated
  32069. * @param ind the current index in the indices array
  32070. * @param shape a Vector3 array, the shape geometry
  32071. * @param positions the positions array to be updated
  32072. * @param meshInd the shape indices array
  32073. * @param indices the indices array to be updated
  32074. * @param meshUV the shape uv array
  32075. * @param uvs the uv array to be updated
  32076. * @param meshCol the shape color array
  32077. * @param colors the color array to be updated
  32078. * @param meshNor the shape normals array
  32079. * @param normals the normals array to be updated
  32080. * @param idx the particle index
  32081. * @param idxInShape the particle index in its shape
  32082. * @param options the addShape() method passed options
  32083. * @model the particle model
  32084. * @hidden
  32085. */
  32086. private _meshBuilder;
  32087. /**
  32088. * Returns a shape Vector3 array from positions float array
  32089. * @param positions float array
  32090. * @returns a vector3 array
  32091. * @hidden
  32092. */
  32093. private _posToShape;
  32094. /**
  32095. * Returns a shapeUV array from a float uvs (array deep copy)
  32096. * @param uvs as a float array
  32097. * @returns a shapeUV array
  32098. * @hidden
  32099. */
  32100. private _uvsToShapeUV;
  32101. /**
  32102. * Adds a new particle object in the particles array
  32103. * @param idx particle index in particles array
  32104. * @param id particle id
  32105. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32106. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32107. * @param model particle ModelShape object
  32108. * @param shapeId model shape identifier
  32109. * @param idxInShape index of the particle in the current model
  32110. * @param bInfo model bounding info object
  32111. * @param storage target storage array, if any
  32112. * @hidden
  32113. */
  32114. private _addParticle;
  32115. /**
  32116. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32117. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32118. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32119. * @param nb (positive integer) the number of particles to be created from this model
  32120. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32121. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32122. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32123. * @returns the number of shapes in the system
  32124. */
  32125. addShape(mesh: Mesh, nb: number, options?: {
  32126. positionFunction?: any;
  32127. vertexFunction?: any;
  32128. storage?: [];
  32129. }): number;
  32130. /**
  32131. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32132. * @hidden
  32133. */
  32134. private _rebuildParticle;
  32135. /**
  32136. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32137. * @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.
  32138. * @returns the SPS.
  32139. */
  32140. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32141. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32142. * Returns an array with the removed particles.
  32143. * 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.
  32144. * The SPS can't be empty so at least one particle needs to remain in place.
  32145. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32146. * @param start index of the first particle to remove
  32147. * @param end index of the last particle to remove (included)
  32148. * @returns an array populated with the removed particles
  32149. */
  32150. removeParticles(start: number, end: number): SolidParticle[];
  32151. /**
  32152. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32153. * @param solidParticleArray an array populated with Solid Particles objects
  32154. * @returns the SPS
  32155. */
  32156. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32157. /**
  32158. * Creates a new particle and modifies the SPS mesh geometry :
  32159. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32160. * - calls _addParticle() to populate the particle array
  32161. * factorized code from addShape() and insertParticlesFromArray()
  32162. * @param idx particle index in the particles array
  32163. * @param i particle index in its shape
  32164. * @param modelShape particle ModelShape object
  32165. * @param shape shape vertex array
  32166. * @param meshInd shape indices array
  32167. * @param meshUV shape uv array
  32168. * @param meshCol shape color array
  32169. * @param meshNor shape normals array
  32170. * @param bbInfo shape bounding info
  32171. * @param storage target particle storage
  32172. * @options addShape() passed options
  32173. * @hidden
  32174. */
  32175. private _insertNewParticle;
  32176. /**
  32177. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32178. * This method calls `updateParticle()` for each particle of the SPS.
  32179. * For an animated SPS, it is usually called within the render loop.
  32180. * 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.
  32181. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32182. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32183. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32184. * @returns the SPS.
  32185. */
  32186. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32187. /**
  32188. * Disposes the SPS.
  32189. */
  32190. dispose(): void;
  32191. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32192. * idx is the particle index in the SPS
  32193. * faceId is the picked face index counted within this particle.
  32194. * Returns null if the pickInfo can't identify a picked particle.
  32195. * @param pickingInfo (PickingInfo object)
  32196. * @returns {idx: number, faceId: number} or null
  32197. */
  32198. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32199. idx: number;
  32200. faceId: number;
  32201. }>;
  32202. /**
  32203. * Returns a SolidParticle object from its identifier : particle.id
  32204. * @param id (integer) the particle Id
  32205. * @returns the searched particle or null if not found in the SPS.
  32206. */
  32207. getParticleById(id: number): Nullable<SolidParticle>;
  32208. /**
  32209. * Returns a new array populated with the particles having the passed shapeId.
  32210. * @param shapeId (integer) the shape identifier
  32211. * @returns a new solid particle array
  32212. */
  32213. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32214. /**
  32215. * Populates the passed array "ref" with the particles having the passed shapeId.
  32216. * @param shapeId the shape identifier
  32217. * @returns the SPS
  32218. * @param ref
  32219. */
  32220. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32221. /**
  32222. * Computes the required SubMeshes according the materials assigned to the particles.
  32223. * @returns the solid particle system.
  32224. * Does nothing if called before the SPS mesh is built.
  32225. */
  32226. computeSubMeshes(): SolidParticleSystem;
  32227. /**
  32228. * Sorts the solid particles by material when MultiMaterial is enabled.
  32229. * Updates the indices32 array.
  32230. * Updates the indicesByMaterial array.
  32231. * Updates the mesh indices array.
  32232. * @returns the SPS
  32233. * @hidden
  32234. */
  32235. private _sortParticlesByMaterial;
  32236. /**
  32237. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32238. * @hidden
  32239. */
  32240. private _setMaterialIndexesById;
  32241. /**
  32242. * Returns an array with unique values of Materials from the passed array
  32243. * @param array the material array to be checked and filtered
  32244. * @hidden
  32245. */
  32246. private _filterUniqueMaterialId;
  32247. /**
  32248. * Sets a new Standard Material as _defaultMaterial if not already set.
  32249. * @hidden
  32250. */
  32251. private _setDefaultMaterial;
  32252. /**
  32253. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32254. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32255. * @returns the SPS.
  32256. */
  32257. refreshVisibleSize(): SolidParticleSystem;
  32258. /**
  32259. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32260. * @param size the size (float) of the visibility box
  32261. * note : this doesn't lock the SPS mesh bounding box.
  32262. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32263. */
  32264. setVisibilityBox(size: number): void;
  32265. /**
  32266. * Gets whether the SPS as always visible or not
  32267. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32268. */
  32269. get isAlwaysVisible(): boolean;
  32270. /**
  32271. * Sets the SPS as always visible or not
  32272. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32273. */
  32274. set isAlwaysVisible(val: boolean);
  32275. /**
  32276. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32277. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32278. */
  32279. set isVisibilityBoxLocked(val: boolean);
  32280. /**
  32281. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32282. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32283. */
  32284. get isVisibilityBoxLocked(): boolean;
  32285. /**
  32286. * Tells to `setParticles()` to compute the particle rotations or not.
  32287. * Default value : true. The SPS is faster when it's set to false.
  32288. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32289. */
  32290. set computeParticleRotation(val: boolean);
  32291. /**
  32292. * Tells to `setParticles()` to compute the particle colors or not.
  32293. * Default value : true. The SPS is faster when it's set to false.
  32294. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32295. */
  32296. set computeParticleColor(val: boolean);
  32297. set computeParticleTexture(val: boolean);
  32298. /**
  32299. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32300. * Default value : false. The SPS is faster when it's set to false.
  32301. * Note : the particle custom vertex positions aren't stored values.
  32302. */
  32303. set computeParticleVertex(val: boolean);
  32304. /**
  32305. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32306. */
  32307. set computeBoundingBox(val: boolean);
  32308. /**
  32309. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32310. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32311. * Default : `true`
  32312. */
  32313. set depthSortParticles(val: boolean);
  32314. /**
  32315. * Gets if `setParticles()` computes the particle rotations or not.
  32316. * Default value : true. The SPS is faster when it's set to false.
  32317. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32318. */
  32319. get computeParticleRotation(): boolean;
  32320. /**
  32321. * Gets if `setParticles()` computes the particle colors or not.
  32322. * Default value : true. The SPS is faster when it's set to false.
  32323. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32324. */
  32325. get computeParticleColor(): boolean;
  32326. /**
  32327. * Gets if `setParticles()` computes the particle textures or not.
  32328. * Default value : true. The SPS is faster when it's set to false.
  32329. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32330. */
  32331. get computeParticleTexture(): boolean;
  32332. /**
  32333. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32334. * Default value : false. The SPS is faster when it's set to false.
  32335. * Note : the particle custom vertex positions aren't stored values.
  32336. */
  32337. get computeParticleVertex(): boolean;
  32338. /**
  32339. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32340. */
  32341. get computeBoundingBox(): boolean;
  32342. /**
  32343. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32344. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32345. * Default : `true`
  32346. */
  32347. get depthSortParticles(): boolean;
  32348. /**
  32349. * Gets if the SPS is created as expandable at construction time.
  32350. * Default : `false`
  32351. */
  32352. get expandable(): boolean;
  32353. /**
  32354. * Gets if the SPS supports the Multi Materials
  32355. */
  32356. get multimaterialEnabled(): boolean;
  32357. /**
  32358. * Gets if the SPS uses the model materials for its own multimaterial.
  32359. */
  32360. get useModelMaterial(): boolean;
  32361. /**
  32362. * The SPS used material array.
  32363. */
  32364. get materials(): Material[];
  32365. /**
  32366. * Sets the SPS MultiMaterial from the passed materials.
  32367. * Note : the passed array is internally copied and not used then by reference.
  32368. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32369. */
  32370. setMultiMaterial(materials: Material[]): void;
  32371. /**
  32372. * The SPS computed multimaterial object
  32373. */
  32374. get multimaterial(): MultiMaterial;
  32375. set multimaterial(mm: MultiMaterial);
  32376. /**
  32377. * If the subMeshes must be updated on the next call to setParticles()
  32378. */
  32379. get autoUpdateSubMeshes(): boolean;
  32380. set autoUpdateSubMeshes(val: boolean);
  32381. /**
  32382. * This function does nothing. It may be overwritten to set all the particle first values.
  32383. * The SPS doesn't call this function, you may have to call it by your own.
  32384. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32385. */
  32386. initParticles(): void;
  32387. /**
  32388. * This function does nothing. It may be overwritten to recycle a particle.
  32389. * The SPS doesn't call this function, you may have to call it by your own.
  32390. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32391. * @param particle The particle to recycle
  32392. * @returns the recycled particle
  32393. */
  32394. recycleParticle(particle: SolidParticle): SolidParticle;
  32395. /**
  32396. * Updates a particle : this function should be overwritten by the user.
  32397. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32398. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32399. * @example : just set a particle position or velocity and recycle conditions
  32400. * @param particle The particle to update
  32401. * @returns the updated particle
  32402. */
  32403. updateParticle(particle: SolidParticle): SolidParticle;
  32404. /**
  32405. * Updates a vertex of a particle : it can be overwritten by the user.
  32406. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32407. * @param particle the current particle
  32408. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32409. * @param pt the index of the current vertex in the particle shape
  32410. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32411. * @example : just set a vertex particle position or color
  32412. * @returns the sps
  32413. */
  32414. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32415. /**
  32416. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32417. * This does nothing and may be overwritten by the user.
  32418. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32419. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32420. * @param update the boolean update value actually passed to setParticles()
  32421. */
  32422. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32423. /**
  32424. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32425. * This will be passed three parameters.
  32426. * This does nothing and may be overwritten by the user.
  32427. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32428. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32429. * @param update the boolean update value actually passed to setParticles()
  32430. */
  32431. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32432. }
  32433. }
  32434. declare module "babylonjs/Particles/solidParticle" {
  32435. import { Nullable } from "babylonjs/types";
  32436. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32437. import { Color4 } from "babylonjs/Maths/math.color";
  32438. import { Mesh } from "babylonjs/Meshes/mesh";
  32439. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32440. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32441. import { Plane } from "babylonjs/Maths/math.plane";
  32442. import { Material } from "babylonjs/Materials/material";
  32443. /**
  32444. * Represents one particle of a solid particle system.
  32445. */
  32446. export class SolidParticle {
  32447. /**
  32448. * particle global index
  32449. */
  32450. idx: number;
  32451. /**
  32452. * particle identifier
  32453. */
  32454. id: number;
  32455. /**
  32456. * The color of the particle
  32457. */
  32458. color: Nullable<Color4>;
  32459. /**
  32460. * The world space position of the particle.
  32461. */
  32462. position: Vector3;
  32463. /**
  32464. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32465. */
  32466. rotation: Vector3;
  32467. /**
  32468. * The world space rotation quaternion of the particle.
  32469. */
  32470. rotationQuaternion: Nullable<Quaternion>;
  32471. /**
  32472. * The scaling of the particle.
  32473. */
  32474. scaling: Vector3;
  32475. /**
  32476. * The uvs of the particle.
  32477. */
  32478. uvs: Vector4;
  32479. /**
  32480. * The current speed of the particle.
  32481. */
  32482. velocity: Vector3;
  32483. /**
  32484. * The pivot point in the particle local space.
  32485. */
  32486. pivot: Vector3;
  32487. /**
  32488. * Must the particle be translated from its pivot point in its local space ?
  32489. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32490. * Default : false
  32491. */
  32492. translateFromPivot: boolean;
  32493. /**
  32494. * Is the particle active or not ?
  32495. */
  32496. alive: boolean;
  32497. /**
  32498. * Is the particle visible or not ?
  32499. */
  32500. isVisible: boolean;
  32501. /**
  32502. * Index of this particle in the global "positions" array (Internal use)
  32503. * @hidden
  32504. */
  32505. _pos: number;
  32506. /**
  32507. * @hidden Index of this particle in the global "indices" array (Internal use)
  32508. */
  32509. _ind: number;
  32510. /**
  32511. * @hidden ModelShape of this particle (Internal use)
  32512. */
  32513. _model: ModelShape;
  32514. /**
  32515. * ModelShape id of this particle
  32516. */
  32517. shapeId: number;
  32518. /**
  32519. * Index of the particle in its shape id
  32520. */
  32521. idxInShape: number;
  32522. /**
  32523. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32524. */
  32525. _modelBoundingInfo: BoundingInfo;
  32526. /**
  32527. * @hidden Particle BoundingInfo object (Internal use)
  32528. */
  32529. _boundingInfo: BoundingInfo;
  32530. /**
  32531. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32532. */
  32533. _sps: SolidParticleSystem;
  32534. /**
  32535. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32536. */
  32537. _stillInvisible: boolean;
  32538. /**
  32539. * @hidden Last computed particle rotation matrix
  32540. */
  32541. _rotationMatrix: number[];
  32542. /**
  32543. * Parent particle Id, if any.
  32544. * Default null.
  32545. */
  32546. parentId: Nullable<number>;
  32547. /**
  32548. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32549. */
  32550. materialIndex: Nullable<number>;
  32551. /**
  32552. * Custom object or properties.
  32553. */
  32554. props: Nullable<any>;
  32555. /**
  32556. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32557. * The possible values are :
  32558. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32559. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32560. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32561. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32562. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32563. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32564. * */
  32565. cullingStrategy: number;
  32566. /**
  32567. * @hidden Internal global position in the SPS.
  32568. */
  32569. _globalPosition: Vector3;
  32570. /**
  32571. * Creates a Solid Particle object.
  32572. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32573. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32574. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32575. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32576. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32577. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32578. * @param shapeId (integer) is the model shape identifier in the SPS.
  32579. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32580. * @param sps defines the sps it is associated to
  32581. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32582. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32583. */
  32584. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32585. /**
  32586. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32587. * @param target the particle target
  32588. * @returns the current particle
  32589. */
  32590. copyToRef(target: SolidParticle): SolidParticle;
  32591. /**
  32592. * Legacy support, changed scale to scaling
  32593. */
  32594. get scale(): Vector3;
  32595. /**
  32596. * Legacy support, changed scale to scaling
  32597. */
  32598. set scale(scale: Vector3);
  32599. /**
  32600. * Legacy support, changed quaternion to rotationQuaternion
  32601. */
  32602. get quaternion(): Nullable<Quaternion>;
  32603. /**
  32604. * Legacy support, changed quaternion to rotationQuaternion
  32605. */
  32606. set quaternion(q: Nullable<Quaternion>);
  32607. /**
  32608. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32609. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32610. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32611. * @returns true if it intersects
  32612. */
  32613. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32614. /**
  32615. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32616. * A particle is in the frustum if its bounding box intersects the frustum
  32617. * @param frustumPlanes defines the frustum to test
  32618. * @returns true if the particle is in the frustum planes
  32619. */
  32620. isInFrustum(frustumPlanes: Plane[]): boolean;
  32621. /**
  32622. * get the rotation matrix of the particle
  32623. * @hidden
  32624. */
  32625. getRotationMatrix(m: Matrix): void;
  32626. }
  32627. /**
  32628. * Represents the shape of the model used by one particle of a solid particle system.
  32629. * SPS internal tool, don't use it manually.
  32630. */
  32631. export class ModelShape {
  32632. /**
  32633. * The shape id
  32634. * @hidden
  32635. */
  32636. shapeID: number;
  32637. /**
  32638. * flat array of model positions (internal use)
  32639. * @hidden
  32640. */
  32641. _shape: Vector3[];
  32642. /**
  32643. * flat array of model UVs (internal use)
  32644. * @hidden
  32645. */
  32646. _shapeUV: number[];
  32647. /**
  32648. * color array of the model
  32649. * @hidden
  32650. */
  32651. _shapeColors: number[];
  32652. /**
  32653. * indices array of the model
  32654. * @hidden
  32655. */
  32656. _indices: number[];
  32657. /**
  32658. * normals array of the model
  32659. * @hidden
  32660. */
  32661. _normals: number[];
  32662. /**
  32663. * length of the shape in the model indices array (internal use)
  32664. * @hidden
  32665. */
  32666. _indicesLength: number;
  32667. /**
  32668. * Custom position function (internal use)
  32669. * @hidden
  32670. */
  32671. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32672. /**
  32673. * Custom vertex function (internal use)
  32674. * @hidden
  32675. */
  32676. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32677. /**
  32678. * Model material (internal use)
  32679. * @hidden
  32680. */
  32681. _material: Nullable<Material>;
  32682. /**
  32683. * 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.
  32684. * SPS internal tool, don't use it manually.
  32685. * @hidden
  32686. */
  32687. 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>);
  32688. }
  32689. /**
  32690. * Represents a Depth Sorted Particle in the solid particle system.
  32691. * @hidden
  32692. */
  32693. export class DepthSortedParticle {
  32694. /**
  32695. * Particle index
  32696. */
  32697. idx: number;
  32698. /**
  32699. * Index of the particle in the "indices" array
  32700. */
  32701. ind: number;
  32702. /**
  32703. * Length of the particle shape in the "indices" array
  32704. */
  32705. indicesLength: number;
  32706. /**
  32707. * Squared distance from the particle to the camera
  32708. */
  32709. sqDistance: number;
  32710. /**
  32711. * Material index when used with MultiMaterials
  32712. */
  32713. materialIndex: number;
  32714. /**
  32715. * Creates a new sorted particle
  32716. * @param materialIndex
  32717. */
  32718. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32719. }
  32720. /**
  32721. * Represents a solid particle vertex
  32722. */
  32723. export class SolidParticleVertex {
  32724. /**
  32725. * Vertex position
  32726. */
  32727. position: Vector3;
  32728. /**
  32729. * Vertex color
  32730. */
  32731. color: Color4;
  32732. /**
  32733. * Vertex UV
  32734. */
  32735. uv: Vector2;
  32736. /**
  32737. * Creates a new solid particle vertex
  32738. */
  32739. constructor();
  32740. /** Vertex x coordinate */
  32741. get x(): number;
  32742. set x(val: number);
  32743. /** Vertex y coordinate */
  32744. get y(): number;
  32745. set y(val: number);
  32746. /** Vertex z coordinate */
  32747. get z(): number;
  32748. set z(val: number);
  32749. }
  32750. }
  32751. declare module "babylonjs/Collisions/meshCollisionData" {
  32752. import { Collider } from "babylonjs/Collisions/collider";
  32753. import { Vector3 } from "babylonjs/Maths/math.vector";
  32754. import { Nullable } from "babylonjs/types";
  32755. import { Observer } from "babylonjs/Misc/observable";
  32756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32757. /**
  32758. * @hidden
  32759. */
  32760. export class _MeshCollisionData {
  32761. _checkCollisions: boolean;
  32762. _collisionMask: number;
  32763. _collisionGroup: number;
  32764. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32765. _collider: Nullable<Collider>;
  32766. _oldPositionForCollisions: Vector3;
  32767. _diffPositionForCollisions: Vector3;
  32768. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32769. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32770. }
  32771. }
  32772. declare module "babylonjs/Meshes/abstractMesh" {
  32773. import { Observable } from "babylonjs/Misc/observable";
  32774. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32775. import { Camera } from "babylonjs/Cameras/camera";
  32776. import { Scene, IDisposable } from "babylonjs/scene";
  32777. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32778. import { Node } from "babylonjs/node";
  32779. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32780. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32781. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32782. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32783. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32784. import { Material } from "babylonjs/Materials/material";
  32785. import { Light } from "babylonjs/Lights/light";
  32786. import { Skeleton } from "babylonjs/Bones/skeleton";
  32787. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32788. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32789. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32790. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32791. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32792. import { Plane } from "babylonjs/Maths/math.plane";
  32793. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32794. import { Ray } from "babylonjs/Culling/ray";
  32795. import { Collider } from "babylonjs/Collisions/collider";
  32796. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32797. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32798. /** @hidden */
  32799. class _FacetDataStorage {
  32800. facetPositions: Vector3[];
  32801. facetNormals: Vector3[];
  32802. facetPartitioning: number[][];
  32803. facetNb: number;
  32804. partitioningSubdivisions: number;
  32805. partitioningBBoxRatio: number;
  32806. facetDataEnabled: boolean;
  32807. facetParameters: any;
  32808. bbSize: Vector3;
  32809. subDiv: {
  32810. max: number;
  32811. X: number;
  32812. Y: number;
  32813. Z: number;
  32814. };
  32815. facetDepthSort: boolean;
  32816. facetDepthSortEnabled: boolean;
  32817. depthSortedIndices: IndicesArray;
  32818. depthSortedFacets: {
  32819. ind: number;
  32820. sqDistance: number;
  32821. }[];
  32822. facetDepthSortFunction: (f1: {
  32823. ind: number;
  32824. sqDistance: number;
  32825. }, f2: {
  32826. ind: number;
  32827. sqDistance: number;
  32828. }) => number;
  32829. facetDepthSortFrom: Vector3;
  32830. facetDepthSortOrigin: Vector3;
  32831. invertedMatrix: Matrix;
  32832. }
  32833. /**
  32834. * @hidden
  32835. **/
  32836. class _InternalAbstractMeshDataInfo {
  32837. _hasVertexAlpha: boolean;
  32838. _useVertexColors: boolean;
  32839. _numBoneInfluencers: number;
  32840. _applyFog: boolean;
  32841. _receiveShadows: boolean;
  32842. _facetData: _FacetDataStorage;
  32843. _visibility: number;
  32844. _skeleton: Nullable<Skeleton>;
  32845. _layerMask: number;
  32846. _computeBonesUsingShaders: boolean;
  32847. _isActive: boolean;
  32848. _onlyForInstances: boolean;
  32849. _isActiveIntermediate: boolean;
  32850. _onlyForInstancesIntermediate: boolean;
  32851. _actAsRegularMesh: boolean;
  32852. }
  32853. /**
  32854. * Class used to store all common mesh properties
  32855. */
  32856. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32857. /** No occlusion */
  32858. static OCCLUSION_TYPE_NONE: number;
  32859. /** Occlusion set to optimisitic */
  32860. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32861. /** Occlusion set to strict */
  32862. static OCCLUSION_TYPE_STRICT: number;
  32863. /** Use an accurante occlusion algorithm */
  32864. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32865. /** Use a conservative occlusion algorithm */
  32866. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32867. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32868. * Test order :
  32869. * Is the bounding sphere outside the frustum ?
  32870. * If not, are the bounding box vertices outside the frustum ?
  32871. * It not, then the cullable object is in the frustum.
  32872. */
  32873. static readonly CULLINGSTRATEGY_STANDARD: number;
  32874. /** Culling strategy : Bounding Sphere Only.
  32875. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32876. * It's also less accurate than the standard because some not visible objects can still be selected.
  32877. * Test : is the bounding sphere outside the frustum ?
  32878. * If not, then the cullable object is in the frustum.
  32879. */
  32880. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32881. /** Culling strategy : Optimistic Inclusion.
  32882. * This in an inclusion test first, then the standard exclusion test.
  32883. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32884. * 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.
  32885. * Anyway, it's as accurate as the standard strategy.
  32886. * Test :
  32887. * Is the cullable object bounding sphere center in the frustum ?
  32888. * If not, apply the default culling strategy.
  32889. */
  32890. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32891. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32892. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32893. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32894. * 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.
  32895. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32896. * Test :
  32897. * Is the cullable object bounding sphere center in the frustum ?
  32898. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32899. */
  32900. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32901. /**
  32902. * No billboard
  32903. */
  32904. static get BILLBOARDMODE_NONE(): number;
  32905. /** Billboard on X axis */
  32906. static get BILLBOARDMODE_X(): number;
  32907. /** Billboard on Y axis */
  32908. static get BILLBOARDMODE_Y(): number;
  32909. /** Billboard on Z axis */
  32910. static get BILLBOARDMODE_Z(): number;
  32911. /** Billboard on all axes */
  32912. static get BILLBOARDMODE_ALL(): number;
  32913. /** Billboard on using position instead of orientation */
  32914. static get BILLBOARDMODE_USE_POSITION(): number;
  32915. /** @hidden */
  32916. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32917. /**
  32918. * The culling strategy to use to check whether the mesh must be rendered or not.
  32919. * This value can be changed at any time and will be used on the next render mesh selection.
  32920. * The possible values are :
  32921. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32922. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32923. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32924. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32925. * Please read each static variable documentation to get details about the culling process.
  32926. * */
  32927. cullingStrategy: number;
  32928. /**
  32929. * Gets the number of facets in the mesh
  32930. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32931. */
  32932. get facetNb(): number;
  32933. /**
  32934. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32935. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32936. */
  32937. get partitioningSubdivisions(): number;
  32938. set partitioningSubdivisions(nb: number);
  32939. /**
  32940. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32941. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32942. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32943. */
  32944. get partitioningBBoxRatio(): number;
  32945. set partitioningBBoxRatio(ratio: number);
  32946. /**
  32947. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32948. * Works only for updatable meshes.
  32949. * Doesn't work with multi-materials
  32950. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32951. */
  32952. get mustDepthSortFacets(): boolean;
  32953. set mustDepthSortFacets(sort: boolean);
  32954. /**
  32955. * The location (Vector3) where the facet depth sort must be computed from.
  32956. * By default, the active camera position.
  32957. * Used only when facet depth sort is enabled
  32958. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32959. */
  32960. get facetDepthSortFrom(): Vector3;
  32961. set facetDepthSortFrom(location: Vector3);
  32962. /**
  32963. * gets a boolean indicating if facetData is enabled
  32964. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32965. */
  32966. get isFacetDataEnabled(): boolean;
  32967. /** @hidden */
  32968. _updateNonUniformScalingState(value: boolean): boolean;
  32969. /**
  32970. * An event triggered when this mesh collides with another one
  32971. */
  32972. onCollideObservable: Observable<AbstractMesh>;
  32973. /** Set a function to call when this mesh collides with another one */
  32974. set onCollide(callback: () => void);
  32975. /**
  32976. * An event triggered when the collision's position changes
  32977. */
  32978. onCollisionPositionChangeObservable: Observable<Vector3>;
  32979. /** Set a function to call when the collision's position changes */
  32980. set onCollisionPositionChange(callback: () => void);
  32981. /**
  32982. * An event triggered when material is changed
  32983. */
  32984. onMaterialChangedObservable: Observable<AbstractMesh>;
  32985. /**
  32986. * Gets or sets the orientation for POV movement & rotation
  32987. */
  32988. definedFacingForward: boolean;
  32989. /** @hidden */
  32990. _occlusionQuery: Nullable<WebGLQuery>;
  32991. /** @hidden */
  32992. _renderingGroup: Nullable<RenderingGroup>;
  32993. /**
  32994. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32995. */
  32996. get visibility(): number;
  32997. /**
  32998. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32999. */
  33000. set visibility(value: number);
  33001. /** Gets or sets the alpha index used to sort transparent meshes
  33002. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33003. */
  33004. alphaIndex: number;
  33005. /**
  33006. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33007. */
  33008. isVisible: boolean;
  33009. /**
  33010. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33011. */
  33012. isPickable: boolean;
  33013. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33014. showSubMeshesBoundingBox: boolean;
  33015. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33016. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33017. */
  33018. isBlocker: boolean;
  33019. /**
  33020. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33021. */
  33022. enablePointerMoveEvents: boolean;
  33023. /**
  33024. * Specifies the rendering group id for this mesh (0 by default)
  33025. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33026. */
  33027. renderingGroupId: number;
  33028. private _material;
  33029. /** Gets or sets current material */
  33030. get material(): Nullable<Material>;
  33031. set material(value: Nullable<Material>);
  33032. /**
  33033. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33034. * @see https://doc.babylonjs.com/babylon101/shadows
  33035. */
  33036. get receiveShadows(): boolean;
  33037. set receiveShadows(value: boolean);
  33038. /** Defines color to use when rendering outline */
  33039. outlineColor: Color3;
  33040. /** Define width to use when rendering outline */
  33041. outlineWidth: number;
  33042. /** Defines color to use when rendering overlay */
  33043. overlayColor: Color3;
  33044. /** Defines alpha to use when rendering overlay */
  33045. overlayAlpha: number;
  33046. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33047. get hasVertexAlpha(): boolean;
  33048. set hasVertexAlpha(value: boolean);
  33049. /** 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) */
  33050. get useVertexColors(): boolean;
  33051. set useVertexColors(value: boolean);
  33052. /**
  33053. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33054. */
  33055. get computeBonesUsingShaders(): boolean;
  33056. set computeBonesUsingShaders(value: boolean);
  33057. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33058. get numBoneInfluencers(): number;
  33059. set numBoneInfluencers(value: number);
  33060. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33061. get applyFog(): boolean;
  33062. set applyFog(value: boolean);
  33063. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33064. useOctreeForRenderingSelection: boolean;
  33065. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33066. useOctreeForPicking: boolean;
  33067. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33068. useOctreeForCollisions: boolean;
  33069. /**
  33070. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33071. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33072. */
  33073. get layerMask(): number;
  33074. set layerMask(value: number);
  33075. /**
  33076. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33077. */
  33078. alwaysSelectAsActiveMesh: boolean;
  33079. /**
  33080. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33081. */
  33082. doNotSyncBoundingInfo: boolean;
  33083. /**
  33084. * Gets or sets the current action manager
  33085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33086. */
  33087. actionManager: Nullable<AbstractActionManager>;
  33088. private _meshCollisionData;
  33089. /**
  33090. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33091. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33092. */
  33093. ellipsoid: Vector3;
  33094. /**
  33095. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33096. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33097. */
  33098. ellipsoidOffset: Vector3;
  33099. /**
  33100. * Gets or sets a collision mask used to mask collisions (default is -1).
  33101. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33102. */
  33103. get collisionMask(): number;
  33104. set collisionMask(mask: number);
  33105. /**
  33106. * Gets or sets the current collision group mask (-1 by default).
  33107. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33108. */
  33109. get collisionGroup(): number;
  33110. set collisionGroup(mask: number);
  33111. /**
  33112. * Gets or sets current surrounding meshes (null by default).
  33113. *
  33114. * By default collision detection is tested against every mesh in the scene.
  33115. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33116. * meshes will be tested for the collision.
  33117. *
  33118. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33119. */
  33120. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33121. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33122. /**
  33123. * Defines edge width used when edgesRenderer is enabled
  33124. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33125. */
  33126. edgesWidth: number;
  33127. /**
  33128. * Defines edge color used when edgesRenderer is enabled
  33129. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33130. */
  33131. edgesColor: Color4;
  33132. /** @hidden */
  33133. _edgesRenderer: Nullable<IEdgesRenderer>;
  33134. /** @hidden */
  33135. _masterMesh: Nullable<AbstractMesh>;
  33136. /** @hidden */
  33137. _boundingInfo: Nullable<BoundingInfo>;
  33138. /** @hidden */
  33139. _renderId: number;
  33140. /**
  33141. * Gets or sets the list of subMeshes
  33142. * @see https://doc.babylonjs.com/how_to/multi_materials
  33143. */
  33144. subMeshes: SubMesh[];
  33145. /** @hidden */
  33146. _intersectionsInProgress: AbstractMesh[];
  33147. /** @hidden */
  33148. _unIndexed: boolean;
  33149. /** @hidden */
  33150. _lightSources: Light[];
  33151. /** Gets the list of lights affecting that mesh */
  33152. get lightSources(): Light[];
  33153. /** @hidden */
  33154. get _positions(): Nullable<Vector3[]>;
  33155. /** @hidden */
  33156. _waitingData: {
  33157. lods: Nullable<any>;
  33158. actions: Nullable<any>;
  33159. freezeWorldMatrix: Nullable<boolean>;
  33160. };
  33161. /** @hidden */
  33162. _bonesTransformMatrices: Nullable<Float32Array>;
  33163. /** @hidden */
  33164. _transformMatrixTexture: Nullable<RawTexture>;
  33165. /**
  33166. * Gets or sets a skeleton to apply skining transformations
  33167. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33168. */
  33169. set skeleton(value: Nullable<Skeleton>);
  33170. get skeleton(): Nullable<Skeleton>;
  33171. /**
  33172. * An event triggered when the mesh is rebuilt.
  33173. */
  33174. onRebuildObservable: Observable<AbstractMesh>;
  33175. /**
  33176. * Creates a new AbstractMesh
  33177. * @param name defines the name of the mesh
  33178. * @param scene defines the hosting scene
  33179. */
  33180. constructor(name: string, scene?: Nullable<Scene>);
  33181. /**
  33182. * Returns the string "AbstractMesh"
  33183. * @returns "AbstractMesh"
  33184. */
  33185. getClassName(): string;
  33186. /**
  33187. * Gets a string representation of the current mesh
  33188. * @param fullDetails defines a boolean indicating if full details must be included
  33189. * @returns a string representation of the current mesh
  33190. */
  33191. toString(fullDetails?: boolean): string;
  33192. /**
  33193. * @hidden
  33194. */
  33195. protected _getEffectiveParent(): Nullable<Node>;
  33196. /** @hidden */
  33197. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33198. /** @hidden */
  33199. _rebuild(): void;
  33200. /** @hidden */
  33201. _resyncLightSources(): void;
  33202. /** @hidden */
  33203. _resyncLightSource(light: Light): void;
  33204. /** @hidden */
  33205. _unBindEffect(): void;
  33206. /** @hidden */
  33207. _removeLightSource(light: Light, dispose: boolean): void;
  33208. private _markSubMeshesAsDirty;
  33209. /** @hidden */
  33210. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33211. /** @hidden */
  33212. _markSubMeshesAsAttributesDirty(): void;
  33213. /** @hidden */
  33214. _markSubMeshesAsMiscDirty(): void;
  33215. /**
  33216. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33217. */
  33218. get scaling(): Vector3;
  33219. set scaling(newScaling: Vector3);
  33220. /**
  33221. * Returns true if the mesh is blocked. Implemented by child classes
  33222. */
  33223. get isBlocked(): boolean;
  33224. /**
  33225. * Returns the mesh itself by default. Implemented by child classes
  33226. * @param camera defines the camera to use to pick the right LOD level
  33227. * @returns the currentAbstractMesh
  33228. */
  33229. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33230. /**
  33231. * Returns 0 by default. Implemented by child classes
  33232. * @returns an integer
  33233. */
  33234. getTotalVertices(): number;
  33235. /**
  33236. * Returns a positive integer : the total number of indices in this mesh geometry.
  33237. * @returns the numner of indices or zero if the mesh has no geometry.
  33238. */
  33239. getTotalIndices(): number;
  33240. /**
  33241. * Returns null by default. Implemented by child classes
  33242. * @returns null
  33243. */
  33244. getIndices(): Nullable<IndicesArray>;
  33245. /**
  33246. * Returns the array of the requested vertex data kind. Implemented by child classes
  33247. * @param kind defines the vertex data kind to use
  33248. * @returns null
  33249. */
  33250. getVerticesData(kind: string): Nullable<FloatArray>;
  33251. /**
  33252. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33253. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33254. * Note that a new underlying VertexBuffer object is created each call.
  33255. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33256. * @param kind defines vertex data kind:
  33257. * * VertexBuffer.PositionKind
  33258. * * VertexBuffer.UVKind
  33259. * * VertexBuffer.UV2Kind
  33260. * * VertexBuffer.UV3Kind
  33261. * * VertexBuffer.UV4Kind
  33262. * * VertexBuffer.UV5Kind
  33263. * * VertexBuffer.UV6Kind
  33264. * * VertexBuffer.ColorKind
  33265. * * VertexBuffer.MatricesIndicesKind
  33266. * * VertexBuffer.MatricesIndicesExtraKind
  33267. * * VertexBuffer.MatricesWeightsKind
  33268. * * VertexBuffer.MatricesWeightsExtraKind
  33269. * @param data defines the data source
  33270. * @param updatable defines if the data must be flagged as updatable (or static)
  33271. * @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
  33272. * @returns the current mesh
  33273. */
  33274. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33275. /**
  33276. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33277. * If the mesh has no geometry, it is simply returned as it is.
  33278. * @param kind defines vertex data kind:
  33279. * * VertexBuffer.PositionKind
  33280. * * VertexBuffer.UVKind
  33281. * * VertexBuffer.UV2Kind
  33282. * * VertexBuffer.UV3Kind
  33283. * * VertexBuffer.UV4Kind
  33284. * * VertexBuffer.UV5Kind
  33285. * * VertexBuffer.UV6Kind
  33286. * * VertexBuffer.ColorKind
  33287. * * VertexBuffer.MatricesIndicesKind
  33288. * * VertexBuffer.MatricesIndicesExtraKind
  33289. * * VertexBuffer.MatricesWeightsKind
  33290. * * VertexBuffer.MatricesWeightsExtraKind
  33291. * @param data defines the data source
  33292. * @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
  33293. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33294. * @returns the current mesh
  33295. */
  33296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33297. /**
  33298. * Sets the mesh indices,
  33299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33300. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33301. * @param totalVertices Defines the total number of vertices
  33302. * @returns the current mesh
  33303. */
  33304. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33305. /**
  33306. * Gets a boolean indicating if specific vertex data is present
  33307. * @param kind defines the vertex data kind to use
  33308. * @returns true is data kind is present
  33309. */
  33310. isVerticesDataPresent(kind: string): boolean;
  33311. /**
  33312. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33313. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33314. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33315. * @returns a BoundingInfo
  33316. */
  33317. getBoundingInfo(): BoundingInfo;
  33318. /**
  33319. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33320. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33321. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33322. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33323. * @returns the current mesh
  33324. */
  33325. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33326. /**
  33327. * Overwrite the current bounding info
  33328. * @param boundingInfo defines the new bounding info
  33329. * @returns the current mesh
  33330. */
  33331. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33332. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33333. get useBones(): boolean;
  33334. /** @hidden */
  33335. _preActivate(): void;
  33336. /** @hidden */
  33337. _preActivateForIntermediateRendering(renderId: number): void;
  33338. /** @hidden */
  33339. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33340. /** @hidden */
  33341. _postActivate(): void;
  33342. /** @hidden */
  33343. _freeze(): void;
  33344. /** @hidden */
  33345. _unFreeze(): void;
  33346. /**
  33347. * Gets the current world matrix
  33348. * @returns a Matrix
  33349. */
  33350. getWorldMatrix(): Matrix;
  33351. /** @hidden */
  33352. _getWorldMatrixDeterminant(): number;
  33353. /**
  33354. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33355. */
  33356. get isAnInstance(): boolean;
  33357. /**
  33358. * Gets a boolean indicating if this mesh has instances
  33359. */
  33360. get hasInstances(): boolean;
  33361. /**
  33362. * Gets a boolean indicating if this mesh has thin instances
  33363. */
  33364. get hasThinInstances(): boolean;
  33365. /**
  33366. * Perform relative position change from the point of view of behind the front of the mesh.
  33367. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33368. * Supports definition of mesh facing forward or backward
  33369. * @param amountRight defines the distance on the right axis
  33370. * @param amountUp defines the distance on the up axis
  33371. * @param amountForward defines the distance on the forward axis
  33372. * @returns the current mesh
  33373. */
  33374. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33375. /**
  33376. * Calculate relative position change from the point of view of behind the front of the mesh.
  33377. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33378. * Supports definition of mesh facing forward or backward
  33379. * @param amountRight defines the distance on the right axis
  33380. * @param amountUp defines the distance on the up axis
  33381. * @param amountForward defines the distance on the forward axis
  33382. * @returns the new displacement vector
  33383. */
  33384. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33385. /**
  33386. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33387. * Supports definition of mesh facing forward or backward
  33388. * @param flipBack defines the flip
  33389. * @param twirlClockwise defines the twirl
  33390. * @param tiltRight defines the tilt
  33391. * @returns the current mesh
  33392. */
  33393. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33394. /**
  33395. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33396. * Supports definition of mesh facing forward or backward.
  33397. * @param flipBack defines the flip
  33398. * @param twirlClockwise defines the twirl
  33399. * @param tiltRight defines the tilt
  33400. * @returns the new rotation vector
  33401. */
  33402. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33403. /**
  33404. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33405. * This means the mesh underlying bounding box and sphere are recomputed.
  33406. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33407. * @returns the current mesh
  33408. */
  33409. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33410. /** @hidden */
  33411. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33412. /** @hidden */
  33413. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33414. /** @hidden */
  33415. _updateBoundingInfo(): AbstractMesh;
  33416. /** @hidden */
  33417. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33418. /** @hidden */
  33419. protected _afterComputeWorldMatrix(): void;
  33420. /** @hidden */
  33421. get _effectiveMesh(): AbstractMesh;
  33422. /**
  33423. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33424. * A mesh is in the frustum if its bounding box intersects the frustum
  33425. * @param frustumPlanes defines the frustum to test
  33426. * @returns true if the mesh is in the frustum planes
  33427. */
  33428. isInFrustum(frustumPlanes: Plane[]): boolean;
  33429. /**
  33430. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33431. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33432. * @param frustumPlanes defines the frustum to test
  33433. * @returns true if the mesh is completely in the frustum planes
  33434. */
  33435. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33436. /**
  33437. * True if the mesh intersects another mesh or a SolidParticle object
  33438. * @param mesh defines a target mesh or SolidParticle to test
  33439. * @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)
  33440. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33441. * @returns true if there is an intersection
  33442. */
  33443. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33444. /**
  33445. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33446. * @param point defines the point to test
  33447. * @returns true if there is an intersection
  33448. */
  33449. intersectsPoint(point: Vector3): boolean;
  33450. /**
  33451. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33452. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33453. */
  33454. get checkCollisions(): boolean;
  33455. set checkCollisions(collisionEnabled: boolean);
  33456. /**
  33457. * Gets Collider object used to compute collisions (not physics)
  33458. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33459. */
  33460. get collider(): Nullable<Collider>;
  33461. /**
  33462. * Move the mesh using collision engine
  33463. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33464. * @param displacement defines the requested displacement vector
  33465. * @returns the current mesh
  33466. */
  33467. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33468. private _onCollisionPositionChange;
  33469. /** @hidden */
  33470. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33471. /** @hidden */
  33472. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33473. /** @hidden */
  33474. _checkCollision(collider: Collider): AbstractMesh;
  33475. /** @hidden */
  33476. _generatePointsArray(): boolean;
  33477. /**
  33478. * Checks if the passed Ray intersects with the mesh
  33479. * @param ray defines the ray to use
  33480. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33481. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33482. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33483. * @returns the picking info
  33484. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33485. */
  33486. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  33487. /**
  33488. * Clones the current mesh
  33489. * @param name defines the mesh name
  33490. * @param newParent defines the new mesh parent
  33491. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33492. * @returns the new mesh
  33493. */
  33494. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33495. /**
  33496. * Disposes all the submeshes of the current meshnp
  33497. * @returns the current mesh
  33498. */
  33499. releaseSubMeshes(): AbstractMesh;
  33500. /**
  33501. * Releases resources associated with this abstract mesh.
  33502. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33503. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33504. */
  33505. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33506. /**
  33507. * Adds the passed mesh as a child to the current mesh
  33508. * @param mesh defines the child mesh
  33509. * @returns the current mesh
  33510. */
  33511. addChild(mesh: AbstractMesh): AbstractMesh;
  33512. /**
  33513. * Removes the passed mesh from the current mesh children list
  33514. * @param mesh defines the child mesh
  33515. * @returns the current mesh
  33516. */
  33517. removeChild(mesh: AbstractMesh): AbstractMesh;
  33518. /** @hidden */
  33519. private _initFacetData;
  33520. /**
  33521. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33522. * This method can be called within the render loop.
  33523. * 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
  33524. * @returns the current mesh
  33525. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33526. */
  33527. updateFacetData(): AbstractMesh;
  33528. /**
  33529. * Returns the facetLocalNormals array.
  33530. * The normals are expressed in the mesh local spac
  33531. * @returns an array of Vector3
  33532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33533. */
  33534. getFacetLocalNormals(): Vector3[];
  33535. /**
  33536. * Returns the facetLocalPositions array.
  33537. * The facet positions are expressed in the mesh local space
  33538. * @returns an array of Vector3
  33539. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33540. */
  33541. getFacetLocalPositions(): Vector3[];
  33542. /**
  33543. * Returns the facetLocalPartioning array
  33544. * @returns an array of array of numbers
  33545. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33546. */
  33547. getFacetLocalPartitioning(): number[][];
  33548. /**
  33549. * Returns the i-th facet position in the world system.
  33550. * This method allocates a new Vector3 per call
  33551. * @param i defines the facet index
  33552. * @returns a new Vector3
  33553. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33554. */
  33555. getFacetPosition(i: number): Vector3;
  33556. /**
  33557. * Sets the reference Vector3 with the i-th facet position in the world system
  33558. * @param i defines the facet index
  33559. * @param ref defines the target vector
  33560. * @returns the current mesh
  33561. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33562. */
  33563. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33564. /**
  33565. * Returns the i-th facet normal in the world system.
  33566. * This method allocates a new Vector3 per call
  33567. * @param i defines the facet index
  33568. * @returns a new Vector3
  33569. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33570. */
  33571. getFacetNormal(i: number): Vector3;
  33572. /**
  33573. * Sets the reference Vector3 with the i-th facet normal in the world system
  33574. * @param i defines the facet index
  33575. * @param ref defines the target vector
  33576. * @returns the current mesh
  33577. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33578. */
  33579. getFacetNormalToRef(i: number, ref: Vector3): this;
  33580. /**
  33581. * 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)
  33582. * @param x defines x coordinate
  33583. * @param y defines y coordinate
  33584. * @param z defines z coordinate
  33585. * @returns the array of facet indexes
  33586. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33587. */
  33588. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33589. /**
  33590. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33591. * @param projected sets as the (x,y,z) world projection on the facet
  33592. * @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
  33593. * @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
  33594. * @param x defines x coordinate
  33595. * @param y defines y coordinate
  33596. * @param z defines z coordinate
  33597. * @returns the face index if found (or null instead)
  33598. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33599. */
  33600. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33601. /**
  33602. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33603. * @param projected sets as the (x,y,z) local projection on the facet
  33604. * @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
  33605. * @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
  33606. * @param x defines x coordinate
  33607. * @param y defines y coordinate
  33608. * @param z defines z coordinate
  33609. * @returns the face index if found (or null instead)
  33610. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33611. */
  33612. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33613. /**
  33614. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33615. * @returns the parameters
  33616. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33617. */
  33618. getFacetDataParameters(): any;
  33619. /**
  33620. * Disables the feature FacetData and frees the related memory
  33621. * @returns the current mesh
  33622. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33623. */
  33624. disableFacetData(): AbstractMesh;
  33625. /**
  33626. * Updates the AbstractMesh indices array
  33627. * @param indices defines the data source
  33628. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33629. * @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)
  33630. * @returns the current mesh
  33631. */
  33632. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33633. /**
  33634. * Creates new normals data for the mesh
  33635. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33636. * @returns the current mesh
  33637. */
  33638. createNormals(updatable: boolean): AbstractMesh;
  33639. /**
  33640. * Align the mesh with a normal
  33641. * @param normal defines the normal to use
  33642. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33643. * @returns the current mesh
  33644. */
  33645. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33646. /** @hidden */
  33647. _checkOcclusionQuery(): boolean;
  33648. /**
  33649. * Disables the mesh edge rendering mode
  33650. * @returns the currentAbstractMesh
  33651. */
  33652. disableEdgesRendering(): AbstractMesh;
  33653. /**
  33654. * Enables the edge rendering mode on the mesh.
  33655. * This mode makes the mesh edges visible
  33656. * @param epsilon defines the maximal distance between two angles to detect a face
  33657. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33658. * @returns the currentAbstractMesh
  33659. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33660. */
  33661. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33662. /**
  33663. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33664. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33665. */
  33666. getConnectedParticleSystems(): IParticleSystem[];
  33667. }
  33668. }
  33669. declare module "babylonjs/Actions/actionEvent" {
  33670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33671. import { Nullable } from "babylonjs/types";
  33672. import { Sprite } from "babylonjs/Sprites/sprite";
  33673. import { Scene } from "babylonjs/scene";
  33674. import { Vector2 } from "babylonjs/Maths/math.vector";
  33675. /**
  33676. * Interface used to define ActionEvent
  33677. */
  33678. export interface IActionEvent {
  33679. /** The mesh or sprite that triggered the action */
  33680. source: any;
  33681. /** The X mouse cursor position at the time of the event */
  33682. pointerX: number;
  33683. /** The Y mouse cursor position at the time of the event */
  33684. pointerY: number;
  33685. /** The mesh that is currently pointed at (can be null) */
  33686. meshUnderPointer: Nullable<AbstractMesh>;
  33687. /** the original (browser) event that triggered the ActionEvent */
  33688. sourceEvent?: any;
  33689. /** additional data for the event */
  33690. additionalData?: any;
  33691. }
  33692. /**
  33693. * ActionEvent is the event being sent when an action is triggered.
  33694. */
  33695. export class ActionEvent implements IActionEvent {
  33696. /** The mesh or sprite that triggered the action */
  33697. source: any;
  33698. /** The X mouse cursor position at the time of the event */
  33699. pointerX: number;
  33700. /** The Y mouse cursor position at the time of the event */
  33701. pointerY: number;
  33702. /** The mesh that is currently pointed at (can be null) */
  33703. meshUnderPointer: Nullable<AbstractMesh>;
  33704. /** the original (browser) event that triggered the ActionEvent */
  33705. sourceEvent?: any;
  33706. /** additional data for the event */
  33707. additionalData?: any;
  33708. /**
  33709. * Creates a new ActionEvent
  33710. * @param source The mesh or sprite that triggered the action
  33711. * @param pointerX The X mouse cursor position at the time of the event
  33712. * @param pointerY The Y mouse cursor position at the time of the event
  33713. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33714. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33715. * @param additionalData additional data for the event
  33716. */
  33717. constructor(
  33718. /** The mesh or sprite that triggered the action */
  33719. source: any,
  33720. /** The X mouse cursor position at the time of the event */
  33721. pointerX: number,
  33722. /** The Y mouse cursor position at the time of the event */
  33723. pointerY: number,
  33724. /** The mesh that is currently pointed at (can be null) */
  33725. meshUnderPointer: Nullable<AbstractMesh>,
  33726. /** the original (browser) event that triggered the ActionEvent */
  33727. sourceEvent?: any,
  33728. /** additional data for the event */
  33729. additionalData?: any);
  33730. /**
  33731. * Helper function to auto-create an ActionEvent from a source mesh.
  33732. * @param source The source mesh that triggered the event
  33733. * @param evt The original (browser) event
  33734. * @param additionalData additional data for the event
  33735. * @returns the new ActionEvent
  33736. */
  33737. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33738. /**
  33739. * Helper function to auto-create an ActionEvent from a source sprite
  33740. * @param source The source sprite that triggered the event
  33741. * @param scene Scene associated with the sprite
  33742. * @param evt The original (browser) event
  33743. * @param additionalData additional data for the event
  33744. * @returns the new ActionEvent
  33745. */
  33746. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33747. /**
  33748. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33749. * @param scene the scene where the event occurred
  33750. * @param evt The original (browser) event
  33751. * @returns the new ActionEvent
  33752. */
  33753. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33754. /**
  33755. * Helper function to auto-create an ActionEvent from a primitive
  33756. * @param prim defines the target primitive
  33757. * @param pointerPos defines the pointer position
  33758. * @param evt The original (browser) event
  33759. * @param additionalData additional data for the event
  33760. * @returns the new ActionEvent
  33761. */
  33762. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33763. }
  33764. }
  33765. declare module "babylonjs/Actions/abstractActionManager" {
  33766. import { IDisposable } from "babylonjs/scene";
  33767. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33768. import { IAction } from "babylonjs/Actions/action";
  33769. import { Nullable } from "babylonjs/types";
  33770. /**
  33771. * Abstract class used to decouple action Manager from scene and meshes.
  33772. * Do not instantiate.
  33773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33774. */
  33775. export abstract class AbstractActionManager implements IDisposable {
  33776. /** Gets the list of active triggers */
  33777. static Triggers: {
  33778. [key: string]: number;
  33779. };
  33780. /** Gets the cursor to use when hovering items */
  33781. hoverCursor: string;
  33782. /** Gets the list of actions */
  33783. actions: IAction[];
  33784. /**
  33785. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33786. */
  33787. isRecursive: boolean;
  33788. /**
  33789. * Releases all associated resources
  33790. */
  33791. abstract dispose(): void;
  33792. /**
  33793. * Does this action manager has pointer triggers
  33794. */
  33795. abstract get hasPointerTriggers(): boolean;
  33796. /**
  33797. * Does this action manager has pick triggers
  33798. */
  33799. abstract get hasPickTriggers(): boolean;
  33800. /**
  33801. * Process a specific trigger
  33802. * @param trigger defines the trigger to process
  33803. * @param evt defines the event details to be processed
  33804. */
  33805. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33806. /**
  33807. * Does this action manager handles actions of any of the given triggers
  33808. * @param triggers defines the triggers to be tested
  33809. * @return a boolean indicating whether one (or more) of the triggers is handled
  33810. */
  33811. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33812. /**
  33813. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33814. * speed.
  33815. * @param triggerA defines the trigger to be tested
  33816. * @param triggerB defines the trigger to be tested
  33817. * @return a boolean indicating whether one (or more) of the triggers is handled
  33818. */
  33819. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33820. /**
  33821. * Does this action manager handles actions of a given trigger
  33822. * @param trigger defines the trigger to be tested
  33823. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33824. * @return whether the trigger is handled
  33825. */
  33826. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33827. /**
  33828. * Serialize this manager to a JSON object
  33829. * @param name defines the property name to store this manager
  33830. * @returns a JSON representation of this manager
  33831. */
  33832. abstract serialize(name: string): any;
  33833. /**
  33834. * Registers an action to this action manager
  33835. * @param action defines the action to be registered
  33836. * @return the action amended (prepared) after registration
  33837. */
  33838. abstract registerAction(action: IAction): Nullable<IAction>;
  33839. /**
  33840. * Unregisters an action to this action manager
  33841. * @param action defines the action to be unregistered
  33842. * @return a boolean indicating whether the action has been unregistered
  33843. */
  33844. abstract unregisterAction(action: IAction): Boolean;
  33845. /**
  33846. * Does exist one action manager with at least one trigger
  33847. **/
  33848. static get HasTriggers(): boolean;
  33849. /**
  33850. * Does exist one action manager with at least one pick trigger
  33851. **/
  33852. static get HasPickTriggers(): boolean;
  33853. /**
  33854. * Does exist one action manager that handles actions of a given trigger
  33855. * @param trigger defines the trigger to be tested
  33856. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33857. **/
  33858. static HasSpecificTrigger(trigger: number): boolean;
  33859. }
  33860. }
  33861. declare module "babylonjs/node" {
  33862. import { Scene } from "babylonjs/scene";
  33863. import { Nullable } from "babylonjs/types";
  33864. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33865. import { Engine } from "babylonjs/Engines/engine";
  33866. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33867. import { Observable } from "babylonjs/Misc/observable";
  33868. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33869. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33870. import { Animatable } from "babylonjs/Animations/animatable";
  33871. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33872. import { Animation } from "babylonjs/Animations/animation";
  33873. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33875. /**
  33876. * Defines how a node can be built from a string name.
  33877. */
  33878. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33879. /**
  33880. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33881. */
  33882. export class Node implements IBehaviorAware<Node> {
  33883. /** @hidden */
  33884. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33885. private static _NodeConstructors;
  33886. /**
  33887. * Add a new node constructor
  33888. * @param type defines the type name of the node to construct
  33889. * @param constructorFunc defines the constructor function
  33890. */
  33891. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33892. /**
  33893. * Returns a node constructor based on type name
  33894. * @param type defines the type name
  33895. * @param name defines the new node name
  33896. * @param scene defines the hosting scene
  33897. * @param options defines optional options to transmit to constructors
  33898. * @returns the new constructor or null
  33899. */
  33900. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33901. /**
  33902. * Gets or sets the name of the node
  33903. */
  33904. name: string;
  33905. /**
  33906. * Gets or sets the id of the node
  33907. */
  33908. id: string;
  33909. /**
  33910. * Gets or sets the unique id of the node
  33911. */
  33912. uniqueId: number;
  33913. /**
  33914. * Gets or sets a string used to store user defined state for the node
  33915. */
  33916. state: string;
  33917. /**
  33918. * Gets or sets an object used to store user defined information for the node
  33919. */
  33920. metadata: any;
  33921. /**
  33922. * For internal use only. Please do not use.
  33923. */
  33924. reservedDataStore: any;
  33925. /**
  33926. * List of inspectable custom properties (used by the Inspector)
  33927. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33928. */
  33929. inspectableCustomProperties: IInspectable[];
  33930. private _doNotSerialize;
  33931. /**
  33932. * Gets or sets a boolean used to define if the node must be serialized
  33933. */
  33934. get doNotSerialize(): boolean;
  33935. set doNotSerialize(value: boolean);
  33936. /** @hidden */
  33937. _isDisposed: boolean;
  33938. /**
  33939. * Gets a list of Animations associated with the node
  33940. */
  33941. animations: import("babylonjs/Animations/animation").Animation[];
  33942. protected _ranges: {
  33943. [name: string]: Nullable<AnimationRange>;
  33944. };
  33945. /**
  33946. * Callback raised when the node is ready to be used
  33947. */
  33948. onReady: Nullable<(node: Node) => void>;
  33949. private _isEnabled;
  33950. private _isParentEnabled;
  33951. private _isReady;
  33952. /** @hidden */
  33953. _currentRenderId: number;
  33954. private _parentUpdateId;
  33955. /** @hidden */
  33956. _childUpdateId: number;
  33957. /** @hidden */
  33958. _waitingParentId: Nullable<string>;
  33959. /** @hidden */
  33960. _scene: Scene;
  33961. /** @hidden */
  33962. _cache: any;
  33963. private _parentNode;
  33964. private _children;
  33965. /** @hidden */
  33966. _worldMatrix: Matrix;
  33967. /** @hidden */
  33968. _worldMatrixDeterminant: number;
  33969. /** @hidden */
  33970. _worldMatrixDeterminantIsDirty: boolean;
  33971. /** @hidden */
  33972. private _sceneRootNodesIndex;
  33973. /**
  33974. * Gets a boolean indicating if the node has been disposed
  33975. * @returns true if the node was disposed
  33976. */
  33977. isDisposed(): boolean;
  33978. /**
  33979. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33980. * @see https://doc.babylonjs.com/how_to/parenting
  33981. */
  33982. set parent(parent: Nullable<Node>);
  33983. get parent(): Nullable<Node>;
  33984. /** @hidden */
  33985. _addToSceneRootNodes(): void;
  33986. /** @hidden */
  33987. _removeFromSceneRootNodes(): void;
  33988. private _animationPropertiesOverride;
  33989. /**
  33990. * Gets or sets the animation properties override
  33991. */
  33992. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33993. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33994. /**
  33995. * Gets a string idenfifying the name of the class
  33996. * @returns "Node" string
  33997. */
  33998. getClassName(): string;
  33999. /** @hidden */
  34000. readonly _isNode: boolean;
  34001. /**
  34002. * An event triggered when the mesh is disposed
  34003. */
  34004. onDisposeObservable: Observable<Node>;
  34005. private _onDisposeObserver;
  34006. /**
  34007. * Sets a callback that will be raised when the node will be disposed
  34008. */
  34009. set onDispose(callback: () => void);
  34010. /**
  34011. * Creates a new Node
  34012. * @param name the name and id to be given to this node
  34013. * @param scene the scene this node will be added to
  34014. */
  34015. constructor(name: string, scene?: Nullable<Scene>);
  34016. /**
  34017. * Gets the scene of the node
  34018. * @returns a scene
  34019. */
  34020. getScene(): Scene;
  34021. /**
  34022. * Gets the engine of the node
  34023. * @returns a Engine
  34024. */
  34025. getEngine(): Engine;
  34026. private _behaviors;
  34027. /**
  34028. * Attach a behavior to the node
  34029. * @see https://doc.babylonjs.com/features/behaviour
  34030. * @param behavior defines the behavior to attach
  34031. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34032. * @returns the current Node
  34033. */
  34034. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34035. /**
  34036. * Remove an attached behavior
  34037. * @see https://doc.babylonjs.com/features/behaviour
  34038. * @param behavior defines the behavior to attach
  34039. * @returns the current Node
  34040. */
  34041. removeBehavior(behavior: Behavior<Node>): Node;
  34042. /**
  34043. * Gets the list of attached behaviors
  34044. * @see https://doc.babylonjs.com/features/behaviour
  34045. */
  34046. get behaviors(): Behavior<Node>[];
  34047. /**
  34048. * Gets an attached behavior by name
  34049. * @param name defines the name of the behavior to look for
  34050. * @see https://doc.babylonjs.com/features/behaviour
  34051. * @returns null if behavior was not found else the requested behavior
  34052. */
  34053. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34054. /**
  34055. * Returns the latest update of the World matrix
  34056. * @returns a Matrix
  34057. */
  34058. getWorldMatrix(): Matrix;
  34059. /** @hidden */
  34060. _getWorldMatrixDeterminant(): number;
  34061. /**
  34062. * Returns directly the latest state of the mesh World matrix.
  34063. * A Matrix is returned.
  34064. */
  34065. get worldMatrixFromCache(): Matrix;
  34066. /** @hidden */
  34067. _initCache(): void;
  34068. /** @hidden */
  34069. updateCache(force?: boolean): void;
  34070. /** @hidden */
  34071. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34072. /** @hidden */
  34073. _updateCache(ignoreParentClass?: boolean): void;
  34074. /** @hidden */
  34075. _isSynchronized(): boolean;
  34076. /** @hidden */
  34077. _markSyncedWithParent(): void;
  34078. /** @hidden */
  34079. isSynchronizedWithParent(): boolean;
  34080. /** @hidden */
  34081. isSynchronized(): boolean;
  34082. /**
  34083. * Is this node ready to be used/rendered
  34084. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34085. * @return true if the node is ready
  34086. */
  34087. isReady(completeCheck?: boolean): boolean;
  34088. /**
  34089. * Is this node enabled?
  34090. * 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
  34091. * @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
  34092. * @return whether this node (and its parent) is enabled
  34093. */
  34094. isEnabled(checkAncestors?: boolean): boolean;
  34095. /** @hidden */
  34096. protected _syncParentEnabledState(): void;
  34097. /**
  34098. * Set the enabled state of this node
  34099. * @param value defines the new enabled state
  34100. */
  34101. setEnabled(value: boolean): void;
  34102. /**
  34103. * Is this node a descendant of the given node?
  34104. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34105. * @param ancestor defines the parent node to inspect
  34106. * @returns a boolean indicating if this node is a descendant of the given node
  34107. */
  34108. isDescendantOf(ancestor: Node): boolean;
  34109. /** @hidden */
  34110. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34111. /**
  34112. * Will return all nodes that have this node as ascendant
  34113. * @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
  34114. * @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
  34115. * @return all children nodes of all types
  34116. */
  34117. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34118. /**
  34119. * Get all child-meshes of this node
  34120. * @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)
  34121. * @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
  34122. * @returns an array of AbstractMesh
  34123. */
  34124. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34125. /**
  34126. * Get all direct children of this node
  34127. * @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
  34128. * @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)
  34129. * @returns an array of Node
  34130. */
  34131. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34132. /** @hidden */
  34133. _setReady(state: boolean): void;
  34134. /**
  34135. * Get an animation by name
  34136. * @param name defines the name of the animation to look for
  34137. * @returns null if not found else the requested animation
  34138. */
  34139. getAnimationByName(name: string): Nullable<Animation>;
  34140. /**
  34141. * Creates an animation range for this node
  34142. * @param name defines the name of the range
  34143. * @param from defines the starting key
  34144. * @param to defines the end key
  34145. */
  34146. createAnimationRange(name: string, from: number, to: number): void;
  34147. /**
  34148. * Delete a specific animation range
  34149. * @param name defines the name of the range to delete
  34150. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34151. */
  34152. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34153. /**
  34154. * Get an animation range by name
  34155. * @param name defines the name of the animation range to look for
  34156. * @returns null if not found else the requested animation range
  34157. */
  34158. getAnimationRange(name: string): Nullable<AnimationRange>;
  34159. /**
  34160. * Gets the list of all animation ranges defined on this node
  34161. * @returns an array
  34162. */
  34163. getAnimationRanges(): Nullable<AnimationRange>[];
  34164. /**
  34165. * Will start the animation sequence
  34166. * @param name defines the range frames for animation sequence
  34167. * @param loop defines if the animation should loop (false by default)
  34168. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34169. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34170. * @returns the object created for this animation. If range does not exist, it will return null
  34171. */
  34172. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34173. /**
  34174. * Serialize animation ranges into a JSON compatible object
  34175. * @returns serialization object
  34176. */
  34177. serializeAnimationRanges(): any;
  34178. /**
  34179. * Computes the world matrix of the node
  34180. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34181. * @returns the world matrix
  34182. */
  34183. computeWorldMatrix(force?: boolean): Matrix;
  34184. /**
  34185. * Releases resources associated with this node.
  34186. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34187. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34188. */
  34189. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34190. /**
  34191. * Parse animation range data from a serialization object and store them into a given node
  34192. * @param node defines where to store the animation ranges
  34193. * @param parsedNode defines the serialization object to read data from
  34194. * @param scene defines the hosting scene
  34195. */
  34196. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34197. /**
  34198. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34199. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34200. * @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
  34201. * @returns the new bounding vectors
  34202. */
  34203. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34204. min: Vector3;
  34205. max: Vector3;
  34206. };
  34207. }
  34208. }
  34209. declare module "babylonjs/Animations/animation" {
  34210. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34211. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34212. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34213. import { Nullable } from "babylonjs/types";
  34214. import { Scene } from "babylonjs/scene";
  34215. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34216. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34217. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34218. import { Node } from "babylonjs/node";
  34219. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34220. import { Size } from "babylonjs/Maths/math.size";
  34221. import { Animatable } from "babylonjs/Animations/animatable";
  34222. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34223. /**
  34224. * @hidden
  34225. */
  34226. export class _IAnimationState {
  34227. key: number;
  34228. repeatCount: number;
  34229. workValue?: any;
  34230. loopMode?: number;
  34231. offsetValue?: any;
  34232. highLimitValue?: any;
  34233. }
  34234. /**
  34235. * Class used to store any kind of animation
  34236. */
  34237. export class Animation {
  34238. /**Name of the animation */
  34239. name: string;
  34240. /**Property to animate */
  34241. targetProperty: string;
  34242. /**The frames per second of the animation */
  34243. framePerSecond: number;
  34244. /**The data type of the animation */
  34245. dataType: number;
  34246. /**The loop mode of the animation */
  34247. loopMode?: number | undefined;
  34248. /**Specifies if blending should be enabled */
  34249. enableBlending?: boolean | undefined;
  34250. /**
  34251. * Use matrix interpolation instead of using direct key value when animating matrices
  34252. */
  34253. static AllowMatricesInterpolation: boolean;
  34254. /**
  34255. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34256. */
  34257. static AllowMatrixDecomposeForInterpolation: boolean;
  34258. /** Define the Url to load snippets */
  34259. static SnippetUrl: string;
  34260. /** Snippet ID if the animation was created from the snippet server */
  34261. snippetId: string;
  34262. /**
  34263. * Stores the key frames of the animation
  34264. */
  34265. private _keys;
  34266. /**
  34267. * Stores the easing function of the animation
  34268. */
  34269. private _easingFunction;
  34270. /**
  34271. * @hidden Internal use only
  34272. */
  34273. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34274. /**
  34275. * The set of event that will be linked to this animation
  34276. */
  34277. private _events;
  34278. /**
  34279. * Stores an array of target property paths
  34280. */
  34281. targetPropertyPath: string[];
  34282. /**
  34283. * Stores the blending speed of the animation
  34284. */
  34285. blendingSpeed: number;
  34286. /**
  34287. * Stores the animation ranges for the animation
  34288. */
  34289. private _ranges;
  34290. /**
  34291. * @hidden Internal use
  34292. */
  34293. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34294. /**
  34295. * Sets up an animation
  34296. * @param property The property to animate
  34297. * @param animationType The animation type to apply
  34298. * @param framePerSecond The frames per second of the animation
  34299. * @param easingFunction The easing function used in the animation
  34300. * @returns The created animation
  34301. */
  34302. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34303. /**
  34304. * Create and start an animation on a node
  34305. * @param name defines the name of the global animation that will be run on all nodes
  34306. * @param node defines the root node where the animation will take place
  34307. * @param targetProperty defines property to animate
  34308. * @param framePerSecond defines the number of frame per second yo use
  34309. * @param totalFrame defines the number of frames in total
  34310. * @param from defines the initial value
  34311. * @param to defines the final value
  34312. * @param loopMode defines which loop mode you want to use (off by default)
  34313. * @param easingFunction defines the easing function to use (linear by default)
  34314. * @param onAnimationEnd defines the callback to call when animation end
  34315. * @returns the animatable created for this animation
  34316. */
  34317. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34318. /**
  34319. * Create and start an animation on a node and its descendants
  34320. * @param name defines the name of the global animation that will be run on all nodes
  34321. * @param node defines the root node where the animation will take place
  34322. * @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
  34323. * @param targetProperty defines property to animate
  34324. * @param framePerSecond defines the number of frame per second to use
  34325. * @param totalFrame defines the number of frames in total
  34326. * @param from defines the initial value
  34327. * @param to defines the final value
  34328. * @param loopMode defines which loop mode you want to use (off by default)
  34329. * @param easingFunction defines the easing function to use (linear by default)
  34330. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34331. * @returns the list of animatables created for all nodes
  34332. * @example https://www.babylonjs-playground.com/#MH0VLI
  34333. */
  34334. 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[]>;
  34335. /**
  34336. * Creates a new animation, merges it with the existing animations and starts it
  34337. * @param name Name of the animation
  34338. * @param node Node which contains the scene that begins the animations
  34339. * @param targetProperty Specifies which property to animate
  34340. * @param framePerSecond The frames per second of the animation
  34341. * @param totalFrame The total number of frames
  34342. * @param from The frame at the beginning of the animation
  34343. * @param to The frame at the end of the animation
  34344. * @param loopMode Specifies the loop mode of the animation
  34345. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34346. * @param onAnimationEnd Callback to run once the animation is complete
  34347. * @returns Nullable animation
  34348. */
  34349. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34350. /**
  34351. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34352. * @param sourceAnimation defines the Animation containing keyframes to convert
  34353. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34354. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34355. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34356. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34357. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34358. */
  34359. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34360. /**
  34361. * Transition property of an host to the target Value
  34362. * @param property The property to transition
  34363. * @param targetValue The target Value of the property
  34364. * @param host The object where the property to animate belongs
  34365. * @param scene Scene used to run the animation
  34366. * @param frameRate Framerate (in frame/s) to use
  34367. * @param transition The transition type we want to use
  34368. * @param duration The duration of the animation, in milliseconds
  34369. * @param onAnimationEnd Callback trigger at the end of the animation
  34370. * @returns Nullable animation
  34371. */
  34372. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34373. /**
  34374. * Return the array of runtime animations currently using this animation
  34375. */
  34376. get runtimeAnimations(): RuntimeAnimation[];
  34377. /**
  34378. * Specifies if any of the runtime animations are currently running
  34379. */
  34380. get hasRunningRuntimeAnimations(): boolean;
  34381. /**
  34382. * Initializes the animation
  34383. * @param name Name of the animation
  34384. * @param targetProperty Property to animate
  34385. * @param framePerSecond The frames per second of the animation
  34386. * @param dataType The data type of the animation
  34387. * @param loopMode The loop mode of the animation
  34388. * @param enableBlending Specifies if blending should be enabled
  34389. */
  34390. constructor(
  34391. /**Name of the animation */
  34392. name: string,
  34393. /**Property to animate */
  34394. targetProperty: string,
  34395. /**The frames per second of the animation */
  34396. framePerSecond: number,
  34397. /**The data type of the animation */
  34398. dataType: number,
  34399. /**The loop mode of the animation */
  34400. loopMode?: number | undefined,
  34401. /**Specifies if blending should be enabled */
  34402. enableBlending?: boolean | undefined);
  34403. /**
  34404. * Converts the animation to a string
  34405. * @param fullDetails support for multiple levels of logging within scene loading
  34406. * @returns String form of the animation
  34407. */
  34408. toString(fullDetails?: boolean): string;
  34409. /**
  34410. * Add an event to this animation
  34411. * @param event Event to add
  34412. */
  34413. addEvent(event: AnimationEvent): void;
  34414. /**
  34415. * Remove all events found at the given frame
  34416. * @param frame The frame to remove events from
  34417. */
  34418. removeEvents(frame: number): void;
  34419. /**
  34420. * Retrieves all the events from the animation
  34421. * @returns Events from the animation
  34422. */
  34423. getEvents(): AnimationEvent[];
  34424. /**
  34425. * Creates an animation range
  34426. * @param name Name of the animation range
  34427. * @param from Starting frame of the animation range
  34428. * @param to Ending frame of the animation
  34429. */
  34430. createRange(name: string, from: number, to: number): void;
  34431. /**
  34432. * Deletes an animation range by name
  34433. * @param name Name of the animation range to delete
  34434. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34435. */
  34436. deleteRange(name: string, deleteFrames?: boolean): void;
  34437. /**
  34438. * Gets the animation range by name, or null if not defined
  34439. * @param name Name of the animation range
  34440. * @returns Nullable animation range
  34441. */
  34442. getRange(name: string): Nullable<AnimationRange>;
  34443. /**
  34444. * Gets the key frames from the animation
  34445. * @returns The key frames of the animation
  34446. */
  34447. getKeys(): Array<IAnimationKey>;
  34448. /**
  34449. * Gets the highest frame rate of the animation
  34450. * @returns Highest frame rate of the animation
  34451. */
  34452. getHighestFrame(): number;
  34453. /**
  34454. * Gets the easing function of the animation
  34455. * @returns Easing function of the animation
  34456. */
  34457. getEasingFunction(): IEasingFunction;
  34458. /**
  34459. * Sets the easing function of the animation
  34460. * @param easingFunction A custom mathematical formula for animation
  34461. */
  34462. setEasingFunction(easingFunction: EasingFunction): void;
  34463. /**
  34464. * Interpolates a scalar linearly
  34465. * @param startValue Start value of the animation curve
  34466. * @param endValue End value of the animation curve
  34467. * @param gradient Scalar amount to interpolate
  34468. * @returns Interpolated scalar value
  34469. */
  34470. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34471. /**
  34472. * Interpolates a scalar cubically
  34473. * @param startValue Start value of the animation curve
  34474. * @param outTangent End tangent of the animation
  34475. * @param endValue End value of the animation curve
  34476. * @param inTangent Start tangent of the animation curve
  34477. * @param gradient Scalar amount to interpolate
  34478. * @returns Interpolated scalar value
  34479. */
  34480. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34481. /**
  34482. * Interpolates a quaternion using a spherical linear interpolation
  34483. * @param startValue Start value of the animation curve
  34484. * @param endValue End value of the animation curve
  34485. * @param gradient Scalar amount to interpolate
  34486. * @returns Interpolated quaternion value
  34487. */
  34488. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34489. /**
  34490. * Interpolates a quaternion cubically
  34491. * @param startValue Start value of the animation curve
  34492. * @param outTangent End tangent of the animation curve
  34493. * @param endValue End value of the animation curve
  34494. * @param inTangent Start tangent of the animation curve
  34495. * @param gradient Scalar amount to interpolate
  34496. * @returns Interpolated quaternion value
  34497. */
  34498. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34499. /**
  34500. * Interpolates a Vector3 linearl
  34501. * @param startValue Start value of the animation curve
  34502. * @param endValue End value of the animation curve
  34503. * @param gradient Scalar amount to interpolate
  34504. * @returns Interpolated scalar value
  34505. */
  34506. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34507. /**
  34508. * Interpolates a Vector3 cubically
  34509. * @param startValue Start value of the animation curve
  34510. * @param outTangent End tangent of the animation
  34511. * @param endValue End value of the animation curve
  34512. * @param inTangent Start tangent of the animation curve
  34513. * @param gradient Scalar amount to interpolate
  34514. * @returns InterpolatedVector3 value
  34515. */
  34516. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34517. /**
  34518. * Interpolates a Vector2 linearly
  34519. * @param startValue Start value of the animation curve
  34520. * @param endValue End value of the animation curve
  34521. * @param gradient Scalar amount to interpolate
  34522. * @returns Interpolated Vector2 value
  34523. */
  34524. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34525. /**
  34526. * Interpolates a Vector2 cubically
  34527. * @param startValue Start value of the animation curve
  34528. * @param outTangent End tangent of the animation
  34529. * @param endValue End value of the animation curve
  34530. * @param inTangent Start tangent of the animation curve
  34531. * @param gradient Scalar amount to interpolate
  34532. * @returns Interpolated Vector2 value
  34533. */
  34534. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34535. /**
  34536. * Interpolates a size linearly
  34537. * @param startValue Start value of the animation curve
  34538. * @param endValue End value of the animation curve
  34539. * @param gradient Scalar amount to interpolate
  34540. * @returns Interpolated Size value
  34541. */
  34542. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34543. /**
  34544. * Interpolates a Color3 linearly
  34545. * @param startValue Start value of the animation curve
  34546. * @param endValue End value of the animation curve
  34547. * @param gradient Scalar amount to interpolate
  34548. * @returns Interpolated Color3 value
  34549. */
  34550. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34551. /**
  34552. * Interpolates a Color4 linearly
  34553. * @param startValue Start value of the animation curve
  34554. * @param endValue End value of the animation curve
  34555. * @param gradient Scalar amount to interpolate
  34556. * @returns Interpolated Color3 value
  34557. */
  34558. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34559. /**
  34560. * @hidden Internal use only
  34561. */
  34562. _getKeyValue(value: any): any;
  34563. /**
  34564. * @hidden Internal use only
  34565. */
  34566. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34567. /**
  34568. * Defines the function to use to interpolate matrices
  34569. * @param startValue defines the start matrix
  34570. * @param endValue defines the end matrix
  34571. * @param gradient defines the gradient between both matrices
  34572. * @param result defines an optional target matrix where to store the interpolation
  34573. * @returns the interpolated matrix
  34574. */
  34575. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34576. /**
  34577. * Makes a copy of the animation
  34578. * @returns Cloned animation
  34579. */
  34580. clone(): Animation;
  34581. /**
  34582. * Sets the key frames of the animation
  34583. * @param values The animation key frames to set
  34584. */
  34585. setKeys(values: Array<IAnimationKey>): void;
  34586. /**
  34587. * Serializes the animation to an object
  34588. * @returns Serialized object
  34589. */
  34590. serialize(): any;
  34591. /**
  34592. * Float animation type
  34593. */
  34594. static readonly ANIMATIONTYPE_FLOAT: number;
  34595. /**
  34596. * Vector3 animation type
  34597. */
  34598. static readonly ANIMATIONTYPE_VECTOR3: number;
  34599. /**
  34600. * Quaternion animation type
  34601. */
  34602. static readonly ANIMATIONTYPE_QUATERNION: number;
  34603. /**
  34604. * Matrix animation type
  34605. */
  34606. static readonly ANIMATIONTYPE_MATRIX: number;
  34607. /**
  34608. * Color3 animation type
  34609. */
  34610. static readonly ANIMATIONTYPE_COLOR3: number;
  34611. /**
  34612. * Color3 animation type
  34613. */
  34614. static readonly ANIMATIONTYPE_COLOR4: number;
  34615. /**
  34616. * Vector2 animation type
  34617. */
  34618. static readonly ANIMATIONTYPE_VECTOR2: number;
  34619. /**
  34620. * Size animation type
  34621. */
  34622. static readonly ANIMATIONTYPE_SIZE: number;
  34623. /**
  34624. * Relative Loop Mode
  34625. */
  34626. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34627. /**
  34628. * Cycle Loop Mode
  34629. */
  34630. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34631. /**
  34632. * Constant Loop Mode
  34633. */
  34634. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34635. /** @hidden */
  34636. static _UniversalLerp(left: any, right: any, amount: number): any;
  34637. /**
  34638. * Parses an animation object and creates an animation
  34639. * @param parsedAnimation Parsed animation object
  34640. * @returns Animation object
  34641. */
  34642. static Parse(parsedAnimation: any): Animation;
  34643. /**
  34644. * Appends the serialized animations from the source animations
  34645. * @param source Source containing the animations
  34646. * @param destination Target to store the animations
  34647. */
  34648. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34649. /**
  34650. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34651. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34652. * @param url defines the url to load from
  34653. * @returns a promise that will resolve to the new animation or an array of animations
  34654. */
  34655. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34656. /**
  34657. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34658. * @param snippetId defines the snippet to load
  34659. * @returns a promise that will resolve to the new animation or a new array of animations
  34660. */
  34661. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34662. }
  34663. }
  34664. declare module "babylonjs/Animations/animatable.interface" {
  34665. import { Nullable } from "babylonjs/types";
  34666. import { Animation } from "babylonjs/Animations/animation";
  34667. /**
  34668. * Interface containing an array of animations
  34669. */
  34670. export interface IAnimatable {
  34671. /**
  34672. * Array of animations
  34673. */
  34674. animations: Nullable<Array<Animation>>;
  34675. }
  34676. }
  34677. declare module "babylonjs/Misc/decorators" {
  34678. import { Nullable } from "babylonjs/types";
  34679. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34680. import { Scene } from "babylonjs/scene";
  34681. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34682. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34683. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34685. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34686. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34687. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34688. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34689. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34690. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34691. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34692. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34693. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34694. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34695. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34696. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34697. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34698. /**
  34699. * Decorator used to define property that can be serialized as reference to a camera
  34700. * @param sourceName defines the name of the property to decorate
  34701. */
  34702. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34703. /**
  34704. * Class used to help serialization objects
  34705. */
  34706. export class SerializationHelper {
  34707. /** @hidden */
  34708. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34709. /** @hidden */
  34710. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34711. /** @hidden */
  34712. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34713. /** @hidden */
  34714. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34715. /**
  34716. * Appends the serialized animations from the source animations
  34717. * @param source Source containing the animations
  34718. * @param destination Target to store the animations
  34719. */
  34720. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34721. /**
  34722. * Static function used to serialized a specific entity
  34723. * @param entity defines the entity to serialize
  34724. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34725. * @returns a JSON compatible object representing the serialization of the entity
  34726. */
  34727. static Serialize<T>(entity: T, serializationObject?: any): any;
  34728. /**
  34729. * Creates a new entity from a serialization data object
  34730. * @param creationFunction defines a function used to instanciated the new entity
  34731. * @param source defines the source serialization data
  34732. * @param scene defines the hosting scene
  34733. * @param rootUrl defines the root url for resources
  34734. * @returns a new entity
  34735. */
  34736. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34737. /**
  34738. * Clones an object
  34739. * @param creationFunction defines the function used to instanciate the new object
  34740. * @param source defines the source object
  34741. * @returns the cloned object
  34742. */
  34743. static Clone<T>(creationFunction: () => T, source: T): T;
  34744. /**
  34745. * Instanciates a new object based on a source one (some data will be shared between both object)
  34746. * @param creationFunction defines the function used to instanciate the new object
  34747. * @param source defines the source object
  34748. * @returns the new object
  34749. */
  34750. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34751. }
  34752. }
  34753. declare module "babylonjs/Materials/Textures/baseTexture" {
  34754. import { Observable } from "babylonjs/Misc/observable";
  34755. import { Nullable } from "babylonjs/types";
  34756. import { Scene } from "babylonjs/scene";
  34757. import { Matrix } from "babylonjs/Maths/math.vector";
  34758. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34759. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34760. import { ISize } from "babylonjs/Maths/math.size";
  34761. import "babylonjs/Misc/fileTools";
  34762. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34763. /**
  34764. * Base class of all the textures in babylon.
  34765. * It groups all the common properties the materials, post process, lights... might need
  34766. * in order to make a correct use of the texture.
  34767. */
  34768. export class BaseTexture implements IAnimatable {
  34769. /**
  34770. * Default anisotropic filtering level for the application.
  34771. * It is set to 4 as a good tradeoff between perf and quality.
  34772. */
  34773. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34774. /**
  34775. * Gets or sets the unique id of the texture
  34776. */
  34777. uniqueId: number;
  34778. /**
  34779. * Define the name of the texture.
  34780. */
  34781. name: string;
  34782. /**
  34783. * Gets or sets an object used to store user defined information.
  34784. */
  34785. metadata: any;
  34786. /**
  34787. * For internal use only. Please do not use.
  34788. */
  34789. reservedDataStore: any;
  34790. private _hasAlpha;
  34791. /**
  34792. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34793. */
  34794. set hasAlpha(value: boolean);
  34795. get hasAlpha(): boolean;
  34796. /**
  34797. * Defines if the alpha value should be determined via the rgb values.
  34798. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34799. */
  34800. getAlphaFromRGB: boolean;
  34801. /**
  34802. * Intensity or strength of the texture.
  34803. * It is commonly used by materials to fine tune the intensity of the texture
  34804. */
  34805. level: number;
  34806. /**
  34807. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34808. * This is part of the texture as textures usually maps to one uv set.
  34809. */
  34810. coordinatesIndex: number;
  34811. private _coordinatesMode;
  34812. /**
  34813. * How a texture is mapped.
  34814. *
  34815. * | Value | Type | Description |
  34816. * | ----- | ----------------------------------- | ----------- |
  34817. * | 0 | EXPLICIT_MODE | |
  34818. * | 1 | SPHERICAL_MODE | |
  34819. * | 2 | PLANAR_MODE | |
  34820. * | 3 | CUBIC_MODE | |
  34821. * | 4 | PROJECTION_MODE | |
  34822. * | 5 | SKYBOX_MODE | |
  34823. * | 6 | INVCUBIC_MODE | |
  34824. * | 7 | EQUIRECTANGULAR_MODE | |
  34825. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34826. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34827. */
  34828. set coordinatesMode(value: number);
  34829. get coordinatesMode(): number;
  34830. /**
  34831. * | Value | Type | Description |
  34832. * | ----- | ------------------ | ----------- |
  34833. * | 0 | CLAMP_ADDRESSMODE | |
  34834. * | 1 | WRAP_ADDRESSMODE | |
  34835. * | 2 | MIRROR_ADDRESSMODE | |
  34836. */
  34837. wrapU: number;
  34838. /**
  34839. * | Value | Type | Description |
  34840. * | ----- | ------------------ | ----------- |
  34841. * | 0 | CLAMP_ADDRESSMODE | |
  34842. * | 1 | WRAP_ADDRESSMODE | |
  34843. * | 2 | MIRROR_ADDRESSMODE | |
  34844. */
  34845. wrapV: number;
  34846. /**
  34847. * | Value | Type | Description |
  34848. * | ----- | ------------------ | ----------- |
  34849. * | 0 | CLAMP_ADDRESSMODE | |
  34850. * | 1 | WRAP_ADDRESSMODE | |
  34851. * | 2 | MIRROR_ADDRESSMODE | |
  34852. */
  34853. wrapR: number;
  34854. /**
  34855. * With compliant hardware and browser (supporting anisotropic filtering)
  34856. * this defines the level of anisotropic filtering in the texture.
  34857. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34858. */
  34859. anisotropicFilteringLevel: number;
  34860. /**
  34861. * Define if the texture is a cube texture or if false a 2d texture.
  34862. */
  34863. get isCube(): boolean;
  34864. set isCube(value: boolean);
  34865. /**
  34866. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34867. */
  34868. get is3D(): boolean;
  34869. set is3D(value: boolean);
  34870. /**
  34871. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34872. */
  34873. get is2DArray(): boolean;
  34874. set is2DArray(value: boolean);
  34875. /**
  34876. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34877. * HDR texture are usually stored in linear space.
  34878. * This only impacts the PBR and Background materials
  34879. */
  34880. gammaSpace: boolean;
  34881. /**
  34882. * Gets or sets whether or not the texture contains RGBD data.
  34883. */
  34884. get isRGBD(): boolean;
  34885. set isRGBD(value: boolean);
  34886. /**
  34887. * Is Z inverted in the texture (useful in a cube texture).
  34888. */
  34889. invertZ: boolean;
  34890. /**
  34891. * Are mip maps generated for this texture or not.
  34892. */
  34893. get noMipmap(): boolean;
  34894. /**
  34895. * @hidden
  34896. */
  34897. lodLevelInAlpha: boolean;
  34898. /**
  34899. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34900. */
  34901. get lodGenerationOffset(): number;
  34902. set lodGenerationOffset(value: number);
  34903. /**
  34904. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34905. */
  34906. get lodGenerationScale(): number;
  34907. set lodGenerationScale(value: number);
  34908. /**
  34909. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34910. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34911. * average roughness values.
  34912. */
  34913. get linearSpecularLOD(): boolean;
  34914. set linearSpecularLOD(value: boolean);
  34915. /**
  34916. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34917. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34918. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34919. */
  34920. get irradianceTexture(): Nullable<BaseTexture>;
  34921. set irradianceTexture(value: Nullable<BaseTexture>);
  34922. /**
  34923. * Define if the texture is a render target.
  34924. */
  34925. isRenderTarget: boolean;
  34926. /**
  34927. * Define the unique id of the texture in the scene.
  34928. */
  34929. get uid(): string;
  34930. /** @hidden */
  34931. _prefiltered: boolean;
  34932. /**
  34933. * Return a string representation of the texture.
  34934. * @returns the texture as a string
  34935. */
  34936. toString(): string;
  34937. /**
  34938. * Get the class name of the texture.
  34939. * @returns "BaseTexture"
  34940. */
  34941. getClassName(): string;
  34942. /**
  34943. * Define the list of animation attached to the texture.
  34944. */
  34945. animations: import("babylonjs/Animations/animation").Animation[];
  34946. /**
  34947. * An event triggered when the texture is disposed.
  34948. */
  34949. onDisposeObservable: Observable<BaseTexture>;
  34950. private _onDisposeObserver;
  34951. /**
  34952. * Callback triggered when the texture has been disposed.
  34953. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34954. */
  34955. set onDispose(callback: () => void);
  34956. /**
  34957. * Define the current state of the loading sequence when in delayed load mode.
  34958. */
  34959. delayLoadState: number;
  34960. private _scene;
  34961. private _engine;
  34962. /** @hidden */
  34963. _texture: Nullable<InternalTexture>;
  34964. private _uid;
  34965. /**
  34966. * Define if the texture is preventinga material to render or not.
  34967. * If not and the texture is not ready, the engine will use a default black texture instead.
  34968. */
  34969. get isBlocking(): boolean;
  34970. /**
  34971. * Instantiates a new BaseTexture.
  34972. * Base class of all the textures in babylon.
  34973. * It groups all the common properties the materials, post process, lights... might need
  34974. * in order to make a correct use of the texture.
  34975. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34976. */
  34977. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34978. /**
  34979. * Get the scene the texture belongs to.
  34980. * @returns the scene or null if undefined
  34981. */
  34982. getScene(): Nullable<Scene>;
  34983. /** @hidden */
  34984. protected _getEngine(): Nullable<ThinEngine>;
  34985. /**
  34986. * Get the texture transform matrix used to offset tile the texture for istance.
  34987. * @returns the transformation matrix
  34988. */
  34989. getTextureMatrix(): Matrix;
  34990. /**
  34991. * Get the texture reflection matrix used to rotate/transform the reflection.
  34992. * @returns the reflection matrix
  34993. */
  34994. getReflectionTextureMatrix(): Matrix;
  34995. /**
  34996. * Get the underlying lower level texture from Babylon.
  34997. * @returns the insternal texture
  34998. */
  34999. getInternalTexture(): Nullable<InternalTexture>;
  35000. /**
  35001. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35002. * @returns true if ready or not blocking
  35003. */
  35004. isReadyOrNotBlocking(): boolean;
  35005. /**
  35006. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35007. * @returns true if fully ready
  35008. */
  35009. isReady(): boolean;
  35010. private _cachedSize;
  35011. /**
  35012. * Get the size of the texture.
  35013. * @returns the texture size.
  35014. */
  35015. getSize(): ISize;
  35016. /**
  35017. * Get the base size of the texture.
  35018. * It can be different from the size if the texture has been resized for POT for instance
  35019. * @returns the base size
  35020. */
  35021. getBaseSize(): ISize;
  35022. /**
  35023. * Update the sampling mode of the texture.
  35024. * Default is Trilinear mode.
  35025. *
  35026. * | Value | Type | Description |
  35027. * | ----- | ------------------ | ----------- |
  35028. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35029. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35030. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35031. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35032. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35033. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35034. * | 7 | NEAREST_LINEAR | |
  35035. * | 8 | NEAREST_NEAREST | |
  35036. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35037. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35038. * | 11 | LINEAR_LINEAR | |
  35039. * | 12 | LINEAR_NEAREST | |
  35040. *
  35041. * > _mag_: magnification filter (close to the viewer)
  35042. * > _min_: minification filter (far from the viewer)
  35043. * > _mip_: filter used between mip map levels
  35044. *@param samplingMode Define the new sampling mode of the texture
  35045. */
  35046. updateSamplingMode(samplingMode: number): void;
  35047. /**
  35048. * Scales the texture if is `canRescale()`
  35049. * @param ratio the resize factor we want to use to rescale
  35050. */
  35051. scale(ratio: number): void;
  35052. /**
  35053. * Get if the texture can rescale.
  35054. */
  35055. get canRescale(): boolean;
  35056. /** @hidden */
  35057. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35058. /** @hidden */
  35059. _rebuild(): void;
  35060. /**
  35061. * Triggers the load sequence in delayed load mode.
  35062. */
  35063. delayLoad(): void;
  35064. /**
  35065. * Clones the texture.
  35066. * @returns the cloned texture
  35067. */
  35068. clone(): Nullable<BaseTexture>;
  35069. /**
  35070. * Get the texture underlying type (INT, FLOAT...)
  35071. */
  35072. get textureType(): number;
  35073. /**
  35074. * Get the texture underlying format (RGB, RGBA...)
  35075. */
  35076. get textureFormat(): number;
  35077. /**
  35078. * Indicates that textures need to be re-calculated for all materials
  35079. */
  35080. protected _markAllSubMeshesAsTexturesDirty(): void;
  35081. /**
  35082. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35083. * This will returns an RGBA array buffer containing either in values (0-255) or
  35084. * float values (0-1) depending of the underlying buffer type.
  35085. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35086. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35087. * @param buffer defines a user defined buffer to fill with data (can be null)
  35088. * @returns The Array buffer containing the pixels data.
  35089. */
  35090. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35091. /**
  35092. * Release and destroy the underlying lower level texture aka internalTexture.
  35093. */
  35094. releaseInternalTexture(): void;
  35095. /** @hidden */
  35096. get _lodTextureHigh(): Nullable<BaseTexture>;
  35097. /** @hidden */
  35098. get _lodTextureMid(): Nullable<BaseTexture>;
  35099. /** @hidden */
  35100. get _lodTextureLow(): Nullable<BaseTexture>;
  35101. /**
  35102. * Dispose the texture and release its associated resources.
  35103. */
  35104. dispose(): void;
  35105. /**
  35106. * Serialize the texture into a JSON representation that can be parsed later on.
  35107. * @returns the JSON representation of the texture
  35108. */
  35109. serialize(): any;
  35110. /**
  35111. * Helper function to be called back once a list of texture contains only ready textures.
  35112. * @param textures Define the list of textures to wait for
  35113. * @param callback Define the callback triggered once the entire list will be ready
  35114. */
  35115. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35116. private static _isScene;
  35117. }
  35118. }
  35119. declare module "babylonjs/Materials/effect" {
  35120. import { Observable } from "babylonjs/Misc/observable";
  35121. import { Nullable } from "babylonjs/types";
  35122. import { IDisposable } from "babylonjs/scene";
  35123. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35124. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35125. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35126. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35127. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35128. import { Engine } from "babylonjs/Engines/engine";
  35129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35131. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35133. /**
  35134. * Options to be used when creating an effect.
  35135. */
  35136. export interface IEffectCreationOptions {
  35137. /**
  35138. * Atrributes that will be used in the shader.
  35139. */
  35140. attributes: string[];
  35141. /**
  35142. * Uniform varible names that will be set in the shader.
  35143. */
  35144. uniformsNames: string[];
  35145. /**
  35146. * Uniform buffer variable names that will be set in the shader.
  35147. */
  35148. uniformBuffersNames: string[];
  35149. /**
  35150. * Sampler texture variable names that will be set in the shader.
  35151. */
  35152. samplers: string[];
  35153. /**
  35154. * Define statements that will be set in the shader.
  35155. */
  35156. defines: any;
  35157. /**
  35158. * Possible fallbacks for this effect to improve performance when needed.
  35159. */
  35160. fallbacks: Nullable<IEffectFallbacks>;
  35161. /**
  35162. * Callback that will be called when the shader is compiled.
  35163. */
  35164. onCompiled: Nullable<(effect: Effect) => void>;
  35165. /**
  35166. * Callback that will be called if an error occurs during shader compilation.
  35167. */
  35168. onError: Nullable<(effect: Effect, errors: string) => void>;
  35169. /**
  35170. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35171. */
  35172. indexParameters?: any;
  35173. /**
  35174. * Max number of lights that can be used in the shader.
  35175. */
  35176. maxSimultaneousLights?: number;
  35177. /**
  35178. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35179. */
  35180. transformFeedbackVaryings?: Nullable<string[]>;
  35181. /**
  35182. * 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
  35183. */
  35184. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35185. /**
  35186. * Is this effect rendering to several color attachments ?
  35187. */
  35188. multiTarget?: boolean;
  35189. }
  35190. /**
  35191. * Effect containing vertex and fragment shader that can be executed on an object.
  35192. */
  35193. export class Effect implements IDisposable {
  35194. /**
  35195. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35196. */
  35197. static ShadersRepository: string;
  35198. /**
  35199. * Enable logging of the shader code when a compilation error occurs
  35200. */
  35201. static LogShaderCodeOnCompilationError: boolean;
  35202. /**
  35203. * Name of the effect.
  35204. */
  35205. name: any;
  35206. /**
  35207. * String container all the define statements that should be set on the shader.
  35208. */
  35209. defines: string;
  35210. /**
  35211. * Callback that will be called when the shader is compiled.
  35212. */
  35213. onCompiled: Nullable<(effect: Effect) => void>;
  35214. /**
  35215. * Callback that will be called if an error occurs during shader compilation.
  35216. */
  35217. onError: Nullable<(effect: Effect, errors: string) => void>;
  35218. /**
  35219. * Callback that will be called when effect is bound.
  35220. */
  35221. onBind: Nullable<(effect: Effect) => void>;
  35222. /**
  35223. * Unique ID of the effect.
  35224. */
  35225. uniqueId: number;
  35226. /**
  35227. * Observable that will be called when the shader is compiled.
  35228. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35229. */
  35230. onCompileObservable: Observable<Effect>;
  35231. /**
  35232. * Observable that will be called if an error occurs during shader compilation.
  35233. */
  35234. onErrorObservable: Observable<Effect>;
  35235. /** @hidden */
  35236. _onBindObservable: Nullable<Observable<Effect>>;
  35237. /**
  35238. * @hidden
  35239. * Specifies if the effect was previously ready
  35240. */
  35241. _wasPreviouslyReady: boolean;
  35242. /**
  35243. * Observable that will be called when effect is bound.
  35244. */
  35245. get onBindObservable(): Observable<Effect>;
  35246. /** @hidden */
  35247. _bonesComputationForcedToCPU: boolean;
  35248. /** @hidden */
  35249. _multiTarget: boolean;
  35250. private static _uniqueIdSeed;
  35251. private _engine;
  35252. private _uniformBuffersNames;
  35253. private _uniformBuffersNamesList;
  35254. private _uniformsNames;
  35255. private _samplerList;
  35256. private _samplers;
  35257. private _isReady;
  35258. private _compilationError;
  35259. private _allFallbacksProcessed;
  35260. private _attributesNames;
  35261. private _attributes;
  35262. private _attributeLocationByName;
  35263. private _uniforms;
  35264. /**
  35265. * Key for the effect.
  35266. * @hidden
  35267. */
  35268. _key: string;
  35269. private _indexParameters;
  35270. private _fallbacks;
  35271. private _vertexSourceCode;
  35272. private _fragmentSourceCode;
  35273. private _vertexSourceCodeOverride;
  35274. private _fragmentSourceCodeOverride;
  35275. private _transformFeedbackVaryings;
  35276. /**
  35277. * Compiled shader to webGL program.
  35278. * @hidden
  35279. */
  35280. _pipelineContext: Nullable<IPipelineContext>;
  35281. private _valueCache;
  35282. private static _baseCache;
  35283. /**
  35284. * Instantiates an effect.
  35285. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35286. * @param baseName Name of the effect.
  35287. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35288. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35289. * @param samplers List of sampler variables that will be passed to the shader.
  35290. * @param engine Engine to be used to render the effect
  35291. * @param defines Define statements to be added to the shader.
  35292. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35293. * @param onCompiled Callback that will be called when the shader is compiled.
  35294. * @param onError Callback that will be called if an error occurs during shader compilation.
  35295. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35296. */
  35297. 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);
  35298. private _useFinalCode;
  35299. /**
  35300. * Unique key for this effect
  35301. */
  35302. get key(): string;
  35303. /**
  35304. * If the effect has been compiled and prepared.
  35305. * @returns if the effect is compiled and prepared.
  35306. */
  35307. isReady(): boolean;
  35308. private _isReadyInternal;
  35309. /**
  35310. * The engine the effect was initialized with.
  35311. * @returns the engine.
  35312. */
  35313. getEngine(): Engine;
  35314. /**
  35315. * The pipeline context for this effect
  35316. * @returns the associated pipeline context
  35317. */
  35318. getPipelineContext(): Nullable<IPipelineContext>;
  35319. /**
  35320. * The set of names of attribute variables for the shader.
  35321. * @returns An array of attribute names.
  35322. */
  35323. getAttributesNames(): string[];
  35324. /**
  35325. * Returns the attribute at the given index.
  35326. * @param index The index of the attribute.
  35327. * @returns The location of the attribute.
  35328. */
  35329. getAttributeLocation(index: number): number;
  35330. /**
  35331. * Returns the attribute based on the name of the variable.
  35332. * @param name of the attribute to look up.
  35333. * @returns the attribute location.
  35334. */
  35335. getAttributeLocationByName(name: string): number;
  35336. /**
  35337. * The number of attributes.
  35338. * @returns the numnber of attributes.
  35339. */
  35340. getAttributesCount(): number;
  35341. /**
  35342. * Gets the index of a uniform variable.
  35343. * @param uniformName of the uniform to look up.
  35344. * @returns the index.
  35345. */
  35346. getUniformIndex(uniformName: string): number;
  35347. /**
  35348. * Returns the attribute based on the name of the variable.
  35349. * @param uniformName of the uniform to look up.
  35350. * @returns the location of the uniform.
  35351. */
  35352. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35353. /**
  35354. * Returns an array of sampler variable names
  35355. * @returns The array of sampler variable names.
  35356. */
  35357. getSamplers(): string[];
  35358. /**
  35359. * Returns an array of uniform variable names
  35360. * @returns The array of uniform variable names.
  35361. */
  35362. getUniformNames(): string[];
  35363. /**
  35364. * Returns an array of uniform buffer variable names
  35365. * @returns The array of uniform buffer variable names.
  35366. */
  35367. getUniformBuffersNames(): string[];
  35368. /**
  35369. * Returns the index parameters used to create the effect
  35370. * @returns The index parameters object
  35371. */
  35372. getIndexParameters(): any;
  35373. /**
  35374. * The error from the last compilation.
  35375. * @returns the error string.
  35376. */
  35377. getCompilationError(): string;
  35378. /**
  35379. * Gets a boolean indicating that all fallbacks were used during compilation
  35380. * @returns true if all fallbacks were used
  35381. */
  35382. allFallbacksProcessed(): boolean;
  35383. /**
  35384. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35385. * @param func The callback to be used.
  35386. */
  35387. executeWhenCompiled(func: (effect: Effect) => void): void;
  35388. private _checkIsReady;
  35389. private _loadShader;
  35390. /**
  35391. * Gets the vertex shader source code of this effect
  35392. */
  35393. get vertexSourceCode(): string;
  35394. /**
  35395. * Gets the fragment shader source code of this effect
  35396. */
  35397. get fragmentSourceCode(): string;
  35398. /**
  35399. * Recompiles the webGL program
  35400. * @param vertexSourceCode The source code for the vertex shader.
  35401. * @param fragmentSourceCode The source code for the fragment shader.
  35402. * @param onCompiled Callback called when completed.
  35403. * @param onError Callback called on error.
  35404. * @hidden
  35405. */
  35406. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35407. /**
  35408. * Prepares the effect
  35409. * @hidden
  35410. */
  35411. _prepareEffect(): void;
  35412. private _getShaderCodeAndErrorLine;
  35413. private _processCompilationErrors;
  35414. /**
  35415. * Checks if the effect is supported. (Must be called after compilation)
  35416. */
  35417. get isSupported(): boolean;
  35418. /**
  35419. * Binds a texture to the engine to be used as output of the shader.
  35420. * @param channel Name of the output variable.
  35421. * @param texture Texture to bind.
  35422. * @hidden
  35423. */
  35424. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35425. /**
  35426. * Sets a texture on the engine to be used in the shader.
  35427. * @param channel Name of the sampler variable.
  35428. * @param texture Texture to set.
  35429. */
  35430. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35431. /**
  35432. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35433. * @param channel Name of the sampler variable.
  35434. * @param texture Texture to set.
  35435. */
  35436. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35437. /**
  35438. * Sets an array of textures on the engine to be used in the shader.
  35439. * @param channel Name of the variable.
  35440. * @param textures Textures to set.
  35441. */
  35442. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35443. /**
  35444. * 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)
  35445. * @param channel Name of the sampler variable.
  35446. * @param postProcess Post process to get the input texture from.
  35447. */
  35448. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35449. /**
  35450. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35451. * 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)
  35452. * @param channel Name of the sampler variable.
  35453. * @param postProcess Post process to get the output texture from.
  35454. */
  35455. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35456. /** @hidden */
  35457. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35458. /** @hidden */
  35459. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35460. /** @hidden */
  35461. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35462. /** @hidden */
  35463. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35464. /**
  35465. * Binds a buffer to a uniform.
  35466. * @param buffer Buffer to bind.
  35467. * @param name Name of the uniform variable to bind to.
  35468. */
  35469. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35470. /**
  35471. * Binds block to a uniform.
  35472. * @param blockName Name of the block to bind.
  35473. * @param index Index to bind.
  35474. */
  35475. bindUniformBlock(blockName: string, index: number): void;
  35476. /**
  35477. * Sets an interger value on a uniform variable.
  35478. * @param uniformName Name of the variable.
  35479. * @param value Value to be set.
  35480. * @returns this effect.
  35481. */
  35482. setInt(uniformName: string, value: number): Effect;
  35483. /**
  35484. * Sets an int array on a uniform variable.
  35485. * @param uniformName Name of the variable.
  35486. * @param array array to be set.
  35487. * @returns this effect.
  35488. */
  35489. setIntArray(uniformName: string, array: Int32Array): Effect;
  35490. /**
  35491. * 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)
  35492. * @param uniformName Name of the variable.
  35493. * @param array array to be set.
  35494. * @returns this effect.
  35495. */
  35496. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35497. /**
  35498. * 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)
  35499. * @param uniformName Name of the variable.
  35500. * @param array array to be set.
  35501. * @returns this effect.
  35502. */
  35503. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35504. /**
  35505. * 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)
  35506. * @param uniformName Name of the variable.
  35507. * @param array array to be set.
  35508. * @returns this effect.
  35509. */
  35510. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35511. /**
  35512. * Sets an float array on a uniform variable.
  35513. * @param uniformName Name of the variable.
  35514. * @param array array to be set.
  35515. * @returns this effect.
  35516. */
  35517. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35518. /**
  35519. * 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)
  35520. * @param uniformName Name of the variable.
  35521. * @param array array to be set.
  35522. * @returns this effect.
  35523. */
  35524. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35525. /**
  35526. * 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)
  35527. * @param uniformName Name of the variable.
  35528. * @param array array to be set.
  35529. * @returns this effect.
  35530. */
  35531. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35532. /**
  35533. * 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)
  35534. * @param uniformName Name of the variable.
  35535. * @param array array to be set.
  35536. * @returns this effect.
  35537. */
  35538. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35539. /**
  35540. * Sets an array on a uniform variable.
  35541. * @param uniformName Name of the variable.
  35542. * @param array array to be set.
  35543. * @returns this effect.
  35544. */
  35545. setArray(uniformName: string, array: number[]): Effect;
  35546. /**
  35547. * 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)
  35548. * @param uniformName Name of the variable.
  35549. * @param array array to be set.
  35550. * @returns this effect.
  35551. */
  35552. setArray2(uniformName: string, array: number[]): Effect;
  35553. /**
  35554. * 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)
  35555. * @param uniformName Name of the variable.
  35556. * @param array array to be set.
  35557. * @returns this effect.
  35558. */
  35559. setArray3(uniformName: string, array: number[]): Effect;
  35560. /**
  35561. * 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)
  35562. * @param uniformName Name of the variable.
  35563. * @param array array to be set.
  35564. * @returns this effect.
  35565. */
  35566. setArray4(uniformName: string, array: number[]): Effect;
  35567. /**
  35568. * Sets matrices on a uniform variable.
  35569. * @param uniformName Name of the variable.
  35570. * @param matrices matrices to be set.
  35571. * @returns this effect.
  35572. */
  35573. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35574. /**
  35575. * Sets matrix on a uniform variable.
  35576. * @param uniformName Name of the variable.
  35577. * @param matrix matrix to be set.
  35578. * @returns this effect.
  35579. */
  35580. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35581. /**
  35582. * 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)
  35583. * @param uniformName Name of the variable.
  35584. * @param matrix matrix to be set.
  35585. * @returns this effect.
  35586. */
  35587. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35588. /**
  35589. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35590. * @param uniformName Name of the variable.
  35591. * @param matrix matrix to be set.
  35592. * @returns this effect.
  35593. */
  35594. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35595. /**
  35596. * Sets a float on a uniform variable.
  35597. * @param uniformName Name of the variable.
  35598. * @param value value to be set.
  35599. * @returns this effect.
  35600. */
  35601. setFloat(uniformName: string, value: number): Effect;
  35602. /**
  35603. * Sets a boolean on a uniform variable.
  35604. * @param uniformName Name of the variable.
  35605. * @param bool value to be set.
  35606. * @returns this effect.
  35607. */
  35608. setBool(uniformName: string, bool: boolean): Effect;
  35609. /**
  35610. * Sets a Vector2 on a uniform variable.
  35611. * @param uniformName Name of the variable.
  35612. * @param vector2 vector2 to be set.
  35613. * @returns this effect.
  35614. */
  35615. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35616. /**
  35617. * Sets a float2 on a uniform variable.
  35618. * @param uniformName Name of the variable.
  35619. * @param x First float in float2.
  35620. * @param y Second float in float2.
  35621. * @returns this effect.
  35622. */
  35623. setFloat2(uniformName: string, x: number, y: number): Effect;
  35624. /**
  35625. * Sets a Vector3 on a uniform variable.
  35626. * @param uniformName Name of the variable.
  35627. * @param vector3 Value to be set.
  35628. * @returns this effect.
  35629. */
  35630. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35631. /**
  35632. * Sets a float3 on a uniform variable.
  35633. * @param uniformName Name of the variable.
  35634. * @param x First float in float3.
  35635. * @param y Second float in float3.
  35636. * @param z Third float in float3.
  35637. * @returns this effect.
  35638. */
  35639. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35640. /**
  35641. * Sets a Vector4 on a uniform variable.
  35642. * @param uniformName Name of the variable.
  35643. * @param vector4 Value to be set.
  35644. * @returns this effect.
  35645. */
  35646. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35647. /**
  35648. * Sets a float4 on a uniform variable.
  35649. * @param uniformName Name of the variable.
  35650. * @param x First float in float4.
  35651. * @param y Second float in float4.
  35652. * @param z Third float in float4.
  35653. * @param w Fourth float in float4.
  35654. * @returns this effect.
  35655. */
  35656. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35657. /**
  35658. * Sets a Color3 on a uniform variable.
  35659. * @param uniformName Name of the variable.
  35660. * @param color3 Value to be set.
  35661. * @returns this effect.
  35662. */
  35663. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35664. /**
  35665. * Sets a Color4 on a uniform variable.
  35666. * @param uniformName Name of the variable.
  35667. * @param color3 Value to be set.
  35668. * @param alpha Alpha value to be set.
  35669. * @returns this effect.
  35670. */
  35671. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35672. /**
  35673. * Sets a Color4 on a uniform variable
  35674. * @param uniformName defines the name of the variable
  35675. * @param color4 defines the value to be set
  35676. * @returns this effect.
  35677. */
  35678. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35679. /** Release all associated resources */
  35680. dispose(): void;
  35681. /**
  35682. * This function will add a new shader to the shader store
  35683. * @param name the name of the shader
  35684. * @param pixelShader optional pixel shader content
  35685. * @param vertexShader optional vertex shader content
  35686. */
  35687. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35688. /**
  35689. * Store of each shader (The can be looked up using effect.key)
  35690. */
  35691. static ShadersStore: {
  35692. [key: string]: string;
  35693. };
  35694. /**
  35695. * Store of each included file for a shader (The can be looked up using effect.key)
  35696. */
  35697. static IncludesShadersStore: {
  35698. [key: string]: string;
  35699. };
  35700. /**
  35701. * Resets the cache of effects.
  35702. */
  35703. static ResetCache(): void;
  35704. }
  35705. }
  35706. declare module "babylonjs/Engines/engineCapabilities" {
  35707. /**
  35708. * Interface used to describe the capabilities of the engine relatively to the current browser
  35709. */
  35710. export interface EngineCapabilities {
  35711. /** Maximum textures units per fragment shader */
  35712. maxTexturesImageUnits: number;
  35713. /** Maximum texture units per vertex shader */
  35714. maxVertexTextureImageUnits: number;
  35715. /** Maximum textures units in the entire pipeline */
  35716. maxCombinedTexturesImageUnits: number;
  35717. /** Maximum texture size */
  35718. maxTextureSize: number;
  35719. /** Maximum texture samples */
  35720. maxSamples?: number;
  35721. /** Maximum cube texture size */
  35722. maxCubemapTextureSize: number;
  35723. /** Maximum render texture size */
  35724. maxRenderTextureSize: number;
  35725. /** Maximum number of vertex attributes */
  35726. maxVertexAttribs: number;
  35727. /** Maximum number of varyings */
  35728. maxVaryingVectors: number;
  35729. /** Maximum number of uniforms per vertex shader */
  35730. maxVertexUniformVectors: number;
  35731. /** Maximum number of uniforms per fragment shader */
  35732. maxFragmentUniformVectors: number;
  35733. /** Defines if standard derivates (dx/dy) are supported */
  35734. standardDerivatives: boolean;
  35735. /** Defines if s3tc texture compression is supported */
  35736. s3tc?: WEBGL_compressed_texture_s3tc;
  35737. /** Defines if pvrtc texture compression is supported */
  35738. pvrtc: any;
  35739. /** Defines if etc1 texture compression is supported */
  35740. etc1: any;
  35741. /** Defines if etc2 texture compression is supported */
  35742. etc2: any;
  35743. /** Defines if astc texture compression is supported */
  35744. astc: any;
  35745. /** Defines if float textures are supported */
  35746. textureFloat: boolean;
  35747. /** Defines if vertex array objects are supported */
  35748. vertexArrayObject: boolean;
  35749. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35750. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35751. /** Gets the maximum level of anisotropy supported */
  35752. maxAnisotropy: number;
  35753. /** Defines if instancing is supported */
  35754. instancedArrays: boolean;
  35755. /** Defines if 32 bits indices are supported */
  35756. uintIndices: boolean;
  35757. /** Defines if high precision shaders are supported */
  35758. highPrecisionShaderSupported: boolean;
  35759. /** Defines if depth reading in the fragment shader is supported */
  35760. fragmentDepthSupported: boolean;
  35761. /** Defines if float texture linear filtering is supported*/
  35762. textureFloatLinearFiltering: boolean;
  35763. /** Defines if rendering to float textures is supported */
  35764. textureFloatRender: boolean;
  35765. /** Defines if half float textures are supported*/
  35766. textureHalfFloat: boolean;
  35767. /** Defines if half float texture linear filtering is supported*/
  35768. textureHalfFloatLinearFiltering: boolean;
  35769. /** Defines if rendering to half float textures is supported */
  35770. textureHalfFloatRender: boolean;
  35771. /** Defines if textureLOD shader command is supported */
  35772. textureLOD: boolean;
  35773. /** Defines if draw buffers extension is supported */
  35774. drawBuffersExtension: boolean;
  35775. /** Defines if depth textures are supported */
  35776. depthTextureExtension: boolean;
  35777. /** Defines if float color buffer are supported */
  35778. colorBufferFloat: boolean;
  35779. /** Gets disjoint timer query extension (null if not supported) */
  35780. timerQuery?: EXT_disjoint_timer_query;
  35781. /** Defines if timestamp can be used with timer query */
  35782. canUseTimestampForTimerQuery: boolean;
  35783. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35784. multiview?: any;
  35785. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35786. oculusMultiview?: any;
  35787. /** Function used to let the system compiles shaders in background */
  35788. parallelShaderCompile?: {
  35789. COMPLETION_STATUS_KHR: number;
  35790. };
  35791. /** Max number of texture samples for MSAA */
  35792. maxMSAASamples: number;
  35793. /** Defines if the blend min max extension is supported */
  35794. blendMinMax: boolean;
  35795. }
  35796. }
  35797. declare module "babylonjs/States/depthCullingState" {
  35798. import { Nullable } from "babylonjs/types";
  35799. /**
  35800. * @hidden
  35801. **/
  35802. export class DepthCullingState {
  35803. private _isDepthTestDirty;
  35804. private _isDepthMaskDirty;
  35805. private _isDepthFuncDirty;
  35806. private _isCullFaceDirty;
  35807. private _isCullDirty;
  35808. private _isZOffsetDirty;
  35809. private _isFrontFaceDirty;
  35810. private _depthTest;
  35811. private _depthMask;
  35812. private _depthFunc;
  35813. private _cull;
  35814. private _cullFace;
  35815. private _zOffset;
  35816. private _frontFace;
  35817. /**
  35818. * Initializes the state.
  35819. */
  35820. constructor();
  35821. get isDirty(): boolean;
  35822. get zOffset(): number;
  35823. set zOffset(value: number);
  35824. get cullFace(): Nullable<number>;
  35825. set cullFace(value: Nullable<number>);
  35826. get cull(): Nullable<boolean>;
  35827. set cull(value: Nullable<boolean>);
  35828. get depthFunc(): Nullable<number>;
  35829. set depthFunc(value: Nullable<number>);
  35830. get depthMask(): boolean;
  35831. set depthMask(value: boolean);
  35832. get depthTest(): boolean;
  35833. set depthTest(value: boolean);
  35834. get frontFace(): Nullable<number>;
  35835. set frontFace(value: Nullable<number>);
  35836. reset(): void;
  35837. apply(gl: WebGLRenderingContext): void;
  35838. }
  35839. }
  35840. declare module "babylonjs/States/stencilState" {
  35841. /**
  35842. * @hidden
  35843. **/
  35844. export class StencilState {
  35845. /** 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 */
  35846. static readonly ALWAYS: number;
  35847. /** Passed to stencilOperation to specify that stencil value must be kept */
  35848. static readonly KEEP: number;
  35849. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35850. static readonly REPLACE: number;
  35851. private _isStencilTestDirty;
  35852. private _isStencilMaskDirty;
  35853. private _isStencilFuncDirty;
  35854. private _isStencilOpDirty;
  35855. private _stencilTest;
  35856. private _stencilMask;
  35857. private _stencilFunc;
  35858. private _stencilFuncRef;
  35859. private _stencilFuncMask;
  35860. private _stencilOpStencilFail;
  35861. private _stencilOpDepthFail;
  35862. private _stencilOpStencilDepthPass;
  35863. get isDirty(): boolean;
  35864. get stencilFunc(): number;
  35865. set stencilFunc(value: number);
  35866. get stencilFuncRef(): number;
  35867. set stencilFuncRef(value: number);
  35868. get stencilFuncMask(): number;
  35869. set stencilFuncMask(value: number);
  35870. get stencilOpStencilFail(): number;
  35871. set stencilOpStencilFail(value: number);
  35872. get stencilOpDepthFail(): number;
  35873. set stencilOpDepthFail(value: number);
  35874. get stencilOpStencilDepthPass(): number;
  35875. set stencilOpStencilDepthPass(value: number);
  35876. get stencilMask(): number;
  35877. set stencilMask(value: number);
  35878. get stencilTest(): boolean;
  35879. set stencilTest(value: boolean);
  35880. constructor();
  35881. reset(): void;
  35882. apply(gl: WebGLRenderingContext): void;
  35883. }
  35884. }
  35885. declare module "babylonjs/States/alphaCullingState" {
  35886. /**
  35887. * @hidden
  35888. **/
  35889. export class AlphaState {
  35890. private _isAlphaBlendDirty;
  35891. private _isBlendFunctionParametersDirty;
  35892. private _isBlendEquationParametersDirty;
  35893. private _isBlendConstantsDirty;
  35894. private _alphaBlend;
  35895. private _blendFunctionParameters;
  35896. private _blendEquationParameters;
  35897. private _blendConstants;
  35898. /**
  35899. * Initializes the state.
  35900. */
  35901. constructor();
  35902. get isDirty(): boolean;
  35903. get alphaBlend(): boolean;
  35904. set alphaBlend(value: boolean);
  35905. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35906. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35907. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35908. reset(): void;
  35909. apply(gl: WebGLRenderingContext): void;
  35910. }
  35911. }
  35912. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35913. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35914. /** @hidden */
  35915. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35916. attributeProcessor(attribute: string): string;
  35917. varyingProcessor(varying: string, isFragment: boolean): string;
  35918. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35919. }
  35920. }
  35921. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35922. /**
  35923. * Interface for attribute information associated with buffer instanciation
  35924. */
  35925. export interface InstancingAttributeInfo {
  35926. /**
  35927. * Name of the GLSL attribute
  35928. * if attribute index is not specified, this is used to retrieve the index from the effect
  35929. */
  35930. attributeName: string;
  35931. /**
  35932. * Index/offset of the attribute in the vertex shader
  35933. * if not specified, this will be computes from the name.
  35934. */
  35935. index?: number;
  35936. /**
  35937. * size of the attribute, 1, 2, 3 or 4
  35938. */
  35939. attributeSize: number;
  35940. /**
  35941. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35942. */
  35943. offset: number;
  35944. /**
  35945. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35946. * default to 1
  35947. */
  35948. divisor?: number;
  35949. /**
  35950. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35951. * default is FLOAT
  35952. */
  35953. attributeType?: number;
  35954. /**
  35955. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35956. */
  35957. normalized?: boolean;
  35958. }
  35959. }
  35960. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35962. import { Nullable } from "babylonjs/types";
  35963. module "babylonjs/Engines/thinEngine" {
  35964. interface ThinEngine {
  35965. /**
  35966. * Update a video texture
  35967. * @param texture defines the texture to update
  35968. * @param video defines the video element to use
  35969. * @param invertY defines if data must be stored with Y axis inverted
  35970. */
  35971. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35972. }
  35973. }
  35974. }
  35975. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35977. import { Nullable } from "babylonjs/types";
  35978. module "babylonjs/Engines/thinEngine" {
  35979. interface ThinEngine {
  35980. /**
  35981. * Creates a dynamic texture
  35982. * @param width defines the width of the texture
  35983. * @param height defines the height of the texture
  35984. * @param generateMipMaps defines if the engine should generate the mip levels
  35985. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35986. * @returns the dynamic texture inside an InternalTexture
  35987. */
  35988. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35989. /**
  35990. * Update the content of a dynamic texture
  35991. * @param texture defines the texture to update
  35992. * @param canvas defines the canvas containing the source
  35993. * @param invertY defines if data must be stored with Y axis inverted
  35994. * @param premulAlpha defines if alpha is stored as premultiplied
  35995. * @param format defines the format of the data
  35996. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35997. */
  35998. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35999. }
  36000. }
  36001. }
  36002. declare module "babylonjs/Materials/Textures/videoTexture" {
  36003. import { Observable } from "babylonjs/Misc/observable";
  36004. import { Nullable } from "babylonjs/types";
  36005. import { Scene } from "babylonjs/scene";
  36006. import { Texture } from "babylonjs/Materials/Textures/texture";
  36007. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36008. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36009. /**
  36010. * Settings for finer control over video usage
  36011. */
  36012. export interface VideoTextureSettings {
  36013. /**
  36014. * Applies `autoplay` to video, if specified
  36015. */
  36016. autoPlay?: boolean;
  36017. /**
  36018. * Applies `loop` to video, if specified
  36019. */
  36020. loop?: boolean;
  36021. /**
  36022. * Automatically updates internal texture from video at every frame in the render loop
  36023. */
  36024. autoUpdateTexture: boolean;
  36025. /**
  36026. * Image src displayed during the video loading or until the user interacts with the video.
  36027. */
  36028. poster?: string;
  36029. }
  36030. /**
  36031. * If you want to display a video in your scene, this is the special texture for that.
  36032. * This special texture works similar to other textures, with the exception of a few parameters.
  36033. * @see https://doc.babylonjs.com/how_to/video_texture
  36034. */
  36035. export class VideoTexture extends Texture {
  36036. /**
  36037. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36038. */
  36039. readonly autoUpdateTexture: boolean;
  36040. /**
  36041. * The video instance used by the texture internally
  36042. */
  36043. readonly video: HTMLVideoElement;
  36044. private _onUserActionRequestedObservable;
  36045. /**
  36046. * Event triggerd when a dom action is required by the user to play the video.
  36047. * This happens due to recent changes in browser policies preventing video to auto start.
  36048. */
  36049. get onUserActionRequestedObservable(): Observable<Texture>;
  36050. private _generateMipMaps;
  36051. private _stillImageCaptured;
  36052. private _displayingPosterTexture;
  36053. private _settings;
  36054. private _createInternalTextureOnEvent;
  36055. private _frameId;
  36056. private _currentSrc;
  36057. /**
  36058. * Creates a video texture.
  36059. * If you want to display a video in your scene, this is the special texture for that.
  36060. * This special texture works similar to other textures, with the exception of a few parameters.
  36061. * @see https://doc.babylonjs.com/how_to/video_texture
  36062. * @param name optional name, will detect from video source, if not defined
  36063. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36064. * @param scene is obviously the current scene.
  36065. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36066. * @param invertY is false by default but can be used to invert video on Y axis
  36067. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36068. * @param settings allows finer control over video usage
  36069. */
  36070. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36071. private _getName;
  36072. private _getVideo;
  36073. private _createInternalTexture;
  36074. private reset;
  36075. /**
  36076. * @hidden Internal method to initiate `update`.
  36077. */
  36078. _rebuild(): void;
  36079. /**
  36080. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36081. */
  36082. update(): void;
  36083. /**
  36084. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36085. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36086. */
  36087. updateTexture(isVisible: boolean): void;
  36088. protected _updateInternalTexture: () => void;
  36089. /**
  36090. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36091. * @param url New url.
  36092. */
  36093. updateURL(url: string): void;
  36094. /**
  36095. * Clones the texture.
  36096. * @returns the cloned texture
  36097. */
  36098. clone(): VideoTexture;
  36099. /**
  36100. * Dispose the texture and release its associated resources.
  36101. */
  36102. dispose(): void;
  36103. /**
  36104. * Creates a video texture straight from a stream.
  36105. * @param scene Define the scene the texture should be created in
  36106. * @param stream Define the stream the texture should be created from
  36107. * @returns The created video texture as a promise
  36108. */
  36109. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36110. /**
  36111. * Creates a video texture straight from your WebCam video feed.
  36112. * @param scene Define the scene the texture should be created in
  36113. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36114. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36115. * @returns The created video texture as a promise
  36116. */
  36117. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36118. minWidth: number;
  36119. maxWidth: number;
  36120. minHeight: number;
  36121. maxHeight: number;
  36122. deviceId: string;
  36123. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36124. /**
  36125. * Creates a video texture straight from your WebCam video feed.
  36126. * @param scene Define the scene the texture should be created in
  36127. * @param onReady Define a callback to triggered once the texture will be ready
  36128. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36129. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36130. */
  36131. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36132. minWidth: number;
  36133. maxWidth: number;
  36134. minHeight: number;
  36135. maxHeight: number;
  36136. deviceId: string;
  36137. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36138. }
  36139. }
  36140. declare module "babylonjs/Engines/thinEngine" {
  36141. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36142. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36143. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36144. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36145. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36146. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36147. import { Observable } from "babylonjs/Misc/observable";
  36148. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36149. import { StencilState } from "babylonjs/States/stencilState";
  36150. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36151. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36152. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36153. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36154. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36155. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36156. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36158. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36160. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36161. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36162. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36163. import { WebRequest } from "babylonjs/Misc/webRequest";
  36164. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36165. /**
  36166. * Defines the interface used by objects working like Scene
  36167. * @hidden
  36168. */
  36169. export interface ISceneLike {
  36170. _addPendingData(data: any): void;
  36171. _removePendingData(data: any): void;
  36172. offlineProvider: IOfflineProvider;
  36173. }
  36174. /** Interface defining initialization parameters for Engine class */
  36175. export interface EngineOptions extends WebGLContextAttributes {
  36176. /**
  36177. * Defines if the engine should no exceed a specified device ratio
  36178. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36179. */
  36180. limitDeviceRatio?: number;
  36181. /**
  36182. * Defines if webvr should be enabled automatically
  36183. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36184. */
  36185. autoEnableWebVR?: boolean;
  36186. /**
  36187. * Defines if webgl2 should be turned off even if supported
  36188. * @see https://doc.babylonjs.com/features/webgl2
  36189. */
  36190. disableWebGL2Support?: boolean;
  36191. /**
  36192. * Defines if webaudio should be initialized as well
  36193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36194. */
  36195. audioEngine?: boolean;
  36196. /**
  36197. * Defines if animations should run using a deterministic lock step
  36198. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36199. */
  36200. deterministicLockstep?: boolean;
  36201. /** Defines the maximum steps to use with deterministic lock step mode */
  36202. lockstepMaxSteps?: number;
  36203. /** Defines the seconds between each deterministic lock step */
  36204. timeStep?: number;
  36205. /**
  36206. * Defines that engine should ignore context lost events
  36207. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36208. */
  36209. doNotHandleContextLost?: boolean;
  36210. /**
  36211. * Defines that engine should ignore modifying touch action attribute and style
  36212. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36213. */
  36214. doNotHandleTouchAction?: boolean;
  36215. /**
  36216. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36217. */
  36218. useHighPrecisionFloats?: boolean;
  36219. /**
  36220. * Make the canvas XR Compatible for XR sessions
  36221. */
  36222. xrCompatible?: boolean;
  36223. /**
  36224. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36225. */
  36226. useHighPrecisionMatrix?: boolean;
  36227. }
  36228. /**
  36229. * The base engine class (root of all engines)
  36230. */
  36231. export class ThinEngine {
  36232. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36233. static ExceptionList: ({
  36234. key: string;
  36235. capture: string;
  36236. captureConstraint: number;
  36237. targets: string[];
  36238. } | {
  36239. key: string;
  36240. capture: null;
  36241. captureConstraint: null;
  36242. targets: string[];
  36243. })[];
  36244. /** @hidden */
  36245. static _TextureLoaders: IInternalTextureLoader[];
  36246. /**
  36247. * Returns the current npm package of the sdk
  36248. */
  36249. static get NpmPackage(): string;
  36250. /**
  36251. * Returns the current version of the framework
  36252. */
  36253. static get Version(): string;
  36254. /**
  36255. * Returns a string describing the current engine
  36256. */
  36257. get description(): string;
  36258. /**
  36259. * Gets or sets the epsilon value used by collision engine
  36260. */
  36261. static CollisionsEpsilon: number;
  36262. /**
  36263. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36264. */
  36265. static get ShadersRepository(): string;
  36266. static set ShadersRepository(value: string);
  36267. /** @hidden */
  36268. _shaderProcessor: IShaderProcessor;
  36269. /**
  36270. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36271. */
  36272. forcePOTTextures: boolean;
  36273. /**
  36274. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36275. */
  36276. isFullscreen: boolean;
  36277. /**
  36278. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36279. */
  36280. cullBackFaces: boolean;
  36281. /**
  36282. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36283. */
  36284. renderEvenInBackground: boolean;
  36285. /**
  36286. * Gets or sets a boolean indicating that cache can be kept between frames
  36287. */
  36288. preventCacheWipeBetweenFrames: boolean;
  36289. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36290. validateShaderPrograms: boolean;
  36291. /**
  36292. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36293. * This can provide greater z depth for distant objects.
  36294. */
  36295. useReverseDepthBuffer: boolean;
  36296. /**
  36297. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36298. */
  36299. disableUniformBuffers: boolean;
  36300. /** @hidden */
  36301. _uniformBuffers: UniformBuffer[];
  36302. /**
  36303. * Gets a boolean indicating that the engine supports uniform buffers
  36304. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36305. */
  36306. get supportsUniformBuffers(): boolean;
  36307. /** @hidden */
  36308. _gl: WebGLRenderingContext;
  36309. /** @hidden */
  36310. _webGLVersion: number;
  36311. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36312. protected _windowIsBackground: boolean;
  36313. protected _creationOptions: EngineOptions;
  36314. protected _highPrecisionShadersAllowed: boolean;
  36315. /** @hidden */
  36316. get _shouldUseHighPrecisionShader(): boolean;
  36317. /**
  36318. * Gets a boolean indicating that only power of 2 textures are supported
  36319. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36320. */
  36321. get needPOTTextures(): boolean;
  36322. /** @hidden */
  36323. _badOS: boolean;
  36324. /** @hidden */
  36325. _badDesktopOS: boolean;
  36326. private _hardwareScalingLevel;
  36327. /** @hidden */
  36328. _caps: EngineCapabilities;
  36329. private _isStencilEnable;
  36330. private _glVersion;
  36331. private _glRenderer;
  36332. private _glVendor;
  36333. /** @hidden */
  36334. _videoTextureSupported: boolean;
  36335. protected _renderingQueueLaunched: boolean;
  36336. protected _activeRenderLoops: (() => void)[];
  36337. /**
  36338. * Observable signaled when a context lost event is raised
  36339. */
  36340. onContextLostObservable: Observable<ThinEngine>;
  36341. /**
  36342. * Observable signaled when a context restored event is raised
  36343. */
  36344. onContextRestoredObservable: Observable<ThinEngine>;
  36345. private _onContextLost;
  36346. private _onContextRestored;
  36347. protected _contextWasLost: boolean;
  36348. /** @hidden */
  36349. _doNotHandleContextLost: boolean;
  36350. /**
  36351. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36353. */
  36354. get doNotHandleContextLost(): boolean;
  36355. set doNotHandleContextLost(value: boolean);
  36356. /**
  36357. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36358. */
  36359. disableVertexArrayObjects: boolean;
  36360. /** @hidden */
  36361. protected _colorWrite: boolean;
  36362. /** @hidden */
  36363. protected _colorWriteChanged: boolean;
  36364. /** @hidden */
  36365. protected _depthCullingState: DepthCullingState;
  36366. /** @hidden */
  36367. protected _stencilState: StencilState;
  36368. /** @hidden */
  36369. _alphaState: AlphaState;
  36370. /** @hidden */
  36371. _alphaMode: number;
  36372. /** @hidden */
  36373. _alphaEquation: number;
  36374. /** @hidden */
  36375. _internalTexturesCache: InternalTexture[];
  36376. /** @hidden */
  36377. protected _activeChannel: number;
  36378. private _currentTextureChannel;
  36379. /** @hidden */
  36380. protected _boundTexturesCache: {
  36381. [key: string]: Nullable<InternalTexture>;
  36382. };
  36383. /** @hidden */
  36384. protected _currentEffect: Nullable<Effect>;
  36385. /** @hidden */
  36386. protected _currentProgram: Nullable<WebGLProgram>;
  36387. private _compiledEffects;
  36388. private _vertexAttribArraysEnabled;
  36389. /** @hidden */
  36390. protected _cachedViewport: Nullable<IViewportLike>;
  36391. private _cachedVertexArrayObject;
  36392. /** @hidden */
  36393. protected _cachedVertexBuffers: any;
  36394. /** @hidden */
  36395. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36396. /** @hidden */
  36397. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36398. /** @hidden */
  36399. _currentRenderTarget: Nullable<InternalTexture>;
  36400. private _uintIndicesCurrentlySet;
  36401. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36402. /** @hidden */
  36403. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36404. /** @hidden */
  36405. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36406. private _currentBufferPointers;
  36407. private _currentInstanceLocations;
  36408. private _currentInstanceBuffers;
  36409. private _textureUnits;
  36410. /** @hidden */
  36411. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36412. /** @hidden */
  36413. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36414. /** @hidden */
  36415. _boundRenderFunction: any;
  36416. private _vaoRecordInProgress;
  36417. private _mustWipeVertexAttributes;
  36418. private _emptyTexture;
  36419. private _emptyCubeTexture;
  36420. private _emptyTexture3D;
  36421. private _emptyTexture2DArray;
  36422. /** @hidden */
  36423. _frameHandler: number;
  36424. private _nextFreeTextureSlots;
  36425. private _maxSimultaneousTextures;
  36426. private _activeRequests;
  36427. /** @hidden */
  36428. _transformTextureUrl: Nullable<(url: string) => string>;
  36429. protected get _supportsHardwareTextureRescaling(): boolean;
  36430. private _framebufferDimensionsObject;
  36431. /**
  36432. * sets the object from which width and height will be taken from when getting render width and height
  36433. * Will fallback to the gl object
  36434. * @param dimensions the framebuffer width and height that will be used.
  36435. */
  36436. set framebufferDimensionsObject(dimensions: Nullable<{
  36437. framebufferWidth: number;
  36438. framebufferHeight: number;
  36439. }>);
  36440. /**
  36441. * Gets the current viewport
  36442. */
  36443. get currentViewport(): Nullable<IViewportLike>;
  36444. /**
  36445. * Gets the default empty texture
  36446. */
  36447. get emptyTexture(): InternalTexture;
  36448. /**
  36449. * Gets the default empty 3D texture
  36450. */
  36451. get emptyTexture3D(): InternalTexture;
  36452. /**
  36453. * Gets the default empty 2D array texture
  36454. */
  36455. get emptyTexture2DArray(): InternalTexture;
  36456. /**
  36457. * Gets the default empty cube texture
  36458. */
  36459. get emptyCubeTexture(): InternalTexture;
  36460. /**
  36461. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36462. */
  36463. readonly premultipliedAlpha: boolean;
  36464. /**
  36465. * Observable event triggered before each texture is initialized
  36466. */
  36467. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36468. /**
  36469. * Creates a new engine
  36470. * @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
  36471. * @param antialias defines enable antialiasing (default: false)
  36472. * @param options defines further options to be sent to the getContext() function
  36473. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36474. */
  36475. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36476. private _rebuildInternalTextures;
  36477. private _rebuildEffects;
  36478. /**
  36479. * Gets a boolean indicating if all created effects are ready
  36480. * @returns true if all effects are ready
  36481. */
  36482. areAllEffectsReady(): boolean;
  36483. protected _rebuildBuffers(): void;
  36484. protected _initGLContext(): void;
  36485. /**
  36486. * Gets version of the current webGL context
  36487. */
  36488. get webGLVersion(): number;
  36489. /**
  36490. * Gets a string idenfifying the name of the class
  36491. * @returns "Engine" string
  36492. */
  36493. getClassName(): string;
  36494. /**
  36495. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36496. */
  36497. get isStencilEnable(): boolean;
  36498. /** @hidden */
  36499. _prepareWorkingCanvas(): void;
  36500. /**
  36501. * Reset the texture cache to empty state
  36502. */
  36503. resetTextureCache(): void;
  36504. /**
  36505. * Gets an object containing information about the current webGL context
  36506. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36507. */
  36508. getGlInfo(): {
  36509. vendor: string;
  36510. renderer: string;
  36511. version: string;
  36512. };
  36513. /**
  36514. * Defines the hardware scaling level.
  36515. * By default the hardware scaling level is computed from the window device ratio.
  36516. * 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.
  36517. * @param level defines the level to use
  36518. */
  36519. setHardwareScalingLevel(level: number): void;
  36520. /**
  36521. * Gets the current hardware scaling level.
  36522. * By default the hardware scaling level is computed from the window device ratio.
  36523. * 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.
  36524. * @returns a number indicating the current hardware scaling level
  36525. */
  36526. getHardwareScalingLevel(): number;
  36527. /**
  36528. * Gets the list of loaded textures
  36529. * @returns an array containing all loaded textures
  36530. */
  36531. getLoadedTexturesCache(): InternalTexture[];
  36532. /**
  36533. * Gets the object containing all engine capabilities
  36534. * @returns the EngineCapabilities object
  36535. */
  36536. getCaps(): EngineCapabilities;
  36537. /**
  36538. * stop executing a render loop function and remove it from the execution array
  36539. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36540. */
  36541. stopRenderLoop(renderFunction?: () => void): void;
  36542. /** @hidden */
  36543. _renderLoop(): void;
  36544. /**
  36545. * Gets the HTML canvas attached with the current webGL context
  36546. * @returns a HTML canvas
  36547. */
  36548. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36549. /**
  36550. * Gets host window
  36551. * @returns the host window object
  36552. */
  36553. getHostWindow(): Nullable<Window>;
  36554. /**
  36555. * Gets the current render width
  36556. * @param useScreen defines if screen size must be used (or the current render target if any)
  36557. * @returns a number defining the current render width
  36558. */
  36559. getRenderWidth(useScreen?: boolean): number;
  36560. /**
  36561. * Gets the current render height
  36562. * @param useScreen defines if screen size must be used (or the current render target if any)
  36563. * @returns a number defining the current render height
  36564. */
  36565. getRenderHeight(useScreen?: boolean): number;
  36566. /**
  36567. * Can be used to override the current requestAnimationFrame requester.
  36568. * @hidden
  36569. */
  36570. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36571. /**
  36572. * Register and execute a render loop. The engine can have more than one render function
  36573. * @param renderFunction defines the function to continuously execute
  36574. */
  36575. runRenderLoop(renderFunction: () => void): void;
  36576. /**
  36577. * Clear the current render buffer or the current render target (if any is set up)
  36578. * @param color defines the color to use
  36579. * @param backBuffer defines if the back buffer must be cleared
  36580. * @param depth defines if the depth buffer must be cleared
  36581. * @param stencil defines if the stencil buffer must be cleared
  36582. */
  36583. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36584. private _viewportCached;
  36585. /** @hidden */
  36586. _viewport(x: number, y: number, width: number, height: number): void;
  36587. /**
  36588. * Set the WebGL's viewport
  36589. * @param viewport defines the viewport element to be used
  36590. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36591. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36592. */
  36593. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36594. /**
  36595. * Begin a new frame
  36596. */
  36597. beginFrame(): void;
  36598. /**
  36599. * Enf the current frame
  36600. */
  36601. endFrame(): void;
  36602. /**
  36603. * Resize the view according to the canvas' size
  36604. */
  36605. resize(): void;
  36606. /**
  36607. * Force a specific size of the canvas
  36608. * @param width defines the new canvas' width
  36609. * @param height defines the new canvas' height
  36610. * @returns true if the size was changed
  36611. */
  36612. setSize(width: number, height: number): boolean;
  36613. /**
  36614. * Binds the frame buffer to the specified texture.
  36615. * @param texture The texture to render to or null for the default canvas
  36616. * @param faceIndex The face of the texture to render to in case of cube texture
  36617. * @param requiredWidth The width of the target to render to
  36618. * @param requiredHeight The height of the target to render to
  36619. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36620. * @param lodLevel defines the lod level to bind to the frame buffer
  36621. * @param layer defines the 2d array index to bind to frame buffer to
  36622. */
  36623. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36624. /** @hidden */
  36625. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36626. /**
  36627. * Unbind the current render target texture from the webGL context
  36628. * @param texture defines the render target texture to unbind
  36629. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36630. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36631. */
  36632. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36633. /**
  36634. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36635. */
  36636. flushFramebuffer(): void;
  36637. /**
  36638. * Unbind the current render target and bind the default framebuffer
  36639. */
  36640. restoreDefaultFramebuffer(): void;
  36641. /** @hidden */
  36642. protected _resetVertexBufferBinding(): void;
  36643. /**
  36644. * Creates a vertex buffer
  36645. * @param data the data for the vertex buffer
  36646. * @returns the new WebGL static buffer
  36647. */
  36648. createVertexBuffer(data: DataArray): DataBuffer;
  36649. private _createVertexBuffer;
  36650. /**
  36651. * Creates a dynamic vertex buffer
  36652. * @param data the data for the dynamic vertex buffer
  36653. * @returns the new WebGL dynamic buffer
  36654. */
  36655. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36656. protected _resetIndexBufferBinding(): void;
  36657. /**
  36658. * Creates a new index buffer
  36659. * @param indices defines the content of the index buffer
  36660. * @param updatable defines if the index buffer must be updatable
  36661. * @returns a new webGL buffer
  36662. */
  36663. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36664. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36665. /**
  36666. * Bind a webGL buffer to the webGL context
  36667. * @param buffer defines the buffer to bind
  36668. */
  36669. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36670. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36671. private bindBuffer;
  36672. /**
  36673. * update the bound buffer with the given data
  36674. * @param data defines the data to update
  36675. */
  36676. updateArrayBuffer(data: Float32Array): void;
  36677. private _vertexAttribPointer;
  36678. /** @hidden */
  36679. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36680. private _bindVertexBuffersAttributes;
  36681. /**
  36682. * Records a vertex array object
  36683. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36684. * @param vertexBuffers defines the list of vertex buffers to store
  36685. * @param indexBuffer defines the index buffer to store
  36686. * @param effect defines the effect to store
  36687. * @returns the new vertex array object
  36688. */
  36689. recordVertexArrayObject(vertexBuffers: {
  36690. [key: string]: VertexBuffer;
  36691. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36692. /**
  36693. * Bind a specific vertex array object
  36694. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36695. * @param vertexArrayObject defines the vertex array object to bind
  36696. * @param indexBuffer defines the index buffer to bind
  36697. */
  36698. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36699. /**
  36700. * Bind webGl buffers directly to the webGL context
  36701. * @param vertexBuffer defines the vertex buffer to bind
  36702. * @param indexBuffer defines the index buffer to bind
  36703. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36704. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36705. * @param effect defines the effect associated with the vertex buffer
  36706. */
  36707. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36708. private _unbindVertexArrayObject;
  36709. /**
  36710. * Bind a list of vertex buffers to the webGL context
  36711. * @param vertexBuffers defines the list of vertex buffers to bind
  36712. * @param indexBuffer defines the index buffer to bind
  36713. * @param effect defines the effect associated with the vertex buffers
  36714. */
  36715. bindBuffers(vertexBuffers: {
  36716. [key: string]: Nullable<VertexBuffer>;
  36717. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36718. /**
  36719. * Unbind all instance attributes
  36720. */
  36721. unbindInstanceAttributes(): void;
  36722. /**
  36723. * Release and free the memory of a vertex array object
  36724. * @param vao defines the vertex array object to delete
  36725. */
  36726. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36727. /** @hidden */
  36728. _releaseBuffer(buffer: DataBuffer): boolean;
  36729. protected _deleteBuffer(buffer: DataBuffer): void;
  36730. /**
  36731. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36732. * @param instancesBuffer defines the webGL buffer to update and bind
  36733. * @param data defines the data to store in the buffer
  36734. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36735. */
  36736. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36737. /**
  36738. * Bind the content of a webGL buffer used with instantiation
  36739. * @param instancesBuffer defines the webGL buffer to bind
  36740. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36741. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36742. */
  36743. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36744. /**
  36745. * Disable the instance attribute corresponding to the name in parameter
  36746. * @param name defines the name of the attribute to disable
  36747. */
  36748. disableInstanceAttributeByName(name: string): void;
  36749. /**
  36750. * Disable the instance attribute corresponding to the location in parameter
  36751. * @param attributeLocation defines the attribute location of the attribute to disable
  36752. */
  36753. disableInstanceAttribute(attributeLocation: number): void;
  36754. /**
  36755. * Disable the attribute corresponding to the location in parameter
  36756. * @param attributeLocation defines the attribute location of the attribute to disable
  36757. */
  36758. disableAttributeByIndex(attributeLocation: number): void;
  36759. /**
  36760. * Send a draw order
  36761. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36762. * @param indexStart defines the starting index
  36763. * @param indexCount defines the number of index to draw
  36764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36765. */
  36766. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36767. /**
  36768. * Draw a list of points
  36769. * @param verticesStart defines the index of first vertex to draw
  36770. * @param verticesCount defines the count of vertices to draw
  36771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36772. */
  36773. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36774. /**
  36775. * Draw a list of unindexed primitives
  36776. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36777. * @param verticesStart defines the index of first vertex to draw
  36778. * @param verticesCount defines the count of vertices to draw
  36779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36780. */
  36781. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36782. /**
  36783. * Draw a list of indexed primitives
  36784. * @param fillMode defines the primitive to use
  36785. * @param indexStart defines the starting index
  36786. * @param indexCount defines the number of index to draw
  36787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36788. */
  36789. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36790. /**
  36791. * Draw a list of unindexed primitives
  36792. * @param fillMode defines the primitive to use
  36793. * @param verticesStart defines the index of first vertex to draw
  36794. * @param verticesCount defines the count of vertices to draw
  36795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36796. */
  36797. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36798. private _drawMode;
  36799. /** @hidden */
  36800. protected _reportDrawCall(): void;
  36801. /** @hidden */
  36802. _releaseEffect(effect: Effect): void;
  36803. /** @hidden */
  36804. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36805. /**
  36806. * Create a new effect (used to store vertex/fragment shaders)
  36807. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36808. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36809. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36810. * @param samplers defines an array of string used to represent textures
  36811. * @param defines defines the string containing the defines to use to compile the shaders
  36812. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36813. * @param onCompiled defines a function to call when the effect creation is successful
  36814. * @param onError defines a function to call when the effect creation has failed
  36815. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36816. * @returns the new Effect
  36817. */
  36818. 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;
  36819. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36820. private _compileShader;
  36821. private _compileRawShader;
  36822. /** @hidden */
  36823. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36824. /**
  36825. * Directly creates a webGL program
  36826. * @param pipelineContext defines the pipeline context to attach to
  36827. * @param vertexCode defines the vertex shader code to use
  36828. * @param fragmentCode defines the fragment shader code to use
  36829. * @param context defines the webGL context to use (if not set, the current one will be used)
  36830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36831. * @returns the new webGL program
  36832. */
  36833. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36834. /**
  36835. * Creates a webGL program
  36836. * @param pipelineContext defines the pipeline context to attach to
  36837. * @param vertexCode defines the vertex shader code to use
  36838. * @param fragmentCode defines the fragment shader code to use
  36839. * @param defines defines the string containing the defines to use to compile the shaders
  36840. * @param context defines the webGL context to use (if not set, the current one will be used)
  36841. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36842. * @returns the new webGL program
  36843. */
  36844. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36845. /**
  36846. * Creates a new pipeline context
  36847. * @returns the new pipeline
  36848. */
  36849. createPipelineContext(): IPipelineContext;
  36850. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36851. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36852. /** @hidden */
  36853. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36854. /** @hidden */
  36855. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36856. /** @hidden */
  36857. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36858. /**
  36859. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36860. * @param pipelineContext defines the pipeline context to use
  36861. * @param uniformsNames defines the list of uniform names
  36862. * @returns an array of webGL uniform locations
  36863. */
  36864. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36865. /**
  36866. * Gets the lsit of active attributes for a given webGL program
  36867. * @param pipelineContext defines the pipeline context to use
  36868. * @param attributesNames defines the list of attribute names to get
  36869. * @returns an array of indices indicating the offset of each attribute
  36870. */
  36871. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36872. /**
  36873. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36874. * @param effect defines the effect to activate
  36875. */
  36876. enableEffect(effect: Nullable<Effect>): void;
  36877. /**
  36878. * Set the value of an uniform to a number (int)
  36879. * @param uniform defines the webGL uniform location where to store the value
  36880. * @param value defines the int number to store
  36881. */
  36882. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36883. /**
  36884. * Set the value of an uniform to an array of int32
  36885. * @param uniform defines the webGL uniform location where to store the value
  36886. * @param array defines the array of int32 to store
  36887. */
  36888. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36889. /**
  36890. * Set the value of an uniform to an array of int32 (stored as vec2)
  36891. * @param uniform defines the webGL uniform location where to store the value
  36892. * @param array defines the array of int32 to store
  36893. */
  36894. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36895. /**
  36896. * Set the value of an uniform to an array of int32 (stored as vec3)
  36897. * @param uniform defines the webGL uniform location where to store the value
  36898. * @param array defines the array of int32 to store
  36899. */
  36900. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36901. /**
  36902. * Set the value of an uniform to an array of int32 (stored as vec4)
  36903. * @param uniform defines the webGL uniform location where to store the value
  36904. * @param array defines the array of int32 to store
  36905. */
  36906. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36907. /**
  36908. * Set the value of an uniform to an array of number
  36909. * @param uniform defines the webGL uniform location where to store the value
  36910. * @param array defines the array of number to store
  36911. */
  36912. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36913. /**
  36914. * Set the value of an uniform to an array of number (stored as vec2)
  36915. * @param uniform defines the webGL uniform location where to store the value
  36916. * @param array defines the array of number to store
  36917. */
  36918. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36919. /**
  36920. * Set the value of an uniform to an array of number (stored as vec3)
  36921. * @param uniform defines the webGL uniform location where to store the value
  36922. * @param array defines the array of number to store
  36923. */
  36924. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36925. /**
  36926. * Set the value of an uniform to an array of number (stored as vec4)
  36927. * @param uniform defines the webGL uniform location where to store the value
  36928. * @param array defines the array of number to store
  36929. */
  36930. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36931. /**
  36932. * Set the value of an uniform to an array of float32 (stored as matrices)
  36933. * @param uniform defines the webGL uniform location where to store the value
  36934. * @param matrices defines the array of float32 to store
  36935. */
  36936. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36937. /**
  36938. * Set the value of an uniform to a matrix (3x3)
  36939. * @param uniform defines the webGL uniform location where to store the value
  36940. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36941. */
  36942. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36943. /**
  36944. * Set the value of an uniform to a matrix (2x2)
  36945. * @param uniform defines the webGL uniform location where to store the value
  36946. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36947. */
  36948. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36949. /**
  36950. * Set the value of an uniform to a number (float)
  36951. * @param uniform defines the webGL uniform location where to store the value
  36952. * @param value defines the float number to store
  36953. */
  36954. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36955. /**
  36956. * Set the value of an uniform to a vec2
  36957. * @param uniform defines the webGL uniform location where to store the value
  36958. * @param x defines the 1st component of the value
  36959. * @param y defines the 2nd component of the value
  36960. */
  36961. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36962. /**
  36963. * Set the value of an uniform to a vec3
  36964. * @param uniform defines the webGL uniform location where to store the value
  36965. * @param x defines the 1st component of the value
  36966. * @param y defines the 2nd component of the value
  36967. * @param z defines the 3rd component of the value
  36968. */
  36969. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36970. /**
  36971. * Set the value of an uniform to a vec4
  36972. * @param uniform defines the webGL uniform location where to store the value
  36973. * @param x defines the 1st component of the value
  36974. * @param y defines the 2nd component of the value
  36975. * @param z defines the 3rd component of the value
  36976. * @param w defines the 4th component of the value
  36977. */
  36978. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36979. /**
  36980. * Apply all cached states (depth, culling, stencil and alpha)
  36981. */
  36982. applyStates(): void;
  36983. /**
  36984. * Enable or disable color writing
  36985. * @param enable defines the state to set
  36986. */
  36987. setColorWrite(enable: boolean): void;
  36988. /**
  36989. * Gets a boolean indicating if color writing is enabled
  36990. * @returns the current color writing state
  36991. */
  36992. getColorWrite(): boolean;
  36993. /**
  36994. * Gets the depth culling state manager
  36995. */
  36996. get depthCullingState(): DepthCullingState;
  36997. /**
  36998. * Gets the alpha state manager
  36999. */
  37000. get alphaState(): AlphaState;
  37001. /**
  37002. * Gets the stencil state manager
  37003. */
  37004. get stencilState(): StencilState;
  37005. /**
  37006. * Clears the list of texture accessible through engine.
  37007. * This can help preventing texture load conflict due to name collision.
  37008. */
  37009. clearInternalTexturesCache(): void;
  37010. /**
  37011. * Force the entire cache to be cleared
  37012. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37013. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37014. */
  37015. wipeCaches(bruteForce?: boolean): void;
  37016. /** @hidden */
  37017. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37018. min: number;
  37019. mag: number;
  37020. };
  37021. /** @hidden */
  37022. _createTexture(): WebGLTexture;
  37023. /**
  37024. * Usually called from Texture.ts.
  37025. * Passed information to create a WebGLTexture
  37026. * @param url defines a value which contains one of the following:
  37027. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37028. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37029. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37030. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37031. * @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)
  37032. * @param scene needed for loading to the correct scene
  37033. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37034. * @param onLoad optional callback to be called upon successful completion
  37035. * @param onError optional callback to be called upon failure
  37036. * @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
  37037. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37038. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37039. * @param forcedExtension defines the extension to use to pick the right loader
  37040. * @param mimeType defines an optional mime type
  37041. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37042. */
  37043. 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): InternalTexture;
  37044. /**
  37045. * Loads an image as an HTMLImageElement.
  37046. * @param input url string, ArrayBuffer, or Blob to load
  37047. * @param onLoad callback called when the image successfully loads
  37048. * @param onError callback called when the image fails to load
  37049. * @param offlineProvider offline provider for caching
  37050. * @param mimeType optional mime type
  37051. * @returns the HTMLImageElement of the loaded image
  37052. * @hidden
  37053. */
  37054. 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>;
  37055. /**
  37056. * @hidden
  37057. */
  37058. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37059. private _unpackFlipYCached;
  37060. /**
  37061. * In case you are sharing the context with other applications, it might
  37062. * be interested to not cache the unpack flip y state to ensure a consistent
  37063. * value would be set.
  37064. */
  37065. enableUnpackFlipYCached: boolean;
  37066. /** @hidden */
  37067. _unpackFlipY(value: boolean): void;
  37068. /** @hidden */
  37069. _getUnpackAlignement(): number;
  37070. private _getTextureTarget;
  37071. /**
  37072. * Update the sampling mode of a given texture
  37073. * @param samplingMode defines the required sampling mode
  37074. * @param texture defines the texture to update
  37075. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37076. */
  37077. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37078. /**
  37079. * Update the sampling mode of a given texture
  37080. * @param texture defines the texture to update
  37081. * @param wrapU defines the texture wrap mode of the u coordinates
  37082. * @param wrapV defines the texture wrap mode of the v coordinates
  37083. * @param wrapR defines the texture wrap mode of the r coordinates
  37084. */
  37085. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37086. /** @hidden */
  37087. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37088. width: number;
  37089. height: number;
  37090. layers?: number;
  37091. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37092. /** @hidden */
  37093. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37094. /** @hidden */
  37095. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37096. /**
  37097. * Update a portion of an internal texture
  37098. * @param texture defines the texture to update
  37099. * @param imageData defines the data to store into the texture
  37100. * @param xOffset defines the x coordinates of the update rectangle
  37101. * @param yOffset defines the y coordinates of the update rectangle
  37102. * @param width defines the width of the update rectangle
  37103. * @param height defines the height of the update rectangle
  37104. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37105. * @param lod defines the lod level to update (0 by default)
  37106. */
  37107. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37108. /** @hidden */
  37109. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37110. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37111. private _prepareWebGLTexture;
  37112. /** @hidden */
  37113. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37114. private _getDepthStencilBuffer;
  37115. /** @hidden */
  37116. _releaseFramebufferObjects(texture: InternalTexture): void;
  37117. /** @hidden */
  37118. _releaseTexture(texture: InternalTexture): void;
  37119. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37120. protected _setProgram(program: WebGLProgram): void;
  37121. protected _boundUniforms: {
  37122. [key: number]: WebGLUniformLocation;
  37123. };
  37124. /**
  37125. * Binds an effect to the webGL context
  37126. * @param effect defines the effect to bind
  37127. */
  37128. bindSamplers(effect: Effect): void;
  37129. private _activateCurrentTexture;
  37130. /** @hidden */
  37131. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37132. /** @hidden */
  37133. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37134. /**
  37135. * Unbind all textures from the webGL context
  37136. */
  37137. unbindAllTextures(): void;
  37138. /**
  37139. * Sets a texture to the according uniform.
  37140. * @param channel The texture channel
  37141. * @param uniform The uniform to set
  37142. * @param texture The texture to apply
  37143. */
  37144. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37145. private _bindSamplerUniformToChannel;
  37146. private _getTextureWrapMode;
  37147. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37148. /**
  37149. * Sets an array of texture to the webGL context
  37150. * @param channel defines the channel where the texture array must be set
  37151. * @param uniform defines the associated uniform location
  37152. * @param textures defines the array of textures to bind
  37153. */
  37154. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37155. /** @hidden */
  37156. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37157. private _setTextureParameterFloat;
  37158. private _setTextureParameterInteger;
  37159. /**
  37160. * Unbind all vertex attributes from the webGL context
  37161. */
  37162. unbindAllAttributes(): void;
  37163. /**
  37164. * 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
  37165. */
  37166. releaseEffects(): void;
  37167. /**
  37168. * Dispose and release all associated resources
  37169. */
  37170. dispose(): void;
  37171. /**
  37172. * Attach a new callback raised when context lost event is fired
  37173. * @param callback defines the callback to call
  37174. */
  37175. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37176. /**
  37177. * Attach a new callback raised when context restored event is fired
  37178. * @param callback defines the callback to call
  37179. */
  37180. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37181. /**
  37182. * Get the current error code of the webGL context
  37183. * @returns the error code
  37184. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37185. */
  37186. getError(): number;
  37187. private _canRenderToFloatFramebuffer;
  37188. private _canRenderToHalfFloatFramebuffer;
  37189. private _canRenderToFramebuffer;
  37190. /** @hidden */
  37191. _getWebGLTextureType(type: number): number;
  37192. /** @hidden */
  37193. _getInternalFormat(format: number): number;
  37194. /** @hidden */
  37195. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37196. /** @hidden */
  37197. _getRGBAMultiSampleBufferFormat(type: number): number;
  37198. /** @hidden */
  37199. _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;
  37200. /**
  37201. * Loads a file from a url
  37202. * @param url url to load
  37203. * @param onSuccess callback called when the file successfully loads
  37204. * @param onProgress callback called while file is loading (if the server supports this mode)
  37205. * @param offlineProvider defines the offline provider for caching
  37206. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37207. * @param onError callback called when the file fails to load
  37208. * @returns a file request object
  37209. * @hidden
  37210. */
  37211. 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;
  37212. /**
  37213. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37214. * @param x defines the x coordinate of the rectangle where pixels must be read
  37215. * @param y defines the y coordinate of the rectangle where pixels must be read
  37216. * @param width defines the width of the rectangle where pixels must be read
  37217. * @param height defines the height of the rectangle where pixels must be read
  37218. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37219. * @returns a Uint8Array containing RGBA colors
  37220. */
  37221. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37222. private static _isSupported;
  37223. /**
  37224. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37225. * @returns true if the engine can be created
  37226. * @ignorenaming
  37227. */
  37228. static isSupported(): boolean;
  37229. /**
  37230. * Find the next highest power of two.
  37231. * @param x Number to start search from.
  37232. * @return Next highest power of two.
  37233. */
  37234. static CeilingPOT(x: number): number;
  37235. /**
  37236. * Find the next lowest power of two.
  37237. * @param x Number to start search from.
  37238. * @return Next lowest power of two.
  37239. */
  37240. static FloorPOT(x: number): number;
  37241. /**
  37242. * Find the nearest power of two.
  37243. * @param x Number to start search from.
  37244. * @return Next nearest power of two.
  37245. */
  37246. static NearestPOT(x: number): number;
  37247. /**
  37248. * Get the closest exponent of two
  37249. * @param value defines the value to approximate
  37250. * @param max defines the maximum value to return
  37251. * @param mode defines how to define the closest value
  37252. * @returns closest exponent of two of the given value
  37253. */
  37254. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37255. /**
  37256. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37257. * @param func - the function to be called
  37258. * @param requester - the object that will request the next frame. Falls back to window.
  37259. * @returns frame number
  37260. */
  37261. static QueueNewFrame(func: () => void, requester?: any): number;
  37262. /**
  37263. * Gets host document
  37264. * @returns the host document object
  37265. */
  37266. getHostDocument(): Nullable<Document>;
  37267. }
  37268. }
  37269. declare module "babylonjs/Maths/sphericalPolynomial" {
  37270. import { Vector3 } from "babylonjs/Maths/math.vector";
  37271. import { Color3 } from "babylonjs/Maths/math.color";
  37272. /**
  37273. * Class representing spherical harmonics coefficients to the 3rd degree
  37274. */
  37275. export class SphericalHarmonics {
  37276. /**
  37277. * Defines whether or not the harmonics have been prescaled for rendering.
  37278. */
  37279. preScaled: boolean;
  37280. /**
  37281. * The l0,0 coefficients of the spherical harmonics
  37282. */
  37283. l00: Vector3;
  37284. /**
  37285. * The l1,-1 coefficients of the spherical harmonics
  37286. */
  37287. l1_1: Vector3;
  37288. /**
  37289. * The l1,0 coefficients of the spherical harmonics
  37290. */
  37291. l10: Vector3;
  37292. /**
  37293. * The l1,1 coefficients of the spherical harmonics
  37294. */
  37295. l11: Vector3;
  37296. /**
  37297. * The l2,-2 coefficients of the spherical harmonics
  37298. */
  37299. l2_2: Vector3;
  37300. /**
  37301. * The l2,-1 coefficients of the spherical harmonics
  37302. */
  37303. l2_1: Vector3;
  37304. /**
  37305. * The l2,0 coefficients of the spherical harmonics
  37306. */
  37307. l20: Vector3;
  37308. /**
  37309. * The l2,1 coefficients of the spherical harmonics
  37310. */
  37311. l21: Vector3;
  37312. /**
  37313. * The l2,2 coefficients of the spherical harmonics
  37314. */
  37315. l22: Vector3;
  37316. /**
  37317. * Adds a light to the spherical harmonics
  37318. * @param direction the direction of the light
  37319. * @param color the color of the light
  37320. * @param deltaSolidAngle the delta solid angle of the light
  37321. */
  37322. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37323. /**
  37324. * Scales the spherical harmonics by the given amount
  37325. * @param scale the amount to scale
  37326. */
  37327. scaleInPlace(scale: number): void;
  37328. /**
  37329. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37330. *
  37331. * ```
  37332. * E_lm = A_l * L_lm
  37333. * ```
  37334. *
  37335. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37336. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37337. * the scaling factors are given in equation 9.
  37338. */
  37339. convertIncidentRadianceToIrradiance(): void;
  37340. /**
  37341. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37342. *
  37343. * ```
  37344. * L = (1/pi) * E * rho
  37345. * ```
  37346. *
  37347. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37348. */
  37349. convertIrradianceToLambertianRadiance(): void;
  37350. /**
  37351. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37352. * required operations at run time.
  37353. *
  37354. * This is simply done by scaling back the SH with Ylm constants parameter.
  37355. * The trigonometric part being applied by the shader at run time.
  37356. */
  37357. preScaleForRendering(): void;
  37358. /**
  37359. * Constructs a spherical harmonics from an array.
  37360. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37361. * @returns the spherical harmonics
  37362. */
  37363. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37364. /**
  37365. * Gets the spherical harmonics from polynomial
  37366. * @param polynomial the spherical polynomial
  37367. * @returns the spherical harmonics
  37368. */
  37369. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37370. }
  37371. /**
  37372. * Class representing spherical polynomial coefficients to the 3rd degree
  37373. */
  37374. export class SphericalPolynomial {
  37375. private _harmonics;
  37376. /**
  37377. * The spherical harmonics used to create the polynomials.
  37378. */
  37379. get preScaledHarmonics(): SphericalHarmonics;
  37380. /**
  37381. * The x coefficients of the spherical polynomial
  37382. */
  37383. x: Vector3;
  37384. /**
  37385. * The y coefficients of the spherical polynomial
  37386. */
  37387. y: Vector3;
  37388. /**
  37389. * The z coefficients of the spherical polynomial
  37390. */
  37391. z: Vector3;
  37392. /**
  37393. * The xx coefficients of the spherical polynomial
  37394. */
  37395. xx: Vector3;
  37396. /**
  37397. * The yy coefficients of the spherical polynomial
  37398. */
  37399. yy: Vector3;
  37400. /**
  37401. * The zz coefficients of the spherical polynomial
  37402. */
  37403. zz: Vector3;
  37404. /**
  37405. * The xy coefficients of the spherical polynomial
  37406. */
  37407. xy: Vector3;
  37408. /**
  37409. * The yz coefficients of the spherical polynomial
  37410. */
  37411. yz: Vector3;
  37412. /**
  37413. * The zx coefficients of the spherical polynomial
  37414. */
  37415. zx: Vector3;
  37416. /**
  37417. * Adds an ambient color to the spherical polynomial
  37418. * @param color the color to add
  37419. */
  37420. addAmbient(color: Color3): void;
  37421. /**
  37422. * Scales the spherical polynomial by the given amount
  37423. * @param scale the amount to scale
  37424. */
  37425. scaleInPlace(scale: number): void;
  37426. /**
  37427. * Gets the spherical polynomial from harmonics
  37428. * @param harmonics the spherical harmonics
  37429. * @returns the spherical polynomial
  37430. */
  37431. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37432. /**
  37433. * Constructs a spherical polynomial from an array.
  37434. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37435. * @returns the spherical polynomial
  37436. */
  37437. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37438. }
  37439. }
  37440. declare module "babylonjs/Materials/Textures/internalTexture" {
  37441. import { Observable } from "babylonjs/Misc/observable";
  37442. import { Nullable, int } from "babylonjs/types";
  37443. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37445. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37446. /**
  37447. * Defines the source of the internal texture
  37448. */
  37449. export enum InternalTextureSource {
  37450. /**
  37451. * The source of the texture data is unknown
  37452. */
  37453. Unknown = 0,
  37454. /**
  37455. * Texture data comes from an URL
  37456. */
  37457. Url = 1,
  37458. /**
  37459. * Texture data is only used for temporary storage
  37460. */
  37461. Temp = 2,
  37462. /**
  37463. * Texture data comes from raw data (ArrayBuffer)
  37464. */
  37465. Raw = 3,
  37466. /**
  37467. * Texture content is dynamic (video or dynamic texture)
  37468. */
  37469. Dynamic = 4,
  37470. /**
  37471. * Texture content is generated by rendering to it
  37472. */
  37473. RenderTarget = 5,
  37474. /**
  37475. * Texture content is part of a multi render target process
  37476. */
  37477. MultiRenderTarget = 6,
  37478. /**
  37479. * Texture data comes from a cube data file
  37480. */
  37481. Cube = 7,
  37482. /**
  37483. * Texture data comes from a raw cube data
  37484. */
  37485. CubeRaw = 8,
  37486. /**
  37487. * Texture data come from a prefiltered cube data file
  37488. */
  37489. CubePrefiltered = 9,
  37490. /**
  37491. * Texture content is raw 3D data
  37492. */
  37493. Raw3D = 10,
  37494. /**
  37495. * Texture content is raw 2D array data
  37496. */
  37497. Raw2DArray = 11,
  37498. /**
  37499. * Texture content is a depth texture
  37500. */
  37501. Depth = 12,
  37502. /**
  37503. * Texture data comes from a raw cube data encoded with RGBD
  37504. */
  37505. CubeRawRGBD = 13
  37506. }
  37507. /**
  37508. * Class used to store data associated with WebGL texture data for the engine
  37509. * This class should not be used directly
  37510. */
  37511. export class InternalTexture {
  37512. /** @hidden */
  37513. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37514. /**
  37515. * Defines if the texture is ready
  37516. */
  37517. isReady: boolean;
  37518. /**
  37519. * Defines if the texture is a cube texture
  37520. */
  37521. isCube: boolean;
  37522. /**
  37523. * Defines if the texture contains 3D data
  37524. */
  37525. is3D: boolean;
  37526. /**
  37527. * Defines if the texture contains 2D array data
  37528. */
  37529. is2DArray: boolean;
  37530. /**
  37531. * Defines if the texture contains multiview data
  37532. */
  37533. isMultiview: boolean;
  37534. /**
  37535. * Gets the URL used to load this texture
  37536. */
  37537. url: string;
  37538. /**
  37539. * Gets the sampling mode of the texture
  37540. */
  37541. samplingMode: number;
  37542. /**
  37543. * Gets a boolean indicating if the texture needs mipmaps generation
  37544. */
  37545. generateMipMaps: boolean;
  37546. /**
  37547. * Gets the number of samples used by the texture (WebGL2+ only)
  37548. */
  37549. samples: number;
  37550. /**
  37551. * Gets the type of the texture (int, float...)
  37552. */
  37553. type: number;
  37554. /**
  37555. * Gets the format of the texture (RGB, RGBA...)
  37556. */
  37557. format: number;
  37558. /**
  37559. * Observable called when the texture is loaded
  37560. */
  37561. onLoadedObservable: Observable<InternalTexture>;
  37562. /**
  37563. * Gets the width of the texture
  37564. */
  37565. width: number;
  37566. /**
  37567. * Gets the height of the texture
  37568. */
  37569. height: number;
  37570. /**
  37571. * Gets the depth of the texture
  37572. */
  37573. depth: number;
  37574. /**
  37575. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37576. */
  37577. baseWidth: number;
  37578. /**
  37579. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37580. */
  37581. baseHeight: number;
  37582. /**
  37583. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37584. */
  37585. baseDepth: number;
  37586. /**
  37587. * Gets a boolean indicating if the texture is inverted on Y axis
  37588. */
  37589. invertY: boolean;
  37590. /** @hidden */
  37591. _invertVScale: boolean;
  37592. /** @hidden */
  37593. _associatedChannel: number;
  37594. /** @hidden */
  37595. _source: InternalTextureSource;
  37596. /** @hidden */
  37597. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37598. /** @hidden */
  37599. _bufferView: Nullable<ArrayBufferView>;
  37600. /** @hidden */
  37601. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37602. /** @hidden */
  37603. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37604. /** @hidden */
  37605. _size: number;
  37606. /** @hidden */
  37607. _extension: string;
  37608. /** @hidden */
  37609. _files: Nullable<string[]>;
  37610. /** @hidden */
  37611. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37612. /** @hidden */
  37613. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37614. /** @hidden */
  37615. _framebuffer: Nullable<WebGLFramebuffer>;
  37616. /** @hidden */
  37617. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37618. /** @hidden */
  37619. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37620. /** @hidden */
  37621. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37622. /** @hidden */
  37623. _attachments: Nullable<number[]>;
  37624. /** @hidden */
  37625. _textureArray: Nullable<InternalTexture[]>;
  37626. /** @hidden */
  37627. _cachedCoordinatesMode: Nullable<number>;
  37628. /** @hidden */
  37629. _cachedWrapU: Nullable<number>;
  37630. /** @hidden */
  37631. _cachedWrapV: Nullable<number>;
  37632. /** @hidden */
  37633. _cachedWrapR: Nullable<number>;
  37634. /** @hidden */
  37635. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37636. /** @hidden */
  37637. _isDisabled: boolean;
  37638. /** @hidden */
  37639. _compression: Nullable<string>;
  37640. /** @hidden */
  37641. _generateStencilBuffer: boolean;
  37642. /** @hidden */
  37643. _generateDepthBuffer: boolean;
  37644. /** @hidden */
  37645. _comparisonFunction: number;
  37646. /** @hidden */
  37647. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37648. /** @hidden */
  37649. _lodGenerationScale: number;
  37650. /** @hidden */
  37651. _lodGenerationOffset: number;
  37652. /** @hidden */
  37653. _depthStencilTexture: Nullable<InternalTexture>;
  37654. /** @hidden */
  37655. _colorTextureArray: Nullable<WebGLTexture>;
  37656. /** @hidden */
  37657. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37658. /** @hidden */
  37659. _lodTextureHigh: Nullable<BaseTexture>;
  37660. /** @hidden */
  37661. _lodTextureMid: Nullable<BaseTexture>;
  37662. /** @hidden */
  37663. _lodTextureLow: Nullable<BaseTexture>;
  37664. /** @hidden */
  37665. _isRGBD: boolean;
  37666. /** @hidden */
  37667. _linearSpecularLOD: boolean;
  37668. /** @hidden */
  37669. _irradianceTexture: Nullable<BaseTexture>;
  37670. /** @hidden */
  37671. _webGLTexture: Nullable<WebGLTexture>;
  37672. /** @hidden */
  37673. _references: number;
  37674. private _engine;
  37675. /**
  37676. * Gets the Engine the texture belongs to.
  37677. * @returns The babylon engine
  37678. */
  37679. getEngine(): ThinEngine;
  37680. /**
  37681. * Gets the data source type of the texture
  37682. */
  37683. get source(): InternalTextureSource;
  37684. /**
  37685. * Creates a new InternalTexture
  37686. * @param engine defines the engine to use
  37687. * @param source defines the type of data that will be used
  37688. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37689. */
  37690. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37691. /**
  37692. * Increments the number of references (ie. the number of Texture that point to it)
  37693. */
  37694. incrementReferences(): void;
  37695. /**
  37696. * Change the size of the texture (not the size of the content)
  37697. * @param width defines the new width
  37698. * @param height defines the new height
  37699. * @param depth defines the new depth (1 by default)
  37700. */
  37701. updateSize(width: int, height: int, depth?: int): void;
  37702. /** @hidden */
  37703. _rebuild(): void;
  37704. /** @hidden */
  37705. _swapAndDie(target: InternalTexture): void;
  37706. /**
  37707. * Dispose the current allocated resources
  37708. */
  37709. dispose(): void;
  37710. }
  37711. }
  37712. declare module "babylonjs/Audio/analyser" {
  37713. import { Scene } from "babylonjs/scene";
  37714. /**
  37715. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37716. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37717. */
  37718. export class Analyser {
  37719. /**
  37720. * Gets or sets the smoothing
  37721. * @ignorenaming
  37722. */
  37723. SMOOTHING: number;
  37724. /**
  37725. * Gets or sets the FFT table size
  37726. * @ignorenaming
  37727. */
  37728. FFT_SIZE: number;
  37729. /**
  37730. * Gets or sets the bar graph amplitude
  37731. * @ignorenaming
  37732. */
  37733. BARGRAPHAMPLITUDE: number;
  37734. /**
  37735. * Gets or sets the position of the debug canvas
  37736. * @ignorenaming
  37737. */
  37738. DEBUGCANVASPOS: {
  37739. x: number;
  37740. y: number;
  37741. };
  37742. /**
  37743. * Gets or sets the debug canvas size
  37744. * @ignorenaming
  37745. */
  37746. DEBUGCANVASSIZE: {
  37747. width: number;
  37748. height: number;
  37749. };
  37750. private _byteFreqs;
  37751. private _byteTime;
  37752. private _floatFreqs;
  37753. private _webAudioAnalyser;
  37754. private _debugCanvas;
  37755. private _debugCanvasContext;
  37756. private _scene;
  37757. private _registerFunc;
  37758. private _audioEngine;
  37759. /**
  37760. * Creates a new analyser
  37761. * @param scene defines hosting scene
  37762. */
  37763. constructor(scene: Scene);
  37764. /**
  37765. * Get the number of data values you will have to play with for the visualization
  37766. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37767. * @returns a number
  37768. */
  37769. getFrequencyBinCount(): number;
  37770. /**
  37771. * Gets the current frequency data as a byte array
  37772. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37773. * @returns a Uint8Array
  37774. */
  37775. getByteFrequencyData(): Uint8Array;
  37776. /**
  37777. * Gets the current waveform as a byte array
  37778. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37779. * @returns a Uint8Array
  37780. */
  37781. getByteTimeDomainData(): Uint8Array;
  37782. /**
  37783. * Gets the current frequency data as a float array
  37784. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37785. * @returns a Float32Array
  37786. */
  37787. getFloatFrequencyData(): Float32Array;
  37788. /**
  37789. * Renders the debug canvas
  37790. */
  37791. drawDebugCanvas(): void;
  37792. /**
  37793. * Stops rendering the debug canvas and removes it
  37794. */
  37795. stopDebugCanvas(): void;
  37796. /**
  37797. * Connects two audio nodes
  37798. * @param inputAudioNode defines first node to connect
  37799. * @param outputAudioNode defines second node to connect
  37800. */
  37801. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37802. /**
  37803. * Releases all associated resources
  37804. */
  37805. dispose(): void;
  37806. }
  37807. }
  37808. declare module "babylonjs/Audio/audioEngine" {
  37809. import { IDisposable } from "babylonjs/scene";
  37810. import { Analyser } from "babylonjs/Audio/analyser";
  37811. import { Nullable } from "babylonjs/types";
  37812. import { Observable } from "babylonjs/Misc/observable";
  37813. /**
  37814. * This represents an audio engine and it is responsible
  37815. * to play, synchronize and analyse sounds throughout the application.
  37816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37817. */
  37818. export interface IAudioEngine extends IDisposable {
  37819. /**
  37820. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37821. */
  37822. readonly canUseWebAudio: boolean;
  37823. /**
  37824. * Gets the current AudioContext if available.
  37825. */
  37826. readonly audioContext: Nullable<AudioContext>;
  37827. /**
  37828. * The master gain node defines the global audio volume of your audio engine.
  37829. */
  37830. readonly masterGain: GainNode;
  37831. /**
  37832. * Gets whether or not mp3 are supported by your browser.
  37833. */
  37834. readonly isMP3supported: boolean;
  37835. /**
  37836. * Gets whether or not ogg are supported by your browser.
  37837. */
  37838. readonly isOGGsupported: boolean;
  37839. /**
  37840. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37841. * @ignoreNaming
  37842. */
  37843. WarnedWebAudioUnsupported: boolean;
  37844. /**
  37845. * Defines if the audio engine relies on a custom unlocked button.
  37846. * In this case, the embedded button will not be displayed.
  37847. */
  37848. useCustomUnlockedButton: boolean;
  37849. /**
  37850. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37851. */
  37852. readonly unlocked: boolean;
  37853. /**
  37854. * Event raised when audio has been unlocked on the browser.
  37855. */
  37856. onAudioUnlockedObservable: Observable<AudioEngine>;
  37857. /**
  37858. * Event raised when audio has been locked on the browser.
  37859. */
  37860. onAudioLockedObservable: Observable<AudioEngine>;
  37861. /**
  37862. * Flags the audio engine in Locked state.
  37863. * This happens due to new browser policies preventing audio to autoplay.
  37864. */
  37865. lock(): void;
  37866. /**
  37867. * Unlocks the audio engine once a user action has been done on the dom.
  37868. * This is helpful to resume play once browser policies have been satisfied.
  37869. */
  37870. unlock(): void;
  37871. /**
  37872. * Gets the global volume sets on the master gain.
  37873. * @returns the global volume if set or -1 otherwise
  37874. */
  37875. getGlobalVolume(): number;
  37876. /**
  37877. * Sets the global volume of your experience (sets on the master gain).
  37878. * @param newVolume Defines the new global volume of the application
  37879. */
  37880. setGlobalVolume(newVolume: number): void;
  37881. /**
  37882. * Connect the audio engine to an audio analyser allowing some amazing
  37883. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37885. * @param analyser The analyser to connect to the engine
  37886. */
  37887. connectToAnalyser(analyser: Analyser): void;
  37888. }
  37889. /**
  37890. * This represents the default audio engine used in babylon.
  37891. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37893. */
  37894. export class AudioEngine implements IAudioEngine {
  37895. private _audioContext;
  37896. private _audioContextInitialized;
  37897. private _muteButton;
  37898. private _hostElement;
  37899. /**
  37900. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37901. */
  37902. canUseWebAudio: boolean;
  37903. /**
  37904. * The master gain node defines the global audio volume of your audio engine.
  37905. */
  37906. masterGain: GainNode;
  37907. /**
  37908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37909. * @ignoreNaming
  37910. */
  37911. WarnedWebAudioUnsupported: boolean;
  37912. /**
  37913. * Gets whether or not mp3 are supported by your browser.
  37914. */
  37915. isMP3supported: boolean;
  37916. /**
  37917. * Gets whether or not ogg are supported by your browser.
  37918. */
  37919. isOGGsupported: boolean;
  37920. /**
  37921. * Gets whether audio has been unlocked on the device.
  37922. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37923. * a user interaction has happened.
  37924. */
  37925. unlocked: boolean;
  37926. /**
  37927. * Defines if the audio engine relies on a custom unlocked button.
  37928. * In this case, the embedded button will not be displayed.
  37929. */
  37930. useCustomUnlockedButton: boolean;
  37931. /**
  37932. * Event raised when audio has been unlocked on the browser.
  37933. */
  37934. onAudioUnlockedObservable: Observable<AudioEngine>;
  37935. /**
  37936. * Event raised when audio has been locked on the browser.
  37937. */
  37938. onAudioLockedObservable: Observable<AudioEngine>;
  37939. /**
  37940. * Gets the current AudioContext if available.
  37941. */
  37942. get audioContext(): Nullable<AudioContext>;
  37943. private _connectedAnalyser;
  37944. /**
  37945. * Instantiates a new audio engine.
  37946. *
  37947. * There should be only one per page as some browsers restrict the number
  37948. * of audio contexts you can create.
  37949. * @param hostElement defines the host element where to display the mute icon if necessary
  37950. */
  37951. constructor(hostElement?: Nullable<HTMLElement>);
  37952. /**
  37953. * Flags the audio engine in Locked state.
  37954. * This happens due to new browser policies preventing audio to autoplay.
  37955. */
  37956. lock(): void;
  37957. /**
  37958. * Unlocks the audio engine once a user action has been done on the dom.
  37959. * This is helpful to resume play once browser policies have been satisfied.
  37960. */
  37961. unlock(): void;
  37962. private _resumeAudioContext;
  37963. private _initializeAudioContext;
  37964. private _tryToRun;
  37965. private _triggerRunningState;
  37966. private _triggerSuspendedState;
  37967. private _displayMuteButton;
  37968. private _moveButtonToTopLeft;
  37969. private _onResize;
  37970. private _hideMuteButton;
  37971. /**
  37972. * Destroy and release the resources associated with the audio ccontext.
  37973. */
  37974. dispose(): void;
  37975. /**
  37976. * Gets the global volume sets on the master gain.
  37977. * @returns the global volume if set or -1 otherwise
  37978. */
  37979. getGlobalVolume(): number;
  37980. /**
  37981. * Sets the global volume of your experience (sets on the master gain).
  37982. * @param newVolume Defines the new global volume of the application
  37983. */
  37984. setGlobalVolume(newVolume: number): void;
  37985. /**
  37986. * Connect the audio engine to an audio analyser allowing some amazing
  37987. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37989. * @param analyser The analyser to connect to the engine
  37990. */
  37991. connectToAnalyser(analyser: Analyser): void;
  37992. }
  37993. }
  37994. declare module "babylonjs/Loading/loadingScreen" {
  37995. /**
  37996. * Interface used to present a loading screen while loading a scene
  37997. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37998. */
  37999. export interface ILoadingScreen {
  38000. /**
  38001. * Function called to display the loading screen
  38002. */
  38003. displayLoadingUI: () => void;
  38004. /**
  38005. * Function called to hide the loading screen
  38006. */
  38007. hideLoadingUI: () => void;
  38008. /**
  38009. * Gets or sets the color to use for the background
  38010. */
  38011. loadingUIBackgroundColor: string;
  38012. /**
  38013. * Gets or sets the text to display while loading
  38014. */
  38015. loadingUIText: string;
  38016. }
  38017. /**
  38018. * Class used for the default loading screen
  38019. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38020. */
  38021. export class DefaultLoadingScreen implements ILoadingScreen {
  38022. private _renderingCanvas;
  38023. private _loadingText;
  38024. private _loadingDivBackgroundColor;
  38025. private _loadingDiv;
  38026. private _loadingTextDiv;
  38027. /** Gets or sets the logo url to use for the default loading screen */
  38028. static DefaultLogoUrl: string;
  38029. /** Gets or sets the spinner url to use for the default loading screen */
  38030. static DefaultSpinnerUrl: string;
  38031. /**
  38032. * Creates a new default loading screen
  38033. * @param _renderingCanvas defines the canvas used to render the scene
  38034. * @param _loadingText defines the default text to display
  38035. * @param _loadingDivBackgroundColor defines the default background color
  38036. */
  38037. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38038. /**
  38039. * Function called to display the loading screen
  38040. */
  38041. displayLoadingUI(): void;
  38042. /**
  38043. * Function called to hide the loading screen
  38044. */
  38045. hideLoadingUI(): void;
  38046. /**
  38047. * Gets or sets the text to display while loading
  38048. */
  38049. set loadingUIText(text: string);
  38050. get loadingUIText(): string;
  38051. /**
  38052. * Gets or sets the color to use for the background
  38053. */
  38054. get loadingUIBackgroundColor(): string;
  38055. set loadingUIBackgroundColor(color: string);
  38056. private _resizeLoadingUI;
  38057. }
  38058. }
  38059. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38060. /**
  38061. * Interface for any object that can request an animation frame
  38062. */
  38063. export interface ICustomAnimationFrameRequester {
  38064. /**
  38065. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38066. */
  38067. renderFunction?: Function;
  38068. /**
  38069. * Called to request the next frame to render to
  38070. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38071. */
  38072. requestAnimationFrame: Function;
  38073. /**
  38074. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38075. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38076. */
  38077. requestID?: number;
  38078. }
  38079. }
  38080. declare module "babylonjs/Misc/performanceMonitor" {
  38081. /**
  38082. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38083. */
  38084. export class PerformanceMonitor {
  38085. private _enabled;
  38086. private _rollingFrameTime;
  38087. private _lastFrameTimeMs;
  38088. /**
  38089. * constructor
  38090. * @param frameSampleSize The number of samples required to saturate the sliding window
  38091. */
  38092. constructor(frameSampleSize?: number);
  38093. /**
  38094. * Samples current frame
  38095. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38096. */
  38097. sampleFrame(timeMs?: number): void;
  38098. /**
  38099. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38100. */
  38101. get averageFrameTime(): number;
  38102. /**
  38103. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38104. */
  38105. get averageFrameTimeVariance(): number;
  38106. /**
  38107. * Returns the frame time of the most recent frame
  38108. */
  38109. get instantaneousFrameTime(): number;
  38110. /**
  38111. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38112. */
  38113. get averageFPS(): number;
  38114. /**
  38115. * Returns the average framerate in frames per second using the most recent frame time
  38116. */
  38117. get instantaneousFPS(): number;
  38118. /**
  38119. * Returns true if enough samples have been taken to completely fill the sliding window
  38120. */
  38121. get isSaturated(): boolean;
  38122. /**
  38123. * Enables contributions to the sliding window sample set
  38124. */
  38125. enable(): void;
  38126. /**
  38127. * Disables contributions to the sliding window sample set
  38128. * Samples will not be interpolated over the disabled period
  38129. */
  38130. disable(): void;
  38131. /**
  38132. * Returns true if sampling is enabled
  38133. */
  38134. get isEnabled(): boolean;
  38135. /**
  38136. * Resets performance monitor
  38137. */
  38138. reset(): void;
  38139. }
  38140. /**
  38141. * RollingAverage
  38142. *
  38143. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38144. */
  38145. export class RollingAverage {
  38146. /**
  38147. * Current average
  38148. */
  38149. average: number;
  38150. /**
  38151. * Current variance
  38152. */
  38153. variance: number;
  38154. protected _samples: Array<number>;
  38155. protected _sampleCount: number;
  38156. protected _pos: number;
  38157. protected _m2: number;
  38158. /**
  38159. * constructor
  38160. * @param length The number of samples required to saturate the sliding window
  38161. */
  38162. constructor(length: number);
  38163. /**
  38164. * Adds a sample to the sample set
  38165. * @param v The sample value
  38166. */
  38167. add(v: number): void;
  38168. /**
  38169. * Returns previously added values or null if outside of history or outside the sliding window domain
  38170. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38171. * @return Value previously recorded with add() or null if outside of range
  38172. */
  38173. history(i: number): number;
  38174. /**
  38175. * Returns true if enough samples have been taken to completely fill the sliding window
  38176. * @return true if sample-set saturated
  38177. */
  38178. isSaturated(): boolean;
  38179. /**
  38180. * Resets the rolling average (equivalent to 0 samples taken so far)
  38181. */
  38182. reset(): void;
  38183. /**
  38184. * Wraps a value around the sample range boundaries
  38185. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38186. * @return Wrapped position in sample range
  38187. */
  38188. protected _wrapPosition(i: number): number;
  38189. }
  38190. }
  38191. declare module "babylonjs/Misc/perfCounter" {
  38192. /**
  38193. * This class is used to track a performance counter which is number based.
  38194. * The user has access to many properties which give statistics of different nature.
  38195. *
  38196. * The implementer can track two kinds of Performance Counter: time and count.
  38197. * 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.
  38198. * 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.
  38199. */
  38200. export class PerfCounter {
  38201. /**
  38202. * Gets or sets a global boolean to turn on and off all the counters
  38203. */
  38204. static Enabled: boolean;
  38205. /**
  38206. * Returns the smallest value ever
  38207. */
  38208. get min(): number;
  38209. /**
  38210. * Returns the biggest value ever
  38211. */
  38212. get max(): number;
  38213. /**
  38214. * Returns the average value since the performance counter is running
  38215. */
  38216. get average(): number;
  38217. /**
  38218. * Returns the average value of the last second the counter was monitored
  38219. */
  38220. get lastSecAverage(): number;
  38221. /**
  38222. * Returns the current value
  38223. */
  38224. get current(): number;
  38225. /**
  38226. * Gets the accumulated total
  38227. */
  38228. get total(): number;
  38229. /**
  38230. * Gets the total value count
  38231. */
  38232. get count(): number;
  38233. /**
  38234. * Creates a new counter
  38235. */
  38236. constructor();
  38237. /**
  38238. * Call this method to start monitoring a new frame.
  38239. * 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.
  38240. */
  38241. fetchNewFrame(): void;
  38242. /**
  38243. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38244. * @param newCount the count value to add to the monitored count
  38245. * @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.
  38246. */
  38247. addCount(newCount: number, fetchResult: boolean): void;
  38248. /**
  38249. * Start monitoring this performance counter
  38250. */
  38251. beginMonitoring(): void;
  38252. /**
  38253. * Compute the time lapsed since the previous beginMonitoring() call.
  38254. * @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
  38255. */
  38256. endMonitoring(newFrame?: boolean): void;
  38257. private _fetchResult;
  38258. private _startMonitoringTime;
  38259. private _min;
  38260. private _max;
  38261. private _average;
  38262. private _current;
  38263. private _totalValueCount;
  38264. private _totalAccumulated;
  38265. private _lastSecAverage;
  38266. private _lastSecAccumulated;
  38267. private _lastSecTime;
  38268. private _lastSecValueCount;
  38269. }
  38270. }
  38271. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38272. module "babylonjs/Engines/thinEngine" {
  38273. interface ThinEngine {
  38274. /**
  38275. * Sets alpha constants used by some alpha blending modes
  38276. * @param r defines the red component
  38277. * @param g defines the green component
  38278. * @param b defines the blue component
  38279. * @param a defines the alpha component
  38280. */
  38281. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38282. /**
  38283. * Sets the current alpha mode
  38284. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38285. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38286. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38287. */
  38288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38289. /**
  38290. * Gets the current alpha mode
  38291. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38292. * @returns the current alpha mode
  38293. */
  38294. getAlphaMode(): number;
  38295. /**
  38296. * Sets the current alpha equation
  38297. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38298. */
  38299. setAlphaEquation(equation: number): void;
  38300. /**
  38301. * Gets the current alpha equation.
  38302. * @returns the current alpha equation
  38303. */
  38304. getAlphaEquation(): number;
  38305. }
  38306. }
  38307. }
  38308. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38310. import { Nullable } from "babylonjs/types";
  38311. module "babylonjs/Engines/thinEngine" {
  38312. interface ThinEngine {
  38313. /** @hidden */
  38314. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38315. }
  38316. }
  38317. }
  38318. declare module "babylonjs/Engines/engine" {
  38319. import { Observable } from "babylonjs/Misc/observable";
  38320. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38321. import { Scene } from "babylonjs/scene";
  38322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38323. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38324. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38325. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38326. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38327. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38328. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38329. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38330. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38331. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38332. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38333. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38334. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38335. import "babylonjs/Engines/Extensions/engine.alpha";
  38336. import "babylonjs/Engines/Extensions/engine.readTexture";
  38337. import { Material } from "babylonjs/Materials/material";
  38338. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38339. /**
  38340. * Defines the interface used by display changed events
  38341. */
  38342. export interface IDisplayChangedEventArgs {
  38343. /** Gets the vrDisplay object (if any) */
  38344. vrDisplay: Nullable<any>;
  38345. /** Gets a boolean indicating if webVR is supported */
  38346. vrSupported: boolean;
  38347. }
  38348. /**
  38349. * Defines the interface used by objects containing a viewport (like a camera)
  38350. */
  38351. interface IViewportOwnerLike {
  38352. /**
  38353. * Gets or sets the viewport
  38354. */
  38355. viewport: IViewportLike;
  38356. }
  38357. /**
  38358. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38359. */
  38360. export class Engine extends ThinEngine {
  38361. /** Defines that alpha blending is disabled */
  38362. static readonly ALPHA_DISABLE: number;
  38363. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38364. static readonly ALPHA_ADD: number;
  38365. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38366. static readonly ALPHA_COMBINE: number;
  38367. /** Defines that alpha blending to DEST - SRC * DEST */
  38368. static readonly ALPHA_SUBTRACT: number;
  38369. /** Defines that alpha blending to SRC * DEST */
  38370. static readonly ALPHA_MULTIPLY: number;
  38371. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38372. static readonly ALPHA_MAXIMIZED: number;
  38373. /** Defines that alpha blending to SRC + DEST */
  38374. static readonly ALPHA_ONEONE: number;
  38375. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38376. static readonly ALPHA_PREMULTIPLIED: number;
  38377. /**
  38378. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38379. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38380. */
  38381. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38382. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38383. static readonly ALPHA_INTERPOLATE: number;
  38384. /**
  38385. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38386. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38387. */
  38388. static readonly ALPHA_SCREENMODE: number;
  38389. /** Defines that the ressource is not delayed*/
  38390. static readonly DELAYLOADSTATE_NONE: number;
  38391. /** Defines that the ressource was successfully delay loaded */
  38392. static readonly DELAYLOADSTATE_LOADED: number;
  38393. /** Defines that the ressource is currently delay loading */
  38394. static readonly DELAYLOADSTATE_LOADING: number;
  38395. /** Defines that the ressource is delayed and has not started loading */
  38396. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38398. static readonly NEVER: number;
  38399. /** 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 */
  38400. static readonly ALWAYS: number;
  38401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38402. static readonly LESS: number;
  38403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38404. static readonly EQUAL: number;
  38405. /** 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 */
  38406. static readonly LEQUAL: number;
  38407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38408. static readonly GREATER: number;
  38409. /** 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 */
  38410. static readonly GEQUAL: number;
  38411. /** 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 */
  38412. static readonly NOTEQUAL: number;
  38413. /** Passed to stencilOperation to specify that stencil value must be kept */
  38414. static readonly KEEP: number;
  38415. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38416. static readonly REPLACE: number;
  38417. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38418. static readonly INCR: number;
  38419. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38420. static readonly DECR: number;
  38421. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38422. static readonly INVERT: number;
  38423. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38424. static readonly INCR_WRAP: number;
  38425. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38426. static readonly DECR_WRAP: number;
  38427. /** Texture is not repeating outside of 0..1 UVs */
  38428. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38429. /** Texture is repeating outside of 0..1 UVs */
  38430. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38431. /** Texture is repeating and mirrored */
  38432. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38433. /** ALPHA */
  38434. static readonly TEXTUREFORMAT_ALPHA: number;
  38435. /** LUMINANCE */
  38436. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38437. /** LUMINANCE_ALPHA */
  38438. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38439. /** RGB */
  38440. static readonly TEXTUREFORMAT_RGB: number;
  38441. /** RGBA */
  38442. static readonly TEXTUREFORMAT_RGBA: number;
  38443. /** RED */
  38444. static readonly TEXTUREFORMAT_RED: number;
  38445. /** RED (2nd reference) */
  38446. static readonly TEXTUREFORMAT_R: number;
  38447. /** RG */
  38448. static readonly TEXTUREFORMAT_RG: number;
  38449. /** RED_INTEGER */
  38450. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38451. /** RED_INTEGER (2nd reference) */
  38452. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38453. /** RG_INTEGER */
  38454. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38455. /** RGB_INTEGER */
  38456. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38457. /** RGBA_INTEGER */
  38458. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38459. /** UNSIGNED_BYTE */
  38460. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38461. /** UNSIGNED_BYTE (2nd reference) */
  38462. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38463. /** FLOAT */
  38464. static readonly TEXTURETYPE_FLOAT: number;
  38465. /** HALF_FLOAT */
  38466. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38467. /** BYTE */
  38468. static readonly TEXTURETYPE_BYTE: number;
  38469. /** SHORT */
  38470. static readonly TEXTURETYPE_SHORT: number;
  38471. /** UNSIGNED_SHORT */
  38472. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38473. /** INT */
  38474. static readonly TEXTURETYPE_INT: number;
  38475. /** UNSIGNED_INT */
  38476. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38477. /** UNSIGNED_SHORT_4_4_4_4 */
  38478. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38479. /** UNSIGNED_SHORT_5_5_5_1 */
  38480. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38481. /** UNSIGNED_SHORT_5_6_5 */
  38482. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38483. /** UNSIGNED_INT_2_10_10_10_REV */
  38484. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38485. /** UNSIGNED_INT_24_8 */
  38486. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38487. /** UNSIGNED_INT_10F_11F_11F_REV */
  38488. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38489. /** UNSIGNED_INT_5_9_9_9_REV */
  38490. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38491. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38492. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38493. /** nearest is mag = nearest and min = nearest and mip = linear */
  38494. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38495. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38496. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38497. /** Trilinear is mag = linear and min = linear and mip = linear */
  38498. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38499. /** nearest is mag = nearest and min = nearest and mip = linear */
  38500. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38501. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38502. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38503. /** Trilinear is mag = linear and min = linear and mip = linear */
  38504. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38505. /** mag = nearest and min = nearest and mip = nearest */
  38506. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38507. /** mag = nearest and min = linear and mip = nearest */
  38508. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38509. /** mag = nearest and min = linear and mip = linear */
  38510. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38511. /** mag = nearest and min = linear and mip = none */
  38512. static readonly TEXTURE_NEAREST_LINEAR: number;
  38513. /** mag = nearest and min = nearest and mip = none */
  38514. static readonly TEXTURE_NEAREST_NEAREST: number;
  38515. /** mag = linear and min = nearest and mip = nearest */
  38516. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38517. /** mag = linear and min = nearest and mip = linear */
  38518. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38519. /** mag = linear and min = linear and mip = none */
  38520. static readonly TEXTURE_LINEAR_LINEAR: number;
  38521. /** mag = linear and min = nearest and mip = none */
  38522. static readonly TEXTURE_LINEAR_NEAREST: number;
  38523. /** Explicit coordinates mode */
  38524. static readonly TEXTURE_EXPLICIT_MODE: number;
  38525. /** Spherical coordinates mode */
  38526. static readonly TEXTURE_SPHERICAL_MODE: number;
  38527. /** Planar coordinates mode */
  38528. static readonly TEXTURE_PLANAR_MODE: number;
  38529. /** Cubic coordinates mode */
  38530. static readonly TEXTURE_CUBIC_MODE: number;
  38531. /** Projection coordinates mode */
  38532. static readonly TEXTURE_PROJECTION_MODE: number;
  38533. /** Skybox coordinates mode */
  38534. static readonly TEXTURE_SKYBOX_MODE: number;
  38535. /** Inverse Cubic coordinates mode */
  38536. static readonly TEXTURE_INVCUBIC_MODE: number;
  38537. /** Equirectangular coordinates mode */
  38538. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38539. /** Equirectangular Fixed coordinates mode */
  38540. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38541. /** Equirectangular Fixed Mirrored coordinates mode */
  38542. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38543. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38544. static readonly SCALEMODE_FLOOR: number;
  38545. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38546. static readonly SCALEMODE_NEAREST: number;
  38547. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38548. static readonly SCALEMODE_CEILING: number;
  38549. /**
  38550. * Returns the current npm package of the sdk
  38551. */
  38552. static get NpmPackage(): string;
  38553. /**
  38554. * Returns the current version of the framework
  38555. */
  38556. static get Version(): string;
  38557. /** Gets the list of created engines */
  38558. static get Instances(): Engine[];
  38559. /**
  38560. * Gets the latest created engine
  38561. */
  38562. static get LastCreatedEngine(): Nullable<Engine>;
  38563. /**
  38564. * Gets the latest created scene
  38565. */
  38566. static get LastCreatedScene(): Nullable<Scene>;
  38567. /**
  38568. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38569. * @param flag defines which part of the materials must be marked as dirty
  38570. * @param predicate defines a predicate used to filter which materials should be affected
  38571. */
  38572. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38573. /**
  38574. * Method called to create the default loading screen.
  38575. * This can be overriden in your own app.
  38576. * @param canvas The rendering canvas element
  38577. * @returns The loading screen
  38578. */
  38579. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38580. /**
  38581. * Method called to create the default rescale post process on each engine.
  38582. */
  38583. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38584. /**
  38585. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38586. **/
  38587. enableOfflineSupport: boolean;
  38588. /**
  38589. * 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)
  38590. **/
  38591. disableManifestCheck: boolean;
  38592. /**
  38593. * Gets the list of created scenes
  38594. */
  38595. scenes: Scene[];
  38596. /**
  38597. * Event raised when a new scene is created
  38598. */
  38599. onNewSceneAddedObservable: Observable<Scene>;
  38600. /**
  38601. * Gets the list of created postprocesses
  38602. */
  38603. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38604. /**
  38605. * Gets a boolean indicating if the pointer is currently locked
  38606. */
  38607. isPointerLock: boolean;
  38608. /**
  38609. * Observable event triggered each time the rendering canvas is resized
  38610. */
  38611. onResizeObservable: Observable<Engine>;
  38612. /**
  38613. * Observable event triggered each time the canvas loses focus
  38614. */
  38615. onCanvasBlurObservable: Observable<Engine>;
  38616. /**
  38617. * Observable event triggered each time the canvas gains focus
  38618. */
  38619. onCanvasFocusObservable: Observable<Engine>;
  38620. /**
  38621. * Observable event triggered each time the canvas receives pointerout event
  38622. */
  38623. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38624. /**
  38625. * Observable raised when the engine begins a new frame
  38626. */
  38627. onBeginFrameObservable: Observable<Engine>;
  38628. /**
  38629. * If set, will be used to request the next animation frame for the render loop
  38630. */
  38631. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38632. /**
  38633. * Observable raised when the engine ends the current frame
  38634. */
  38635. onEndFrameObservable: Observable<Engine>;
  38636. /**
  38637. * Observable raised when the engine is about to compile a shader
  38638. */
  38639. onBeforeShaderCompilationObservable: Observable<Engine>;
  38640. /**
  38641. * Observable raised when the engine has jsut compiled a shader
  38642. */
  38643. onAfterShaderCompilationObservable: Observable<Engine>;
  38644. /**
  38645. * Gets the audio engine
  38646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38647. * @ignorenaming
  38648. */
  38649. static audioEngine: IAudioEngine;
  38650. /**
  38651. * Default AudioEngine factory responsible of creating the Audio Engine.
  38652. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38653. */
  38654. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38655. /**
  38656. * Default offline support factory responsible of creating a tool used to store data locally.
  38657. * By default, this will create a Database object if the workload has been embedded.
  38658. */
  38659. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38660. private _loadingScreen;
  38661. private _pointerLockRequested;
  38662. private _rescalePostProcess;
  38663. private _deterministicLockstep;
  38664. private _lockstepMaxSteps;
  38665. private _timeStep;
  38666. protected get _supportsHardwareTextureRescaling(): boolean;
  38667. private _fps;
  38668. private _deltaTime;
  38669. /** @hidden */
  38670. _drawCalls: PerfCounter;
  38671. /** 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 */
  38672. canvasTabIndex: number;
  38673. /**
  38674. * Turn this value on if you want to pause FPS computation when in background
  38675. */
  38676. disablePerformanceMonitorInBackground: boolean;
  38677. private _performanceMonitor;
  38678. /**
  38679. * Gets the performance monitor attached to this engine
  38680. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38681. */
  38682. get performanceMonitor(): PerformanceMonitor;
  38683. private _onFocus;
  38684. private _onBlur;
  38685. private _onCanvasPointerOut;
  38686. private _onCanvasBlur;
  38687. private _onCanvasFocus;
  38688. private _onFullscreenChange;
  38689. private _onPointerLockChange;
  38690. /**
  38691. * Gets the HTML element used to attach event listeners
  38692. * @returns a HTML element
  38693. */
  38694. getInputElement(): Nullable<HTMLElement>;
  38695. /**
  38696. * Creates a new engine
  38697. * @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
  38698. * @param antialias defines enable antialiasing (default: false)
  38699. * @param options defines further options to be sent to the getContext() function
  38700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38701. */
  38702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38703. /**
  38704. * Gets current aspect ratio
  38705. * @param viewportOwner defines the camera to use to get the aspect ratio
  38706. * @param useScreen defines if screen size must be used (or the current render target if any)
  38707. * @returns a number defining the aspect ratio
  38708. */
  38709. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38710. /**
  38711. * Gets current screen aspect ratio
  38712. * @returns a number defining the aspect ratio
  38713. */
  38714. getScreenAspectRatio(): number;
  38715. /**
  38716. * Gets the client rect of the HTML canvas attached with the current webGL context
  38717. * @returns a client rectanglee
  38718. */
  38719. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38720. /**
  38721. * Gets the client rect of the HTML element used for events
  38722. * @returns a client rectanglee
  38723. */
  38724. getInputElementClientRect(): Nullable<ClientRect>;
  38725. /**
  38726. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38728. * @returns true if engine is in deterministic lock step mode
  38729. */
  38730. isDeterministicLockStep(): boolean;
  38731. /**
  38732. * Gets the max steps when engine is running in deterministic lock step
  38733. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38734. * @returns the max steps
  38735. */
  38736. getLockstepMaxSteps(): number;
  38737. /**
  38738. * Returns the time in ms between steps when using deterministic lock step.
  38739. * @returns time step in (ms)
  38740. */
  38741. getTimeStep(): number;
  38742. /**
  38743. * Force the mipmap generation for the given render target texture
  38744. * @param texture defines the render target texture to use
  38745. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38746. */
  38747. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38748. /** States */
  38749. /**
  38750. * Set various states to the webGL context
  38751. * @param culling defines backface culling state
  38752. * @param zOffset defines the value to apply to zOffset (0 by default)
  38753. * @param force defines if states must be applied even if cache is up to date
  38754. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38755. */
  38756. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38757. /**
  38758. * Set the z offset to apply to current rendering
  38759. * @param value defines the offset to apply
  38760. */
  38761. setZOffset(value: number): void;
  38762. /**
  38763. * Gets the current value of the zOffset
  38764. * @returns the current zOffset state
  38765. */
  38766. getZOffset(): number;
  38767. /**
  38768. * Enable or disable depth buffering
  38769. * @param enable defines the state to set
  38770. */
  38771. setDepthBuffer(enable: boolean): void;
  38772. /**
  38773. * Gets a boolean indicating if depth writing is enabled
  38774. * @returns the current depth writing state
  38775. */
  38776. getDepthWrite(): boolean;
  38777. /**
  38778. * Enable or disable depth writing
  38779. * @param enable defines the state to set
  38780. */
  38781. setDepthWrite(enable: boolean): void;
  38782. /**
  38783. * Gets a boolean indicating if stencil buffer is enabled
  38784. * @returns the current stencil buffer state
  38785. */
  38786. getStencilBuffer(): boolean;
  38787. /**
  38788. * Enable or disable the stencil buffer
  38789. * @param enable defines if the stencil buffer must be enabled or disabled
  38790. */
  38791. setStencilBuffer(enable: boolean): void;
  38792. /**
  38793. * Gets the current stencil mask
  38794. * @returns a number defining the new stencil mask to use
  38795. */
  38796. getStencilMask(): number;
  38797. /**
  38798. * Sets the current stencil mask
  38799. * @param mask defines the new stencil mask to use
  38800. */
  38801. setStencilMask(mask: number): void;
  38802. /**
  38803. * Gets the current stencil function
  38804. * @returns a number defining the stencil function to use
  38805. */
  38806. getStencilFunction(): number;
  38807. /**
  38808. * Gets the current stencil reference value
  38809. * @returns a number defining the stencil reference value to use
  38810. */
  38811. getStencilFunctionReference(): number;
  38812. /**
  38813. * Gets the current stencil mask
  38814. * @returns a number defining the stencil mask to use
  38815. */
  38816. getStencilFunctionMask(): number;
  38817. /**
  38818. * Sets the current stencil function
  38819. * @param stencilFunc defines the new stencil function to use
  38820. */
  38821. setStencilFunction(stencilFunc: number): void;
  38822. /**
  38823. * Sets the current stencil reference
  38824. * @param reference defines the new stencil reference to use
  38825. */
  38826. setStencilFunctionReference(reference: number): void;
  38827. /**
  38828. * Sets the current stencil mask
  38829. * @param mask defines the new stencil mask to use
  38830. */
  38831. setStencilFunctionMask(mask: number): void;
  38832. /**
  38833. * Gets the current stencil operation when stencil fails
  38834. * @returns a number defining stencil operation to use when stencil fails
  38835. */
  38836. getStencilOperationFail(): number;
  38837. /**
  38838. * Gets the current stencil operation when depth fails
  38839. * @returns a number defining stencil operation to use when depth fails
  38840. */
  38841. getStencilOperationDepthFail(): number;
  38842. /**
  38843. * Gets the current stencil operation when stencil passes
  38844. * @returns a number defining stencil operation to use when stencil passes
  38845. */
  38846. getStencilOperationPass(): number;
  38847. /**
  38848. * Sets the stencil operation to use when stencil fails
  38849. * @param operation defines the stencil operation to use when stencil fails
  38850. */
  38851. setStencilOperationFail(operation: number): void;
  38852. /**
  38853. * Sets the stencil operation to use when depth fails
  38854. * @param operation defines the stencil operation to use when depth fails
  38855. */
  38856. setStencilOperationDepthFail(operation: number): void;
  38857. /**
  38858. * Sets the stencil operation to use when stencil passes
  38859. * @param operation defines the stencil operation to use when stencil passes
  38860. */
  38861. setStencilOperationPass(operation: number): void;
  38862. /**
  38863. * Sets a boolean indicating if the dithering state is enabled or disabled
  38864. * @param value defines the dithering state
  38865. */
  38866. setDitheringState(value: boolean): void;
  38867. /**
  38868. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38869. * @param value defines the rasterizer state
  38870. */
  38871. setRasterizerState(value: boolean): void;
  38872. /**
  38873. * Gets the current depth function
  38874. * @returns a number defining the depth function
  38875. */
  38876. getDepthFunction(): Nullable<number>;
  38877. /**
  38878. * Sets the current depth function
  38879. * @param depthFunc defines the function to use
  38880. */
  38881. setDepthFunction(depthFunc: number): void;
  38882. /**
  38883. * Sets the current depth function to GREATER
  38884. */
  38885. setDepthFunctionToGreater(): void;
  38886. /**
  38887. * Sets the current depth function to GEQUAL
  38888. */
  38889. setDepthFunctionToGreaterOrEqual(): void;
  38890. /**
  38891. * Sets the current depth function to LESS
  38892. */
  38893. setDepthFunctionToLess(): void;
  38894. /**
  38895. * Sets the current depth function to LEQUAL
  38896. */
  38897. setDepthFunctionToLessOrEqual(): void;
  38898. private _cachedStencilBuffer;
  38899. private _cachedStencilFunction;
  38900. private _cachedStencilMask;
  38901. private _cachedStencilOperationPass;
  38902. private _cachedStencilOperationFail;
  38903. private _cachedStencilOperationDepthFail;
  38904. private _cachedStencilReference;
  38905. /**
  38906. * Caches the the state of the stencil buffer
  38907. */
  38908. cacheStencilState(): void;
  38909. /**
  38910. * Restores the state of the stencil buffer
  38911. */
  38912. restoreStencilState(): void;
  38913. /**
  38914. * Directly set the WebGL Viewport
  38915. * @param x defines the x coordinate of the viewport (in screen space)
  38916. * @param y defines the y coordinate of the viewport (in screen space)
  38917. * @param width defines the width of the viewport (in screen space)
  38918. * @param height defines the height of the viewport (in screen space)
  38919. * @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
  38920. */
  38921. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38922. /**
  38923. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38924. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38925. * @param y defines the y-coordinate of the corner of the clear rectangle
  38926. * @param width defines the width of the clear rectangle
  38927. * @param height defines the height of the clear rectangle
  38928. * @param clearColor defines the clear color
  38929. */
  38930. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38931. /**
  38932. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38933. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38934. * @param y defines the y-coordinate of the corner of the clear rectangle
  38935. * @param width defines the width of the clear rectangle
  38936. * @param height defines the height of the clear rectangle
  38937. */
  38938. enableScissor(x: number, y: number, width: number, height: number): void;
  38939. /**
  38940. * Disable previously set scissor test rectangle
  38941. */
  38942. disableScissor(): void;
  38943. protected _reportDrawCall(): void;
  38944. /**
  38945. * Initializes a webVR display and starts listening to display change events
  38946. * The onVRDisplayChangedObservable will be notified upon these changes
  38947. * @returns The onVRDisplayChangedObservable
  38948. */
  38949. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38950. /** @hidden */
  38951. _prepareVRComponent(): void;
  38952. /** @hidden */
  38953. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38954. /** @hidden */
  38955. _submitVRFrame(): void;
  38956. /**
  38957. * Call this function to leave webVR mode
  38958. * Will do nothing if webVR is not supported or if there is no webVR device
  38959. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38960. */
  38961. disableVR(): void;
  38962. /**
  38963. * Gets a boolean indicating that the system is in VR mode and is presenting
  38964. * @returns true if VR mode is engaged
  38965. */
  38966. isVRPresenting(): boolean;
  38967. /** @hidden */
  38968. _requestVRFrame(): void;
  38969. /** @hidden */
  38970. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38971. /**
  38972. * Gets the source code of the vertex shader associated with a specific webGL program
  38973. * @param program defines the program to use
  38974. * @returns a string containing the source code of the vertex shader associated with the program
  38975. */
  38976. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38977. /**
  38978. * Gets the source code of the fragment shader associated with a specific webGL program
  38979. * @param program defines the program to use
  38980. * @returns a string containing the source code of the fragment shader associated with the program
  38981. */
  38982. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38983. /**
  38984. * Sets a depth stencil texture from a render target to the according uniform.
  38985. * @param channel The texture channel
  38986. * @param uniform The uniform to set
  38987. * @param texture The render target texture containing the depth stencil texture to apply
  38988. */
  38989. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38990. /**
  38991. * Sets a texture to the webGL context from a postprocess
  38992. * @param channel defines the channel to use
  38993. * @param postProcess defines the source postprocess
  38994. */
  38995. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38996. /**
  38997. * Binds the output of the passed in post process to the texture channel specified
  38998. * @param channel The channel the texture should be bound to
  38999. * @param postProcess The post process which's output should be bound
  39000. */
  39001. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39002. protected _rebuildBuffers(): void;
  39003. /** @hidden */
  39004. _renderFrame(): void;
  39005. _renderLoop(): void;
  39006. /** @hidden */
  39007. _renderViews(): boolean;
  39008. /**
  39009. * Toggle full screen mode
  39010. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39011. */
  39012. switchFullscreen(requestPointerLock: boolean): void;
  39013. /**
  39014. * Enters full screen mode
  39015. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39016. */
  39017. enterFullscreen(requestPointerLock: boolean): void;
  39018. /**
  39019. * Exits full screen mode
  39020. */
  39021. exitFullscreen(): void;
  39022. /**
  39023. * Enters Pointerlock mode
  39024. */
  39025. enterPointerlock(): void;
  39026. /**
  39027. * Exits Pointerlock mode
  39028. */
  39029. exitPointerlock(): void;
  39030. /**
  39031. * Begin a new frame
  39032. */
  39033. beginFrame(): void;
  39034. /**
  39035. * Enf the current frame
  39036. */
  39037. endFrame(): void;
  39038. resize(): void;
  39039. /**
  39040. * Force a specific size of the canvas
  39041. * @param width defines the new canvas' width
  39042. * @param height defines the new canvas' height
  39043. * @returns true if the size was changed
  39044. */
  39045. setSize(width: number, height: number): boolean;
  39046. /**
  39047. * Updates a dynamic vertex buffer.
  39048. * @param vertexBuffer the vertex buffer to update
  39049. * @param data the data used to update the vertex buffer
  39050. * @param byteOffset the byte offset of the data
  39051. * @param byteLength the byte length of the data
  39052. */
  39053. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39054. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39055. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39056. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39057. _releaseTexture(texture: InternalTexture): void;
  39058. /**
  39059. * @hidden
  39060. * Rescales a texture
  39061. * @param source input texutre
  39062. * @param destination destination texture
  39063. * @param scene scene to use to render the resize
  39064. * @param internalFormat format to use when resizing
  39065. * @param onComplete callback to be called when resize has completed
  39066. */
  39067. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39068. /**
  39069. * Gets the current framerate
  39070. * @returns a number representing the framerate
  39071. */
  39072. getFps(): number;
  39073. /**
  39074. * Gets the time spent between current and previous frame
  39075. * @returns a number representing the delta time in ms
  39076. */
  39077. getDeltaTime(): number;
  39078. private _measureFps;
  39079. /** @hidden */
  39080. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39081. /**
  39082. * Update a dynamic index buffer
  39083. * @param indexBuffer defines the target index buffer
  39084. * @param indices defines the data to update
  39085. * @param offset defines the offset in the target index buffer where update should start
  39086. */
  39087. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39088. /**
  39089. * Updates the sample count of a render target texture
  39090. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39091. * @param texture defines the texture to update
  39092. * @param samples defines the sample count to set
  39093. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39094. */
  39095. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39096. /**
  39097. * Updates a depth texture Comparison Mode and Function.
  39098. * If the comparison Function is equal to 0, the mode will be set to none.
  39099. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39100. * @param texture The texture to set the comparison function for
  39101. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39102. */
  39103. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39104. /**
  39105. * Creates a webGL buffer to use with instanciation
  39106. * @param capacity defines the size of the buffer
  39107. * @returns the webGL buffer
  39108. */
  39109. createInstancesBuffer(capacity: number): DataBuffer;
  39110. /**
  39111. * Delete a webGL buffer used with instanciation
  39112. * @param buffer defines the webGL buffer to delete
  39113. */
  39114. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39115. private _clientWaitAsync;
  39116. /** @hidden */
  39117. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39118. dispose(): void;
  39119. private _disableTouchAction;
  39120. /**
  39121. * Display the loading screen
  39122. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39123. */
  39124. displayLoadingUI(): void;
  39125. /**
  39126. * Hide the loading screen
  39127. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39128. */
  39129. hideLoadingUI(): void;
  39130. /**
  39131. * Gets the current loading screen object
  39132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39133. */
  39134. get loadingScreen(): ILoadingScreen;
  39135. /**
  39136. * Sets the current loading screen object
  39137. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39138. */
  39139. set loadingScreen(loadingScreen: ILoadingScreen);
  39140. /**
  39141. * Sets the current loading screen text
  39142. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39143. */
  39144. set loadingUIText(text: string);
  39145. /**
  39146. * Sets the current loading screen background color
  39147. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39148. */
  39149. set loadingUIBackgroundColor(color: string);
  39150. /** Pointerlock and fullscreen */
  39151. /**
  39152. * Ask the browser to promote the current element to pointerlock mode
  39153. * @param element defines the DOM element to promote
  39154. */
  39155. static _RequestPointerlock(element: HTMLElement): void;
  39156. /**
  39157. * Asks the browser to exit pointerlock mode
  39158. */
  39159. static _ExitPointerlock(): void;
  39160. /**
  39161. * Ask the browser to promote the current element to fullscreen rendering mode
  39162. * @param element defines the DOM element to promote
  39163. */
  39164. static _RequestFullscreen(element: HTMLElement): void;
  39165. /**
  39166. * Asks the browser to exit fullscreen mode
  39167. */
  39168. static _ExitFullscreen(): void;
  39169. }
  39170. }
  39171. declare module "babylonjs/Engines/engineStore" {
  39172. import { Nullable } from "babylonjs/types";
  39173. import { Engine } from "babylonjs/Engines/engine";
  39174. import { Scene } from "babylonjs/scene";
  39175. /**
  39176. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39177. * during the life time of the application.
  39178. */
  39179. export class EngineStore {
  39180. /** Gets the list of created engines */
  39181. static Instances: import("babylonjs/Engines/engine").Engine[];
  39182. /** @hidden */
  39183. static _LastCreatedScene: Nullable<Scene>;
  39184. /**
  39185. * Gets the latest created engine
  39186. */
  39187. static get LastCreatedEngine(): Nullable<Engine>;
  39188. /**
  39189. * Gets the latest created scene
  39190. */
  39191. static get LastCreatedScene(): Nullable<Scene>;
  39192. /**
  39193. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39194. * @ignorenaming
  39195. */
  39196. static UseFallbackTexture: boolean;
  39197. /**
  39198. * Texture content used if a texture cannot loaded
  39199. * @ignorenaming
  39200. */
  39201. static FallbackTexture: string;
  39202. }
  39203. }
  39204. declare module "babylonjs/Misc/promise" {
  39205. /**
  39206. * Helper class that provides a small promise polyfill
  39207. */
  39208. export class PromisePolyfill {
  39209. /**
  39210. * Static function used to check if the polyfill is required
  39211. * If this is the case then the function will inject the polyfill to window.Promise
  39212. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39213. */
  39214. static Apply(force?: boolean): void;
  39215. }
  39216. }
  39217. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39218. /**
  39219. * Interface for screenshot methods with describe argument called `size` as object with options
  39220. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39221. */
  39222. export interface IScreenshotSize {
  39223. /**
  39224. * number in pixels for canvas height
  39225. */
  39226. height?: number;
  39227. /**
  39228. * multiplier allowing render at a higher or lower resolution
  39229. * If value is defined then height and width will be ignored and taken from camera
  39230. */
  39231. precision?: number;
  39232. /**
  39233. * number in pixels for canvas width
  39234. */
  39235. width?: number;
  39236. }
  39237. }
  39238. declare module "babylonjs/Misc/tools" {
  39239. import { Nullable, float } from "babylonjs/types";
  39240. import { DomManagement } from "babylonjs/Misc/domManagement";
  39241. import { WebRequest } from "babylonjs/Misc/webRequest";
  39242. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39243. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39244. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39245. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39246. import { Camera } from "babylonjs/Cameras/camera";
  39247. import { Engine } from "babylonjs/Engines/engine";
  39248. interface IColor4Like {
  39249. r: float;
  39250. g: float;
  39251. b: float;
  39252. a: float;
  39253. }
  39254. /**
  39255. * Class containing a set of static utilities functions
  39256. */
  39257. export class Tools {
  39258. /**
  39259. * Gets or sets the base URL to use to load assets
  39260. */
  39261. static get BaseUrl(): string;
  39262. static set BaseUrl(value: string);
  39263. /**
  39264. * Enable/Disable Custom HTTP Request Headers globally.
  39265. * default = false
  39266. * @see CustomRequestHeaders
  39267. */
  39268. static UseCustomRequestHeaders: boolean;
  39269. /**
  39270. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39271. * i.e. when loading files, where the server/service expects an Authorization header
  39272. */
  39273. static CustomRequestHeaders: {
  39274. [key: string]: string;
  39275. };
  39276. /**
  39277. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39278. */
  39279. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39280. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39281. /**
  39282. * Default behaviour for cors in the application.
  39283. * It can be a string if the expected behavior is identical in the entire app.
  39284. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39285. */
  39286. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39287. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39288. /**
  39289. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39290. * @ignorenaming
  39291. */
  39292. static get UseFallbackTexture(): boolean;
  39293. static set UseFallbackTexture(value: boolean);
  39294. /**
  39295. * Use this object to register external classes like custom textures or material
  39296. * to allow the laoders to instantiate them
  39297. */
  39298. static get RegisteredExternalClasses(): {
  39299. [key: string]: Object;
  39300. };
  39301. static set RegisteredExternalClasses(classes: {
  39302. [key: string]: Object;
  39303. });
  39304. /**
  39305. * Texture content used if a texture cannot loaded
  39306. * @ignorenaming
  39307. */
  39308. static get fallbackTexture(): string;
  39309. static set fallbackTexture(value: string);
  39310. /**
  39311. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39312. * @param u defines the coordinate on X axis
  39313. * @param v defines the coordinate on Y axis
  39314. * @param width defines the width of the source data
  39315. * @param height defines the height of the source data
  39316. * @param pixels defines the source byte array
  39317. * @param color defines the output color
  39318. */
  39319. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39320. /**
  39321. * Interpolates between a and b via alpha
  39322. * @param a The lower value (returned when alpha = 0)
  39323. * @param b The upper value (returned when alpha = 1)
  39324. * @param alpha The interpolation-factor
  39325. * @return The mixed value
  39326. */
  39327. static Mix(a: number, b: number, alpha: number): number;
  39328. /**
  39329. * Tries to instantiate a new object from a given class name
  39330. * @param className defines the class name to instantiate
  39331. * @returns the new object or null if the system was not able to do the instantiation
  39332. */
  39333. static Instantiate(className: string): any;
  39334. /**
  39335. * Provides a slice function that will work even on IE
  39336. * @param data defines the array to slice
  39337. * @param start defines the start of the data (optional)
  39338. * @param end defines the end of the data (optional)
  39339. * @returns the new sliced array
  39340. */
  39341. static Slice<T>(data: T, start?: number, end?: number): T;
  39342. /**
  39343. * Polyfill for setImmediate
  39344. * @param action defines the action to execute after the current execution block
  39345. */
  39346. static SetImmediate(action: () => void): void;
  39347. /**
  39348. * Function indicating if a number is an exponent of 2
  39349. * @param value defines the value to test
  39350. * @returns true if the value is an exponent of 2
  39351. */
  39352. static IsExponentOfTwo(value: number): boolean;
  39353. private static _tmpFloatArray;
  39354. /**
  39355. * Returns the nearest 32-bit single precision float representation of a Number
  39356. * @param value A Number. If the parameter is of a different type, it will get converted
  39357. * to a number or to NaN if it cannot be converted
  39358. * @returns number
  39359. */
  39360. static FloatRound(value: number): number;
  39361. /**
  39362. * Extracts the filename from a path
  39363. * @param path defines the path to use
  39364. * @returns the filename
  39365. */
  39366. static GetFilename(path: string): string;
  39367. /**
  39368. * Extracts the "folder" part of a path (everything before the filename).
  39369. * @param uri The URI to extract the info from
  39370. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39371. * @returns The "folder" part of the path
  39372. */
  39373. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39374. /**
  39375. * Extracts text content from a DOM element hierarchy
  39376. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39377. */
  39378. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39379. /**
  39380. * Convert an angle in radians to degrees
  39381. * @param angle defines the angle to convert
  39382. * @returns the angle in degrees
  39383. */
  39384. static ToDegrees(angle: number): number;
  39385. /**
  39386. * Convert an angle in degrees to radians
  39387. * @param angle defines the angle to convert
  39388. * @returns the angle in radians
  39389. */
  39390. static ToRadians(angle: number): number;
  39391. /**
  39392. * Returns an array if obj is not an array
  39393. * @param obj defines the object to evaluate as an array
  39394. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39395. * @returns either obj directly if obj is an array or a new array containing obj
  39396. */
  39397. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39398. /**
  39399. * Gets the pointer prefix to use
  39400. * @param engine defines the engine we are finding the prefix for
  39401. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39402. */
  39403. static GetPointerPrefix(engine: Engine): string;
  39404. /**
  39405. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39406. * @param url define the url we are trying
  39407. * @param element define the dom element where to configure the cors policy
  39408. */
  39409. static SetCorsBehavior(url: string | string[], element: {
  39410. crossOrigin: string | null;
  39411. }): void;
  39412. /**
  39413. * Removes unwanted characters from an url
  39414. * @param url defines the url to clean
  39415. * @returns the cleaned url
  39416. */
  39417. static CleanUrl(url: string): string;
  39418. /**
  39419. * Gets or sets a function used to pre-process url before using them to load assets
  39420. */
  39421. static get PreprocessUrl(): (url: string) => string;
  39422. static set PreprocessUrl(processor: (url: string) => string);
  39423. /**
  39424. * Loads an image as an HTMLImageElement.
  39425. * @param input url string, ArrayBuffer, or Blob to load
  39426. * @param onLoad callback called when the image successfully loads
  39427. * @param onError callback called when the image fails to load
  39428. * @param offlineProvider offline provider for caching
  39429. * @param mimeType optional mime type
  39430. * @returns the HTMLImageElement of the loaded image
  39431. */
  39432. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39433. /**
  39434. * Loads a file from a url
  39435. * @param url url string, ArrayBuffer, or Blob to load
  39436. * @param onSuccess callback called when the file successfully loads
  39437. * @param onProgress callback called while file is loading (if the server supports this mode)
  39438. * @param offlineProvider defines the offline provider for caching
  39439. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39440. * @param onError callback called when the file fails to load
  39441. * @returns a file request object
  39442. */
  39443. 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;
  39444. /**
  39445. * Loads a file from a url
  39446. * @param url the file url to load
  39447. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39448. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39449. */
  39450. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39451. /**
  39452. * Load a script (identified by an url). When the url returns, the
  39453. * content of this file is added into a new script element, attached to the DOM (body element)
  39454. * @param scriptUrl defines the url of the script to laod
  39455. * @param onSuccess defines the callback called when the script is loaded
  39456. * @param onError defines the callback to call if an error occurs
  39457. * @param scriptId defines the id of the script element
  39458. */
  39459. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39460. /**
  39461. * Load an asynchronous script (identified by an url). When the url returns, the
  39462. * content of this file is added into a new script element, attached to the DOM (body element)
  39463. * @param scriptUrl defines the url of the script to laod
  39464. * @param scriptId defines the id of the script element
  39465. * @returns a promise request object
  39466. */
  39467. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39468. /**
  39469. * Loads a file from a blob
  39470. * @param fileToLoad defines the blob to use
  39471. * @param callback defines the callback to call when data is loaded
  39472. * @param progressCallback defines the callback to call during loading process
  39473. * @returns a file request object
  39474. */
  39475. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39476. /**
  39477. * Reads a file from a File object
  39478. * @param file defines the file to load
  39479. * @param onSuccess defines the callback to call when data is loaded
  39480. * @param onProgress defines the callback to call during loading process
  39481. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39482. * @param onError defines the callback to call when an error occurs
  39483. * @returns a file request object
  39484. */
  39485. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39486. /**
  39487. * Creates a data url from a given string content
  39488. * @param content defines the content to convert
  39489. * @returns the new data url link
  39490. */
  39491. static FileAsURL(content: string): string;
  39492. /**
  39493. * Format the given number to a specific decimal format
  39494. * @param value defines the number to format
  39495. * @param decimals defines the number of decimals to use
  39496. * @returns the formatted string
  39497. */
  39498. static Format(value: number, decimals?: number): string;
  39499. /**
  39500. * Tries to copy an object by duplicating every property
  39501. * @param source defines the source object
  39502. * @param destination defines the target object
  39503. * @param doNotCopyList defines a list of properties to avoid
  39504. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39505. */
  39506. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39507. /**
  39508. * Gets a boolean indicating if the given object has no own property
  39509. * @param obj defines the object to test
  39510. * @returns true if object has no own property
  39511. */
  39512. static IsEmpty(obj: any): boolean;
  39513. /**
  39514. * Function used to register events at window level
  39515. * @param windowElement defines the Window object to use
  39516. * @param events defines the events to register
  39517. */
  39518. static RegisterTopRootEvents(windowElement: Window, events: {
  39519. name: string;
  39520. handler: Nullable<(e: FocusEvent) => any>;
  39521. }[]): void;
  39522. /**
  39523. * Function used to unregister events from window level
  39524. * @param windowElement defines the Window object to use
  39525. * @param events defines the events to unregister
  39526. */
  39527. static UnregisterTopRootEvents(windowElement: Window, events: {
  39528. name: string;
  39529. handler: Nullable<(e: FocusEvent) => any>;
  39530. }[]): void;
  39531. /**
  39532. * @ignore
  39533. */
  39534. static _ScreenshotCanvas: HTMLCanvasElement;
  39535. /**
  39536. * Dumps the current bound framebuffer
  39537. * @param width defines the rendering width
  39538. * @param height defines the rendering height
  39539. * @param engine defines the hosting engine
  39540. * @param successCallback defines the callback triggered once the data are available
  39541. * @param mimeType defines the mime type of the result
  39542. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39543. */
  39544. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39545. /**
  39546. * Converts the canvas data to blob.
  39547. * This acts as a polyfill for browsers not supporting the to blob function.
  39548. * @param canvas Defines the canvas to extract the data from
  39549. * @param successCallback Defines the callback triggered once the data are available
  39550. * @param mimeType Defines the mime type of the result
  39551. */
  39552. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39553. /**
  39554. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39555. * @param successCallback defines the callback triggered once the data are available
  39556. * @param mimeType defines the mime type of the result
  39557. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39558. */
  39559. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39560. /**
  39561. * Downloads a blob in the browser
  39562. * @param blob defines the blob to download
  39563. * @param fileName defines the name of the downloaded file
  39564. */
  39565. static Download(blob: Blob, fileName: string): void;
  39566. /**
  39567. * Captures a screenshot of the current rendering
  39568. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39569. * @param engine defines the rendering engine
  39570. * @param camera defines the source camera
  39571. * @param size This parameter can be set to a single number or to an object with the
  39572. * following (optional) properties: precision, width, height. If a single number is passed,
  39573. * it will be used for both width and height. If an object is passed, the screenshot size
  39574. * will be derived from the parameters. The precision property is a multiplier allowing
  39575. * rendering at a higher or lower resolution
  39576. * @param successCallback defines the callback receives a single parameter which contains the
  39577. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39578. * src parameter of an <img> to display it
  39579. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39580. * Check your browser for supported MIME types
  39581. */
  39582. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39583. /**
  39584. * Captures a screenshot of the current rendering
  39585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39586. * @param engine defines the rendering engine
  39587. * @param camera defines the source camera
  39588. * @param size This parameter can be set to a single number or to an object with the
  39589. * following (optional) properties: precision, width, height. If a single number is passed,
  39590. * it will be used for both width and height. If an object is passed, the screenshot size
  39591. * will be derived from the parameters. The precision property is a multiplier allowing
  39592. * rendering at a higher or lower resolution
  39593. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39594. * Check your browser for supported MIME types
  39595. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39596. * to the src parameter of an <img> to display it
  39597. */
  39598. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39599. /**
  39600. * Generates an image screenshot from the specified camera.
  39601. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39602. * @param engine The engine to use for rendering
  39603. * @param camera The camera to use for rendering
  39604. * @param size This parameter can be set to a single number or to an object with the
  39605. * following (optional) properties: precision, width, height. If a single number is passed,
  39606. * it will be used for both width and height. If an object is passed, the screenshot size
  39607. * will be derived from the parameters. The precision property is a multiplier allowing
  39608. * rendering at a higher or lower resolution
  39609. * @param successCallback The callback receives a single parameter which contains the
  39610. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39611. * src parameter of an <img> to display it
  39612. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39613. * Check your browser for supported MIME types
  39614. * @param samples Texture samples (default: 1)
  39615. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39616. * @param fileName A name for for the downloaded file.
  39617. */
  39618. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39619. /**
  39620. * Generates an image screenshot from the specified camera.
  39621. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39622. * @param engine The engine to use for rendering
  39623. * @param camera The camera to use for rendering
  39624. * @param size This parameter can be set to a single number or to an object with the
  39625. * following (optional) properties: precision, width, height. If a single number is passed,
  39626. * it will be used for both width and height. If an object is passed, the screenshot size
  39627. * will be derived from the parameters. The precision property is a multiplier allowing
  39628. * rendering at a higher or lower resolution
  39629. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39630. * Check your browser for supported MIME types
  39631. * @param samples Texture samples (default: 1)
  39632. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39633. * @param fileName A name for for the downloaded file.
  39634. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39635. * to the src parameter of an <img> to display it
  39636. */
  39637. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39638. /**
  39639. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39640. * Be aware Math.random() could cause collisions, but:
  39641. * "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"
  39642. * @returns a pseudo random id
  39643. */
  39644. static RandomId(): string;
  39645. /**
  39646. * Test if the given uri is a base64 string
  39647. * @param uri The uri to test
  39648. * @return True if the uri is a base64 string or false otherwise
  39649. */
  39650. static IsBase64(uri: string): boolean;
  39651. /**
  39652. * Decode the given base64 uri.
  39653. * @param uri The uri to decode
  39654. * @return The decoded base64 data.
  39655. */
  39656. static DecodeBase64(uri: string): ArrayBuffer;
  39657. /**
  39658. * Gets the absolute url.
  39659. * @param url the input url
  39660. * @return the absolute url
  39661. */
  39662. static GetAbsoluteUrl(url: string): string;
  39663. /**
  39664. * No log
  39665. */
  39666. static readonly NoneLogLevel: number;
  39667. /**
  39668. * Only message logs
  39669. */
  39670. static readonly MessageLogLevel: number;
  39671. /**
  39672. * Only warning logs
  39673. */
  39674. static readonly WarningLogLevel: number;
  39675. /**
  39676. * Only error logs
  39677. */
  39678. static readonly ErrorLogLevel: number;
  39679. /**
  39680. * All logs
  39681. */
  39682. static readonly AllLogLevel: number;
  39683. /**
  39684. * Gets a value indicating the number of loading errors
  39685. * @ignorenaming
  39686. */
  39687. static get errorsCount(): number;
  39688. /**
  39689. * Callback called when a new log is added
  39690. */
  39691. static OnNewCacheEntry: (entry: string) => void;
  39692. /**
  39693. * Log a message to the console
  39694. * @param message defines the message to log
  39695. */
  39696. static Log(message: string): void;
  39697. /**
  39698. * Write a warning message to the console
  39699. * @param message defines the message to log
  39700. */
  39701. static Warn(message: string): void;
  39702. /**
  39703. * Write an error message to the console
  39704. * @param message defines the message to log
  39705. */
  39706. static Error(message: string): void;
  39707. /**
  39708. * Gets current log cache (list of logs)
  39709. */
  39710. static get LogCache(): string;
  39711. /**
  39712. * Clears the log cache
  39713. */
  39714. static ClearLogCache(): void;
  39715. /**
  39716. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39717. */
  39718. static set LogLevels(level: number);
  39719. /**
  39720. * Checks if the window object exists
  39721. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39722. */
  39723. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39724. /**
  39725. * No performance log
  39726. */
  39727. static readonly PerformanceNoneLogLevel: number;
  39728. /**
  39729. * Use user marks to log performance
  39730. */
  39731. static readonly PerformanceUserMarkLogLevel: number;
  39732. /**
  39733. * Log performance to the console
  39734. */
  39735. static readonly PerformanceConsoleLogLevel: number;
  39736. private static _performance;
  39737. /**
  39738. * Sets the current performance log level
  39739. */
  39740. static set PerformanceLogLevel(level: number);
  39741. private static _StartPerformanceCounterDisabled;
  39742. private static _EndPerformanceCounterDisabled;
  39743. private static _StartUserMark;
  39744. private static _EndUserMark;
  39745. private static _StartPerformanceConsole;
  39746. private static _EndPerformanceConsole;
  39747. /**
  39748. * Starts a performance counter
  39749. */
  39750. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39751. /**
  39752. * Ends a specific performance coutner
  39753. */
  39754. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39755. /**
  39756. * Gets either window.performance.now() if supported or Date.now() else
  39757. */
  39758. static get Now(): number;
  39759. /**
  39760. * This method will return the name of the class used to create the instance of the given object.
  39761. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39762. * @param object the object to get the class name from
  39763. * @param isType defines if the object is actually a type
  39764. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39765. */
  39766. static GetClassName(object: any, isType?: boolean): string;
  39767. /**
  39768. * Gets the first element of an array satisfying a given predicate
  39769. * @param array defines the array to browse
  39770. * @param predicate defines the predicate to use
  39771. * @returns null if not found or the element
  39772. */
  39773. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39774. /**
  39775. * This method will return the name of the full name of the class, including its owning module (if any).
  39776. * 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).
  39777. * @param object the object to get the class name from
  39778. * @param isType defines if the object is actually a type
  39779. * @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.
  39780. * @ignorenaming
  39781. */
  39782. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39783. /**
  39784. * Returns a promise that resolves after the given amount of time.
  39785. * @param delay Number of milliseconds to delay
  39786. * @returns Promise that resolves after the given amount of time
  39787. */
  39788. static DelayAsync(delay: number): Promise<void>;
  39789. /**
  39790. * Utility function to detect if the current user agent is Safari
  39791. * @returns whether or not the current user agent is safari
  39792. */
  39793. static IsSafari(): boolean;
  39794. }
  39795. /**
  39796. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39797. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39798. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39799. * @param name The name of the class, case should be preserved
  39800. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39801. */
  39802. export function className(name: string, module?: string): (target: Object) => void;
  39803. /**
  39804. * An implementation of a loop for asynchronous functions.
  39805. */
  39806. export class AsyncLoop {
  39807. /**
  39808. * Defines the number of iterations for the loop
  39809. */
  39810. iterations: number;
  39811. /**
  39812. * Defines the current index of the loop.
  39813. */
  39814. index: number;
  39815. private _done;
  39816. private _fn;
  39817. private _successCallback;
  39818. /**
  39819. * Constructor.
  39820. * @param iterations the number of iterations.
  39821. * @param func the function to run each iteration
  39822. * @param successCallback the callback that will be called upon succesful execution
  39823. * @param offset starting offset.
  39824. */
  39825. constructor(
  39826. /**
  39827. * Defines the number of iterations for the loop
  39828. */
  39829. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39830. /**
  39831. * Execute the next iteration. Must be called after the last iteration was finished.
  39832. */
  39833. executeNext(): void;
  39834. /**
  39835. * Break the loop and run the success callback.
  39836. */
  39837. breakLoop(): void;
  39838. /**
  39839. * Create and run an async loop.
  39840. * @param iterations the number of iterations.
  39841. * @param fn the function to run each iteration
  39842. * @param successCallback the callback that will be called upon succesful execution
  39843. * @param offset starting offset.
  39844. * @returns the created async loop object
  39845. */
  39846. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39847. /**
  39848. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39849. * @param iterations total number of iterations
  39850. * @param syncedIterations number of synchronous iterations in each async iteration.
  39851. * @param fn the function to call each iteration.
  39852. * @param callback a success call back that will be called when iterating stops.
  39853. * @param breakFunction a break condition (optional)
  39854. * @param timeout timeout settings for the setTimeout function. default - 0.
  39855. * @returns the created async loop object
  39856. */
  39857. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39858. }
  39859. }
  39860. declare module "babylonjs/Misc/stringDictionary" {
  39861. import { Nullable } from "babylonjs/types";
  39862. /**
  39863. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39864. * The underlying implementation relies on an associative array to ensure the best performances.
  39865. * The value can be anything including 'null' but except 'undefined'
  39866. */
  39867. export class StringDictionary<T> {
  39868. /**
  39869. * This will clear this dictionary and copy the content from the 'source' one.
  39870. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39871. * @param source the dictionary to take the content from and copy to this dictionary
  39872. */
  39873. copyFrom(source: StringDictionary<T>): void;
  39874. /**
  39875. * Get a value based from its key
  39876. * @param key the given key to get the matching value from
  39877. * @return the value if found, otherwise undefined is returned
  39878. */
  39879. get(key: string): T | undefined;
  39880. /**
  39881. * Get a value from its key or add it if it doesn't exist.
  39882. * This method will ensure you that a given key/data will be present in the dictionary.
  39883. * @param key the given key to get the matching value from
  39884. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39885. * The factory will only be invoked if there's no data for the given key.
  39886. * @return the value corresponding to the key.
  39887. */
  39888. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39889. /**
  39890. * Get a value from its key if present in the dictionary otherwise add it
  39891. * @param key the key to get the value from
  39892. * @param val if there's no such key/value pair in the dictionary add it with this value
  39893. * @return the value corresponding to the key
  39894. */
  39895. getOrAdd(key: string, val: T): T;
  39896. /**
  39897. * Check if there's a given key in the dictionary
  39898. * @param key the key to check for
  39899. * @return true if the key is present, false otherwise
  39900. */
  39901. contains(key: string): boolean;
  39902. /**
  39903. * Add a new key and its corresponding value
  39904. * @param key the key to add
  39905. * @param value the value corresponding to the key
  39906. * @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
  39907. */
  39908. add(key: string, value: T): boolean;
  39909. /**
  39910. * Update a specific value associated to a key
  39911. * @param key defines the key to use
  39912. * @param value defines the value to store
  39913. * @returns true if the value was updated (or false if the key was not found)
  39914. */
  39915. set(key: string, value: T): boolean;
  39916. /**
  39917. * Get the element of the given key and remove it from the dictionary
  39918. * @param key defines the key to search
  39919. * @returns the value associated with the key or null if not found
  39920. */
  39921. getAndRemove(key: string): Nullable<T>;
  39922. /**
  39923. * Remove a key/value from the dictionary.
  39924. * @param key the key to remove
  39925. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39926. */
  39927. remove(key: string): boolean;
  39928. /**
  39929. * Clear the whole content of the dictionary
  39930. */
  39931. clear(): void;
  39932. /**
  39933. * Gets the current count
  39934. */
  39935. get count(): number;
  39936. /**
  39937. * Execute a callback on each key/val of the dictionary.
  39938. * Note that you can remove any element in this dictionary in the callback implementation
  39939. * @param callback the callback to execute on a given key/value pair
  39940. */
  39941. forEach(callback: (key: string, val: T) => void): void;
  39942. /**
  39943. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39944. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39945. * Note that you can remove any element in this dictionary in the callback implementation
  39946. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39947. * @returns the first item
  39948. */
  39949. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39950. private _count;
  39951. private _data;
  39952. }
  39953. }
  39954. declare module "babylonjs/Collisions/collisionCoordinator" {
  39955. import { Nullable } from "babylonjs/types";
  39956. import { Scene } from "babylonjs/scene";
  39957. import { Vector3 } from "babylonjs/Maths/math.vector";
  39958. import { Collider } from "babylonjs/Collisions/collider";
  39959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39960. /** @hidden */
  39961. export interface ICollisionCoordinator {
  39962. createCollider(): Collider;
  39963. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39964. init(scene: Scene): void;
  39965. }
  39966. /** @hidden */
  39967. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39968. private _scene;
  39969. private _scaledPosition;
  39970. private _scaledVelocity;
  39971. private _finalPosition;
  39972. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39973. createCollider(): Collider;
  39974. init(scene: Scene): void;
  39975. private _collideWithWorld;
  39976. }
  39977. }
  39978. declare module "babylonjs/Inputs/scene.inputManager" {
  39979. import { Nullable } from "babylonjs/types";
  39980. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39981. import { Vector2 } from "babylonjs/Maths/math.vector";
  39982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39983. import { Scene } from "babylonjs/scene";
  39984. /**
  39985. * Class used to manage all inputs for the scene.
  39986. */
  39987. export class InputManager {
  39988. /** The distance in pixel that you have to move to prevent some events */
  39989. static DragMovementThreshold: number;
  39990. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39991. static LongPressDelay: number;
  39992. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39993. static DoubleClickDelay: number;
  39994. /** If you need to check double click without raising a single click at first click, enable this flag */
  39995. static ExclusiveDoubleClickMode: boolean;
  39996. private _wheelEventName;
  39997. private _onPointerMove;
  39998. private _onPointerDown;
  39999. private _onPointerUp;
  40000. private _initClickEvent;
  40001. private _initActionManager;
  40002. private _delayedSimpleClick;
  40003. private _delayedSimpleClickTimeout;
  40004. private _previousDelayedSimpleClickTimeout;
  40005. private _meshPickProceed;
  40006. private _previousButtonPressed;
  40007. private _currentPickResult;
  40008. private _previousPickResult;
  40009. private _totalPointersPressed;
  40010. private _doubleClickOccured;
  40011. private _pointerOverMesh;
  40012. private _pickedDownMesh;
  40013. private _pickedUpMesh;
  40014. private _pointerX;
  40015. private _pointerY;
  40016. private _unTranslatedPointerX;
  40017. private _unTranslatedPointerY;
  40018. private _startingPointerPosition;
  40019. private _previousStartingPointerPosition;
  40020. private _startingPointerTime;
  40021. private _previousStartingPointerTime;
  40022. private _pointerCaptures;
  40023. private _onKeyDown;
  40024. private _onKeyUp;
  40025. private _onCanvasFocusObserver;
  40026. private _onCanvasBlurObserver;
  40027. private _scene;
  40028. /**
  40029. * Creates a new InputManager
  40030. * @param scene defines the hosting scene
  40031. */
  40032. constructor(scene: Scene);
  40033. /**
  40034. * Gets the mesh that is currently under the pointer
  40035. */
  40036. get meshUnderPointer(): Nullable<AbstractMesh>;
  40037. /**
  40038. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40039. */
  40040. get unTranslatedPointer(): Vector2;
  40041. /**
  40042. * Gets or sets the current on-screen X position of the pointer
  40043. */
  40044. get pointerX(): number;
  40045. set pointerX(value: number);
  40046. /**
  40047. * Gets or sets the current on-screen Y position of the pointer
  40048. */
  40049. get pointerY(): number;
  40050. set pointerY(value: number);
  40051. private _updatePointerPosition;
  40052. private _processPointerMove;
  40053. private _setRayOnPointerInfo;
  40054. private _checkPrePointerObservable;
  40055. /**
  40056. * Use this method to simulate a pointer move on a mesh
  40057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40060. */
  40061. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40062. /**
  40063. * Use this method to simulate a pointer down on a mesh
  40064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40067. */
  40068. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40069. private _processPointerDown;
  40070. /** @hidden */
  40071. _isPointerSwiping(): boolean;
  40072. /**
  40073. * Use this method to simulate a pointer up on a mesh
  40074. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40075. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40076. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40077. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40078. */
  40079. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40080. private _processPointerUp;
  40081. /**
  40082. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40083. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40084. * @returns true if the pointer was captured
  40085. */
  40086. isPointerCaptured(pointerId?: number): boolean;
  40087. /**
  40088. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40089. * @param attachUp defines if you want to attach events to pointerup
  40090. * @param attachDown defines if you want to attach events to pointerdown
  40091. * @param attachMove defines if you want to attach events to pointermove
  40092. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40093. */
  40094. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40095. /**
  40096. * Detaches all event handlers
  40097. */
  40098. detachControl(): void;
  40099. /**
  40100. * Force the value of meshUnderPointer
  40101. * @param mesh defines the mesh to use
  40102. */
  40103. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40104. /**
  40105. * Gets the mesh under the pointer
  40106. * @returns a Mesh or null if no mesh is under the pointer
  40107. */
  40108. getPointerOverMesh(): Nullable<AbstractMesh>;
  40109. }
  40110. }
  40111. declare module "babylonjs/Animations/animationGroup" {
  40112. import { Animatable } from "babylonjs/Animations/animatable";
  40113. import { Animation } from "babylonjs/Animations/animation";
  40114. import { Scene, IDisposable } from "babylonjs/scene";
  40115. import { Observable } from "babylonjs/Misc/observable";
  40116. import { Nullable } from "babylonjs/types";
  40117. import "babylonjs/Animations/animatable";
  40118. /**
  40119. * This class defines the direct association between an animation and a target
  40120. */
  40121. export class TargetedAnimation {
  40122. /**
  40123. * Animation to perform
  40124. */
  40125. animation: Animation;
  40126. /**
  40127. * Target to animate
  40128. */
  40129. target: any;
  40130. /**
  40131. * Returns the string "TargetedAnimation"
  40132. * @returns "TargetedAnimation"
  40133. */
  40134. getClassName(): string;
  40135. /**
  40136. * Serialize the object
  40137. * @returns the JSON object representing the current entity
  40138. */
  40139. serialize(): any;
  40140. }
  40141. /**
  40142. * Use this class to create coordinated animations on multiple targets
  40143. */
  40144. export class AnimationGroup implements IDisposable {
  40145. /** The name of the animation group */
  40146. name: string;
  40147. private _scene;
  40148. private _targetedAnimations;
  40149. private _animatables;
  40150. private _from;
  40151. private _to;
  40152. private _isStarted;
  40153. private _isPaused;
  40154. private _speedRatio;
  40155. private _loopAnimation;
  40156. private _isAdditive;
  40157. /**
  40158. * Gets or sets the unique id of the node
  40159. */
  40160. uniqueId: number;
  40161. /**
  40162. * This observable will notify when one animation have ended
  40163. */
  40164. onAnimationEndObservable: Observable<TargetedAnimation>;
  40165. /**
  40166. * Observer raised when one animation loops
  40167. */
  40168. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40169. /**
  40170. * Observer raised when all animations have looped
  40171. */
  40172. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40173. /**
  40174. * This observable will notify when all animations have ended.
  40175. */
  40176. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40177. /**
  40178. * This observable will notify when all animations have paused.
  40179. */
  40180. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40181. /**
  40182. * This observable will notify when all animations are playing.
  40183. */
  40184. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40185. /**
  40186. * Gets the first frame
  40187. */
  40188. get from(): number;
  40189. /**
  40190. * Gets the last frame
  40191. */
  40192. get to(): number;
  40193. /**
  40194. * Define if the animations are started
  40195. */
  40196. get isStarted(): boolean;
  40197. /**
  40198. * Gets a value indicating that the current group is playing
  40199. */
  40200. get isPlaying(): boolean;
  40201. /**
  40202. * Gets or sets the speed ratio to use for all animations
  40203. */
  40204. get speedRatio(): number;
  40205. /**
  40206. * Gets or sets the speed ratio to use for all animations
  40207. */
  40208. set speedRatio(value: number);
  40209. /**
  40210. * Gets or sets if all animations should loop or not
  40211. */
  40212. get loopAnimation(): boolean;
  40213. set loopAnimation(value: boolean);
  40214. /**
  40215. * Gets or sets if all animations should be evaluated additively
  40216. */
  40217. get isAdditive(): boolean;
  40218. set isAdditive(value: boolean);
  40219. /**
  40220. * Gets the targeted animations for this animation group
  40221. */
  40222. get targetedAnimations(): Array<TargetedAnimation>;
  40223. /**
  40224. * returning the list of animatables controlled by this animation group.
  40225. */
  40226. get animatables(): Array<Animatable>;
  40227. /**
  40228. * Gets the list of target animations
  40229. */
  40230. get children(): TargetedAnimation[];
  40231. /**
  40232. * Instantiates a new Animation Group.
  40233. * This helps managing several animations at once.
  40234. * @see https://doc.babylonjs.com/how_to/group
  40235. * @param name Defines the name of the group
  40236. * @param scene Defines the scene the group belongs to
  40237. */
  40238. constructor(
  40239. /** The name of the animation group */
  40240. name: string, scene?: Nullable<Scene>);
  40241. /**
  40242. * Add an animation (with its target) in the group
  40243. * @param animation defines the animation we want to add
  40244. * @param target defines the target of the animation
  40245. * @returns the TargetedAnimation object
  40246. */
  40247. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40248. /**
  40249. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40250. * It can add constant keys at begin or end
  40251. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40252. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40253. * @returns the animation group
  40254. */
  40255. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40256. private _animationLoopCount;
  40257. private _animationLoopFlags;
  40258. private _processLoop;
  40259. /**
  40260. * Start all animations on given targets
  40261. * @param loop defines if animations must loop
  40262. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40263. * @param from defines the from key (optional)
  40264. * @param to defines the to key (optional)
  40265. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40266. * @returns the current animation group
  40267. */
  40268. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40269. /**
  40270. * Pause all animations
  40271. * @returns the animation group
  40272. */
  40273. pause(): AnimationGroup;
  40274. /**
  40275. * Play all animations to initial state
  40276. * This function will start() the animations if they were not started or will restart() them if they were paused
  40277. * @param loop defines if animations must loop
  40278. * @returns the animation group
  40279. */
  40280. play(loop?: boolean): AnimationGroup;
  40281. /**
  40282. * Reset all animations to initial state
  40283. * @returns the animation group
  40284. */
  40285. reset(): AnimationGroup;
  40286. /**
  40287. * Restart animations from key 0
  40288. * @returns the animation group
  40289. */
  40290. restart(): AnimationGroup;
  40291. /**
  40292. * Stop all animations
  40293. * @returns the animation group
  40294. */
  40295. stop(): AnimationGroup;
  40296. /**
  40297. * Set animation weight for all animatables
  40298. * @param weight defines the weight to use
  40299. * @return the animationGroup
  40300. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40301. */
  40302. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40303. /**
  40304. * Synchronize and normalize all animatables with a source animatable
  40305. * @param root defines the root animatable to synchronize with
  40306. * @return the animationGroup
  40307. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40308. */
  40309. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40310. /**
  40311. * Goes to a specific frame in this animation group
  40312. * @param frame the frame number to go to
  40313. * @return the animationGroup
  40314. */
  40315. goToFrame(frame: number): AnimationGroup;
  40316. /**
  40317. * Dispose all associated resources
  40318. */
  40319. dispose(): void;
  40320. private _checkAnimationGroupEnded;
  40321. /**
  40322. * Clone the current animation group and returns a copy
  40323. * @param newName defines the name of the new group
  40324. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40325. * @returns the new aniamtion group
  40326. */
  40327. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40328. /**
  40329. * Serializes the animationGroup to an object
  40330. * @returns Serialized object
  40331. */
  40332. serialize(): any;
  40333. /**
  40334. * Returns a new AnimationGroup object parsed from the source provided.
  40335. * @param parsedAnimationGroup defines the source
  40336. * @param scene defines the scene that will receive the animationGroup
  40337. * @returns a new AnimationGroup
  40338. */
  40339. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40340. /**
  40341. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40342. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40343. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40344. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40345. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40346. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40347. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40348. */
  40349. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40350. /**
  40351. * Returns the string "AnimationGroup"
  40352. * @returns "AnimationGroup"
  40353. */
  40354. getClassName(): string;
  40355. /**
  40356. * Creates a detailled string about the object
  40357. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40358. * @returns a string representing the object
  40359. */
  40360. toString(fullDetails?: boolean): string;
  40361. }
  40362. }
  40363. declare module "babylonjs/scene" {
  40364. import { Nullable } from "babylonjs/types";
  40365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40366. import { Observable } from "babylonjs/Misc/observable";
  40367. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40368. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40369. import { Geometry } from "babylonjs/Meshes/geometry";
  40370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40371. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40373. import { Mesh } from "babylonjs/Meshes/mesh";
  40374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40375. import { Bone } from "babylonjs/Bones/bone";
  40376. import { Skeleton } from "babylonjs/Bones/skeleton";
  40377. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40378. import { Camera } from "babylonjs/Cameras/camera";
  40379. import { AbstractScene } from "babylonjs/abstractScene";
  40380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40382. import { Material } from "babylonjs/Materials/material";
  40383. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40384. import { Effect } from "babylonjs/Materials/effect";
  40385. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40386. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40387. import { Light } from "babylonjs/Lights/light";
  40388. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40389. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40390. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40391. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40393. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40394. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40395. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40396. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40397. import { Engine } from "babylonjs/Engines/engine";
  40398. import { Node } from "babylonjs/node";
  40399. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40400. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40401. import { WebRequest } from "babylonjs/Misc/webRequest";
  40402. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40403. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40404. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40405. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40406. import { Plane } from "babylonjs/Maths/math.plane";
  40407. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40408. import { Ray } from "babylonjs/Culling/ray";
  40409. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40410. import { Animation } from "babylonjs/Animations/animation";
  40411. import { Animatable } from "babylonjs/Animations/animatable";
  40412. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40413. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40414. import { Collider } from "babylonjs/Collisions/collider";
  40415. /**
  40416. * Define an interface for all classes that will hold resources
  40417. */
  40418. export interface IDisposable {
  40419. /**
  40420. * Releases all held resources
  40421. */
  40422. dispose(): void;
  40423. }
  40424. /** Interface defining initialization parameters for Scene class */
  40425. export interface SceneOptions {
  40426. /**
  40427. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40428. * It will improve performance when the number of geometries becomes important.
  40429. */
  40430. useGeometryUniqueIdsMap?: boolean;
  40431. /**
  40432. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40433. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40434. */
  40435. useMaterialMeshMap?: boolean;
  40436. /**
  40437. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40438. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40439. */
  40440. useClonedMeshMap?: boolean;
  40441. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40442. virtual?: boolean;
  40443. }
  40444. /**
  40445. * Represents a scene to be rendered by the engine.
  40446. * @see https://doc.babylonjs.com/features/scene
  40447. */
  40448. export class Scene extends AbstractScene implements IAnimatable {
  40449. /** The fog is deactivated */
  40450. static readonly FOGMODE_NONE: number;
  40451. /** The fog density is following an exponential function */
  40452. static readonly FOGMODE_EXP: number;
  40453. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40454. static readonly FOGMODE_EXP2: number;
  40455. /** The fog density is following a linear function. */
  40456. static readonly FOGMODE_LINEAR: number;
  40457. /**
  40458. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40459. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40460. */
  40461. static MinDeltaTime: number;
  40462. /**
  40463. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40464. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40465. */
  40466. static MaxDeltaTime: number;
  40467. /**
  40468. * Factory used to create the default material.
  40469. * @param name The name of the material to create
  40470. * @param scene The scene to create the material for
  40471. * @returns The default material
  40472. */
  40473. static DefaultMaterialFactory(scene: Scene): Material;
  40474. /**
  40475. * Factory used to create the a collision coordinator.
  40476. * @returns The collision coordinator
  40477. */
  40478. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40479. /** @hidden */
  40480. _inputManager: InputManager;
  40481. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40482. cameraToUseForPointers: Nullable<Camera>;
  40483. /** @hidden */
  40484. readonly _isScene: boolean;
  40485. /** @hidden */
  40486. _blockEntityCollection: boolean;
  40487. /**
  40488. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40489. */
  40490. autoClear: boolean;
  40491. /**
  40492. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40493. */
  40494. autoClearDepthAndStencil: boolean;
  40495. /**
  40496. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40497. */
  40498. clearColor: Color4;
  40499. /**
  40500. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40501. */
  40502. ambientColor: Color3;
  40503. /**
  40504. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40505. * It should only be one of the following (if not the default embedded one):
  40506. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40507. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40508. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40509. * The material properties need to be setup according to the type of texture in use.
  40510. */
  40511. environmentBRDFTexture: BaseTexture;
  40512. /** @hidden */
  40513. protected _environmentTexture: Nullable<BaseTexture>;
  40514. /**
  40515. * Texture used in all pbr material as the reflection texture.
  40516. * As in the majority of the scene they are the same (exception for multi room and so on),
  40517. * this is easier to reference from here than from all the materials.
  40518. */
  40519. get environmentTexture(): Nullable<BaseTexture>;
  40520. /**
  40521. * Texture used in all pbr material as the reflection texture.
  40522. * As in the majority of the scene they are the same (exception for multi room and so on),
  40523. * this is easier to set here than in all the materials.
  40524. */
  40525. set environmentTexture(value: Nullable<BaseTexture>);
  40526. /** @hidden */
  40527. protected _environmentIntensity: number;
  40528. /**
  40529. * Intensity of the environment in all pbr material.
  40530. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40531. * As in the majority of the scene they are the same (exception for multi room and so on),
  40532. * this is easier to reference from here than from all the materials.
  40533. */
  40534. get environmentIntensity(): number;
  40535. /**
  40536. * Intensity of the environment in all pbr material.
  40537. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40538. * As in the majority of the scene they are the same (exception for multi room and so on),
  40539. * this is easier to set here than in all the materials.
  40540. */
  40541. set environmentIntensity(value: number);
  40542. /** @hidden */
  40543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40544. /**
  40545. * Default image processing configuration used either in the rendering
  40546. * Forward main pass or through the imageProcessingPostProcess if present.
  40547. * As in the majority of the scene they are the same (exception for multi camera),
  40548. * this is easier to reference from here than from all the materials and post process.
  40549. *
  40550. * No setter as we it is a shared configuration, you can set the values instead.
  40551. */
  40552. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40553. private _forceWireframe;
  40554. /**
  40555. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40556. */
  40557. set forceWireframe(value: boolean);
  40558. get forceWireframe(): boolean;
  40559. private _skipFrustumClipping;
  40560. /**
  40561. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40562. */
  40563. set skipFrustumClipping(value: boolean);
  40564. get skipFrustumClipping(): boolean;
  40565. private _forcePointsCloud;
  40566. /**
  40567. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40568. */
  40569. set forcePointsCloud(value: boolean);
  40570. get forcePointsCloud(): boolean;
  40571. /**
  40572. * Gets or sets the active clipplane 1
  40573. */
  40574. clipPlane: Nullable<Plane>;
  40575. /**
  40576. * Gets or sets the active clipplane 2
  40577. */
  40578. clipPlane2: Nullable<Plane>;
  40579. /**
  40580. * Gets or sets the active clipplane 3
  40581. */
  40582. clipPlane3: Nullable<Plane>;
  40583. /**
  40584. * Gets or sets the active clipplane 4
  40585. */
  40586. clipPlane4: Nullable<Plane>;
  40587. /**
  40588. * Gets or sets the active clipplane 5
  40589. */
  40590. clipPlane5: Nullable<Plane>;
  40591. /**
  40592. * Gets or sets the active clipplane 6
  40593. */
  40594. clipPlane6: Nullable<Plane>;
  40595. /**
  40596. * Gets or sets a boolean indicating if animations are enabled
  40597. */
  40598. animationsEnabled: boolean;
  40599. private _animationPropertiesOverride;
  40600. /**
  40601. * Gets or sets the animation properties override
  40602. */
  40603. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40604. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40605. /**
  40606. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40607. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40608. */
  40609. useConstantAnimationDeltaTime: boolean;
  40610. /**
  40611. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40612. * Please note that it requires to run a ray cast through the scene on every frame
  40613. */
  40614. constantlyUpdateMeshUnderPointer: boolean;
  40615. /**
  40616. * Defines the HTML cursor to use when hovering over interactive elements
  40617. */
  40618. hoverCursor: string;
  40619. /**
  40620. * Defines the HTML default cursor to use (empty by default)
  40621. */
  40622. defaultCursor: string;
  40623. /**
  40624. * Defines whether cursors are handled by the scene.
  40625. */
  40626. doNotHandleCursors: boolean;
  40627. /**
  40628. * This is used to call preventDefault() on pointer down
  40629. * in order to block unwanted artifacts like system double clicks
  40630. */
  40631. preventDefaultOnPointerDown: boolean;
  40632. /**
  40633. * This is used to call preventDefault() on pointer up
  40634. * in order to block unwanted artifacts like system double clicks
  40635. */
  40636. preventDefaultOnPointerUp: boolean;
  40637. /**
  40638. * Gets or sets user defined metadata
  40639. */
  40640. metadata: any;
  40641. /**
  40642. * For internal use only. Please do not use.
  40643. */
  40644. reservedDataStore: any;
  40645. /**
  40646. * Gets the name of the plugin used to load this scene (null by default)
  40647. */
  40648. loadingPluginName: string;
  40649. /**
  40650. * Use this array to add regular expressions used to disable offline support for specific urls
  40651. */
  40652. disableOfflineSupportExceptionRules: RegExp[];
  40653. /**
  40654. * An event triggered when the scene is disposed.
  40655. */
  40656. onDisposeObservable: Observable<Scene>;
  40657. private _onDisposeObserver;
  40658. /** Sets a function to be executed when this scene is disposed. */
  40659. set onDispose(callback: () => void);
  40660. /**
  40661. * An event triggered before rendering the scene (right after animations and physics)
  40662. */
  40663. onBeforeRenderObservable: Observable<Scene>;
  40664. private _onBeforeRenderObserver;
  40665. /** Sets a function to be executed before rendering this scene */
  40666. set beforeRender(callback: Nullable<() => void>);
  40667. /**
  40668. * An event triggered after rendering the scene
  40669. */
  40670. onAfterRenderObservable: Observable<Scene>;
  40671. /**
  40672. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40673. */
  40674. onAfterRenderCameraObservable: Observable<Camera>;
  40675. private _onAfterRenderObserver;
  40676. /** Sets a function to be executed after rendering this scene */
  40677. set afterRender(callback: Nullable<() => void>);
  40678. /**
  40679. * An event triggered before animating the scene
  40680. */
  40681. onBeforeAnimationsObservable: Observable<Scene>;
  40682. /**
  40683. * An event triggered after animations processing
  40684. */
  40685. onAfterAnimationsObservable: Observable<Scene>;
  40686. /**
  40687. * An event triggered before draw calls are ready to be sent
  40688. */
  40689. onBeforeDrawPhaseObservable: Observable<Scene>;
  40690. /**
  40691. * An event triggered after draw calls have been sent
  40692. */
  40693. onAfterDrawPhaseObservable: Observable<Scene>;
  40694. /**
  40695. * An event triggered when the scene is ready
  40696. */
  40697. onReadyObservable: Observable<Scene>;
  40698. /**
  40699. * An event triggered before rendering a camera
  40700. */
  40701. onBeforeCameraRenderObservable: Observable<Camera>;
  40702. private _onBeforeCameraRenderObserver;
  40703. /** Sets a function to be executed before rendering a camera*/
  40704. set beforeCameraRender(callback: () => void);
  40705. /**
  40706. * An event triggered after rendering a camera
  40707. */
  40708. onAfterCameraRenderObservable: Observable<Camera>;
  40709. private _onAfterCameraRenderObserver;
  40710. /** Sets a function to be executed after rendering a camera*/
  40711. set afterCameraRender(callback: () => void);
  40712. /**
  40713. * An event triggered when active meshes evaluation is about to start
  40714. */
  40715. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40716. /**
  40717. * An event triggered when active meshes evaluation is done
  40718. */
  40719. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40720. /**
  40721. * An event triggered when particles rendering is about to start
  40722. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40723. */
  40724. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40725. /**
  40726. * An event triggered when particles rendering is done
  40727. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40728. */
  40729. onAfterParticlesRenderingObservable: Observable<Scene>;
  40730. /**
  40731. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40732. */
  40733. onDataLoadedObservable: Observable<Scene>;
  40734. /**
  40735. * An event triggered when a camera is created
  40736. */
  40737. onNewCameraAddedObservable: Observable<Camera>;
  40738. /**
  40739. * An event triggered when a camera is removed
  40740. */
  40741. onCameraRemovedObservable: Observable<Camera>;
  40742. /**
  40743. * An event triggered when a light is created
  40744. */
  40745. onNewLightAddedObservable: Observable<Light>;
  40746. /**
  40747. * An event triggered when a light is removed
  40748. */
  40749. onLightRemovedObservable: Observable<Light>;
  40750. /**
  40751. * An event triggered when a geometry is created
  40752. */
  40753. onNewGeometryAddedObservable: Observable<Geometry>;
  40754. /**
  40755. * An event triggered when a geometry is removed
  40756. */
  40757. onGeometryRemovedObservable: Observable<Geometry>;
  40758. /**
  40759. * An event triggered when a transform node is created
  40760. */
  40761. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40762. /**
  40763. * An event triggered when a transform node is removed
  40764. */
  40765. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40766. /**
  40767. * An event triggered when a mesh is created
  40768. */
  40769. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40770. /**
  40771. * An event triggered when a mesh is removed
  40772. */
  40773. onMeshRemovedObservable: Observable<AbstractMesh>;
  40774. /**
  40775. * An event triggered when a skeleton is created
  40776. */
  40777. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40778. /**
  40779. * An event triggered when a skeleton is removed
  40780. */
  40781. onSkeletonRemovedObservable: Observable<Skeleton>;
  40782. /**
  40783. * An event triggered when a material is created
  40784. */
  40785. onNewMaterialAddedObservable: Observable<Material>;
  40786. /**
  40787. * An event triggered when a material is removed
  40788. */
  40789. onMaterialRemovedObservable: Observable<Material>;
  40790. /**
  40791. * An event triggered when a texture is created
  40792. */
  40793. onNewTextureAddedObservable: Observable<BaseTexture>;
  40794. /**
  40795. * An event triggered when a texture is removed
  40796. */
  40797. onTextureRemovedObservable: Observable<BaseTexture>;
  40798. /**
  40799. * An event triggered when render targets are about to be rendered
  40800. * Can happen multiple times per frame.
  40801. */
  40802. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40803. /**
  40804. * An event triggered when render targets were rendered.
  40805. * Can happen multiple times per frame.
  40806. */
  40807. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40808. /**
  40809. * An event triggered before calculating deterministic simulation step
  40810. */
  40811. onBeforeStepObservable: Observable<Scene>;
  40812. /**
  40813. * An event triggered after calculating deterministic simulation step
  40814. */
  40815. onAfterStepObservable: Observable<Scene>;
  40816. /**
  40817. * An event triggered when the activeCamera property is updated
  40818. */
  40819. onActiveCameraChanged: Observable<Scene>;
  40820. /**
  40821. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40822. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40823. * 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)
  40824. */
  40825. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40826. /**
  40827. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40828. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40829. * 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)
  40830. */
  40831. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40832. /**
  40833. * This Observable will when a mesh has been imported into the scene.
  40834. */
  40835. onMeshImportedObservable: Observable<AbstractMesh>;
  40836. /**
  40837. * This Observable will when an animation file has been imported into the scene.
  40838. */
  40839. onAnimationFileImportedObservable: Observable<Scene>;
  40840. /**
  40841. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40842. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40843. */
  40844. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40845. /** @hidden */
  40846. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40847. /**
  40848. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40849. */
  40850. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40851. /**
  40852. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40853. */
  40854. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40855. /**
  40856. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40857. */
  40858. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40859. /** Callback called when a pointer move is detected */
  40860. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40861. /** Callback called when a pointer down is detected */
  40862. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40863. /** Callback called when a pointer up is detected */
  40864. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40865. /** Callback called when a pointer pick is detected */
  40866. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40867. /**
  40868. * 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).
  40869. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40870. */
  40871. onPrePointerObservable: Observable<PointerInfoPre>;
  40872. /**
  40873. * Observable event triggered each time an input event is received from the rendering canvas
  40874. */
  40875. onPointerObservable: Observable<PointerInfo>;
  40876. /**
  40877. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40878. */
  40879. get unTranslatedPointer(): Vector2;
  40880. /**
  40881. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40882. */
  40883. static get DragMovementThreshold(): number;
  40884. static set DragMovementThreshold(value: number);
  40885. /**
  40886. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40887. */
  40888. static get LongPressDelay(): number;
  40889. static set LongPressDelay(value: number);
  40890. /**
  40891. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40892. */
  40893. static get DoubleClickDelay(): number;
  40894. static set DoubleClickDelay(value: number);
  40895. /** If you need to check double click without raising a single click at first click, enable this flag */
  40896. static get ExclusiveDoubleClickMode(): boolean;
  40897. static set ExclusiveDoubleClickMode(value: boolean);
  40898. /** @hidden */
  40899. _mirroredCameraPosition: Nullable<Vector3>;
  40900. /**
  40901. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40902. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40903. */
  40904. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40905. /**
  40906. * Observable event triggered each time an keyboard event is received from the hosting window
  40907. */
  40908. onKeyboardObservable: Observable<KeyboardInfo>;
  40909. private _useRightHandedSystem;
  40910. /**
  40911. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40912. */
  40913. set useRightHandedSystem(value: boolean);
  40914. get useRightHandedSystem(): boolean;
  40915. private _timeAccumulator;
  40916. private _currentStepId;
  40917. private _currentInternalStep;
  40918. /**
  40919. * Sets the step Id used by deterministic lock step
  40920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40921. * @param newStepId defines the step Id
  40922. */
  40923. setStepId(newStepId: number): void;
  40924. /**
  40925. * Gets the step Id used by deterministic lock step
  40926. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40927. * @returns the step Id
  40928. */
  40929. getStepId(): number;
  40930. /**
  40931. * Gets the internal step used by deterministic lock step
  40932. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40933. * @returns the internal step
  40934. */
  40935. getInternalStep(): number;
  40936. private _fogEnabled;
  40937. /**
  40938. * Gets or sets a boolean indicating if fog is enabled on this scene
  40939. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40940. * (Default is true)
  40941. */
  40942. set fogEnabled(value: boolean);
  40943. get fogEnabled(): boolean;
  40944. private _fogMode;
  40945. /**
  40946. * Gets or sets the fog mode to use
  40947. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40948. * | mode | value |
  40949. * | --- | --- |
  40950. * | FOGMODE_NONE | 0 |
  40951. * | FOGMODE_EXP | 1 |
  40952. * | FOGMODE_EXP2 | 2 |
  40953. * | FOGMODE_LINEAR | 3 |
  40954. */
  40955. set fogMode(value: number);
  40956. get fogMode(): number;
  40957. /**
  40958. * Gets or sets the fog color to use
  40959. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40960. * (Default is Color3(0.2, 0.2, 0.3))
  40961. */
  40962. fogColor: Color3;
  40963. /**
  40964. * Gets or sets the fog density to use
  40965. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40966. * (Default is 0.1)
  40967. */
  40968. fogDensity: number;
  40969. /**
  40970. * Gets or sets the fog start distance to use
  40971. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40972. * (Default is 0)
  40973. */
  40974. fogStart: number;
  40975. /**
  40976. * Gets or sets the fog end distance to use
  40977. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40978. * (Default is 1000)
  40979. */
  40980. fogEnd: number;
  40981. /**
  40982. * Flag indicating that the frame buffer binding is handled by another component
  40983. */
  40984. prePass: boolean;
  40985. private _shadowsEnabled;
  40986. /**
  40987. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40988. */
  40989. set shadowsEnabled(value: boolean);
  40990. get shadowsEnabled(): boolean;
  40991. private _lightsEnabled;
  40992. /**
  40993. * Gets or sets a boolean indicating if lights are enabled on this scene
  40994. */
  40995. set lightsEnabled(value: boolean);
  40996. get lightsEnabled(): boolean;
  40997. /** All of the active cameras added to this scene. */
  40998. activeCameras: Camera[];
  40999. /** @hidden */
  41000. _activeCamera: Nullable<Camera>;
  41001. /** Gets or sets the current active camera */
  41002. get activeCamera(): Nullable<Camera>;
  41003. set activeCamera(value: Nullable<Camera>);
  41004. private _defaultMaterial;
  41005. /** The default material used on meshes when no material is affected */
  41006. get defaultMaterial(): Material;
  41007. /** The default material used on meshes when no material is affected */
  41008. set defaultMaterial(value: Material);
  41009. private _texturesEnabled;
  41010. /**
  41011. * Gets or sets a boolean indicating if textures are enabled on this scene
  41012. */
  41013. set texturesEnabled(value: boolean);
  41014. get texturesEnabled(): boolean;
  41015. /**
  41016. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41017. */
  41018. physicsEnabled: boolean;
  41019. /**
  41020. * Gets or sets a boolean indicating if particles are enabled on this scene
  41021. */
  41022. particlesEnabled: boolean;
  41023. /**
  41024. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41025. */
  41026. spritesEnabled: boolean;
  41027. private _skeletonsEnabled;
  41028. /**
  41029. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41030. */
  41031. set skeletonsEnabled(value: boolean);
  41032. get skeletonsEnabled(): boolean;
  41033. /**
  41034. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41035. */
  41036. lensFlaresEnabled: boolean;
  41037. /**
  41038. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41039. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41040. */
  41041. collisionsEnabled: boolean;
  41042. private _collisionCoordinator;
  41043. /** @hidden */
  41044. get collisionCoordinator(): ICollisionCoordinator;
  41045. /**
  41046. * Defines the gravity applied to this scene (used only for collisions)
  41047. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41048. */
  41049. gravity: Vector3;
  41050. /**
  41051. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41052. */
  41053. postProcessesEnabled: boolean;
  41054. /**
  41055. * The list of postprocesses added to the scene
  41056. */
  41057. postProcesses: PostProcess[];
  41058. /**
  41059. * Gets the current postprocess manager
  41060. */
  41061. postProcessManager: PostProcessManager;
  41062. /**
  41063. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41064. */
  41065. renderTargetsEnabled: boolean;
  41066. /**
  41067. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41068. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41069. */
  41070. dumpNextRenderTargets: boolean;
  41071. /**
  41072. * The list of user defined render targets added to the scene
  41073. */
  41074. customRenderTargets: RenderTargetTexture[];
  41075. /**
  41076. * Defines if texture loading must be delayed
  41077. * If true, textures will only be loaded when they need to be rendered
  41078. */
  41079. useDelayedTextureLoading: boolean;
  41080. /**
  41081. * Gets the list of meshes imported to the scene through SceneLoader
  41082. */
  41083. importedMeshesFiles: String[];
  41084. /**
  41085. * Gets or sets a boolean indicating if probes are enabled on this scene
  41086. */
  41087. probesEnabled: boolean;
  41088. /**
  41089. * Gets or sets the current offline provider to use to store scene data
  41090. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41091. */
  41092. offlineProvider: IOfflineProvider;
  41093. /**
  41094. * Gets or sets the action manager associated with the scene
  41095. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41096. */
  41097. actionManager: AbstractActionManager;
  41098. private _meshesForIntersections;
  41099. /**
  41100. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41101. */
  41102. proceduralTexturesEnabled: boolean;
  41103. private _engine;
  41104. private _totalVertices;
  41105. /** @hidden */
  41106. _activeIndices: PerfCounter;
  41107. /** @hidden */
  41108. _activeParticles: PerfCounter;
  41109. /** @hidden */
  41110. _activeBones: PerfCounter;
  41111. private _animationRatio;
  41112. /** @hidden */
  41113. _animationTimeLast: number;
  41114. /** @hidden */
  41115. _animationTime: number;
  41116. /**
  41117. * Gets or sets a general scale for animation speed
  41118. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41119. */
  41120. animationTimeScale: number;
  41121. /** @hidden */
  41122. _cachedMaterial: Nullable<Material>;
  41123. /** @hidden */
  41124. _cachedEffect: Nullable<Effect>;
  41125. /** @hidden */
  41126. _cachedVisibility: Nullable<number>;
  41127. private _renderId;
  41128. private _frameId;
  41129. private _executeWhenReadyTimeoutId;
  41130. private _intermediateRendering;
  41131. private _viewUpdateFlag;
  41132. private _projectionUpdateFlag;
  41133. /** @hidden */
  41134. _toBeDisposed: Nullable<IDisposable>[];
  41135. private _activeRequests;
  41136. /** @hidden */
  41137. _pendingData: any[];
  41138. private _isDisposed;
  41139. /**
  41140. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41141. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41142. */
  41143. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41144. private _activeMeshes;
  41145. private _processedMaterials;
  41146. private _renderTargets;
  41147. /** @hidden */
  41148. _activeParticleSystems: SmartArray<IParticleSystem>;
  41149. private _activeSkeletons;
  41150. private _softwareSkinnedMeshes;
  41151. private _renderingManager;
  41152. /** @hidden */
  41153. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41154. private _transformMatrix;
  41155. private _sceneUbo;
  41156. /** @hidden */
  41157. _viewMatrix: Matrix;
  41158. private _projectionMatrix;
  41159. /** @hidden */
  41160. _forcedViewPosition: Nullable<Vector3>;
  41161. /** @hidden */
  41162. _frustumPlanes: Plane[];
  41163. /**
  41164. * Gets the list of frustum planes (built from the active camera)
  41165. */
  41166. get frustumPlanes(): Plane[];
  41167. /**
  41168. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41169. * This is useful if there are more lights that the maximum simulteanous authorized
  41170. */
  41171. requireLightSorting: boolean;
  41172. /** @hidden */
  41173. readonly useMaterialMeshMap: boolean;
  41174. /** @hidden */
  41175. readonly useClonedMeshMap: boolean;
  41176. private _externalData;
  41177. private _uid;
  41178. /**
  41179. * @hidden
  41180. * Backing store of defined scene components.
  41181. */
  41182. _components: ISceneComponent[];
  41183. /**
  41184. * @hidden
  41185. * Backing store of defined scene components.
  41186. */
  41187. _serializableComponents: ISceneSerializableComponent[];
  41188. /**
  41189. * List of components to register on the next registration step.
  41190. */
  41191. private _transientComponents;
  41192. /**
  41193. * Registers the transient components if needed.
  41194. */
  41195. private _registerTransientComponents;
  41196. /**
  41197. * @hidden
  41198. * Add a component to the scene.
  41199. * Note that the ccomponent could be registered on th next frame if this is called after
  41200. * the register component stage.
  41201. * @param component Defines the component to add to the scene
  41202. */
  41203. _addComponent(component: ISceneComponent): void;
  41204. /**
  41205. * @hidden
  41206. * Gets a component from the scene.
  41207. * @param name defines the name of the component to retrieve
  41208. * @returns the component or null if not present
  41209. */
  41210. _getComponent(name: string): Nullable<ISceneComponent>;
  41211. /**
  41212. * @hidden
  41213. * Defines the actions happening before camera updates.
  41214. */
  41215. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41216. /**
  41217. * @hidden
  41218. * Defines the actions happening before clear the canvas.
  41219. */
  41220. _beforeClearStage: Stage<SimpleStageAction>;
  41221. /**
  41222. * @hidden
  41223. * Defines the actions when collecting render targets for the frame.
  41224. */
  41225. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41226. /**
  41227. * @hidden
  41228. * Defines the actions happening for one camera in the frame.
  41229. */
  41230. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41231. /**
  41232. * @hidden
  41233. * Defines the actions happening during the per mesh ready checks.
  41234. */
  41235. _isReadyForMeshStage: Stage<MeshStageAction>;
  41236. /**
  41237. * @hidden
  41238. * Defines the actions happening before evaluate active mesh checks.
  41239. */
  41240. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41241. /**
  41242. * @hidden
  41243. * Defines the actions happening during the evaluate sub mesh checks.
  41244. */
  41245. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41246. /**
  41247. * @hidden
  41248. * Defines the actions happening during the active mesh stage.
  41249. */
  41250. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41251. /**
  41252. * @hidden
  41253. * Defines the actions happening during the per camera render target step.
  41254. */
  41255. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41256. /**
  41257. * @hidden
  41258. * Defines the actions happening just before the active camera is drawing.
  41259. */
  41260. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41261. /**
  41262. * @hidden
  41263. * Defines the actions happening just before a render target is drawing.
  41264. */
  41265. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41266. /**
  41267. * @hidden
  41268. * Defines the actions happening just before a rendering group is drawing.
  41269. */
  41270. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41271. /**
  41272. * @hidden
  41273. * Defines the actions happening just before a mesh is drawing.
  41274. */
  41275. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41276. /**
  41277. * @hidden
  41278. * Defines the actions happening just after a mesh has been drawn.
  41279. */
  41280. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41281. /**
  41282. * @hidden
  41283. * Defines the actions happening just after a rendering group has been drawn.
  41284. */
  41285. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41286. /**
  41287. * @hidden
  41288. * Defines the actions happening just after the active camera has been drawn.
  41289. */
  41290. _afterCameraDrawStage: Stage<CameraStageAction>;
  41291. /**
  41292. * @hidden
  41293. * Defines the actions happening just after a render target has been drawn.
  41294. */
  41295. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41296. /**
  41297. * @hidden
  41298. * Defines the actions happening just after rendering all cameras and computing intersections.
  41299. */
  41300. _afterRenderStage: Stage<SimpleStageAction>;
  41301. /**
  41302. * @hidden
  41303. * Defines the actions happening when a pointer move event happens.
  41304. */
  41305. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41306. /**
  41307. * @hidden
  41308. * Defines the actions happening when a pointer down event happens.
  41309. */
  41310. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41311. /**
  41312. * @hidden
  41313. * Defines the actions happening when a pointer up event happens.
  41314. */
  41315. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41316. /**
  41317. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41318. */
  41319. private geometriesByUniqueId;
  41320. /**
  41321. * Creates a new Scene
  41322. * @param engine defines the engine to use to render this scene
  41323. * @param options defines the scene options
  41324. */
  41325. constructor(engine: Engine, options?: SceneOptions);
  41326. /**
  41327. * Gets a string idenfifying the name of the class
  41328. * @returns "Scene" string
  41329. */
  41330. getClassName(): string;
  41331. private _defaultMeshCandidates;
  41332. /**
  41333. * @hidden
  41334. */
  41335. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41336. private _defaultSubMeshCandidates;
  41337. /**
  41338. * @hidden
  41339. */
  41340. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41341. /**
  41342. * Sets the default candidate providers for the scene.
  41343. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41344. * and getCollidingSubMeshCandidates to their default function
  41345. */
  41346. setDefaultCandidateProviders(): void;
  41347. /**
  41348. * Gets the mesh that is currently under the pointer
  41349. */
  41350. get meshUnderPointer(): Nullable<AbstractMesh>;
  41351. /**
  41352. * Gets or sets the current on-screen X position of the pointer
  41353. */
  41354. get pointerX(): number;
  41355. set pointerX(value: number);
  41356. /**
  41357. * Gets or sets the current on-screen Y position of the pointer
  41358. */
  41359. get pointerY(): number;
  41360. set pointerY(value: number);
  41361. /**
  41362. * Gets the cached material (ie. the latest rendered one)
  41363. * @returns the cached material
  41364. */
  41365. getCachedMaterial(): Nullable<Material>;
  41366. /**
  41367. * Gets the cached effect (ie. the latest rendered one)
  41368. * @returns the cached effect
  41369. */
  41370. getCachedEffect(): Nullable<Effect>;
  41371. /**
  41372. * Gets the cached visibility state (ie. the latest rendered one)
  41373. * @returns the cached visibility state
  41374. */
  41375. getCachedVisibility(): Nullable<number>;
  41376. /**
  41377. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41378. * @param material defines the current material
  41379. * @param effect defines the current effect
  41380. * @param visibility defines the current visibility state
  41381. * @returns true if one parameter is not cached
  41382. */
  41383. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41384. /**
  41385. * Gets the engine associated with the scene
  41386. * @returns an Engine
  41387. */
  41388. getEngine(): Engine;
  41389. /**
  41390. * Gets the total number of vertices rendered per frame
  41391. * @returns the total number of vertices rendered per frame
  41392. */
  41393. getTotalVertices(): number;
  41394. /**
  41395. * Gets the performance counter for total vertices
  41396. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41397. */
  41398. get totalVerticesPerfCounter(): PerfCounter;
  41399. /**
  41400. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41401. * @returns the total number of active indices rendered per frame
  41402. */
  41403. getActiveIndices(): number;
  41404. /**
  41405. * Gets the performance counter for active indices
  41406. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41407. */
  41408. get totalActiveIndicesPerfCounter(): PerfCounter;
  41409. /**
  41410. * Gets the total number of active particles rendered per frame
  41411. * @returns the total number of active particles rendered per frame
  41412. */
  41413. getActiveParticles(): number;
  41414. /**
  41415. * Gets the performance counter for active particles
  41416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41417. */
  41418. get activeParticlesPerfCounter(): PerfCounter;
  41419. /**
  41420. * Gets the total number of active bones rendered per frame
  41421. * @returns the total number of active bones rendered per frame
  41422. */
  41423. getActiveBones(): number;
  41424. /**
  41425. * Gets the performance counter for active bones
  41426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41427. */
  41428. get activeBonesPerfCounter(): PerfCounter;
  41429. /**
  41430. * Gets the array of active meshes
  41431. * @returns an array of AbstractMesh
  41432. */
  41433. getActiveMeshes(): SmartArray<AbstractMesh>;
  41434. /**
  41435. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41436. * @returns a number
  41437. */
  41438. getAnimationRatio(): number;
  41439. /**
  41440. * Gets an unique Id for the current render phase
  41441. * @returns a number
  41442. */
  41443. getRenderId(): number;
  41444. /**
  41445. * Gets an unique Id for the current frame
  41446. * @returns a number
  41447. */
  41448. getFrameId(): number;
  41449. /** Call this function if you want to manually increment the render Id*/
  41450. incrementRenderId(): void;
  41451. private _createUbo;
  41452. /**
  41453. * Use this method to simulate a pointer move on a mesh
  41454. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41455. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41456. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41457. * @returns the current scene
  41458. */
  41459. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41460. /**
  41461. * Use this method to simulate a pointer down on a mesh
  41462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41465. * @returns the current scene
  41466. */
  41467. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41468. /**
  41469. * Use this method to simulate a pointer up on a mesh
  41470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41473. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41474. * @returns the current scene
  41475. */
  41476. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41477. /**
  41478. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41479. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41480. * @returns true if the pointer was captured
  41481. */
  41482. isPointerCaptured(pointerId?: number): boolean;
  41483. /**
  41484. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41485. * @param attachUp defines if you want to attach events to pointerup
  41486. * @param attachDown defines if you want to attach events to pointerdown
  41487. * @param attachMove defines if you want to attach events to pointermove
  41488. */
  41489. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41490. /** Detaches all event handlers*/
  41491. detachControl(): void;
  41492. /**
  41493. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41494. * Delay loaded resources are not taking in account
  41495. * @return true if all required resources are ready
  41496. */
  41497. isReady(): boolean;
  41498. /** Resets all cached information relative to material (including effect and visibility) */
  41499. resetCachedMaterial(): void;
  41500. /**
  41501. * Registers a function to be called before every frame render
  41502. * @param func defines the function to register
  41503. */
  41504. registerBeforeRender(func: () => void): void;
  41505. /**
  41506. * Unregisters a function called before every frame render
  41507. * @param func defines the function to unregister
  41508. */
  41509. unregisterBeforeRender(func: () => void): void;
  41510. /**
  41511. * Registers a function to be called after every frame render
  41512. * @param func defines the function to register
  41513. */
  41514. registerAfterRender(func: () => void): void;
  41515. /**
  41516. * Unregisters a function called after every frame render
  41517. * @param func defines the function to unregister
  41518. */
  41519. unregisterAfterRender(func: () => void): void;
  41520. private _executeOnceBeforeRender;
  41521. /**
  41522. * The provided function will run before render once and will be disposed afterwards.
  41523. * A timeout delay can be provided so that the function will be executed in N ms.
  41524. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41525. * @param func The function to be executed.
  41526. * @param timeout optional delay in ms
  41527. */
  41528. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41529. /** @hidden */
  41530. _addPendingData(data: any): void;
  41531. /** @hidden */
  41532. _removePendingData(data: any): void;
  41533. /**
  41534. * Returns the number of items waiting to be loaded
  41535. * @returns the number of items waiting to be loaded
  41536. */
  41537. getWaitingItemsCount(): number;
  41538. /**
  41539. * Returns a boolean indicating if the scene is still loading data
  41540. */
  41541. get isLoading(): boolean;
  41542. /**
  41543. * Registers a function to be executed when the scene is ready
  41544. * @param {Function} func - the function to be executed
  41545. */
  41546. executeWhenReady(func: () => void): void;
  41547. /**
  41548. * Returns a promise that resolves when the scene is ready
  41549. * @returns A promise that resolves when the scene is ready
  41550. */
  41551. whenReadyAsync(): Promise<void>;
  41552. /** @hidden */
  41553. _checkIsReady(): void;
  41554. /**
  41555. * Gets all animatable attached to the scene
  41556. */
  41557. get animatables(): Animatable[];
  41558. /**
  41559. * Resets the last animation time frame.
  41560. * Useful to override when animations start running when loading a scene for the first time.
  41561. */
  41562. resetLastAnimationTimeFrame(): void;
  41563. /**
  41564. * Gets the current view matrix
  41565. * @returns a Matrix
  41566. */
  41567. getViewMatrix(): Matrix;
  41568. /**
  41569. * Gets the current projection matrix
  41570. * @returns a Matrix
  41571. */
  41572. getProjectionMatrix(): Matrix;
  41573. /**
  41574. * Gets the current transform matrix
  41575. * @returns a Matrix made of View * Projection
  41576. */
  41577. getTransformMatrix(): Matrix;
  41578. /**
  41579. * Sets the current transform matrix
  41580. * @param viewL defines the View matrix to use
  41581. * @param projectionL defines the Projection matrix to use
  41582. * @param viewR defines the right View matrix to use (if provided)
  41583. * @param projectionR defines the right Projection matrix to use (if provided)
  41584. */
  41585. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41586. /**
  41587. * Gets the uniform buffer used to store scene data
  41588. * @returns a UniformBuffer
  41589. */
  41590. getSceneUniformBuffer(): UniformBuffer;
  41591. /**
  41592. * Gets an unique (relatively to the current scene) Id
  41593. * @returns an unique number for the scene
  41594. */
  41595. getUniqueId(): number;
  41596. /**
  41597. * Add a mesh to the list of scene's meshes
  41598. * @param newMesh defines the mesh to add
  41599. * @param recursive if all child meshes should also be added to the scene
  41600. */
  41601. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41602. /**
  41603. * Remove a mesh for the list of scene's meshes
  41604. * @param toRemove defines the mesh to remove
  41605. * @param recursive if all child meshes should also be removed from the scene
  41606. * @returns the index where the mesh was in the mesh list
  41607. */
  41608. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41609. /**
  41610. * Add a transform node to the list of scene's transform nodes
  41611. * @param newTransformNode defines the transform node to add
  41612. */
  41613. addTransformNode(newTransformNode: TransformNode): void;
  41614. /**
  41615. * Remove a transform node for the list of scene's transform nodes
  41616. * @param toRemove defines the transform node to remove
  41617. * @returns the index where the transform node was in the transform node list
  41618. */
  41619. removeTransformNode(toRemove: TransformNode): number;
  41620. /**
  41621. * Remove a skeleton for the list of scene's skeletons
  41622. * @param toRemove defines the skeleton to remove
  41623. * @returns the index where the skeleton was in the skeleton list
  41624. */
  41625. removeSkeleton(toRemove: Skeleton): number;
  41626. /**
  41627. * Remove a morph target for the list of scene's morph targets
  41628. * @param toRemove defines the morph target to remove
  41629. * @returns the index where the morph target was in the morph target list
  41630. */
  41631. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41632. /**
  41633. * Remove a light for the list of scene's lights
  41634. * @param toRemove defines the light to remove
  41635. * @returns the index where the light was in the light list
  41636. */
  41637. removeLight(toRemove: Light): number;
  41638. /**
  41639. * Remove a camera for the list of scene's cameras
  41640. * @param toRemove defines the camera to remove
  41641. * @returns the index where the camera was in the camera list
  41642. */
  41643. removeCamera(toRemove: Camera): number;
  41644. /**
  41645. * Remove a particle system for the list of scene's particle systems
  41646. * @param toRemove defines the particle system to remove
  41647. * @returns the index where the particle system was in the particle system list
  41648. */
  41649. removeParticleSystem(toRemove: IParticleSystem): number;
  41650. /**
  41651. * Remove a animation for the list of scene's animations
  41652. * @param toRemove defines the animation to remove
  41653. * @returns the index where the animation was in the animation list
  41654. */
  41655. removeAnimation(toRemove: Animation): number;
  41656. /**
  41657. * Will stop the animation of the given target
  41658. * @param target - the target
  41659. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41660. * @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)
  41661. */
  41662. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41663. /**
  41664. * Removes the given animation group from this scene.
  41665. * @param toRemove The animation group to remove
  41666. * @returns The index of the removed animation group
  41667. */
  41668. removeAnimationGroup(toRemove: AnimationGroup): number;
  41669. /**
  41670. * Removes the given multi-material from this scene.
  41671. * @param toRemove The multi-material to remove
  41672. * @returns The index of the removed multi-material
  41673. */
  41674. removeMultiMaterial(toRemove: MultiMaterial): number;
  41675. /**
  41676. * Removes the given material from this scene.
  41677. * @param toRemove The material to remove
  41678. * @returns The index of the removed material
  41679. */
  41680. removeMaterial(toRemove: Material): number;
  41681. /**
  41682. * Removes the given action manager from this scene.
  41683. * @param toRemove The action manager to remove
  41684. * @returns The index of the removed action manager
  41685. */
  41686. removeActionManager(toRemove: AbstractActionManager): number;
  41687. /**
  41688. * Removes the given texture from this scene.
  41689. * @param toRemove The texture to remove
  41690. * @returns The index of the removed texture
  41691. */
  41692. removeTexture(toRemove: BaseTexture): number;
  41693. /**
  41694. * Adds the given light to this scene
  41695. * @param newLight The light to add
  41696. */
  41697. addLight(newLight: Light): void;
  41698. /**
  41699. * Sorts the list list based on light priorities
  41700. */
  41701. sortLightsByPriority(): void;
  41702. /**
  41703. * Adds the given camera to this scene
  41704. * @param newCamera The camera to add
  41705. */
  41706. addCamera(newCamera: Camera): void;
  41707. /**
  41708. * Adds the given skeleton to this scene
  41709. * @param newSkeleton The skeleton to add
  41710. */
  41711. addSkeleton(newSkeleton: Skeleton): void;
  41712. /**
  41713. * Adds the given particle system to this scene
  41714. * @param newParticleSystem The particle system to add
  41715. */
  41716. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41717. /**
  41718. * Adds the given animation to this scene
  41719. * @param newAnimation The animation to add
  41720. */
  41721. addAnimation(newAnimation: Animation): void;
  41722. /**
  41723. * Adds the given animation group to this scene.
  41724. * @param newAnimationGroup The animation group to add
  41725. */
  41726. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41727. /**
  41728. * Adds the given multi-material to this scene
  41729. * @param newMultiMaterial The multi-material to add
  41730. */
  41731. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41732. /**
  41733. * Adds the given material to this scene
  41734. * @param newMaterial The material to add
  41735. */
  41736. addMaterial(newMaterial: Material): void;
  41737. /**
  41738. * Adds the given morph target to this scene
  41739. * @param newMorphTargetManager The morph target to add
  41740. */
  41741. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41742. /**
  41743. * Adds the given geometry to this scene
  41744. * @param newGeometry The geometry to add
  41745. */
  41746. addGeometry(newGeometry: Geometry): void;
  41747. /**
  41748. * Adds the given action manager to this scene
  41749. * @param newActionManager The action manager to add
  41750. */
  41751. addActionManager(newActionManager: AbstractActionManager): void;
  41752. /**
  41753. * Adds the given texture to this scene.
  41754. * @param newTexture The texture to add
  41755. */
  41756. addTexture(newTexture: BaseTexture): void;
  41757. /**
  41758. * Switch active camera
  41759. * @param newCamera defines the new active camera
  41760. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41761. */
  41762. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41763. /**
  41764. * sets the active camera of the scene using its ID
  41765. * @param id defines the camera's ID
  41766. * @return the new active camera or null if none found.
  41767. */
  41768. setActiveCameraByID(id: string): Nullable<Camera>;
  41769. /**
  41770. * sets the active camera of the scene using its name
  41771. * @param name defines the camera's name
  41772. * @returns the new active camera or null if none found.
  41773. */
  41774. setActiveCameraByName(name: string): Nullable<Camera>;
  41775. /**
  41776. * get an animation group using its name
  41777. * @param name defines the material's name
  41778. * @return the animation group or null if none found.
  41779. */
  41780. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41781. /**
  41782. * Get a material using its unique id
  41783. * @param uniqueId defines the material's unique id
  41784. * @return the material or null if none found.
  41785. */
  41786. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41787. /**
  41788. * get a material using its id
  41789. * @param id defines the material's ID
  41790. * @return the material or null if none found.
  41791. */
  41792. getMaterialByID(id: string): Nullable<Material>;
  41793. /**
  41794. * Gets a the last added material using a given id
  41795. * @param id defines the material's ID
  41796. * @return the last material with the given id or null if none found.
  41797. */
  41798. getLastMaterialByID(id: string): Nullable<Material>;
  41799. /**
  41800. * Gets a material using its name
  41801. * @param name defines the material's name
  41802. * @return the material or null if none found.
  41803. */
  41804. getMaterialByName(name: string): Nullable<Material>;
  41805. /**
  41806. * Get a texture using its unique id
  41807. * @param uniqueId defines the texture's unique id
  41808. * @return the texture or null if none found.
  41809. */
  41810. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41811. /**
  41812. * Gets a camera using its id
  41813. * @param id defines the id to look for
  41814. * @returns the camera or null if not found
  41815. */
  41816. getCameraByID(id: string): Nullable<Camera>;
  41817. /**
  41818. * Gets a camera using its unique id
  41819. * @param uniqueId defines the unique id to look for
  41820. * @returns the camera or null if not found
  41821. */
  41822. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41823. /**
  41824. * Gets a camera using its name
  41825. * @param name defines the camera's name
  41826. * @return the camera or null if none found.
  41827. */
  41828. getCameraByName(name: string): Nullable<Camera>;
  41829. /**
  41830. * Gets a bone using its id
  41831. * @param id defines the bone's id
  41832. * @return the bone or null if not found
  41833. */
  41834. getBoneByID(id: string): Nullable<Bone>;
  41835. /**
  41836. * Gets a bone using its id
  41837. * @param name defines the bone's name
  41838. * @return the bone or null if not found
  41839. */
  41840. getBoneByName(name: string): Nullable<Bone>;
  41841. /**
  41842. * Gets a light node using its name
  41843. * @param name defines the the light's name
  41844. * @return the light or null if none found.
  41845. */
  41846. getLightByName(name: string): Nullable<Light>;
  41847. /**
  41848. * Gets a light node using its id
  41849. * @param id defines the light's id
  41850. * @return the light or null if none found.
  41851. */
  41852. getLightByID(id: string): Nullable<Light>;
  41853. /**
  41854. * Gets a light node using its scene-generated unique ID
  41855. * @param uniqueId defines the light's unique id
  41856. * @return the light or null if none found.
  41857. */
  41858. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41859. /**
  41860. * Gets a particle system by id
  41861. * @param id defines the particle system id
  41862. * @return the corresponding system or null if none found
  41863. */
  41864. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41865. /**
  41866. * Gets a geometry using its ID
  41867. * @param id defines the geometry's id
  41868. * @return the geometry or null if none found.
  41869. */
  41870. getGeometryByID(id: string): Nullable<Geometry>;
  41871. private _getGeometryByUniqueID;
  41872. /**
  41873. * Add a new geometry to this scene
  41874. * @param geometry defines the geometry to be added to the scene.
  41875. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41876. * @return a boolean defining if the geometry was added or not
  41877. */
  41878. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41879. /**
  41880. * Removes an existing geometry
  41881. * @param geometry defines the geometry to be removed from the scene
  41882. * @return a boolean defining if the geometry was removed or not
  41883. */
  41884. removeGeometry(geometry: Geometry): boolean;
  41885. /**
  41886. * Gets the list of geometries attached to the scene
  41887. * @returns an array of Geometry
  41888. */
  41889. getGeometries(): Geometry[];
  41890. /**
  41891. * Gets the first added mesh found of a given ID
  41892. * @param id defines the id to search for
  41893. * @return the mesh found or null if not found at all
  41894. */
  41895. getMeshByID(id: string): Nullable<AbstractMesh>;
  41896. /**
  41897. * Gets a list of meshes using their id
  41898. * @param id defines the id to search for
  41899. * @returns a list of meshes
  41900. */
  41901. getMeshesByID(id: string): Array<AbstractMesh>;
  41902. /**
  41903. * Gets the first added transform node found of a given ID
  41904. * @param id defines the id to search for
  41905. * @return the found transform node or null if not found at all.
  41906. */
  41907. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41908. /**
  41909. * Gets a transform node with its auto-generated unique id
  41910. * @param uniqueId efines the unique id to search for
  41911. * @return the found transform node or null if not found at all.
  41912. */
  41913. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41914. /**
  41915. * Gets a list of transform nodes using their id
  41916. * @param id defines the id to search for
  41917. * @returns a list of transform nodes
  41918. */
  41919. getTransformNodesByID(id: string): Array<TransformNode>;
  41920. /**
  41921. * Gets a mesh with its auto-generated unique id
  41922. * @param uniqueId defines the unique id to search for
  41923. * @return the found mesh or null if not found at all.
  41924. */
  41925. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41926. /**
  41927. * Gets a the last added mesh using a given id
  41928. * @param id defines the id to search for
  41929. * @return the found mesh or null if not found at all.
  41930. */
  41931. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41932. /**
  41933. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41934. * @param id defines the id to search for
  41935. * @return the found node or null if not found at all
  41936. */
  41937. getLastEntryByID(id: string): Nullable<Node>;
  41938. /**
  41939. * Gets a node (Mesh, Camera, Light) using a given id
  41940. * @param id defines the id to search for
  41941. * @return the found node or null if not found at all
  41942. */
  41943. getNodeByID(id: string): Nullable<Node>;
  41944. /**
  41945. * Gets a node (Mesh, Camera, Light) using a given name
  41946. * @param name defines the name to search for
  41947. * @return the found node or null if not found at all.
  41948. */
  41949. getNodeByName(name: string): Nullable<Node>;
  41950. /**
  41951. * Gets a mesh using a given name
  41952. * @param name defines the name to search for
  41953. * @return the found mesh or null if not found at all.
  41954. */
  41955. getMeshByName(name: string): Nullable<AbstractMesh>;
  41956. /**
  41957. * Gets a transform node using a given name
  41958. * @param name defines the name to search for
  41959. * @return the found transform node or null if not found at all.
  41960. */
  41961. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41962. /**
  41963. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41964. * @param id defines the id to search for
  41965. * @return the found skeleton or null if not found at all.
  41966. */
  41967. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41968. /**
  41969. * Gets a skeleton using a given auto generated unique id
  41970. * @param uniqueId defines the unique id to search for
  41971. * @return the found skeleton or null if not found at all.
  41972. */
  41973. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41974. /**
  41975. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41976. * @param id defines the id to search for
  41977. * @return the found skeleton or null if not found at all.
  41978. */
  41979. getSkeletonById(id: string): Nullable<Skeleton>;
  41980. /**
  41981. * Gets a skeleton using a given name
  41982. * @param name defines the name to search for
  41983. * @return the found skeleton or null if not found at all.
  41984. */
  41985. getSkeletonByName(name: string): Nullable<Skeleton>;
  41986. /**
  41987. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41988. * @param id defines the id to search for
  41989. * @return the found morph target manager or null if not found at all.
  41990. */
  41991. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41992. /**
  41993. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41994. * @param id defines the id to search for
  41995. * @return the found morph target or null if not found at all.
  41996. */
  41997. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41998. /**
  41999. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42000. * @param name defines the name to search for
  42001. * @return the found morph target or null if not found at all.
  42002. */
  42003. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42004. /**
  42005. * Gets a boolean indicating if the given mesh is active
  42006. * @param mesh defines the mesh to look for
  42007. * @returns true if the mesh is in the active list
  42008. */
  42009. isActiveMesh(mesh: AbstractMesh): boolean;
  42010. /**
  42011. * Return a unique id as a string which can serve as an identifier for the scene
  42012. */
  42013. get uid(): string;
  42014. /**
  42015. * Add an externaly attached data from its key.
  42016. * This method call will fail and return false, if such key already exists.
  42017. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42018. * @param key the unique key that identifies the data
  42019. * @param data the data object to associate to the key for this Engine instance
  42020. * @return true if no such key were already present and the data was added successfully, false otherwise
  42021. */
  42022. addExternalData<T>(key: string, data: T): boolean;
  42023. /**
  42024. * Get an externaly attached data from its key
  42025. * @param key the unique key that identifies the data
  42026. * @return the associated data, if present (can be null), or undefined if not present
  42027. */
  42028. getExternalData<T>(key: string): Nullable<T>;
  42029. /**
  42030. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42031. * @param key the unique key that identifies the data
  42032. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42033. * @return the associated data, can be null if the factory returned null.
  42034. */
  42035. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42036. /**
  42037. * Remove an externaly attached data from the Engine instance
  42038. * @param key the unique key that identifies the data
  42039. * @return true if the data was successfully removed, false if it doesn't exist
  42040. */
  42041. removeExternalData(key: string): boolean;
  42042. private _evaluateSubMesh;
  42043. /**
  42044. * Clear the processed materials smart array preventing retention point in material dispose.
  42045. */
  42046. freeProcessedMaterials(): void;
  42047. private _preventFreeActiveMeshesAndRenderingGroups;
  42048. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42049. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42050. * when disposing several meshes in a row or a hierarchy of meshes.
  42051. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42052. */
  42053. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42054. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42055. /**
  42056. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42057. */
  42058. freeActiveMeshes(): void;
  42059. /**
  42060. * Clear the info related to rendering groups preventing retention points during dispose.
  42061. */
  42062. freeRenderingGroups(): void;
  42063. /** @hidden */
  42064. _isInIntermediateRendering(): boolean;
  42065. /**
  42066. * Lambda returning the list of potentially active meshes.
  42067. */
  42068. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42069. /**
  42070. * Lambda returning the list of potentially active sub meshes.
  42071. */
  42072. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42073. /**
  42074. * Lambda returning the list of potentially intersecting sub meshes.
  42075. */
  42076. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42077. /**
  42078. * Lambda returning the list of potentially colliding sub meshes.
  42079. */
  42080. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42081. private _activeMeshesFrozen;
  42082. private _skipEvaluateActiveMeshesCompletely;
  42083. /**
  42084. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42085. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42086. * @returns the current scene
  42087. */
  42088. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42089. /**
  42090. * Use this function to restart evaluating active meshes on every frame
  42091. * @returns the current scene
  42092. */
  42093. unfreezeActiveMeshes(): Scene;
  42094. private _evaluateActiveMeshes;
  42095. private _activeMesh;
  42096. /**
  42097. * Update the transform matrix to update from the current active camera
  42098. * @param force defines a boolean used to force the update even if cache is up to date
  42099. */
  42100. updateTransformMatrix(force?: boolean): void;
  42101. private _bindFrameBuffer;
  42102. /** @hidden */
  42103. _allowPostProcessClearColor: boolean;
  42104. /** @hidden */
  42105. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42106. private _processSubCameras;
  42107. private _checkIntersections;
  42108. /** @hidden */
  42109. _advancePhysicsEngineStep(step: number): void;
  42110. /**
  42111. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42112. */
  42113. getDeterministicFrameTime: () => number;
  42114. /** @hidden */
  42115. _animate(): void;
  42116. /** Execute all animations (for a frame) */
  42117. animate(): void;
  42118. /**
  42119. * Render the scene
  42120. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42121. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42122. */
  42123. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42124. /**
  42125. * Freeze all materials
  42126. * A frozen material will not be updatable but should be faster to render
  42127. */
  42128. freezeMaterials(): void;
  42129. /**
  42130. * Unfreeze all materials
  42131. * A frozen material will not be updatable but should be faster to render
  42132. */
  42133. unfreezeMaterials(): void;
  42134. /**
  42135. * Releases all held ressources
  42136. */
  42137. dispose(): void;
  42138. /**
  42139. * Gets if the scene is already disposed
  42140. */
  42141. get isDisposed(): boolean;
  42142. /**
  42143. * Call this function to reduce memory footprint of the scene.
  42144. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42145. */
  42146. clearCachedVertexData(): void;
  42147. /**
  42148. * This function will remove the local cached buffer data from texture.
  42149. * It will save memory but will prevent the texture from being rebuilt
  42150. */
  42151. cleanCachedTextureBuffer(): void;
  42152. /**
  42153. * Get the world extend vectors with an optional filter
  42154. *
  42155. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42156. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42157. */
  42158. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42159. min: Vector3;
  42160. max: Vector3;
  42161. };
  42162. /**
  42163. * Creates a ray that can be used to pick in the scene
  42164. * @param x defines the x coordinate of the origin (on-screen)
  42165. * @param y defines the y coordinate of the origin (on-screen)
  42166. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42167. * @param camera defines the camera to use for the picking
  42168. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42169. * @returns a Ray
  42170. */
  42171. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42172. /**
  42173. * Creates a ray that can be used to pick in the scene
  42174. * @param x defines the x coordinate of the origin (on-screen)
  42175. * @param y defines the y coordinate of the origin (on-screen)
  42176. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42177. * @param result defines the ray where to store the picking ray
  42178. * @param camera defines the camera to use for the picking
  42179. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42180. * @returns the current scene
  42181. */
  42182. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42183. /**
  42184. * Creates a ray that can be used to pick in the scene
  42185. * @param x defines the x coordinate of the origin (on-screen)
  42186. * @param y defines the y coordinate of the origin (on-screen)
  42187. * @param camera defines the camera to use for the picking
  42188. * @returns a Ray
  42189. */
  42190. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42191. /**
  42192. * Creates a ray that can be used to pick in the scene
  42193. * @param x defines the x coordinate of the origin (on-screen)
  42194. * @param y defines the y coordinate of the origin (on-screen)
  42195. * @param result defines the ray where to store the picking ray
  42196. * @param camera defines the camera to use for the picking
  42197. * @returns the current scene
  42198. */
  42199. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42200. /** Launch a ray to try to pick a mesh in the scene
  42201. * @param x position on screen
  42202. * @param y position on screen
  42203. * @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
  42204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42205. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42206. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42207. * @returns a PickingInfo
  42208. */
  42209. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42210. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42211. * @param x position on screen
  42212. * @param y position on screen
  42213. * @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
  42214. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42215. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42216. * @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)
  42217. */
  42218. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42219. /** Use the given ray to pick a mesh in the scene
  42220. * @param ray The ray to use to pick meshes
  42221. * @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
  42222. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42224. * @returns a PickingInfo
  42225. */
  42226. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42227. /**
  42228. * Launch a ray to try to pick a mesh in the scene
  42229. * @param x X position on screen
  42230. * @param y Y position on screen
  42231. * @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
  42232. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42233. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42234. * @returns an array of PickingInfo
  42235. */
  42236. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42237. /**
  42238. * Launch a ray to try to pick a mesh in the scene
  42239. * @param ray Ray to use
  42240. * @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
  42241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42242. * @returns an array of PickingInfo
  42243. */
  42244. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42245. /**
  42246. * Force the value of meshUnderPointer
  42247. * @param mesh defines the mesh to use
  42248. */
  42249. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42250. /**
  42251. * Gets the mesh under the pointer
  42252. * @returns a Mesh or null if no mesh is under the pointer
  42253. */
  42254. getPointerOverMesh(): Nullable<AbstractMesh>;
  42255. /** @hidden */
  42256. _rebuildGeometries(): void;
  42257. /** @hidden */
  42258. _rebuildTextures(): void;
  42259. private _getByTags;
  42260. /**
  42261. * Get a list of meshes by tags
  42262. * @param tagsQuery defines the tags query to use
  42263. * @param forEach defines a predicate used to filter results
  42264. * @returns an array of Mesh
  42265. */
  42266. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42267. /**
  42268. * Get a list of cameras by tags
  42269. * @param tagsQuery defines the tags query to use
  42270. * @param forEach defines a predicate used to filter results
  42271. * @returns an array of Camera
  42272. */
  42273. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42274. /**
  42275. * Get a list of lights by tags
  42276. * @param tagsQuery defines the tags query to use
  42277. * @param forEach defines a predicate used to filter results
  42278. * @returns an array of Light
  42279. */
  42280. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42281. /**
  42282. * Get a list of materials by tags
  42283. * @param tagsQuery defines the tags query to use
  42284. * @param forEach defines a predicate used to filter results
  42285. * @returns an array of Material
  42286. */
  42287. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42288. /**
  42289. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42290. * This allowed control for front to back rendering or reversly depending of the special needs.
  42291. *
  42292. * @param renderingGroupId The rendering group id corresponding to its index
  42293. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42294. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42295. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42296. */
  42297. 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;
  42298. /**
  42299. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42300. *
  42301. * @param renderingGroupId The rendering group id corresponding to its index
  42302. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42303. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42304. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42305. */
  42306. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42307. /**
  42308. * Gets the current auto clear configuration for one rendering group of the rendering
  42309. * manager.
  42310. * @param index the rendering group index to get the information for
  42311. * @returns The auto clear setup for the requested rendering group
  42312. */
  42313. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42314. private _blockMaterialDirtyMechanism;
  42315. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42316. get blockMaterialDirtyMechanism(): boolean;
  42317. set blockMaterialDirtyMechanism(value: boolean);
  42318. /**
  42319. * Will flag all materials as dirty to trigger new shader compilation
  42320. * @param flag defines the flag used to specify which material part must be marked as dirty
  42321. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42322. */
  42323. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42324. /** @hidden */
  42325. _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;
  42326. /** @hidden */
  42327. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42328. /** @hidden */
  42329. _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;
  42330. /** @hidden */
  42331. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42332. /** @hidden */
  42333. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42334. /** @hidden */
  42335. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42336. }
  42337. }
  42338. declare module "babylonjs/assetContainer" {
  42339. import { AbstractScene } from "babylonjs/abstractScene";
  42340. import { Scene } from "babylonjs/scene";
  42341. import { Mesh } from "babylonjs/Meshes/mesh";
  42342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42343. import { Skeleton } from "babylonjs/Bones/skeleton";
  42344. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42345. import { Animatable } from "babylonjs/Animations/animatable";
  42346. import { Nullable } from "babylonjs/types";
  42347. import { Node } from "babylonjs/node";
  42348. /**
  42349. * Set of assets to keep when moving a scene into an asset container.
  42350. */
  42351. export class KeepAssets extends AbstractScene {
  42352. }
  42353. /**
  42354. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42355. */
  42356. export class InstantiatedEntries {
  42357. /**
  42358. * List of new root nodes (eg. nodes with no parent)
  42359. */
  42360. rootNodes: TransformNode[];
  42361. /**
  42362. * List of new skeletons
  42363. */
  42364. skeletons: Skeleton[];
  42365. /**
  42366. * List of new animation groups
  42367. */
  42368. animationGroups: AnimationGroup[];
  42369. }
  42370. /**
  42371. * Container with a set of assets that can be added or removed from a scene.
  42372. */
  42373. export class AssetContainer extends AbstractScene {
  42374. private _wasAddedToScene;
  42375. /**
  42376. * The scene the AssetContainer belongs to.
  42377. */
  42378. scene: Scene;
  42379. /**
  42380. * Instantiates an AssetContainer.
  42381. * @param scene The scene the AssetContainer belongs to.
  42382. */
  42383. constructor(scene: Scene);
  42384. /**
  42385. * Instantiate or clone all meshes and add the new ones to the scene.
  42386. * Skeletons and animation groups will all be cloned
  42387. * @param nameFunction defines an optional function used to get new names for clones
  42388. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42389. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42390. */
  42391. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42392. /**
  42393. * Adds all the assets from the container to the scene.
  42394. */
  42395. addAllToScene(): void;
  42396. /**
  42397. * Removes all the assets in the container from the scene
  42398. */
  42399. removeAllFromScene(): void;
  42400. /**
  42401. * Disposes all the assets in the container
  42402. */
  42403. dispose(): void;
  42404. private _moveAssets;
  42405. /**
  42406. * Removes all the assets contained in the scene and adds them to the container.
  42407. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42408. */
  42409. moveAllFromScene(keepAssets?: KeepAssets): void;
  42410. /**
  42411. * 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.
  42412. * @returns the root mesh
  42413. */
  42414. createRootMesh(): Mesh;
  42415. /**
  42416. * Merge animations (direct and animation groups) from this asset container into a scene
  42417. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42418. * @param animatables set of animatables to retarget to a node from the scene
  42419. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42420. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42421. */
  42422. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42423. }
  42424. }
  42425. declare module "babylonjs/abstractScene" {
  42426. import { Scene } from "babylonjs/scene";
  42427. import { Nullable } from "babylonjs/types";
  42428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42429. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42430. import { Geometry } from "babylonjs/Meshes/geometry";
  42431. import { Skeleton } from "babylonjs/Bones/skeleton";
  42432. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42433. import { AssetContainer } from "babylonjs/assetContainer";
  42434. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42435. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42437. import { Material } from "babylonjs/Materials/material";
  42438. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42439. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42440. import { Camera } from "babylonjs/Cameras/camera";
  42441. import { Light } from "babylonjs/Lights/light";
  42442. import { Node } from "babylonjs/node";
  42443. import { Animation } from "babylonjs/Animations/animation";
  42444. /**
  42445. * Defines how the parser contract is defined.
  42446. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42447. */
  42448. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42449. /**
  42450. * Defines how the individual parser contract is defined.
  42451. * These parser can parse an individual asset
  42452. */
  42453. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42454. /**
  42455. * Base class of the scene acting as a container for the different elements composing a scene.
  42456. * This class is dynamically extended by the different components of the scene increasing
  42457. * flexibility and reducing coupling
  42458. */
  42459. export abstract class AbstractScene {
  42460. /**
  42461. * Stores the list of available parsers in the application.
  42462. */
  42463. private static _BabylonFileParsers;
  42464. /**
  42465. * Stores the list of available individual parsers in the application.
  42466. */
  42467. private static _IndividualBabylonFileParsers;
  42468. /**
  42469. * Adds a parser in the list of available ones
  42470. * @param name Defines the name of the parser
  42471. * @param parser Defines the parser to add
  42472. */
  42473. static AddParser(name: string, parser: BabylonFileParser): void;
  42474. /**
  42475. * Gets a general parser from the list of avaialble ones
  42476. * @param name Defines the name of the parser
  42477. * @returns the requested parser or null
  42478. */
  42479. static GetParser(name: string): Nullable<BabylonFileParser>;
  42480. /**
  42481. * Adds n individual parser in the list of available ones
  42482. * @param name Defines the name of the parser
  42483. * @param parser Defines the parser to add
  42484. */
  42485. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42486. /**
  42487. * Gets an individual parser from the list of avaialble ones
  42488. * @param name Defines the name of the parser
  42489. * @returns the requested parser or null
  42490. */
  42491. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42492. /**
  42493. * Parser json data and populate both a scene and its associated container object
  42494. * @param jsonData Defines the data to parse
  42495. * @param scene Defines the scene to parse the data for
  42496. * @param container Defines the container attached to the parsing sequence
  42497. * @param rootUrl Defines the root url of the data
  42498. */
  42499. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42500. /**
  42501. * Gets the list of root nodes (ie. nodes with no parent)
  42502. */
  42503. rootNodes: Node[];
  42504. /** All of the cameras added to this scene
  42505. * @see https://doc.babylonjs.com/babylon101/cameras
  42506. */
  42507. cameras: Camera[];
  42508. /**
  42509. * All of the lights added to this scene
  42510. * @see https://doc.babylonjs.com/babylon101/lights
  42511. */
  42512. lights: Light[];
  42513. /**
  42514. * All of the (abstract) meshes added to this scene
  42515. */
  42516. meshes: AbstractMesh[];
  42517. /**
  42518. * The list of skeletons added to the scene
  42519. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42520. */
  42521. skeletons: Skeleton[];
  42522. /**
  42523. * All of the particle systems added to this scene
  42524. * @see https://doc.babylonjs.com/babylon101/particles
  42525. */
  42526. particleSystems: IParticleSystem[];
  42527. /**
  42528. * Gets a list of Animations associated with the scene
  42529. */
  42530. animations: Animation[];
  42531. /**
  42532. * All of the animation groups added to this scene
  42533. * @see https://doc.babylonjs.com/how_to/group
  42534. */
  42535. animationGroups: AnimationGroup[];
  42536. /**
  42537. * All of the multi-materials added to this scene
  42538. * @see https://doc.babylonjs.com/how_to/multi_materials
  42539. */
  42540. multiMaterials: MultiMaterial[];
  42541. /**
  42542. * All of the materials added to this scene
  42543. * In the context of a Scene, it is not supposed to be modified manually.
  42544. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42545. * Note also that the order of the Material within the array is not significant and might change.
  42546. * @see https://doc.babylonjs.com/babylon101/materials
  42547. */
  42548. materials: Material[];
  42549. /**
  42550. * The list of morph target managers added to the scene
  42551. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42552. */
  42553. morphTargetManagers: MorphTargetManager[];
  42554. /**
  42555. * The list of geometries used in the scene.
  42556. */
  42557. geometries: Geometry[];
  42558. /**
  42559. * All of the tranform nodes added to this scene
  42560. * In the context of a Scene, it is not supposed to be modified manually.
  42561. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42562. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42563. * @see https://doc.babylonjs.com/how_to/transformnode
  42564. */
  42565. transformNodes: TransformNode[];
  42566. /**
  42567. * ActionManagers available on the scene.
  42568. */
  42569. actionManagers: AbstractActionManager[];
  42570. /**
  42571. * Textures to keep.
  42572. */
  42573. textures: BaseTexture[];
  42574. /**
  42575. * Environment texture for the scene
  42576. */
  42577. environmentTexture: Nullable<BaseTexture>;
  42578. /**
  42579. * @returns all meshes, lights, cameras, transformNodes and bones
  42580. */
  42581. getNodes(): Array<Node>;
  42582. }
  42583. }
  42584. declare module "babylonjs/Audio/sound" {
  42585. import { Observable } from "babylonjs/Misc/observable";
  42586. import { Vector3 } from "babylonjs/Maths/math.vector";
  42587. import { Nullable } from "babylonjs/types";
  42588. import { Scene } from "babylonjs/scene";
  42589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42590. /**
  42591. * Interface used to define options for Sound class
  42592. */
  42593. export interface ISoundOptions {
  42594. /**
  42595. * Does the sound autoplay once loaded.
  42596. */
  42597. autoplay?: boolean;
  42598. /**
  42599. * Does the sound loop after it finishes playing once.
  42600. */
  42601. loop?: boolean;
  42602. /**
  42603. * Sound's volume
  42604. */
  42605. volume?: number;
  42606. /**
  42607. * Is it a spatial sound?
  42608. */
  42609. spatialSound?: boolean;
  42610. /**
  42611. * Maximum distance to hear that sound
  42612. */
  42613. maxDistance?: number;
  42614. /**
  42615. * Uses user defined attenuation function
  42616. */
  42617. useCustomAttenuation?: boolean;
  42618. /**
  42619. * Define the roll off factor of spatial sounds.
  42620. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42621. */
  42622. rolloffFactor?: number;
  42623. /**
  42624. * Define the reference distance the sound should be heard perfectly.
  42625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42626. */
  42627. refDistance?: number;
  42628. /**
  42629. * Define the distance attenuation model the sound will follow.
  42630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42631. */
  42632. distanceModel?: string;
  42633. /**
  42634. * Defines the playback speed (1 by default)
  42635. */
  42636. playbackRate?: number;
  42637. /**
  42638. * Defines if the sound is from a streaming source
  42639. */
  42640. streaming?: boolean;
  42641. /**
  42642. * Defines an optional length (in seconds) inside the sound file
  42643. */
  42644. length?: number;
  42645. /**
  42646. * Defines an optional offset (in seconds) inside the sound file
  42647. */
  42648. offset?: number;
  42649. /**
  42650. * If true, URLs will not be required to state the audio file codec to use.
  42651. */
  42652. skipCodecCheck?: boolean;
  42653. }
  42654. /**
  42655. * Defines a sound that can be played in the application.
  42656. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42657. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42658. */
  42659. export class Sound {
  42660. /**
  42661. * The name of the sound in the scene.
  42662. */
  42663. name: string;
  42664. /**
  42665. * Does the sound autoplay once loaded.
  42666. */
  42667. autoplay: boolean;
  42668. /**
  42669. * Does the sound loop after it finishes playing once.
  42670. */
  42671. loop: boolean;
  42672. /**
  42673. * Does the sound use a custom attenuation curve to simulate the falloff
  42674. * happening when the source gets further away from the camera.
  42675. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42676. */
  42677. useCustomAttenuation: boolean;
  42678. /**
  42679. * The sound track id this sound belongs to.
  42680. */
  42681. soundTrackId: number;
  42682. /**
  42683. * Is this sound currently played.
  42684. */
  42685. isPlaying: boolean;
  42686. /**
  42687. * Is this sound currently paused.
  42688. */
  42689. isPaused: boolean;
  42690. /**
  42691. * Does this sound enables spatial sound.
  42692. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42693. */
  42694. spatialSound: boolean;
  42695. /**
  42696. * Define the reference distance the sound should be heard perfectly.
  42697. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42698. */
  42699. refDistance: number;
  42700. /**
  42701. * Define the roll off factor of spatial sounds.
  42702. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42703. */
  42704. rolloffFactor: number;
  42705. /**
  42706. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42708. */
  42709. maxDistance: number;
  42710. /**
  42711. * Define the distance attenuation model the sound will follow.
  42712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42713. */
  42714. distanceModel: string;
  42715. /**
  42716. * @hidden
  42717. * Back Compat
  42718. **/
  42719. onended: () => any;
  42720. /**
  42721. * Gets or sets an object used to store user defined information for the sound.
  42722. */
  42723. metadata: any;
  42724. /**
  42725. * Observable event when the current playing sound finishes.
  42726. */
  42727. onEndedObservable: Observable<Sound>;
  42728. private _panningModel;
  42729. private _playbackRate;
  42730. private _streaming;
  42731. private _startTime;
  42732. private _startOffset;
  42733. private _position;
  42734. /** @hidden */
  42735. _positionInEmitterSpace: boolean;
  42736. private _localDirection;
  42737. private _volume;
  42738. private _isReadyToPlay;
  42739. private _isDirectional;
  42740. private _readyToPlayCallback;
  42741. private _audioBuffer;
  42742. private _soundSource;
  42743. private _streamingSource;
  42744. private _soundPanner;
  42745. private _soundGain;
  42746. private _inputAudioNode;
  42747. private _outputAudioNode;
  42748. private _coneInnerAngle;
  42749. private _coneOuterAngle;
  42750. private _coneOuterGain;
  42751. private _scene;
  42752. private _connectedTransformNode;
  42753. private _customAttenuationFunction;
  42754. private _registerFunc;
  42755. private _isOutputConnected;
  42756. private _htmlAudioElement;
  42757. private _urlType;
  42758. private _length?;
  42759. private _offset?;
  42760. /** @hidden */
  42761. static _SceneComponentInitialization: (scene: Scene) => void;
  42762. /**
  42763. * Create a sound and attach it to a scene
  42764. * @param name Name of your sound
  42765. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42766. * @param scene defines the scene the sound belongs to
  42767. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42768. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42769. */
  42770. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42771. /**
  42772. * Release the sound and its associated resources
  42773. */
  42774. dispose(): void;
  42775. /**
  42776. * Gets if the sounds is ready to be played or not.
  42777. * @returns true if ready, otherwise false
  42778. */
  42779. isReady(): boolean;
  42780. private _soundLoaded;
  42781. /**
  42782. * Sets the data of the sound from an audiobuffer
  42783. * @param audioBuffer The audioBuffer containing the data
  42784. */
  42785. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42786. /**
  42787. * Updates the current sounds options such as maxdistance, loop...
  42788. * @param options A JSON object containing values named as the object properties
  42789. */
  42790. updateOptions(options: ISoundOptions): void;
  42791. private _createSpatialParameters;
  42792. private _updateSpatialParameters;
  42793. /**
  42794. * Switch the panning model to HRTF:
  42795. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42796. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42797. */
  42798. switchPanningModelToHRTF(): void;
  42799. /**
  42800. * Switch the panning model to Equal Power:
  42801. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42802. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42803. */
  42804. switchPanningModelToEqualPower(): void;
  42805. private _switchPanningModel;
  42806. /**
  42807. * Connect this sound to a sound track audio node like gain...
  42808. * @param soundTrackAudioNode the sound track audio node to connect to
  42809. */
  42810. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42811. /**
  42812. * Transform this sound into a directional source
  42813. * @param coneInnerAngle Size of the inner cone in degree
  42814. * @param coneOuterAngle Size of the outer cone in degree
  42815. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42816. */
  42817. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42818. /**
  42819. * Gets or sets the inner angle for the directional cone.
  42820. */
  42821. get directionalConeInnerAngle(): number;
  42822. /**
  42823. * Gets or sets the inner angle for the directional cone.
  42824. */
  42825. set directionalConeInnerAngle(value: number);
  42826. /**
  42827. * Gets or sets the outer angle for the directional cone.
  42828. */
  42829. get directionalConeOuterAngle(): number;
  42830. /**
  42831. * Gets or sets the outer angle for the directional cone.
  42832. */
  42833. set directionalConeOuterAngle(value: number);
  42834. /**
  42835. * Sets the position of the emitter if spatial sound is enabled
  42836. * @param newPosition Defines the new posisiton
  42837. */
  42838. setPosition(newPosition: Vector3): void;
  42839. /**
  42840. * Sets the local direction of the emitter if spatial sound is enabled
  42841. * @param newLocalDirection Defines the new local direction
  42842. */
  42843. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42844. private _updateDirection;
  42845. /** @hidden */
  42846. updateDistanceFromListener(): void;
  42847. /**
  42848. * Sets a new custom attenuation function for the sound.
  42849. * @param callback Defines the function used for the attenuation
  42850. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42851. */
  42852. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42853. /**
  42854. * Play the sound
  42855. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42856. * @param offset (optional) Start the sound at a specific time in seconds
  42857. * @param length (optional) Sound duration (in seconds)
  42858. */
  42859. play(time?: number, offset?: number, length?: number): void;
  42860. private _onended;
  42861. /**
  42862. * Stop the sound
  42863. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42864. */
  42865. stop(time?: number): void;
  42866. /**
  42867. * Put the sound in pause
  42868. */
  42869. pause(): void;
  42870. /**
  42871. * Sets a dedicated volume for this sounds
  42872. * @param newVolume Define the new volume of the sound
  42873. * @param time Define time for gradual change to new volume
  42874. */
  42875. setVolume(newVolume: number, time?: number): void;
  42876. /**
  42877. * Set the sound play back rate
  42878. * @param newPlaybackRate Define the playback rate the sound should be played at
  42879. */
  42880. setPlaybackRate(newPlaybackRate: number): void;
  42881. /**
  42882. * Gets the volume of the sound.
  42883. * @returns the volume of the sound
  42884. */
  42885. getVolume(): number;
  42886. /**
  42887. * Attach the sound to a dedicated mesh
  42888. * @param transformNode The transform node to connect the sound with
  42889. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42890. */
  42891. attachToMesh(transformNode: TransformNode): void;
  42892. /**
  42893. * Detach the sound from the previously attached mesh
  42894. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42895. */
  42896. detachFromMesh(): void;
  42897. private _onRegisterAfterWorldMatrixUpdate;
  42898. /**
  42899. * Clone the current sound in the scene.
  42900. * @returns the new sound clone
  42901. */
  42902. clone(): Nullable<Sound>;
  42903. /**
  42904. * Gets the current underlying audio buffer containing the data
  42905. * @returns the audio buffer
  42906. */
  42907. getAudioBuffer(): Nullable<AudioBuffer>;
  42908. /**
  42909. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42910. * @returns the source node
  42911. */
  42912. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42913. /**
  42914. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42915. * @returns the gain node
  42916. */
  42917. getSoundGain(): Nullable<GainNode>;
  42918. /**
  42919. * Serializes the Sound in a JSON representation
  42920. * @returns the JSON representation of the sound
  42921. */
  42922. serialize(): any;
  42923. /**
  42924. * Parse a JSON representation of a sound to innstantiate in a given scene
  42925. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42926. * @param scene Define the scene the new parsed sound should be created in
  42927. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42928. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42929. * @returns the newly parsed sound
  42930. */
  42931. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42932. }
  42933. }
  42934. declare module "babylonjs/Actions/directAudioActions" {
  42935. import { Action } from "babylonjs/Actions/action";
  42936. import { Condition } from "babylonjs/Actions/condition";
  42937. import { Sound } from "babylonjs/Audio/sound";
  42938. /**
  42939. * This defines an action helpful to play a defined sound on a triggered action.
  42940. */
  42941. export class PlaySoundAction extends Action {
  42942. private _sound;
  42943. /**
  42944. * Instantiate the action
  42945. * @param triggerOptions defines the trigger options
  42946. * @param sound defines the sound to play
  42947. * @param condition defines the trigger related conditions
  42948. */
  42949. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42950. /** @hidden */
  42951. _prepare(): void;
  42952. /**
  42953. * Execute the action and play the sound.
  42954. */
  42955. execute(): void;
  42956. /**
  42957. * Serializes the actions and its related information.
  42958. * @param parent defines the object to serialize in
  42959. * @returns the serialized object
  42960. */
  42961. serialize(parent: any): any;
  42962. }
  42963. /**
  42964. * This defines an action helpful to stop a defined sound on a triggered action.
  42965. */
  42966. export class StopSoundAction extends Action {
  42967. private _sound;
  42968. /**
  42969. * Instantiate the action
  42970. * @param triggerOptions defines the trigger options
  42971. * @param sound defines the sound to stop
  42972. * @param condition defines the trigger related conditions
  42973. */
  42974. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42975. /** @hidden */
  42976. _prepare(): void;
  42977. /**
  42978. * Execute the action and stop the sound.
  42979. */
  42980. execute(): void;
  42981. /**
  42982. * Serializes the actions and its related information.
  42983. * @param parent defines the object to serialize in
  42984. * @returns the serialized object
  42985. */
  42986. serialize(parent: any): any;
  42987. }
  42988. }
  42989. declare module "babylonjs/Actions/interpolateValueAction" {
  42990. import { Action } from "babylonjs/Actions/action";
  42991. import { Condition } from "babylonjs/Actions/condition";
  42992. import { Observable } from "babylonjs/Misc/observable";
  42993. /**
  42994. * This defines an action responsible to change the value of a property
  42995. * by interpolating between its current value and the newly set one once triggered.
  42996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42997. */
  42998. export class InterpolateValueAction extends Action {
  42999. /**
  43000. * Defines the path of the property where the value should be interpolated
  43001. */
  43002. propertyPath: string;
  43003. /**
  43004. * Defines the target value at the end of the interpolation.
  43005. */
  43006. value: any;
  43007. /**
  43008. * Defines the time it will take for the property to interpolate to the value.
  43009. */
  43010. duration: number;
  43011. /**
  43012. * Defines if the other scene animations should be stopped when the action has been triggered
  43013. */
  43014. stopOtherAnimations?: boolean;
  43015. /**
  43016. * Defines a callback raised once the interpolation animation has been done.
  43017. */
  43018. onInterpolationDone?: () => void;
  43019. /**
  43020. * Observable triggered once the interpolation animation has been done.
  43021. */
  43022. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43023. private _target;
  43024. private _effectiveTarget;
  43025. private _property;
  43026. /**
  43027. * Instantiate the action
  43028. * @param triggerOptions defines the trigger options
  43029. * @param target defines the object containing the value to interpolate
  43030. * @param propertyPath defines the path to the property in the target object
  43031. * @param value defines the target value at the end of the interpolation
  43032. * @param duration deines the time it will take for the property to interpolate to the value.
  43033. * @param condition defines the trigger related conditions
  43034. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43035. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43036. */
  43037. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43038. /** @hidden */
  43039. _prepare(): void;
  43040. /**
  43041. * Execute the action starts the value interpolation.
  43042. */
  43043. execute(): void;
  43044. /**
  43045. * Serializes the actions and its related information.
  43046. * @param parent defines the object to serialize in
  43047. * @returns the serialized object
  43048. */
  43049. serialize(parent: any): any;
  43050. }
  43051. }
  43052. declare module "babylonjs/Actions/index" {
  43053. export * from "babylonjs/Actions/abstractActionManager";
  43054. export * from "babylonjs/Actions/action";
  43055. export * from "babylonjs/Actions/actionEvent";
  43056. export * from "babylonjs/Actions/actionManager";
  43057. export * from "babylonjs/Actions/condition";
  43058. export * from "babylonjs/Actions/directActions";
  43059. export * from "babylonjs/Actions/directAudioActions";
  43060. export * from "babylonjs/Actions/interpolateValueAction";
  43061. }
  43062. declare module "babylonjs/Animations/index" {
  43063. export * from "babylonjs/Animations/animatable";
  43064. export * from "babylonjs/Animations/animation";
  43065. export * from "babylonjs/Animations/animationGroup";
  43066. export * from "babylonjs/Animations/animationPropertiesOverride";
  43067. export * from "babylonjs/Animations/easing";
  43068. export * from "babylonjs/Animations/runtimeAnimation";
  43069. export * from "babylonjs/Animations/animationEvent";
  43070. export * from "babylonjs/Animations/animationGroup";
  43071. export * from "babylonjs/Animations/animationKey";
  43072. export * from "babylonjs/Animations/animationRange";
  43073. export * from "babylonjs/Animations/animatable.interface";
  43074. }
  43075. declare module "babylonjs/Audio/soundTrack" {
  43076. import { Sound } from "babylonjs/Audio/sound";
  43077. import { Analyser } from "babylonjs/Audio/analyser";
  43078. import { Scene } from "babylonjs/scene";
  43079. /**
  43080. * Options allowed during the creation of a sound track.
  43081. */
  43082. export interface ISoundTrackOptions {
  43083. /**
  43084. * The volume the sound track should take during creation
  43085. */
  43086. volume?: number;
  43087. /**
  43088. * Define if the sound track is the main sound track of the scene
  43089. */
  43090. mainTrack?: boolean;
  43091. }
  43092. /**
  43093. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43094. * It will be also used in a future release to apply effects on a specific track.
  43095. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43096. */
  43097. export class SoundTrack {
  43098. /**
  43099. * The unique identifier of the sound track in the scene.
  43100. */
  43101. id: number;
  43102. /**
  43103. * The list of sounds included in the sound track.
  43104. */
  43105. soundCollection: Array<Sound>;
  43106. private _outputAudioNode;
  43107. private _scene;
  43108. private _connectedAnalyser;
  43109. private _options;
  43110. private _isInitialized;
  43111. /**
  43112. * Creates a new sound track.
  43113. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43114. * @param scene Define the scene the sound track belongs to
  43115. * @param options
  43116. */
  43117. constructor(scene: Scene, options?: ISoundTrackOptions);
  43118. private _initializeSoundTrackAudioGraph;
  43119. /**
  43120. * Release the sound track and its associated resources
  43121. */
  43122. dispose(): void;
  43123. /**
  43124. * Adds a sound to this sound track
  43125. * @param sound define the cound to add
  43126. * @ignoreNaming
  43127. */
  43128. AddSound(sound: Sound): void;
  43129. /**
  43130. * Removes a sound to this sound track
  43131. * @param sound define the cound to remove
  43132. * @ignoreNaming
  43133. */
  43134. RemoveSound(sound: Sound): void;
  43135. /**
  43136. * Set a global volume for the full sound track.
  43137. * @param newVolume Define the new volume of the sound track
  43138. */
  43139. setVolume(newVolume: number): void;
  43140. /**
  43141. * Switch the panning model to HRTF:
  43142. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43144. */
  43145. switchPanningModelToHRTF(): void;
  43146. /**
  43147. * Switch the panning model to Equal Power:
  43148. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43150. */
  43151. switchPanningModelToEqualPower(): void;
  43152. /**
  43153. * Connect the sound track to an audio analyser allowing some amazing
  43154. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43155. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43156. * @param analyser The analyser to connect to the engine
  43157. */
  43158. connectToAnalyser(analyser: Analyser): void;
  43159. }
  43160. }
  43161. declare module "babylonjs/Audio/audioSceneComponent" {
  43162. import { Sound } from "babylonjs/Audio/sound";
  43163. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43164. import { Nullable } from "babylonjs/types";
  43165. import { Vector3 } from "babylonjs/Maths/math.vector";
  43166. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43167. import { Scene } from "babylonjs/scene";
  43168. import { AbstractScene } from "babylonjs/abstractScene";
  43169. import "babylonjs/Audio/audioEngine";
  43170. module "babylonjs/abstractScene" {
  43171. interface AbstractScene {
  43172. /**
  43173. * The list of sounds used in the scene.
  43174. */
  43175. sounds: Nullable<Array<Sound>>;
  43176. }
  43177. }
  43178. module "babylonjs/scene" {
  43179. interface Scene {
  43180. /**
  43181. * @hidden
  43182. * Backing field
  43183. */
  43184. _mainSoundTrack: SoundTrack;
  43185. /**
  43186. * The main sound track played by the scene.
  43187. * It cotains your primary collection of sounds.
  43188. */
  43189. mainSoundTrack: SoundTrack;
  43190. /**
  43191. * The list of sound tracks added to the scene
  43192. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43193. */
  43194. soundTracks: Nullable<Array<SoundTrack>>;
  43195. /**
  43196. * Gets a sound using a given name
  43197. * @param name defines the name to search for
  43198. * @return the found sound or null if not found at all.
  43199. */
  43200. getSoundByName(name: string): Nullable<Sound>;
  43201. /**
  43202. * Gets or sets if audio support is enabled
  43203. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43204. */
  43205. audioEnabled: boolean;
  43206. /**
  43207. * Gets or sets if audio will be output to headphones
  43208. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43209. */
  43210. headphone: boolean;
  43211. /**
  43212. * Gets or sets custom audio listener position provider
  43213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43214. */
  43215. audioListenerPositionProvider: Nullable<() => Vector3>;
  43216. /**
  43217. * Gets or sets a refresh rate when using 3D audio positioning
  43218. */
  43219. audioPositioningRefreshRate: number;
  43220. }
  43221. }
  43222. /**
  43223. * Defines the sound scene component responsible to manage any sounds
  43224. * in a given scene.
  43225. */
  43226. export class AudioSceneComponent implements ISceneSerializableComponent {
  43227. /**
  43228. * The component name helpfull to identify the component in the list of scene components.
  43229. */
  43230. readonly name: string;
  43231. /**
  43232. * The scene the component belongs to.
  43233. */
  43234. scene: Scene;
  43235. private _audioEnabled;
  43236. /**
  43237. * Gets whether audio is enabled or not.
  43238. * Please use related enable/disable method to switch state.
  43239. */
  43240. get audioEnabled(): boolean;
  43241. private _headphone;
  43242. /**
  43243. * Gets whether audio is outputing to headphone or not.
  43244. * Please use the according Switch methods to change output.
  43245. */
  43246. get headphone(): boolean;
  43247. /**
  43248. * Gets or sets a refresh rate when using 3D audio positioning
  43249. */
  43250. audioPositioningRefreshRate: number;
  43251. private _audioListenerPositionProvider;
  43252. /**
  43253. * Gets the current audio listener position provider
  43254. */
  43255. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43256. /**
  43257. * Sets a custom listener position for all sounds in the scene
  43258. * By default, this is the position of the first active camera
  43259. */
  43260. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43261. /**
  43262. * Creates a new instance of the component for the given scene
  43263. * @param scene Defines the scene to register the component in
  43264. */
  43265. constructor(scene: Scene);
  43266. /**
  43267. * Registers the component in a given scene
  43268. */
  43269. register(): void;
  43270. /**
  43271. * Rebuilds the elements related to this component in case of
  43272. * context lost for instance.
  43273. */
  43274. rebuild(): void;
  43275. /**
  43276. * Serializes the component data to the specified json object
  43277. * @param serializationObject The object to serialize to
  43278. */
  43279. serialize(serializationObject: any): void;
  43280. /**
  43281. * Adds all the elements from the container to the scene
  43282. * @param container the container holding the elements
  43283. */
  43284. addFromContainer(container: AbstractScene): void;
  43285. /**
  43286. * Removes all the elements in the container from the scene
  43287. * @param container contains the elements to remove
  43288. * @param dispose if the removed element should be disposed (default: false)
  43289. */
  43290. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43291. /**
  43292. * Disposes the component and the associated ressources.
  43293. */
  43294. dispose(): void;
  43295. /**
  43296. * Disables audio in the associated scene.
  43297. */
  43298. disableAudio(): void;
  43299. /**
  43300. * Enables audio in the associated scene.
  43301. */
  43302. enableAudio(): void;
  43303. /**
  43304. * Switch audio to headphone output.
  43305. */
  43306. switchAudioModeForHeadphones(): void;
  43307. /**
  43308. * Switch audio to normal speakers.
  43309. */
  43310. switchAudioModeForNormalSpeakers(): void;
  43311. private _cachedCameraDirection;
  43312. private _cachedCameraPosition;
  43313. private _lastCheck;
  43314. private _afterRender;
  43315. }
  43316. }
  43317. declare module "babylonjs/Audio/weightedsound" {
  43318. import { Sound } from "babylonjs/Audio/sound";
  43319. /**
  43320. * Wraps one or more Sound objects and selects one with random weight for playback.
  43321. */
  43322. export class WeightedSound {
  43323. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43324. loop: boolean;
  43325. private _coneInnerAngle;
  43326. private _coneOuterAngle;
  43327. private _volume;
  43328. /** A Sound is currently playing. */
  43329. isPlaying: boolean;
  43330. /** A Sound is currently paused. */
  43331. isPaused: boolean;
  43332. private _sounds;
  43333. private _weights;
  43334. private _currentIndex?;
  43335. /**
  43336. * Creates a new WeightedSound from the list of sounds given.
  43337. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43338. * @param sounds Array of Sounds that will be selected from.
  43339. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43340. */
  43341. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43342. /**
  43343. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43344. */
  43345. get directionalConeInnerAngle(): number;
  43346. /**
  43347. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43348. */
  43349. set directionalConeInnerAngle(value: number);
  43350. /**
  43351. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43352. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43353. */
  43354. get directionalConeOuterAngle(): number;
  43355. /**
  43356. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43357. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43358. */
  43359. set directionalConeOuterAngle(value: number);
  43360. /**
  43361. * Playback volume.
  43362. */
  43363. get volume(): number;
  43364. /**
  43365. * Playback volume.
  43366. */
  43367. set volume(value: number);
  43368. private _onended;
  43369. /**
  43370. * Suspend playback
  43371. */
  43372. pause(): void;
  43373. /**
  43374. * Stop playback
  43375. */
  43376. stop(): void;
  43377. /**
  43378. * Start playback.
  43379. * @param startOffset Position the clip head at a specific time in seconds.
  43380. */
  43381. play(startOffset?: number): void;
  43382. }
  43383. }
  43384. declare module "babylonjs/Audio/index" {
  43385. export * from "babylonjs/Audio/analyser";
  43386. export * from "babylonjs/Audio/audioEngine";
  43387. export * from "babylonjs/Audio/audioSceneComponent";
  43388. export * from "babylonjs/Audio/sound";
  43389. export * from "babylonjs/Audio/soundTrack";
  43390. export * from "babylonjs/Audio/weightedsound";
  43391. }
  43392. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43393. import { Behavior } from "babylonjs/Behaviors/behavior";
  43394. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43395. import { BackEase } from "babylonjs/Animations/easing";
  43396. /**
  43397. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43398. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43399. */
  43400. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43401. /**
  43402. * Gets the name of the behavior.
  43403. */
  43404. get name(): string;
  43405. /**
  43406. * The easing function used by animations
  43407. */
  43408. static EasingFunction: BackEase;
  43409. /**
  43410. * The easing mode used by animations
  43411. */
  43412. static EasingMode: number;
  43413. /**
  43414. * The duration of the animation, in milliseconds
  43415. */
  43416. transitionDuration: number;
  43417. /**
  43418. * Length of the distance animated by the transition when lower radius is reached
  43419. */
  43420. lowerRadiusTransitionRange: number;
  43421. /**
  43422. * Length of the distance animated by the transition when upper radius is reached
  43423. */
  43424. upperRadiusTransitionRange: number;
  43425. private _autoTransitionRange;
  43426. /**
  43427. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43428. */
  43429. get autoTransitionRange(): boolean;
  43430. /**
  43431. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43432. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43433. */
  43434. set autoTransitionRange(value: boolean);
  43435. private _attachedCamera;
  43436. private _onAfterCheckInputsObserver;
  43437. private _onMeshTargetChangedObserver;
  43438. /**
  43439. * Initializes the behavior.
  43440. */
  43441. init(): void;
  43442. /**
  43443. * Attaches the behavior to its arc rotate camera.
  43444. * @param camera Defines the camera to attach the behavior to
  43445. */
  43446. attach(camera: ArcRotateCamera): void;
  43447. /**
  43448. * Detaches the behavior from its current arc rotate camera.
  43449. */
  43450. detach(): void;
  43451. private _radiusIsAnimating;
  43452. private _radiusBounceTransition;
  43453. private _animatables;
  43454. private _cachedWheelPrecision;
  43455. /**
  43456. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43457. * @param radiusLimit The limit to check against.
  43458. * @return Bool to indicate if at limit.
  43459. */
  43460. private _isRadiusAtLimit;
  43461. /**
  43462. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43463. * @param radiusDelta The delta by which to animate to. Can be negative.
  43464. */
  43465. private _applyBoundRadiusAnimation;
  43466. /**
  43467. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43468. */
  43469. protected _clearAnimationLocks(): void;
  43470. /**
  43471. * Stops and removes all animations that have been applied to the camera
  43472. */
  43473. stopAllAnimations(): void;
  43474. }
  43475. }
  43476. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43477. import { Behavior } from "babylonjs/Behaviors/behavior";
  43478. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43479. import { ExponentialEase } from "babylonjs/Animations/easing";
  43480. import { Nullable } from "babylonjs/types";
  43481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43482. import { Vector3 } from "babylonjs/Maths/math.vector";
  43483. /**
  43484. * 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.
  43485. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43486. */
  43487. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43488. /**
  43489. * Gets the name of the behavior.
  43490. */
  43491. get name(): string;
  43492. private _mode;
  43493. private _radiusScale;
  43494. private _positionScale;
  43495. private _defaultElevation;
  43496. private _elevationReturnTime;
  43497. private _elevationReturnWaitTime;
  43498. private _zoomStopsAnimation;
  43499. private _framingTime;
  43500. /**
  43501. * The easing function used by animations
  43502. */
  43503. static EasingFunction: ExponentialEase;
  43504. /**
  43505. * The easing mode used by animations
  43506. */
  43507. static EasingMode: number;
  43508. /**
  43509. * Sets the current mode used by the behavior
  43510. */
  43511. set mode(mode: number);
  43512. /**
  43513. * Gets current mode used by the behavior.
  43514. */
  43515. get mode(): number;
  43516. /**
  43517. * Sets the scale applied to the radius (1 by default)
  43518. */
  43519. set radiusScale(radius: number);
  43520. /**
  43521. * Gets the scale applied to the radius
  43522. */
  43523. get radiusScale(): number;
  43524. /**
  43525. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43526. */
  43527. set positionScale(scale: number);
  43528. /**
  43529. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43530. */
  43531. get positionScale(): number;
  43532. /**
  43533. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43534. * behaviour is triggered, in radians.
  43535. */
  43536. set defaultElevation(elevation: number);
  43537. /**
  43538. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43539. * behaviour is triggered, in radians.
  43540. */
  43541. get defaultElevation(): number;
  43542. /**
  43543. * Sets the time (in milliseconds) taken to return to the default beta position.
  43544. * Negative value indicates camera should not return to default.
  43545. */
  43546. set elevationReturnTime(speed: number);
  43547. /**
  43548. * Gets the time (in milliseconds) taken to return to the default beta position.
  43549. * Negative value indicates camera should not return to default.
  43550. */
  43551. get elevationReturnTime(): number;
  43552. /**
  43553. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43554. */
  43555. set elevationReturnWaitTime(time: number);
  43556. /**
  43557. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43558. */
  43559. get elevationReturnWaitTime(): number;
  43560. /**
  43561. * Sets the flag that indicates if user zooming should stop animation.
  43562. */
  43563. set zoomStopsAnimation(flag: boolean);
  43564. /**
  43565. * Gets the flag that indicates if user zooming should stop animation.
  43566. */
  43567. get zoomStopsAnimation(): boolean;
  43568. /**
  43569. * Sets the transition time when framing the mesh, in milliseconds
  43570. */
  43571. set framingTime(time: number);
  43572. /**
  43573. * Gets the transition time when framing the mesh, in milliseconds
  43574. */
  43575. get framingTime(): number;
  43576. /**
  43577. * Define if the behavior should automatically change the configured
  43578. * camera limits and sensibilities.
  43579. */
  43580. autoCorrectCameraLimitsAndSensibility: boolean;
  43581. private _onPrePointerObservableObserver;
  43582. private _onAfterCheckInputsObserver;
  43583. private _onMeshTargetChangedObserver;
  43584. private _attachedCamera;
  43585. private _isPointerDown;
  43586. private _lastInteractionTime;
  43587. /**
  43588. * Initializes the behavior.
  43589. */
  43590. init(): void;
  43591. /**
  43592. * Attaches the behavior to its arc rotate camera.
  43593. * @param camera Defines the camera to attach the behavior to
  43594. */
  43595. attach(camera: ArcRotateCamera): void;
  43596. /**
  43597. * Detaches the behavior from its current arc rotate camera.
  43598. */
  43599. detach(): void;
  43600. private _animatables;
  43601. private _betaIsAnimating;
  43602. private _betaTransition;
  43603. private _radiusTransition;
  43604. private _vectorTransition;
  43605. /**
  43606. * Targets the given mesh and updates zoom level accordingly.
  43607. * @param mesh The mesh to target.
  43608. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43609. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43610. */
  43611. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43612. /**
  43613. * Targets the given mesh with its children and updates zoom level accordingly.
  43614. * @param mesh The mesh to target.
  43615. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43616. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43617. */
  43618. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43619. /**
  43620. * Targets the given meshes with their children and updates zoom level accordingly.
  43621. * @param meshes The mesh to target.
  43622. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43623. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43624. */
  43625. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43626. /**
  43627. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43628. * @param minimumWorld Determines the smaller position of the bounding box extend
  43629. * @param maximumWorld Determines the bigger position of the bounding box extend
  43630. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43631. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43632. */
  43633. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43634. /**
  43635. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43636. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43637. * frustum width.
  43638. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43639. * to fully enclose the mesh in the viewing frustum.
  43640. */
  43641. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43642. /**
  43643. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43644. * is automatically returned to its default position (expected to be above ground plane).
  43645. */
  43646. private _maintainCameraAboveGround;
  43647. /**
  43648. * Returns the frustum slope based on the canvas ratio and camera FOV
  43649. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43650. */
  43651. private _getFrustumSlope;
  43652. /**
  43653. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43654. */
  43655. private _clearAnimationLocks;
  43656. /**
  43657. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43658. */
  43659. private _applyUserInteraction;
  43660. /**
  43661. * Stops and removes all animations that have been applied to the camera
  43662. */
  43663. stopAllAnimations(): void;
  43664. /**
  43665. * Gets a value indicating if the user is moving the camera
  43666. */
  43667. get isUserIsMoving(): boolean;
  43668. /**
  43669. * The camera can move all the way towards the mesh.
  43670. */
  43671. static IgnoreBoundsSizeMode: number;
  43672. /**
  43673. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43674. */
  43675. static FitFrustumSidesMode: number;
  43676. }
  43677. }
  43678. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43679. import { Nullable } from "babylonjs/types";
  43680. import { Camera } from "babylonjs/Cameras/camera";
  43681. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43682. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43683. /**
  43684. * Base class for Camera Pointer Inputs.
  43685. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43686. * for example usage.
  43687. */
  43688. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43689. /**
  43690. * Defines the camera the input is attached to.
  43691. */
  43692. abstract camera: Camera;
  43693. /**
  43694. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43695. */
  43696. protected _altKey: boolean;
  43697. protected _ctrlKey: boolean;
  43698. protected _metaKey: boolean;
  43699. protected _shiftKey: boolean;
  43700. /**
  43701. * Which mouse buttons were pressed at time of last mouse event.
  43702. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43703. */
  43704. protected _buttonsPressed: number;
  43705. /**
  43706. * Defines the buttons associated with the input to handle camera move.
  43707. */
  43708. buttons: number[];
  43709. /**
  43710. * Attach the input controls to a specific dom element to get the input from.
  43711. * @param element Defines the element the controls should be listened from
  43712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43713. */
  43714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43715. /**
  43716. * Detach the current controls from the specified dom element.
  43717. * @param element Defines the element to stop listening the inputs from
  43718. */
  43719. detachControl(element: Nullable<HTMLElement>): void;
  43720. /**
  43721. * Gets the class name of the current input.
  43722. * @returns the class name
  43723. */
  43724. getClassName(): string;
  43725. /**
  43726. * Get the friendly name associated with the input class.
  43727. * @returns the input friendly name
  43728. */
  43729. getSimpleName(): string;
  43730. /**
  43731. * Called on pointer POINTERDOUBLETAP event.
  43732. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43733. */
  43734. protected onDoubleTap(type: string): void;
  43735. /**
  43736. * Called on pointer POINTERMOVE event if only a single touch is active.
  43737. * Override this method to provide functionality.
  43738. */
  43739. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43740. /**
  43741. * Called on pointer POINTERMOVE event if multiple touches are active.
  43742. * Override this method to provide functionality.
  43743. */
  43744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43745. /**
  43746. * Called on JS contextmenu event.
  43747. * Override this method to provide functionality.
  43748. */
  43749. protected onContextMenu(evt: PointerEvent): void;
  43750. /**
  43751. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43752. * press.
  43753. * Override this method to provide functionality.
  43754. */
  43755. protected onButtonDown(evt: PointerEvent): void;
  43756. /**
  43757. * Called each time a new POINTERUP event occurs. Ie, for each button
  43758. * release.
  43759. * Override this method to provide functionality.
  43760. */
  43761. protected onButtonUp(evt: PointerEvent): void;
  43762. /**
  43763. * Called when window becomes inactive.
  43764. * Override this method to provide functionality.
  43765. */
  43766. protected onLostFocus(): void;
  43767. private _pointerInput;
  43768. private _observer;
  43769. private _onLostFocus;
  43770. private pointA;
  43771. private pointB;
  43772. }
  43773. }
  43774. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43775. import { Nullable } from "babylonjs/types";
  43776. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43777. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43778. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43779. /**
  43780. * Manage the pointers inputs to control an arc rotate camera.
  43781. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43782. */
  43783. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43784. /**
  43785. * Defines the camera the input is attached to.
  43786. */
  43787. camera: ArcRotateCamera;
  43788. /**
  43789. * Gets the class name of the current input.
  43790. * @returns the class name
  43791. */
  43792. getClassName(): string;
  43793. /**
  43794. * Defines the buttons associated with the input to handle camera move.
  43795. */
  43796. buttons: number[];
  43797. /**
  43798. * Defines the pointer angular sensibility along the X axis or how fast is
  43799. * the camera rotating.
  43800. */
  43801. angularSensibilityX: number;
  43802. /**
  43803. * Defines the pointer angular sensibility along the Y axis or how fast is
  43804. * the camera rotating.
  43805. */
  43806. angularSensibilityY: number;
  43807. /**
  43808. * Defines the pointer pinch precision or how fast is the camera zooming.
  43809. */
  43810. pinchPrecision: number;
  43811. /**
  43812. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43813. * from 0.
  43814. * It defines the percentage of current camera.radius to use as delta when
  43815. * pinch zoom is used.
  43816. */
  43817. pinchDeltaPercentage: number;
  43818. /**
  43819. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43820. * that any object in the plane at the camera's target point will scale
  43821. * perfectly with finger motion.
  43822. * Overrides pinchDeltaPercentage and pinchPrecision.
  43823. */
  43824. useNaturalPinchZoom: boolean;
  43825. /**
  43826. * Defines the pointer panning sensibility or how fast is the camera moving.
  43827. */
  43828. panningSensibility: number;
  43829. /**
  43830. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43831. */
  43832. multiTouchPanning: boolean;
  43833. /**
  43834. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43835. * zoom (pinch) through multitouch.
  43836. */
  43837. multiTouchPanAndZoom: boolean;
  43838. /**
  43839. * Revers pinch action direction.
  43840. */
  43841. pinchInwards: boolean;
  43842. private _isPanClick;
  43843. private _twoFingerActivityCount;
  43844. private _isPinching;
  43845. /**
  43846. * Called on pointer POINTERMOVE event if only a single touch is active.
  43847. */
  43848. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43849. /**
  43850. * Called on pointer POINTERDOUBLETAP event.
  43851. */
  43852. protected onDoubleTap(type: string): void;
  43853. /**
  43854. * Called on pointer POINTERMOVE event if multiple touches are active.
  43855. */
  43856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43857. /**
  43858. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43859. * press.
  43860. */
  43861. protected onButtonDown(evt: PointerEvent): void;
  43862. /**
  43863. * Called each time a new POINTERUP event occurs. Ie, for each button
  43864. * release.
  43865. */
  43866. protected onButtonUp(evt: PointerEvent): void;
  43867. /**
  43868. * Called when window becomes inactive.
  43869. */
  43870. protected onLostFocus(): void;
  43871. }
  43872. }
  43873. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43874. import { Nullable } from "babylonjs/types";
  43875. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43876. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43877. /**
  43878. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43880. */
  43881. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43882. /**
  43883. * Defines the camera the input is attached to.
  43884. */
  43885. camera: ArcRotateCamera;
  43886. /**
  43887. * Defines the list of key codes associated with the up action (increase alpha)
  43888. */
  43889. keysUp: number[];
  43890. /**
  43891. * Defines the list of key codes associated with the down action (decrease alpha)
  43892. */
  43893. keysDown: number[];
  43894. /**
  43895. * Defines the list of key codes associated with the left action (increase beta)
  43896. */
  43897. keysLeft: number[];
  43898. /**
  43899. * Defines the list of key codes associated with the right action (decrease beta)
  43900. */
  43901. keysRight: number[];
  43902. /**
  43903. * Defines the list of key codes associated with the reset action.
  43904. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43905. */
  43906. keysReset: number[];
  43907. /**
  43908. * Defines the panning sensibility of the inputs.
  43909. * (How fast is the camera panning)
  43910. */
  43911. panningSensibility: number;
  43912. /**
  43913. * Defines the zooming sensibility of the inputs.
  43914. * (How fast is the camera zooming)
  43915. */
  43916. zoomingSensibility: number;
  43917. /**
  43918. * Defines whether maintaining the alt key down switch the movement mode from
  43919. * orientation to zoom.
  43920. */
  43921. useAltToZoom: boolean;
  43922. /**
  43923. * Rotation speed of the camera
  43924. */
  43925. angularSpeed: number;
  43926. private _keys;
  43927. private _ctrlPressed;
  43928. private _altPressed;
  43929. private _onCanvasBlurObserver;
  43930. private _onKeyboardObserver;
  43931. private _engine;
  43932. private _scene;
  43933. /**
  43934. * Attach the input controls to a specific dom element to get the input from.
  43935. * @param element Defines the element the controls should be listened from
  43936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43937. */
  43938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43939. /**
  43940. * Detach the current controls from the specified dom element.
  43941. * @param element Defines the element to stop listening the inputs from
  43942. */
  43943. detachControl(element: Nullable<HTMLElement>): void;
  43944. /**
  43945. * Update the current camera state depending on the inputs that have been used this frame.
  43946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43947. */
  43948. checkInputs(): void;
  43949. /**
  43950. * Gets the class name of the current intput.
  43951. * @returns the class name
  43952. */
  43953. getClassName(): string;
  43954. /**
  43955. * Get the friendly name associated with the input class.
  43956. * @returns the input friendly name
  43957. */
  43958. getSimpleName(): string;
  43959. }
  43960. }
  43961. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43962. import { Nullable } from "babylonjs/types";
  43963. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43964. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43965. /**
  43966. * Manage the mouse wheel inputs to control an arc rotate camera.
  43967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43968. */
  43969. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43970. /**
  43971. * Defines the camera the input is attached to.
  43972. */
  43973. camera: ArcRotateCamera;
  43974. /**
  43975. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43976. */
  43977. wheelPrecision: number;
  43978. /**
  43979. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43980. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43981. */
  43982. wheelDeltaPercentage: number;
  43983. private _wheel;
  43984. private _observer;
  43985. private computeDeltaFromMouseWheelLegacyEvent;
  43986. /**
  43987. * Attach the input controls to a specific dom element to get the input from.
  43988. * @param element Defines the element the controls should be listened from
  43989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43990. */
  43991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43992. /**
  43993. * Detach the current controls from the specified dom element.
  43994. * @param element Defines the element to stop listening the inputs from
  43995. */
  43996. detachControl(element: Nullable<HTMLElement>): void;
  43997. /**
  43998. * Gets the class name of the current intput.
  43999. * @returns the class name
  44000. */
  44001. getClassName(): string;
  44002. /**
  44003. * Get the friendly name associated with the input class.
  44004. * @returns the input friendly name
  44005. */
  44006. getSimpleName(): string;
  44007. }
  44008. }
  44009. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44010. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44011. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44012. /**
  44013. * Default Inputs manager for the ArcRotateCamera.
  44014. * It groups all the default supported inputs for ease of use.
  44015. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44016. */
  44017. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44018. /**
  44019. * Instantiates a new ArcRotateCameraInputsManager.
  44020. * @param camera Defines the camera the inputs belong to
  44021. */
  44022. constructor(camera: ArcRotateCamera);
  44023. /**
  44024. * Add mouse wheel input support to the input manager.
  44025. * @returns the current input manager
  44026. */
  44027. addMouseWheel(): ArcRotateCameraInputsManager;
  44028. /**
  44029. * Add pointers input support to the input manager.
  44030. * @returns the current input manager
  44031. */
  44032. addPointers(): ArcRotateCameraInputsManager;
  44033. /**
  44034. * Add keyboard input support to the input manager.
  44035. * @returns the current input manager
  44036. */
  44037. addKeyboard(): ArcRotateCameraInputsManager;
  44038. }
  44039. }
  44040. declare module "babylonjs/Cameras/arcRotateCamera" {
  44041. import { Observable } from "babylonjs/Misc/observable";
  44042. import { Nullable } from "babylonjs/types";
  44043. import { Scene } from "babylonjs/scene";
  44044. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44046. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44047. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44048. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44049. import { Camera } from "babylonjs/Cameras/camera";
  44050. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44051. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44052. import { Collider } from "babylonjs/Collisions/collider";
  44053. /**
  44054. * This represents an orbital type of camera.
  44055. *
  44056. * 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.
  44057. * 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.
  44058. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44059. */
  44060. export class ArcRotateCamera extends TargetCamera {
  44061. /**
  44062. * Defines the rotation angle of the camera along the longitudinal axis.
  44063. */
  44064. alpha: number;
  44065. /**
  44066. * Defines the rotation angle of the camera along the latitudinal axis.
  44067. */
  44068. beta: number;
  44069. /**
  44070. * Defines the radius of the camera from it s target point.
  44071. */
  44072. radius: number;
  44073. protected _target: Vector3;
  44074. protected _targetHost: Nullable<AbstractMesh>;
  44075. /**
  44076. * Defines the target point of the camera.
  44077. * The camera looks towards it form the radius distance.
  44078. */
  44079. get target(): Vector3;
  44080. set target(value: Vector3);
  44081. /**
  44082. * Define the current local position of the camera in the scene
  44083. */
  44084. get position(): Vector3;
  44085. set position(newPosition: Vector3);
  44086. protected _upVector: Vector3;
  44087. protected _upToYMatrix: Matrix;
  44088. protected _YToUpMatrix: Matrix;
  44089. /**
  44090. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44091. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44092. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44093. */
  44094. set upVector(vec: Vector3);
  44095. get upVector(): Vector3;
  44096. /**
  44097. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44098. */
  44099. setMatUp(): void;
  44100. /**
  44101. * Current inertia value on the longitudinal axis.
  44102. * The bigger this number the longer it will take for the camera to stop.
  44103. */
  44104. inertialAlphaOffset: number;
  44105. /**
  44106. * Current inertia value on the latitudinal axis.
  44107. * The bigger this number the longer it will take for the camera to stop.
  44108. */
  44109. inertialBetaOffset: number;
  44110. /**
  44111. * Current inertia value on the radius axis.
  44112. * The bigger this number the longer it will take for the camera to stop.
  44113. */
  44114. inertialRadiusOffset: number;
  44115. /**
  44116. * Minimum allowed angle on the longitudinal axis.
  44117. * This can help limiting how the Camera is able to move in the scene.
  44118. */
  44119. lowerAlphaLimit: Nullable<number>;
  44120. /**
  44121. * Maximum allowed angle on the longitudinal axis.
  44122. * This can help limiting how the Camera is able to move in the scene.
  44123. */
  44124. upperAlphaLimit: Nullable<number>;
  44125. /**
  44126. * Minimum allowed angle on the latitudinal axis.
  44127. * This can help limiting how the Camera is able to move in the scene.
  44128. */
  44129. lowerBetaLimit: number;
  44130. /**
  44131. * Maximum allowed angle on the latitudinal axis.
  44132. * This can help limiting how the Camera is able to move in the scene.
  44133. */
  44134. upperBetaLimit: number;
  44135. /**
  44136. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44137. * This can help limiting how the Camera is able to move in the scene.
  44138. */
  44139. lowerRadiusLimit: Nullable<number>;
  44140. /**
  44141. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44142. * This can help limiting how the Camera is able to move in the scene.
  44143. */
  44144. upperRadiusLimit: Nullable<number>;
  44145. /**
  44146. * Defines the current inertia value used during panning of the camera along the X axis.
  44147. */
  44148. inertialPanningX: number;
  44149. /**
  44150. * Defines the current inertia value used during panning of the camera along the Y axis.
  44151. */
  44152. inertialPanningY: number;
  44153. /**
  44154. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44155. * Basically if your fingers moves away from more than this distance you will be considered
  44156. * in pinch mode.
  44157. */
  44158. pinchToPanMaxDistance: number;
  44159. /**
  44160. * Defines the maximum distance the camera can pan.
  44161. * This could help keeping the cammera always in your scene.
  44162. */
  44163. panningDistanceLimit: Nullable<number>;
  44164. /**
  44165. * Defines the target of the camera before paning.
  44166. */
  44167. panningOriginTarget: Vector3;
  44168. /**
  44169. * Defines the value of the inertia used during panning.
  44170. * 0 would mean stop inertia and one would mean no decelleration at all.
  44171. */
  44172. panningInertia: number;
  44173. /**
  44174. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44175. */
  44176. get angularSensibilityX(): number;
  44177. set angularSensibilityX(value: number);
  44178. /**
  44179. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44180. */
  44181. get angularSensibilityY(): number;
  44182. set angularSensibilityY(value: number);
  44183. /**
  44184. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44185. */
  44186. get pinchPrecision(): number;
  44187. set pinchPrecision(value: number);
  44188. /**
  44189. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44190. * It will be used instead of pinchDeltaPrecision if different from 0.
  44191. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44192. */
  44193. get pinchDeltaPercentage(): number;
  44194. set pinchDeltaPercentage(value: number);
  44195. /**
  44196. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44197. * and pinch delta percentage.
  44198. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44199. * that any object in the plane at the camera's target point will scale
  44200. * perfectly with finger motion.
  44201. */
  44202. get useNaturalPinchZoom(): boolean;
  44203. set useNaturalPinchZoom(value: boolean);
  44204. /**
  44205. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44206. */
  44207. get panningSensibility(): number;
  44208. set panningSensibility(value: number);
  44209. /**
  44210. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44211. */
  44212. get keysUp(): number[];
  44213. set keysUp(value: number[]);
  44214. /**
  44215. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44216. */
  44217. get keysDown(): number[];
  44218. set keysDown(value: number[]);
  44219. /**
  44220. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44221. */
  44222. get keysLeft(): number[];
  44223. set keysLeft(value: number[]);
  44224. /**
  44225. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44226. */
  44227. get keysRight(): number[];
  44228. set keysRight(value: number[]);
  44229. /**
  44230. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44231. */
  44232. get wheelPrecision(): number;
  44233. set wheelPrecision(value: number);
  44234. /**
  44235. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44236. * It will be used instead of pinchDeltaPrecision if different from 0.
  44237. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44238. */
  44239. get wheelDeltaPercentage(): number;
  44240. set wheelDeltaPercentage(value: number);
  44241. /**
  44242. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44243. */
  44244. zoomOnFactor: number;
  44245. /**
  44246. * Defines a screen offset for the camera position.
  44247. */
  44248. targetScreenOffset: Vector2;
  44249. /**
  44250. * Allows the camera to be completely reversed.
  44251. * If false the camera can not arrive upside down.
  44252. */
  44253. allowUpsideDown: boolean;
  44254. /**
  44255. * Define if double tap/click is used to restore the previously saved state of the camera.
  44256. */
  44257. useInputToRestoreState: boolean;
  44258. /** @hidden */
  44259. _viewMatrix: Matrix;
  44260. /** @hidden */
  44261. _useCtrlForPanning: boolean;
  44262. /** @hidden */
  44263. _panningMouseButton: number;
  44264. /**
  44265. * Defines the input associated to the camera.
  44266. */
  44267. inputs: ArcRotateCameraInputsManager;
  44268. /** @hidden */
  44269. _reset: () => void;
  44270. /**
  44271. * Defines the allowed panning axis.
  44272. */
  44273. panningAxis: Vector3;
  44274. protected _localDirection: Vector3;
  44275. protected _transformedDirection: Vector3;
  44276. private _bouncingBehavior;
  44277. /**
  44278. * Gets the bouncing behavior of the camera if it has been enabled.
  44279. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44280. */
  44281. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44282. /**
  44283. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44284. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44285. */
  44286. get useBouncingBehavior(): boolean;
  44287. set useBouncingBehavior(value: boolean);
  44288. private _framingBehavior;
  44289. /**
  44290. * Gets the framing behavior of the camera if it has been enabled.
  44291. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44292. */
  44293. get framingBehavior(): Nullable<FramingBehavior>;
  44294. /**
  44295. * Defines if the framing behavior of the camera is enabled on the camera.
  44296. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44297. */
  44298. get useFramingBehavior(): boolean;
  44299. set useFramingBehavior(value: boolean);
  44300. private _autoRotationBehavior;
  44301. /**
  44302. * Gets the auto rotation behavior of the camera if it has been enabled.
  44303. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44304. */
  44305. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44306. /**
  44307. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44308. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44309. */
  44310. get useAutoRotationBehavior(): boolean;
  44311. set useAutoRotationBehavior(value: boolean);
  44312. /**
  44313. * Observable triggered when the mesh target has been changed on the camera.
  44314. */
  44315. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44316. /**
  44317. * Event raised when the camera is colliding with a mesh.
  44318. */
  44319. onCollide: (collidedMesh: AbstractMesh) => void;
  44320. /**
  44321. * Defines whether the camera should check collision with the objects oh the scene.
  44322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44323. */
  44324. checkCollisions: boolean;
  44325. /**
  44326. * Defines the collision radius of the camera.
  44327. * This simulates a sphere around the camera.
  44328. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44329. */
  44330. collisionRadius: Vector3;
  44331. protected _collider: Collider;
  44332. protected _previousPosition: Vector3;
  44333. protected _collisionVelocity: Vector3;
  44334. protected _newPosition: Vector3;
  44335. protected _previousAlpha: number;
  44336. protected _previousBeta: number;
  44337. protected _previousRadius: number;
  44338. protected _collisionTriggered: boolean;
  44339. protected _targetBoundingCenter: Nullable<Vector3>;
  44340. private _computationVector;
  44341. /**
  44342. * Instantiates a new ArcRotateCamera in a given scene
  44343. * @param name Defines the name of the camera
  44344. * @param alpha Defines the camera rotation along the logitudinal axis
  44345. * @param beta Defines the camera rotation along the latitudinal axis
  44346. * @param radius Defines the camera distance from its target
  44347. * @param target Defines the camera target
  44348. * @param scene Defines the scene the camera belongs to
  44349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44350. */
  44351. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44352. /** @hidden */
  44353. _initCache(): void;
  44354. /** @hidden */
  44355. _updateCache(ignoreParentClass?: boolean): void;
  44356. protected _getTargetPosition(): Vector3;
  44357. private _storedAlpha;
  44358. private _storedBeta;
  44359. private _storedRadius;
  44360. private _storedTarget;
  44361. private _storedTargetScreenOffset;
  44362. /**
  44363. * Stores the current state of the camera (alpha, beta, radius and target)
  44364. * @returns the camera itself
  44365. */
  44366. storeState(): Camera;
  44367. /**
  44368. * @hidden
  44369. * Restored camera state. You must call storeState() first
  44370. */
  44371. _restoreStateValues(): boolean;
  44372. /** @hidden */
  44373. _isSynchronizedViewMatrix(): boolean;
  44374. /**
  44375. * Attached controls to the current camera.
  44376. * @param element Defines the element the controls should be listened from
  44377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44378. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44379. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44380. */
  44381. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44382. /**
  44383. * Detach the current controls from the camera.
  44384. * The camera will stop reacting to inputs.
  44385. * @param element Defines the element to stop listening the inputs from
  44386. */
  44387. detachControl(element: HTMLElement): void;
  44388. /** @hidden */
  44389. _checkInputs(): void;
  44390. protected _checkLimits(): void;
  44391. /**
  44392. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44393. */
  44394. rebuildAnglesAndRadius(): void;
  44395. /**
  44396. * Use a position to define the current camera related information like alpha, beta and radius
  44397. * @param position Defines the position to set the camera at
  44398. */
  44399. setPosition(position: Vector3): void;
  44400. /**
  44401. * Defines the target the camera should look at.
  44402. * This will automatically adapt alpha beta and radius to fit within the new target.
  44403. * @param target Defines the new target as a Vector or a mesh
  44404. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44405. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44406. */
  44407. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44408. /** @hidden */
  44409. _getViewMatrix(): Matrix;
  44410. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44411. /**
  44412. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44413. * @param meshes Defines the mesh to zoom on
  44414. * @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)
  44415. */
  44416. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44417. /**
  44418. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44419. * The target will be changed but the radius
  44420. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44421. * @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)
  44422. */
  44423. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44424. min: Vector3;
  44425. max: Vector3;
  44426. distance: number;
  44427. }, doNotUpdateMaxZ?: boolean): void;
  44428. /**
  44429. * @override
  44430. * Override Camera.createRigCamera
  44431. */
  44432. createRigCamera(name: string, cameraIndex: number): Camera;
  44433. /**
  44434. * @hidden
  44435. * @override
  44436. * Override Camera._updateRigCameras
  44437. */
  44438. _updateRigCameras(): void;
  44439. /**
  44440. * Destroy the camera and release the current resources hold by it.
  44441. */
  44442. dispose(): void;
  44443. /**
  44444. * Gets the current object class name.
  44445. * @return the class name
  44446. */
  44447. getClassName(): string;
  44448. }
  44449. }
  44450. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44451. import { Behavior } from "babylonjs/Behaviors/behavior";
  44452. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44453. /**
  44454. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44455. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44456. */
  44457. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44458. /**
  44459. * Gets the name of the behavior.
  44460. */
  44461. get name(): string;
  44462. private _zoomStopsAnimation;
  44463. private _idleRotationSpeed;
  44464. private _idleRotationWaitTime;
  44465. private _idleRotationSpinupTime;
  44466. /**
  44467. * Sets the flag that indicates if user zooming should stop animation.
  44468. */
  44469. set zoomStopsAnimation(flag: boolean);
  44470. /**
  44471. * Gets the flag that indicates if user zooming should stop animation.
  44472. */
  44473. get zoomStopsAnimation(): boolean;
  44474. /**
  44475. * Sets the default speed at which the camera rotates around the model.
  44476. */
  44477. set idleRotationSpeed(speed: number);
  44478. /**
  44479. * Gets the default speed at which the camera rotates around the model.
  44480. */
  44481. get idleRotationSpeed(): number;
  44482. /**
  44483. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44484. */
  44485. set idleRotationWaitTime(time: number);
  44486. /**
  44487. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44488. */
  44489. get idleRotationWaitTime(): number;
  44490. /**
  44491. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44492. */
  44493. set idleRotationSpinupTime(time: number);
  44494. /**
  44495. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44496. */
  44497. get idleRotationSpinupTime(): number;
  44498. /**
  44499. * Gets a value indicating if the camera is currently rotating because of this behavior
  44500. */
  44501. get rotationInProgress(): boolean;
  44502. private _onPrePointerObservableObserver;
  44503. private _onAfterCheckInputsObserver;
  44504. private _attachedCamera;
  44505. private _isPointerDown;
  44506. private _lastFrameTime;
  44507. private _lastInteractionTime;
  44508. private _cameraRotationSpeed;
  44509. /**
  44510. * Initializes the behavior.
  44511. */
  44512. init(): void;
  44513. /**
  44514. * Attaches the behavior to its arc rotate camera.
  44515. * @param camera Defines the camera to attach the behavior to
  44516. */
  44517. attach(camera: ArcRotateCamera): void;
  44518. /**
  44519. * Detaches the behavior from its current arc rotate camera.
  44520. */
  44521. detach(): void;
  44522. /**
  44523. * Returns true if user is scrolling.
  44524. * @return true if user is scrolling.
  44525. */
  44526. private _userIsZooming;
  44527. private _lastFrameRadius;
  44528. private _shouldAnimationStopForInteraction;
  44529. /**
  44530. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44531. */
  44532. private _applyUserInteraction;
  44533. private _userIsMoving;
  44534. }
  44535. }
  44536. declare module "babylonjs/Behaviors/Cameras/index" {
  44537. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44538. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44539. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44540. }
  44541. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44542. import { Mesh } from "babylonjs/Meshes/mesh";
  44543. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44544. import { Behavior } from "babylonjs/Behaviors/behavior";
  44545. /**
  44546. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44547. */
  44548. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44549. private ui;
  44550. /**
  44551. * The name of the behavior
  44552. */
  44553. name: string;
  44554. /**
  44555. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44556. */
  44557. distanceAwayFromFace: number;
  44558. /**
  44559. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44560. */
  44561. distanceAwayFromBottomOfFace: number;
  44562. private _faceVectors;
  44563. private _target;
  44564. private _scene;
  44565. private _onRenderObserver;
  44566. private _tmpMatrix;
  44567. private _tmpVector;
  44568. /**
  44569. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44570. * @param ui The transform node that should be attched to the mesh
  44571. */
  44572. constructor(ui: TransformNode);
  44573. /**
  44574. * Initializes the behavior
  44575. */
  44576. init(): void;
  44577. private _closestFace;
  44578. private _zeroVector;
  44579. private _lookAtTmpMatrix;
  44580. private _lookAtToRef;
  44581. /**
  44582. * Attaches the AttachToBoxBehavior to the passed in mesh
  44583. * @param target The mesh that the specified node will be attached to
  44584. */
  44585. attach(target: Mesh): void;
  44586. /**
  44587. * Detaches the behavior from the mesh
  44588. */
  44589. detach(): void;
  44590. }
  44591. }
  44592. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44593. import { Behavior } from "babylonjs/Behaviors/behavior";
  44594. import { Mesh } from "babylonjs/Meshes/mesh";
  44595. /**
  44596. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44597. */
  44598. export class FadeInOutBehavior implements Behavior<Mesh> {
  44599. /**
  44600. * Time in milliseconds to delay before fading in (Default: 0)
  44601. */
  44602. delay: number;
  44603. /**
  44604. * Time in milliseconds for the mesh to fade in (Default: 300)
  44605. */
  44606. fadeInTime: number;
  44607. private _millisecondsPerFrame;
  44608. private _hovered;
  44609. private _hoverValue;
  44610. private _ownerNode;
  44611. /**
  44612. * Instatiates the FadeInOutBehavior
  44613. */
  44614. constructor();
  44615. /**
  44616. * The name of the behavior
  44617. */
  44618. get name(): string;
  44619. /**
  44620. * Initializes the behavior
  44621. */
  44622. init(): void;
  44623. /**
  44624. * Attaches the fade behavior on the passed in mesh
  44625. * @param ownerNode The mesh that will be faded in/out once attached
  44626. */
  44627. attach(ownerNode: Mesh): void;
  44628. /**
  44629. * Detaches the behavior from the mesh
  44630. */
  44631. detach(): void;
  44632. /**
  44633. * Triggers the mesh to begin fading in or out
  44634. * @param value if the object should fade in or out (true to fade in)
  44635. */
  44636. fadeIn(value: boolean): void;
  44637. private _update;
  44638. private _setAllVisibility;
  44639. }
  44640. }
  44641. declare module "babylonjs/Misc/pivotTools" {
  44642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44643. /**
  44644. * Class containing a set of static utilities functions for managing Pivots
  44645. * @hidden
  44646. */
  44647. export class PivotTools {
  44648. private static _PivotCached;
  44649. private static _OldPivotPoint;
  44650. private static _PivotTranslation;
  44651. private static _PivotTmpVector;
  44652. /** @hidden */
  44653. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44654. /** @hidden */
  44655. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44656. }
  44657. }
  44658. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44659. import { Scene } from "babylonjs/scene";
  44660. import { Vector4 } from "babylonjs/Maths/math.vector";
  44661. import { Mesh } from "babylonjs/Meshes/mesh";
  44662. import { Nullable } from "babylonjs/types";
  44663. import { Plane } from "babylonjs/Maths/math.plane";
  44664. /**
  44665. * Class containing static functions to help procedurally build meshes
  44666. */
  44667. export class PlaneBuilder {
  44668. /**
  44669. * Creates a plane mesh
  44670. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44671. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44672. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44676. * @param name defines the name of the mesh
  44677. * @param options defines the options used to create the mesh
  44678. * @param scene defines the hosting scene
  44679. * @returns the plane mesh
  44680. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44681. */
  44682. static CreatePlane(name: string, options: {
  44683. size?: number;
  44684. width?: number;
  44685. height?: number;
  44686. sideOrientation?: number;
  44687. frontUVs?: Vector4;
  44688. backUVs?: Vector4;
  44689. updatable?: boolean;
  44690. sourcePlane?: Plane;
  44691. }, scene?: Nullable<Scene>): Mesh;
  44692. }
  44693. }
  44694. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44695. import { Behavior } from "babylonjs/Behaviors/behavior";
  44696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44697. import { Observable } from "babylonjs/Misc/observable";
  44698. import { Vector3 } from "babylonjs/Maths/math.vector";
  44699. import { Ray } from "babylonjs/Culling/ray";
  44700. import "babylonjs/Meshes/Builders/planeBuilder";
  44701. /**
  44702. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44703. */
  44704. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44705. private static _AnyMouseID;
  44706. /**
  44707. * Abstract mesh the behavior is set on
  44708. */
  44709. attachedNode: AbstractMesh;
  44710. private _dragPlane;
  44711. private _scene;
  44712. private _pointerObserver;
  44713. private _beforeRenderObserver;
  44714. private static _planeScene;
  44715. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44716. /**
  44717. * 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)
  44718. */
  44719. maxDragAngle: number;
  44720. /**
  44721. * @hidden
  44722. */
  44723. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44724. /**
  44725. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44726. */
  44727. currentDraggingPointerID: number;
  44728. /**
  44729. * The last position where the pointer hit the drag plane in world space
  44730. */
  44731. lastDragPosition: Vector3;
  44732. /**
  44733. * If the behavior is currently in a dragging state
  44734. */
  44735. dragging: boolean;
  44736. /**
  44737. * 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)
  44738. */
  44739. dragDeltaRatio: number;
  44740. /**
  44741. * If the drag plane orientation should be updated during the dragging (Default: true)
  44742. */
  44743. updateDragPlane: boolean;
  44744. private _debugMode;
  44745. private _moving;
  44746. /**
  44747. * Fires each time the attached mesh is dragged with the pointer
  44748. * * delta between last drag position and current drag position in world space
  44749. * * dragDistance along the drag axis
  44750. * * dragPlaneNormal normal of the current drag plane used during the drag
  44751. * * dragPlanePoint in world space where the drag intersects the drag plane
  44752. */
  44753. onDragObservable: Observable<{
  44754. delta: Vector3;
  44755. dragPlanePoint: Vector3;
  44756. dragPlaneNormal: Vector3;
  44757. dragDistance: number;
  44758. pointerId: number;
  44759. }>;
  44760. /**
  44761. * Fires each time a drag begins (eg. mouse down on mesh)
  44762. */
  44763. onDragStartObservable: Observable<{
  44764. dragPlanePoint: Vector3;
  44765. pointerId: number;
  44766. }>;
  44767. /**
  44768. * Fires each time a drag ends (eg. mouse release after drag)
  44769. */
  44770. onDragEndObservable: Observable<{
  44771. dragPlanePoint: Vector3;
  44772. pointerId: number;
  44773. }>;
  44774. /**
  44775. * If the attached mesh should be moved when dragged
  44776. */
  44777. moveAttached: boolean;
  44778. /**
  44779. * If the drag behavior will react to drag events (Default: true)
  44780. */
  44781. enabled: boolean;
  44782. /**
  44783. * If pointer events should start and release the drag (Default: true)
  44784. */
  44785. startAndReleaseDragOnPointerEvents: boolean;
  44786. /**
  44787. * If camera controls should be detached during the drag
  44788. */
  44789. detachCameraControls: boolean;
  44790. /**
  44791. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44792. */
  44793. useObjectOrientationForDragging: boolean;
  44794. private _options;
  44795. /**
  44796. * Gets the options used by the behavior
  44797. */
  44798. get options(): {
  44799. dragAxis?: Vector3;
  44800. dragPlaneNormal?: Vector3;
  44801. };
  44802. /**
  44803. * Sets the options used by the behavior
  44804. */
  44805. set options(options: {
  44806. dragAxis?: Vector3;
  44807. dragPlaneNormal?: Vector3;
  44808. });
  44809. /**
  44810. * Creates a pointer drag behavior that can be attached to a mesh
  44811. * @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)
  44812. */
  44813. constructor(options?: {
  44814. dragAxis?: Vector3;
  44815. dragPlaneNormal?: Vector3;
  44816. });
  44817. /**
  44818. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44819. */
  44820. validateDrag: (targetPosition: Vector3) => boolean;
  44821. /**
  44822. * The name of the behavior
  44823. */
  44824. get name(): string;
  44825. /**
  44826. * Initializes the behavior
  44827. */
  44828. init(): void;
  44829. private _tmpVector;
  44830. private _alternatePickedPoint;
  44831. private _worldDragAxis;
  44832. private _targetPosition;
  44833. private _attachedElement;
  44834. /**
  44835. * Attaches the drag behavior the passed in mesh
  44836. * @param ownerNode The mesh that will be dragged around once attached
  44837. * @param predicate Predicate to use for pick filtering
  44838. */
  44839. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44840. /**
  44841. * Force relase the drag action by code.
  44842. */
  44843. releaseDrag(): void;
  44844. private _startDragRay;
  44845. private _lastPointerRay;
  44846. /**
  44847. * Simulates the start of a pointer drag event on the behavior
  44848. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44849. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44850. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44851. */
  44852. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44853. private _startDrag;
  44854. private _dragDelta;
  44855. private _moveDrag;
  44856. private _pickWithRayOnDragPlane;
  44857. private _pointA;
  44858. private _pointC;
  44859. private _localAxis;
  44860. private _lookAt;
  44861. private _updateDragPlanePosition;
  44862. /**
  44863. * Detaches the behavior from the mesh
  44864. */
  44865. detach(): void;
  44866. }
  44867. }
  44868. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44869. import { Mesh } from "babylonjs/Meshes/mesh";
  44870. import { Behavior } from "babylonjs/Behaviors/behavior";
  44871. /**
  44872. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44873. */
  44874. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44875. private _dragBehaviorA;
  44876. private _dragBehaviorB;
  44877. private _startDistance;
  44878. private _initialScale;
  44879. private _targetScale;
  44880. private _ownerNode;
  44881. private _sceneRenderObserver;
  44882. /**
  44883. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44884. */
  44885. constructor();
  44886. /**
  44887. * The name of the behavior
  44888. */
  44889. get name(): string;
  44890. /**
  44891. * Initializes the behavior
  44892. */
  44893. init(): void;
  44894. private _getCurrentDistance;
  44895. /**
  44896. * Attaches the scale behavior the passed in mesh
  44897. * @param ownerNode The mesh that will be scaled around once attached
  44898. */
  44899. attach(ownerNode: Mesh): void;
  44900. /**
  44901. * Detaches the behavior from the mesh
  44902. */
  44903. detach(): void;
  44904. }
  44905. }
  44906. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44907. import { Behavior } from "babylonjs/Behaviors/behavior";
  44908. import { Mesh } from "babylonjs/Meshes/mesh";
  44909. import { Observable } from "babylonjs/Misc/observable";
  44910. /**
  44911. * 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
  44912. */
  44913. export class SixDofDragBehavior implements Behavior<Mesh> {
  44914. private static _virtualScene;
  44915. private _ownerNode;
  44916. private _sceneRenderObserver;
  44917. private _scene;
  44918. private _targetPosition;
  44919. private _virtualOriginMesh;
  44920. private _virtualDragMesh;
  44921. private _pointerObserver;
  44922. private _moving;
  44923. private _startingOrientation;
  44924. private _attachedElement;
  44925. /**
  44926. * 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)
  44927. */
  44928. private zDragFactor;
  44929. /**
  44930. * If the object should rotate to face the drag origin
  44931. */
  44932. rotateDraggedObject: boolean;
  44933. /**
  44934. * If the behavior is currently in a dragging state
  44935. */
  44936. dragging: boolean;
  44937. /**
  44938. * 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)
  44939. */
  44940. dragDeltaRatio: number;
  44941. /**
  44942. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44943. */
  44944. currentDraggingPointerID: number;
  44945. /**
  44946. * If camera controls should be detached during the drag
  44947. */
  44948. detachCameraControls: boolean;
  44949. /**
  44950. * Fires each time a drag starts
  44951. */
  44952. onDragStartObservable: Observable<{}>;
  44953. /**
  44954. * Fires each time a drag ends (eg. mouse release after drag)
  44955. */
  44956. onDragEndObservable: Observable<{}>;
  44957. /**
  44958. * 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
  44959. */
  44960. constructor();
  44961. /**
  44962. * The name of the behavior
  44963. */
  44964. get name(): string;
  44965. /**
  44966. * Initializes the behavior
  44967. */
  44968. init(): void;
  44969. /**
  44970. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44971. */
  44972. private get _pointerCamera();
  44973. /**
  44974. * Attaches the scale behavior the passed in mesh
  44975. * @param ownerNode The mesh that will be scaled around once attached
  44976. */
  44977. attach(ownerNode: Mesh): void;
  44978. /**
  44979. * Detaches the behavior from the mesh
  44980. */
  44981. detach(): void;
  44982. }
  44983. }
  44984. declare module "babylonjs/Behaviors/Meshes/index" {
  44985. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44986. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44987. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44988. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44989. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44990. }
  44991. declare module "babylonjs/Behaviors/index" {
  44992. export * from "babylonjs/Behaviors/behavior";
  44993. export * from "babylonjs/Behaviors/Cameras/index";
  44994. export * from "babylonjs/Behaviors/Meshes/index";
  44995. }
  44996. declare module "babylonjs/Bones/boneIKController" {
  44997. import { Bone } from "babylonjs/Bones/bone";
  44998. import { Vector3 } from "babylonjs/Maths/math.vector";
  44999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45000. import { Nullable } from "babylonjs/types";
  45001. /**
  45002. * Class used to apply inverse kinematics to bones
  45003. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45004. */
  45005. export class BoneIKController {
  45006. private static _tmpVecs;
  45007. private static _tmpQuat;
  45008. private static _tmpMats;
  45009. /**
  45010. * Gets or sets the target mesh
  45011. */
  45012. targetMesh: AbstractMesh;
  45013. /** Gets or sets the mesh used as pole */
  45014. poleTargetMesh: AbstractMesh;
  45015. /**
  45016. * Gets or sets the bone used as pole
  45017. */
  45018. poleTargetBone: Nullable<Bone>;
  45019. /**
  45020. * Gets or sets the target position
  45021. */
  45022. targetPosition: Vector3;
  45023. /**
  45024. * Gets or sets the pole target position
  45025. */
  45026. poleTargetPosition: Vector3;
  45027. /**
  45028. * Gets or sets the pole target local offset
  45029. */
  45030. poleTargetLocalOffset: Vector3;
  45031. /**
  45032. * Gets or sets the pole angle
  45033. */
  45034. poleAngle: number;
  45035. /**
  45036. * Gets or sets the mesh associated with the controller
  45037. */
  45038. mesh: AbstractMesh;
  45039. /**
  45040. * 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)
  45041. */
  45042. slerpAmount: number;
  45043. private _bone1Quat;
  45044. private _bone1Mat;
  45045. private _bone2Ang;
  45046. private _bone1;
  45047. private _bone2;
  45048. private _bone1Length;
  45049. private _bone2Length;
  45050. private _maxAngle;
  45051. private _maxReach;
  45052. private _rightHandedSystem;
  45053. private _bendAxis;
  45054. private _slerping;
  45055. private _adjustRoll;
  45056. /**
  45057. * Gets or sets maximum allowed angle
  45058. */
  45059. get maxAngle(): number;
  45060. set maxAngle(value: number);
  45061. /**
  45062. * Creates a new BoneIKController
  45063. * @param mesh defines the mesh to control
  45064. * @param bone defines the bone to control
  45065. * @param options defines options to set up the controller
  45066. */
  45067. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45068. targetMesh?: AbstractMesh;
  45069. poleTargetMesh?: AbstractMesh;
  45070. poleTargetBone?: Bone;
  45071. poleTargetLocalOffset?: Vector3;
  45072. poleAngle?: number;
  45073. bendAxis?: Vector3;
  45074. maxAngle?: number;
  45075. slerpAmount?: number;
  45076. });
  45077. private _setMaxAngle;
  45078. /**
  45079. * Force the controller to update the bones
  45080. */
  45081. update(): void;
  45082. }
  45083. }
  45084. declare module "babylonjs/Bones/boneLookController" {
  45085. import { Vector3 } from "babylonjs/Maths/math.vector";
  45086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45087. import { Bone } from "babylonjs/Bones/bone";
  45088. import { Space } from "babylonjs/Maths/math.axis";
  45089. /**
  45090. * Class used to make a bone look toward a point in space
  45091. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45092. */
  45093. export class BoneLookController {
  45094. private static _tmpVecs;
  45095. private static _tmpQuat;
  45096. private static _tmpMats;
  45097. /**
  45098. * The target Vector3 that the bone will look at
  45099. */
  45100. target: Vector3;
  45101. /**
  45102. * The mesh that the bone is attached to
  45103. */
  45104. mesh: AbstractMesh;
  45105. /**
  45106. * The bone that will be looking to the target
  45107. */
  45108. bone: Bone;
  45109. /**
  45110. * The up axis of the coordinate system that is used when the bone is rotated
  45111. */
  45112. upAxis: Vector3;
  45113. /**
  45114. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45115. */
  45116. upAxisSpace: Space;
  45117. /**
  45118. * Used to make an adjustment to the yaw of the bone
  45119. */
  45120. adjustYaw: number;
  45121. /**
  45122. * Used to make an adjustment to the pitch of the bone
  45123. */
  45124. adjustPitch: number;
  45125. /**
  45126. * Used to make an adjustment to the roll of the bone
  45127. */
  45128. adjustRoll: number;
  45129. /**
  45130. * 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)
  45131. */
  45132. slerpAmount: number;
  45133. private _minYaw;
  45134. private _maxYaw;
  45135. private _minPitch;
  45136. private _maxPitch;
  45137. private _minYawSin;
  45138. private _minYawCos;
  45139. private _maxYawSin;
  45140. private _maxYawCos;
  45141. private _midYawConstraint;
  45142. private _minPitchTan;
  45143. private _maxPitchTan;
  45144. private _boneQuat;
  45145. private _slerping;
  45146. private _transformYawPitch;
  45147. private _transformYawPitchInv;
  45148. private _firstFrameSkipped;
  45149. private _yawRange;
  45150. private _fowardAxis;
  45151. /**
  45152. * Gets or sets the minimum yaw angle that the bone can look to
  45153. */
  45154. get minYaw(): number;
  45155. set minYaw(value: number);
  45156. /**
  45157. * Gets or sets the maximum yaw angle that the bone can look to
  45158. */
  45159. get maxYaw(): number;
  45160. set maxYaw(value: number);
  45161. /**
  45162. * Gets or sets the minimum pitch angle that the bone can look to
  45163. */
  45164. get minPitch(): number;
  45165. set minPitch(value: number);
  45166. /**
  45167. * Gets or sets the maximum pitch angle that the bone can look to
  45168. */
  45169. get maxPitch(): number;
  45170. set maxPitch(value: number);
  45171. /**
  45172. * Create a BoneLookController
  45173. * @param mesh the mesh that the bone belongs to
  45174. * @param bone the bone that will be looking to the target
  45175. * @param target the target Vector3 to look at
  45176. * @param options optional settings:
  45177. * * maxYaw: the maximum angle the bone will yaw to
  45178. * * minYaw: the minimum angle the bone will yaw to
  45179. * * maxPitch: the maximum angle the bone will pitch to
  45180. * * minPitch: the minimum angle the bone will yaw to
  45181. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45182. * * upAxis: the up axis of the coordinate system
  45183. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45184. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45185. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45186. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45187. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45188. * * adjustRoll: used to make an adjustment to the roll of the bone
  45189. **/
  45190. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45191. maxYaw?: number;
  45192. minYaw?: number;
  45193. maxPitch?: number;
  45194. minPitch?: number;
  45195. slerpAmount?: number;
  45196. upAxis?: Vector3;
  45197. upAxisSpace?: Space;
  45198. yawAxis?: Vector3;
  45199. pitchAxis?: Vector3;
  45200. adjustYaw?: number;
  45201. adjustPitch?: number;
  45202. adjustRoll?: number;
  45203. });
  45204. /**
  45205. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45206. */
  45207. update(): void;
  45208. private _getAngleDiff;
  45209. private _getAngleBetween;
  45210. private _isAngleBetween;
  45211. }
  45212. }
  45213. declare module "babylonjs/Bones/index" {
  45214. export * from "babylonjs/Bones/bone";
  45215. export * from "babylonjs/Bones/boneIKController";
  45216. export * from "babylonjs/Bones/boneLookController";
  45217. export * from "babylonjs/Bones/skeleton";
  45218. }
  45219. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45220. import { Nullable } from "babylonjs/types";
  45221. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45222. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45223. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45224. /**
  45225. * Manage the gamepad inputs to control an arc rotate camera.
  45226. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45227. */
  45228. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45229. /**
  45230. * Defines the camera the input is attached to.
  45231. */
  45232. camera: ArcRotateCamera;
  45233. /**
  45234. * Defines the gamepad the input is gathering event from.
  45235. */
  45236. gamepad: Nullable<Gamepad>;
  45237. /**
  45238. * Defines the gamepad rotation sensiblity.
  45239. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45240. */
  45241. gamepadRotationSensibility: number;
  45242. /**
  45243. * Defines the gamepad move sensiblity.
  45244. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45245. */
  45246. gamepadMoveSensibility: number;
  45247. private _yAxisScale;
  45248. /**
  45249. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45250. */
  45251. get invertYAxis(): boolean;
  45252. set invertYAxis(value: boolean);
  45253. private _onGamepadConnectedObserver;
  45254. private _onGamepadDisconnectedObserver;
  45255. /**
  45256. * Attach the input controls to a specific dom element to get the input from.
  45257. * @param element Defines the element the controls should be listened from
  45258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45259. */
  45260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45261. /**
  45262. * Detach the current controls from the specified dom element.
  45263. * @param element Defines the element to stop listening the inputs from
  45264. */
  45265. detachControl(element: Nullable<HTMLElement>): void;
  45266. /**
  45267. * Update the current camera state depending on the inputs that have been used this frame.
  45268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45269. */
  45270. checkInputs(): void;
  45271. /**
  45272. * Gets the class name of the current intput.
  45273. * @returns the class name
  45274. */
  45275. getClassName(): string;
  45276. /**
  45277. * Get the friendly name associated with the input class.
  45278. * @returns the input friendly name
  45279. */
  45280. getSimpleName(): string;
  45281. }
  45282. }
  45283. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45284. import { Nullable } from "babylonjs/types";
  45285. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45286. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45287. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45288. interface ArcRotateCameraInputsManager {
  45289. /**
  45290. * Add orientation input support to the input manager.
  45291. * @returns the current input manager
  45292. */
  45293. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45294. }
  45295. }
  45296. /**
  45297. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45298. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45299. */
  45300. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45301. /**
  45302. * Defines the camera the input is attached to.
  45303. */
  45304. camera: ArcRotateCamera;
  45305. /**
  45306. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45307. */
  45308. alphaCorrection: number;
  45309. /**
  45310. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45311. */
  45312. gammaCorrection: number;
  45313. private _alpha;
  45314. private _gamma;
  45315. private _dirty;
  45316. private _deviceOrientationHandler;
  45317. /**
  45318. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45319. */
  45320. constructor();
  45321. /**
  45322. * Attach the input controls to a specific dom element to get the input from.
  45323. * @param element Defines the element the controls should be listened from
  45324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45325. */
  45326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45327. /** @hidden */
  45328. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45329. /**
  45330. * Update the current camera state depending on the inputs that have been used this frame.
  45331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45332. */
  45333. checkInputs(): void;
  45334. /**
  45335. * Detach the current controls from the specified dom element.
  45336. * @param element Defines the element to stop listening the inputs from
  45337. */
  45338. detachControl(element: Nullable<HTMLElement>): void;
  45339. /**
  45340. * Gets the class name of the current intput.
  45341. * @returns the class name
  45342. */
  45343. getClassName(): string;
  45344. /**
  45345. * Get the friendly name associated with the input class.
  45346. * @returns the input friendly name
  45347. */
  45348. getSimpleName(): string;
  45349. }
  45350. }
  45351. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45352. import { Nullable } from "babylonjs/types";
  45353. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45354. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45355. /**
  45356. * Listen to mouse events to control the camera.
  45357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45358. */
  45359. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45360. /**
  45361. * Defines the camera the input is attached to.
  45362. */
  45363. camera: FlyCamera;
  45364. /**
  45365. * Defines if touch is enabled. (Default is true.)
  45366. */
  45367. touchEnabled: boolean;
  45368. /**
  45369. * Defines the buttons associated with the input to handle camera rotation.
  45370. */
  45371. buttons: number[];
  45372. /**
  45373. * Assign buttons for Yaw control.
  45374. */
  45375. buttonsYaw: number[];
  45376. /**
  45377. * Assign buttons for Pitch control.
  45378. */
  45379. buttonsPitch: number[];
  45380. /**
  45381. * Assign buttons for Roll control.
  45382. */
  45383. buttonsRoll: number[];
  45384. /**
  45385. * Detect if any button is being pressed while mouse is moved.
  45386. * -1 = Mouse locked.
  45387. * 0 = Left button.
  45388. * 1 = Middle Button.
  45389. * 2 = Right Button.
  45390. */
  45391. activeButton: number;
  45392. /**
  45393. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45394. * Higher values reduce its sensitivity.
  45395. */
  45396. angularSensibility: number;
  45397. private _mousemoveCallback;
  45398. private _observer;
  45399. private _rollObserver;
  45400. private previousPosition;
  45401. private noPreventDefault;
  45402. private element;
  45403. /**
  45404. * Listen to mouse events to control the camera.
  45405. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45407. */
  45408. constructor(touchEnabled?: boolean);
  45409. /**
  45410. * Attach the mouse control to the HTML DOM element.
  45411. * @param element Defines the element that listens to the input events.
  45412. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45413. */
  45414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45415. /**
  45416. * Detach the current controls from the specified dom element.
  45417. * @param element Defines the element to stop listening the inputs from
  45418. */
  45419. detachControl(element: Nullable<HTMLElement>): void;
  45420. /**
  45421. * Gets the class name of the current input.
  45422. * @returns the class name.
  45423. */
  45424. getClassName(): string;
  45425. /**
  45426. * Get the friendly name associated with the input class.
  45427. * @returns the input's friendly name.
  45428. */
  45429. getSimpleName(): string;
  45430. private _pointerInput;
  45431. private _onMouseMove;
  45432. /**
  45433. * Rotate camera by mouse offset.
  45434. */
  45435. private rotateCamera;
  45436. }
  45437. }
  45438. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45439. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45440. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45441. /**
  45442. * Default Inputs manager for the FlyCamera.
  45443. * It groups all the default supported inputs for ease of use.
  45444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45445. */
  45446. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45447. /**
  45448. * Instantiates a new FlyCameraInputsManager.
  45449. * @param camera Defines the camera the inputs belong to.
  45450. */
  45451. constructor(camera: FlyCamera);
  45452. /**
  45453. * Add keyboard input support to the input manager.
  45454. * @returns the new FlyCameraKeyboardMoveInput().
  45455. */
  45456. addKeyboard(): FlyCameraInputsManager;
  45457. /**
  45458. * Add mouse input support to the input manager.
  45459. * @param touchEnabled Enable touch screen support.
  45460. * @returns the new FlyCameraMouseInput().
  45461. */
  45462. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45463. }
  45464. }
  45465. declare module "babylonjs/Cameras/flyCamera" {
  45466. import { Scene } from "babylonjs/scene";
  45467. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45469. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45470. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45471. /**
  45472. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45473. * such as in a 3D Space Shooter or a Flight Simulator.
  45474. */
  45475. export class FlyCamera extends TargetCamera {
  45476. /**
  45477. * Define the collision ellipsoid of the camera.
  45478. * This is helpful for simulating a camera body, like a player's body.
  45479. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45480. */
  45481. ellipsoid: Vector3;
  45482. /**
  45483. * Define an offset for the position of the ellipsoid around the camera.
  45484. * This can be helpful if the camera is attached away from the player's body center,
  45485. * such as at its head.
  45486. */
  45487. ellipsoidOffset: Vector3;
  45488. /**
  45489. * Enable or disable collisions of the camera with the rest of the scene objects.
  45490. */
  45491. checkCollisions: boolean;
  45492. /**
  45493. * Enable or disable gravity on the camera.
  45494. */
  45495. applyGravity: boolean;
  45496. /**
  45497. * Define the current direction the camera is moving to.
  45498. */
  45499. cameraDirection: Vector3;
  45500. /**
  45501. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45502. * This overrides and empties cameraRotation.
  45503. */
  45504. rotationQuaternion: Quaternion;
  45505. /**
  45506. * Track Roll to maintain the wanted Rolling when looking around.
  45507. */
  45508. _trackRoll: number;
  45509. /**
  45510. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45511. */
  45512. rollCorrect: number;
  45513. /**
  45514. * Mimic a banked turn, Rolling the camera when Yawing.
  45515. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45516. */
  45517. bankedTurn: boolean;
  45518. /**
  45519. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45520. */
  45521. bankedTurnLimit: number;
  45522. /**
  45523. * Value of 0 disables the banked Roll.
  45524. * Value of 1 is equal to the Yaw angle in radians.
  45525. */
  45526. bankedTurnMultiplier: number;
  45527. /**
  45528. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45529. */
  45530. inputs: FlyCameraInputsManager;
  45531. /**
  45532. * Gets the input sensibility for mouse input.
  45533. * Higher values reduce sensitivity.
  45534. */
  45535. get angularSensibility(): number;
  45536. /**
  45537. * Sets the input sensibility for a mouse input.
  45538. * Higher values reduce sensitivity.
  45539. */
  45540. set angularSensibility(value: number);
  45541. /**
  45542. * Get the keys for camera movement forward.
  45543. */
  45544. get keysForward(): number[];
  45545. /**
  45546. * Set the keys for camera movement forward.
  45547. */
  45548. set keysForward(value: number[]);
  45549. /**
  45550. * Get the keys for camera movement backward.
  45551. */
  45552. get keysBackward(): number[];
  45553. set keysBackward(value: number[]);
  45554. /**
  45555. * Get the keys for camera movement up.
  45556. */
  45557. get keysUp(): number[];
  45558. /**
  45559. * Set the keys for camera movement up.
  45560. */
  45561. set keysUp(value: number[]);
  45562. /**
  45563. * Get the keys for camera movement down.
  45564. */
  45565. get keysDown(): number[];
  45566. /**
  45567. * Set the keys for camera movement down.
  45568. */
  45569. set keysDown(value: number[]);
  45570. /**
  45571. * Get the keys for camera movement left.
  45572. */
  45573. get keysLeft(): number[];
  45574. /**
  45575. * Set the keys for camera movement left.
  45576. */
  45577. set keysLeft(value: number[]);
  45578. /**
  45579. * Set the keys for camera movement right.
  45580. */
  45581. get keysRight(): number[];
  45582. /**
  45583. * Set the keys for camera movement right.
  45584. */
  45585. set keysRight(value: number[]);
  45586. /**
  45587. * Event raised when the camera collides with a mesh in the scene.
  45588. */
  45589. onCollide: (collidedMesh: AbstractMesh) => void;
  45590. private _collider;
  45591. private _needMoveForGravity;
  45592. private _oldPosition;
  45593. private _diffPosition;
  45594. private _newPosition;
  45595. /** @hidden */
  45596. _localDirection: Vector3;
  45597. /** @hidden */
  45598. _transformedDirection: Vector3;
  45599. /**
  45600. * Instantiates a FlyCamera.
  45601. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45602. * such as in a 3D Space Shooter or a Flight Simulator.
  45603. * @param name Define the name of the camera in the scene.
  45604. * @param position Define the starting position of the camera in the scene.
  45605. * @param scene Define the scene the camera belongs to.
  45606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45607. */
  45608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45609. /**
  45610. * Attach a control to the HTML DOM element.
  45611. * @param element Defines the element that listens to the input events.
  45612. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45613. */
  45614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45615. /**
  45616. * Detach a control from the HTML DOM element.
  45617. * The camera will stop reacting to that input.
  45618. * @param element Defines the element that listens to the input events.
  45619. */
  45620. detachControl(element: HTMLElement): void;
  45621. private _collisionMask;
  45622. /**
  45623. * Get the mask that the camera ignores in collision events.
  45624. */
  45625. get collisionMask(): number;
  45626. /**
  45627. * Set the mask that the camera ignores in collision events.
  45628. */
  45629. set collisionMask(mask: number);
  45630. /** @hidden */
  45631. _collideWithWorld(displacement: Vector3): void;
  45632. /** @hidden */
  45633. private _onCollisionPositionChange;
  45634. /** @hidden */
  45635. _checkInputs(): void;
  45636. /** @hidden */
  45637. _decideIfNeedsToMove(): boolean;
  45638. /** @hidden */
  45639. _updatePosition(): void;
  45640. /**
  45641. * Restore the Roll to its target value at the rate specified.
  45642. * @param rate - Higher means slower restoring.
  45643. * @hidden
  45644. */
  45645. restoreRoll(rate: number): void;
  45646. /**
  45647. * Destroy the camera and release the current resources held by it.
  45648. */
  45649. dispose(): void;
  45650. /**
  45651. * Get the current object class name.
  45652. * @returns the class name.
  45653. */
  45654. getClassName(): string;
  45655. }
  45656. }
  45657. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45658. import { Nullable } from "babylonjs/types";
  45659. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45660. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45661. /**
  45662. * Listen to keyboard events to control the camera.
  45663. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45664. */
  45665. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45666. /**
  45667. * Defines the camera the input is attached to.
  45668. */
  45669. camera: FlyCamera;
  45670. /**
  45671. * The list of keyboard keys used to control the forward move of the camera.
  45672. */
  45673. keysForward: number[];
  45674. /**
  45675. * The list of keyboard keys used to control the backward move of the camera.
  45676. */
  45677. keysBackward: number[];
  45678. /**
  45679. * The list of keyboard keys used to control the forward move of the camera.
  45680. */
  45681. keysUp: number[];
  45682. /**
  45683. * The list of keyboard keys used to control the backward move of the camera.
  45684. */
  45685. keysDown: number[];
  45686. /**
  45687. * The list of keyboard keys used to control the right strafe move of the camera.
  45688. */
  45689. keysRight: number[];
  45690. /**
  45691. * The list of keyboard keys used to control the left strafe move of the camera.
  45692. */
  45693. keysLeft: number[];
  45694. private _keys;
  45695. private _onCanvasBlurObserver;
  45696. private _onKeyboardObserver;
  45697. private _engine;
  45698. private _scene;
  45699. /**
  45700. * Attach the input controls to a specific dom element to get the input from.
  45701. * @param element Defines the element the controls should be listened from
  45702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45703. */
  45704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45705. /**
  45706. * Detach the current controls from the specified dom element.
  45707. * @param element Defines the element to stop listening the inputs from
  45708. */
  45709. detachControl(element: Nullable<HTMLElement>): void;
  45710. /**
  45711. * Gets the class name of the current intput.
  45712. * @returns the class name
  45713. */
  45714. getClassName(): string;
  45715. /** @hidden */
  45716. _onLostFocus(e: FocusEvent): void;
  45717. /**
  45718. * Get the friendly name associated with the input class.
  45719. * @returns the input friendly name
  45720. */
  45721. getSimpleName(): string;
  45722. /**
  45723. * Update the current camera state depending on the inputs that have been used this frame.
  45724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45725. */
  45726. checkInputs(): void;
  45727. }
  45728. }
  45729. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45730. import { Nullable } from "babylonjs/types";
  45731. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45733. /**
  45734. * Manage the mouse wheel inputs to control a follow camera.
  45735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45736. */
  45737. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45738. /**
  45739. * Defines the camera the input is attached to.
  45740. */
  45741. camera: FollowCamera;
  45742. /**
  45743. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45744. */
  45745. axisControlRadius: boolean;
  45746. /**
  45747. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45748. */
  45749. axisControlHeight: boolean;
  45750. /**
  45751. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45752. */
  45753. axisControlRotation: boolean;
  45754. /**
  45755. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45756. * relation to mouseWheel events.
  45757. */
  45758. wheelPrecision: number;
  45759. /**
  45760. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45761. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45762. */
  45763. wheelDeltaPercentage: number;
  45764. private _wheel;
  45765. private _observer;
  45766. /**
  45767. * Attach the input controls to a specific dom element to get the input from.
  45768. * @param element Defines the element the controls should be listened from
  45769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45770. */
  45771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45772. /**
  45773. * Detach the current controls from the specified dom element.
  45774. * @param element Defines the element to stop listening the inputs from
  45775. */
  45776. detachControl(element: Nullable<HTMLElement>): void;
  45777. /**
  45778. * Gets the class name of the current intput.
  45779. * @returns the class name
  45780. */
  45781. getClassName(): string;
  45782. /**
  45783. * Get the friendly name associated with the input class.
  45784. * @returns the input friendly name
  45785. */
  45786. getSimpleName(): string;
  45787. }
  45788. }
  45789. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45790. import { Nullable } from "babylonjs/types";
  45791. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45792. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45793. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45794. /**
  45795. * Manage the pointers inputs to control an follow camera.
  45796. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45797. */
  45798. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45799. /**
  45800. * Defines the camera the input is attached to.
  45801. */
  45802. camera: FollowCamera;
  45803. /**
  45804. * Gets the class name of the current input.
  45805. * @returns the class name
  45806. */
  45807. getClassName(): string;
  45808. /**
  45809. * Defines the pointer angular sensibility along the X axis or how fast is
  45810. * the camera rotating.
  45811. * A negative number will reverse the axis direction.
  45812. */
  45813. angularSensibilityX: number;
  45814. /**
  45815. * Defines the pointer angular sensibility along the Y axis or how fast is
  45816. * the camera rotating.
  45817. * A negative number will reverse the axis direction.
  45818. */
  45819. angularSensibilityY: number;
  45820. /**
  45821. * Defines the pointer pinch precision or how fast is the camera zooming.
  45822. * A negative number will reverse the axis direction.
  45823. */
  45824. pinchPrecision: number;
  45825. /**
  45826. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45827. * from 0.
  45828. * It defines the percentage of current camera.radius to use as delta when
  45829. * pinch zoom is used.
  45830. */
  45831. pinchDeltaPercentage: number;
  45832. /**
  45833. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45834. */
  45835. axisXControlRadius: boolean;
  45836. /**
  45837. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45838. */
  45839. axisXControlHeight: boolean;
  45840. /**
  45841. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45842. */
  45843. axisXControlRotation: boolean;
  45844. /**
  45845. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45846. */
  45847. axisYControlRadius: boolean;
  45848. /**
  45849. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45850. */
  45851. axisYControlHeight: boolean;
  45852. /**
  45853. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45854. */
  45855. axisYControlRotation: boolean;
  45856. /**
  45857. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45858. */
  45859. axisPinchControlRadius: boolean;
  45860. /**
  45861. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45862. */
  45863. axisPinchControlHeight: boolean;
  45864. /**
  45865. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45866. */
  45867. axisPinchControlRotation: boolean;
  45868. /**
  45869. * Log error messages if basic misconfiguration has occurred.
  45870. */
  45871. warningEnable: boolean;
  45872. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45873. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45874. private _warningCounter;
  45875. private _warning;
  45876. }
  45877. }
  45878. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45879. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45880. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45881. /**
  45882. * Default Inputs manager for the FollowCamera.
  45883. * It groups all the default supported inputs for ease of use.
  45884. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45885. */
  45886. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45887. /**
  45888. * Instantiates a new FollowCameraInputsManager.
  45889. * @param camera Defines the camera the inputs belong to
  45890. */
  45891. constructor(camera: FollowCamera);
  45892. /**
  45893. * Add keyboard input support to the input manager.
  45894. * @returns the current input manager
  45895. */
  45896. addKeyboard(): FollowCameraInputsManager;
  45897. /**
  45898. * Add mouse wheel input support to the input manager.
  45899. * @returns the current input manager
  45900. */
  45901. addMouseWheel(): FollowCameraInputsManager;
  45902. /**
  45903. * Add pointers input support to the input manager.
  45904. * @returns the current input manager
  45905. */
  45906. addPointers(): FollowCameraInputsManager;
  45907. /**
  45908. * Add orientation input support to the input manager.
  45909. * @returns the current input manager
  45910. */
  45911. addVRDeviceOrientation(): FollowCameraInputsManager;
  45912. }
  45913. }
  45914. declare module "babylonjs/Cameras/followCamera" {
  45915. import { Nullable } from "babylonjs/types";
  45916. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45917. import { Scene } from "babylonjs/scene";
  45918. import { Vector3 } from "babylonjs/Maths/math.vector";
  45919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45920. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45921. /**
  45922. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45923. * an arc rotate version arcFollowCamera are available.
  45924. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45925. */
  45926. export class FollowCamera extends TargetCamera {
  45927. /**
  45928. * Distance the follow camera should follow an object at
  45929. */
  45930. radius: number;
  45931. /**
  45932. * Minimum allowed distance of the camera to the axis of rotation
  45933. * (The camera can not get closer).
  45934. * This can help limiting how the Camera is able to move in the scene.
  45935. */
  45936. lowerRadiusLimit: Nullable<number>;
  45937. /**
  45938. * Maximum allowed distance of the camera to the axis of rotation
  45939. * (The camera can not get further).
  45940. * This can help limiting how the Camera is able to move in the scene.
  45941. */
  45942. upperRadiusLimit: Nullable<number>;
  45943. /**
  45944. * Define a rotation offset between the camera and the object it follows
  45945. */
  45946. rotationOffset: number;
  45947. /**
  45948. * Minimum allowed angle to camera position relative to target object.
  45949. * This can help limiting how the Camera is able to move in the scene.
  45950. */
  45951. lowerRotationOffsetLimit: Nullable<number>;
  45952. /**
  45953. * Maximum allowed angle to camera position relative to target object.
  45954. * This can help limiting how the Camera is able to move in the scene.
  45955. */
  45956. upperRotationOffsetLimit: Nullable<number>;
  45957. /**
  45958. * Define a height offset between the camera and the object it follows.
  45959. * It can help following an object from the top (like a car chaing a plane)
  45960. */
  45961. heightOffset: number;
  45962. /**
  45963. * Minimum allowed height of camera position relative to target object.
  45964. * This can help limiting how the Camera is able to move in the scene.
  45965. */
  45966. lowerHeightOffsetLimit: Nullable<number>;
  45967. /**
  45968. * Maximum allowed height of camera position relative to target object.
  45969. * This can help limiting how the Camera is able to move in the scene.
  45970. */
  45971. upperHeightOffsetLimit: Nullable<number>;
  45972. /**
  45973. * Define how fast the camera can accelerate to follow it s target.
  45974. */
  45975. cameraAcceleration: number;
  45976. /**
  45977. * Define the speed limit of the camera following an object.
  45978. */
  45979. maxCameraSpeed: number;
  45980. /**
  45981. * Define the target of the camera.
  45982. */
  45983. lockedTarget: Nullable<AbstractMesh>;
  45984. /**
  45985. * Defines the input associated with the camera.
  45986. */
  45987. inputs: FollowCameraInputsManager;
  45988. /**
  45989. * Instantiates the follow camera.
  45990. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45991. * @param name Define the name of the camera in the scene
  45992. * @param position Define the position of the camera
  45993. * @param scene Define the scene the camera belong to
  45994. * @param lockedTarget Define the target of the camera
  45995. */
  45996. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45997. private _follow;
  45998. /**
  45999. * Attached controls to the current camera.
  46000. * @param element Defines the element the controls should be listened from
  46001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46002. */
  46003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46004. /**
  46005. * Detach the current controls from the camera.
  46006. * The camera will stop reacting to inputs.
  46007. * @param element Defines the element to stop listening the inputs from
  46008. */
  46009. detachControl(element: HTMLElement): void;
  46010. /** @hidden */
  46011. _checkInputs(): void;
  46012. private _checkLimits;
  46013. /**
  46014. * Gets the camera class name.
  46015. * @returns the class name
  46016. */
  46017. getClassName(): string;
  46018. }
  46019. /**
  46020. * Arc Rotate version of the follow camera.
  46021. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46022. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46023. */
  46024. export class ArcFollowCamera extends TargetCamera {
  46025. /** The longitudinal angle of the camera */
  46026. alpha: number;
  46027. /** The latitudinal angle of the camera */
  46028. beta: number;
  46029. /** The radius of the camera from its target */
  46030. radius: number;
  46031. /** Define the camera target (the mesh it should follow) */
  46032. target: Nullable<AbstractMesh>;
  46033. private _cartesianCoordinates;
  46034. /**
  46035. * Instantiates a new ArcFollowCamera
  46036. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46037. * @param name Define the name of the camera
  46038. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46039. * @param beta Define the rotation angle of the camera around the elevation axis
  46040. * @param radius Define the radius of the camera from its target point
  46041. * @param target Define the target of the camera
  46042. * @param scene Define the scene the camera belongs to
  46043. */
  46044. constructor(name: string,
  46045. /** The longitudinal angle of the camera */
  46046. alpha: number,
  46047. /** The latitudinal angle of the camera */
  46048. beta: number,
  46049. /** The radius of the camera from its target */
  46050. radius: number,
  46051. /** Define the camera target (the mesh it should follow) */
  46052. target: Nullable<AbstractMesh>, scene: Scene);
  46053. private _follow;
  46054. /** @hidden */
  46055. _checkInputs(): void;
  46056. /**
  46057. * Returns the class name of the object.
  46058. * It is mostly used internally for serialization purposes.
  46059. */
  46060. getClassName(): string;
  46061. }
  46062. }
  46063. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46064. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46065. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46066. import { Nullable } from "babylonjs/types";
  46067. /**
  46068. * Manage the keyboard inputs to control the movement of a follow camera.
  46069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46070. */
  46071. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46072. /**
  46073. * Defines the camera the input is attached to.
  46074. */
  46075. camera: FollowCamera;
  46076. /**
  46077. * Defines the list of key codes associated with the up action (increase heightOffset)
  46078. */
  46079. keysHeightOffsetIncr: number[];
  46080. /**
  46081. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46082. */
  46083. keysHeightOffsetDecr: number[];
  46084. /**
  46085. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46086. */
  46087. keysHeightOffsetModifierAlt: boolean;
  46088. /**
  46089. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46090. */
  46091. keysHeightOffsetModifierCtrl: boolean;
  46092. /**
  46093. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46094. */
  46095. keysHeightOffsetModifierShift: boolean;
  46096. /**
  46097. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46098. */
  46099. keysRotationOffsetIncr: number[];
  46100. /**
  46101. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46102. */
  46103. keysRotationOffsetDecr: number[];
  46104. /**
  46105. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46106. */
  46107. keysRotationOffsetModifierAlt: boolean;
  46108. /**
  46109. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46110. */
  46111. keysRotationOffsetModifierCtrl: boolean;
  46112. /**
  46113. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46114. */
  46115. keysRotationOffsetModifierShift: boolean;
  46116. /**
  46117. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46118. */
  46119. keysRadiusIncr: number[];
  46120. /**
  46121. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46122. */
  46123. keysRadiusDecr: number[];
  46124. /**
  46125. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46126. */
  46127. keysRadiusModifierAlt: boolean;
  46128. /**
  46129. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46130. */
  46131. keysRadiusModifierCtrl: boolean;
  46132. /**
  46133. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46134. */
  46135. keysRadiusModifierShift: boolean;
  46136. /**
  46137. * Defines the rate of change of heightOffset.
  46138. */
  46139. heightSensibility: number;
  46140. /**
  46141. * Defines the rate of change of rotationOffset.
  46142. */
  46143. rotationSensibility: number;
  46144. /**
  46145. * Defines the rate of change of radius.
  46146. */
  46147. radiusSensibility: number;
  46148. private _keys;
  46149. private _ctrlPressed;
  46150. private _altPressed;
  46151. private _shiftPressed;
  46152. private _onCanvasBlurObserver;
  46153. private _onKeyboardObserver;
  46154. private _engine;
  46155. private _scene;
  46156. /**
  46157. * Attach the input controls to a specific dom element to get the input from.
  46158. * @param element Defines the element the controls should be listened from
  46159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46160. */
  46161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46162. /**
  46163. * Detach the current controls from the specified dom element.
  46164. * @param element Defines the element to stop listening the inputs from
  46165. */
  46166. detachControl(element: Nullable<HTMLElement>): void;
  46167. /**
  46168. * Update the current camera state depending on the inputs that have been used this frame.
  46169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46170. */
  46171. checkInputs(): void;
  46172. /**
  46173. * Gets the class name of the current input.
  46174. * @returns the class name
  46175. */
  46176. getClassName(): string;
  46177. /**
  46178. * Get the friendly name associated with the input class.
  46179. * @returns the input friendly name
  46180. */
  46181. getSimpleName(): string;
  46182. /**
  46183. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46184. * allow modification of the heightOffset value.
  46185. */
  46186. private _modifierHeightOffset;
  46187. /**
  46188. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46189. * allow modification of the rotationOffset value.
  46190. */
  46191. private _modifierRotationOffset;
  46192. /**
  46193. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46194. * allow modification of the radius value.
  46195. */
  46196. private _modifierRadius;
  46197. }
  46198. }
  46199. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46200. import { Nullable } from "babylonjs/types";
  46201. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46203. import { Observable } from "babylonjs/Misc/observable";
  46204. module "babylonjs/Cameras/freeCameraInputsManager" {
  46205. interface FreeCameraInputsManager {
  46206. /**
  46207. * @hidden
  46208. */
  46209. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46210. /**
  46211. * Add orientation input support to the input manager.
  46212. * @returns the current input manager
  46213. */
  46214. addDeviceOrientation(): FreeCameraInputsManager;
  46215. }
  46216. }
  46217. /**
  46218. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46219. * Screen rotation is taken into account.
  46220. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46221. */
  46222. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46223. private _camera;
  46224. private _screenOrientationAngle;
  46225. private _constantTranform;
  46226. private _screenQuaternion;
  46227. private _alpha;
  46228. private _beta;
  46229. private _gamma;
  46230. /**
  46231. * Can be used to detect if a device orientation sensor is available on a device
  46232. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46233. * @returns a promise that will resolve on orientation change
  46234. */
  46235. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46236. /**
  46237. * @hidden
  46238. */
  46239. _onDeviceOrientationChangedObservable: Observable<void>;
  46240. /**
  46241. * Instantiates a new input
  46242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46243. */
  46244. constructor();
  46245. /**
  46246. * Define the camera controlled by the input.
  46247. */
  46248. get camera(): FreeCamera;
  46249. set camera(camera: FreeCamera);
  46250. /**
  46251. * Attach the input controls to a specific dom element to get the input from.
  46252. * @param element Defines the element the controls should be listened from
  46253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46254. */
  46255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46256. private _orientationChanged;
  46257. private _deviceOrientation;
  46258. /**
  46259. * Detach the current controls from the specified dom element.
  46260. * @param element Defines the element to stop listening the inputs from
  46261. */
  46262. detachControl(element: Nullable<HTMLElement>): void;
  46263. /**
  46264. * Update the current camera state depending on the inputs that have been used this frame.
  46265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46266. */
  46267. checkInputs(): void;
  46268. /**
  46269. * Gets the class name of the current intput.
  46270. * @returns the class name
  46271. */
  46272. getClassName(): string;
  46273. /**
  46274. * Get the friendly name associated with the input class.
  46275. * @returns the input friendly name
  46276. */
  46277. getSimpleName(): string;
  46278. }
  46279. }
  46280. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46281. import { Nullable } from "babylonjs/types";
  46282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46284. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46285. /**
  46286. * Manage the gamepad inputs to control a free camera.
  46287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46288. */
  46289. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46290. /**
  46291. * Define the camera the input is attached to.
  46292. */
  46293. camera: FreeCamera;
  46294. /**
  46295. * Define the Gamepad controlling the input
  46296. */
  46297. gamepad: Nullable<Gamepad>;
  46298. /**
  46299. * Defines the gamepad rotation sensiblity.
  46300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46301. */
  46302. gamepadAngularSensibility: number;
  46303. /**
  46304. * Defines the gamepad move sensiblity.
  46305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46306. */
  46307. gamepadMoveSensibility: number;
  46308. private _yAxisScale;
  46309. /**
  46310. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46311. */
  46312. get invertYAxis(): boolean;
  46313. set invertYAxis(value: boolean);
  46314. private _onGamepadConnectedObserver;
  46315. private _onGamepadDisconnectedObserver;
  46316. private _cameraTransform;
  46317. private _deltaTransform;
  46318. private _vector3;
  46319. private _vector2;
  46320. /**
  46321. * Attach the input controls to a specific dom element to get the input from.
  46322. * @param element Defines the element the controls should be listened from
  46323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46324. */
  46325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46326. /**
  46327. * Detach the current controls from the specified dom element.
  46328. * @param element Defines the element to stop listening the inputs from
  46329. */
  46330. detachControl(element: Nullable<HTMLElement>): void;
  46331. /**
  46332. * Update the current camera state depending on the inputs that have been used this frame.
  46333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46334. */
  46335. checkInputs(): void;
  46336. /**
  46337. * Gets the class name of the current intput.
  46338. * @returns the class name
  46339. */
  46340. getClassName(): string;
  46341. /**
  46342. * Get the friendly name associated with the input class.
  46343. * @returns the input friendly name
  46344. */
  46345. getSimpleName(): string;
  46346. }
  46347. }
  46348. declare module "babylonjs/Misc/virtualJoystick" {
  46349. import { Nullable } from "babylonjs/types";
  46350. import { Vector3 } from "babylonjs/Maths/math.vector";
  46351. /**
  46352. * Defines the potential axis of a Joystick
  46353. */
  46354. export enum JoystickAxis {
  46355. /** X axis */
  46356. X = 0,
  46357. /** Y axis */
  46358. Y = 1,
  46359. /** Z axis */
  46360. Z = 2
  46361. }
  46362. /**
  46363. * Represents the different customization options available
  46364. * for VirtualJoystick
  46365. */
  46366. interface VirtualJoystickCustomizations {
  46367. /**
  46368. * Size of the joystick's puck
  46369. */
  46370. puckSize: number;
  46371. /**
  46372. * Size of the joystick's container
  46373. */
  46374. containerSize: number;
  46375. /**
  46376. * Color of the joystick && puck
  46377. */
  46378. color: string;
  46379. /**
  46380. * Image URL for the joystick's puck
  46381. */
  46382. puckImage?: string;
  46383. /**
  46384. * Image URL for the joystick's container
  46385. */
  46386. containerImage?: string;
  46387. /**
  46388. * Defines the unmoving position of the joystick container
  46389. */
  46390. position?: {
  46391. x: number;
  46392. y: number;
  46393. };
  46394. /**
  46395. * Defines whether or not the joystick container is always visible
  46396. */
  46397. alwaysVisible: boolean;
  46398. /**
  46399. * Defines whether or not to limit the movement of the puck to the joystick's container
  46400. */
  46401. limitToContainer: boolean;
  46402. }
  46403. /**
  46404. * Class used to define virtual joystick (used in touch mode)
  46405. */
  46406. export class VirtualJoystick {
  46407. /**
  46408. * Gets or sets a boolean indicating that left and right values must be inverted
  46409. */
  46410. reverseLeftRight: boolean;
  46411. /**
  46412. * Gets or sets a boolean indicating that up and down values must be inverted
  46413. */
  46414. reverseUpDown: boolean;
  46415. /**
  46416. * Gets the offset value for the position (ie. the change of the position value)
  46417. */
  46418. deltaPosition: Vector3;
  46419. /**
  46420. * Gets a boolean indicating if the virtual joystick was pressed
  46421. */
  46422. pressed: boolean;
  46423. /**
  46424. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46425. */
  46426. static Canvas: Nullable<HTMLCanvasElement>;
  46427. /**
  46428. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46429. */
  46430. limitToContainer: boolean;
  46431. private static _globalJoystickIndex;
  46432. private static _alwaysVisibleSticks;
  46433. private static vjCanvasContext;
  46434. private static vjCanvasWidth;
  46435. private static vjCanvasHeight;
  46436. private static halfWidth;
  46437. private static _GetDefaultOptions;
  46438. private _action;
  46439. private _axisTargetedByLeftAndRight;
  46440. private _axisTargetedByUpAndDown;
  46441. private _joystickSensibility;
  46442. private _inversedSensibility;
  46443. private _joystickPointerID;
  46444. private _joystickColor;
  46445. private _joystickPointerPos;
  46446. private _joystickPreviousPointerPos;
  46447. private _joystickPointerStartPos;
  46448. private _deltaJoystickVector;
  46449. private _leftJoystick;
  46450. private _touches;
  46451. private _joystickPosition;
  46452. private _alwaysVisible;
  46453. private _puckImage;
  46454. private _containerImage;
  46455. private _joystickPuckSize;
  46456. private _joystickContainerSize;
  46457. private _clearPuckSize;
  46458. private _clearContainerSize;
  46459. private _clearPuckSizeOffset;
  46460. private _clearContainerSizeOffset;
  46461. private _onPointerDownHandlerRef;
  46462. private _onPointerMoveHandlerRef;
  46463. private _onPointerUpHandlerRef;
  46464. private _onResize;
  46465. /**
  46466. * Creates a new virtual joystick
  46467. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46468. * @param customizations Defines the options we want to customize the VirtualJoystick
  46469. */
  46470. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46471. /**
  46472. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46473. * @param newJoystickSensibility defines the new sensibility
  46474. */
  46475. setJoystickSensibility(newJoystickSensibility: number): void;
  46476. private _onPointerDown;
  46477. private _onPointerMove;
  46478. private _onPointerUp;
  46479. /**
  46480. * Change the color of the virtual joystick
  46481. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46482. */
  46483. setJoystickColor(newColor: string): void;
  46484. /**
  46485. * Size of the joystick's container
  46486. */
  46487. set containerSize(newSize: number);
  46488. get containerSize(): number;
  46489. /**
  46490. * Size of the joystick's puck
  46491. */
  46492. set puckSize(newSize: number);
  46493. get puckSize(): number;
  46494. /**
  46495. * Clears the set position of the joystick
  46496. */
  46497. clearPosition(): void;
  46498. /**
  46499. * Defines whether or not the joystick container is always visible
  46500. */
  46501. set alwaysVisible(value: boolean);
  46502. get alwaysVisible(): boolean;
  46503. /**
  46504. * Sets the constant position of the Joystick container
  46505. * @param x X axis coordinate
  46506. * @param y Y axis coordinate
  46507. */
  46508. setPosition(x: number, y: number): void;
  46509. /**
  46510. * Defines a callback to call when the joystick is touched
  46511. * @param action defines the callback
  46512. */
  46513. setActionOnTouch(action: () => any): void;
  46514. /**
  46515. * Defines which axis you'd like to control for left & right
  46516. * @param axis defines the axis to use
  46517. */
  46518. setAxisForLeftRight(axis: JoystickAxis): void;
  46519. /**
  46520. * Defines which axis you'd like to control for up & down
  46521. * @param axis defines the axis to use
  46522. */
  46523. setAxisForUpDown(axis: JoystickAxis): void;
  46524. /**
  46525. * Clears the canvas from the previous puck / container draw
  46526. */
  46527. private _clearPreviousDraw;
  46528. /**
  46529. * Loads `urlPath` to be used for the container's image
  46530. * @param urlPath defines the urlPath of an image to use
  46531. */
  46532. setContainerImage(urlPath: string): void;
  46533. /**
  46534. * Loads `urlPath` to be used for the puck's image
  46535. * @param urlPath defines the urlPath of an image to use
  46536. */
  46537. setPuckImage(urlPath: string): void;
  46538. /**
  46539. * Draws the Virtual Joystick's container
  46540. */
  46541. private _drawContainer;
  46542. /**
  46543. * Draws the Virtual Joystick's puck
  46544. */
  46545. private _drawPuck;
  46546. private _drawVirtualJoystick;
  46547. /**
  46548. * Release internal HTML canvas
  46549. */
  46550. releaseCanvas(): void;
  46551. }
  46552. }
  46553. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46554. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46555. import { Nullable } from "babylonjs/types";
  46556. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46557. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46558. module "babylonjs/Cameras/freeCameraInputsManager" {
  46559. interface FreeCameraInputsManager {
  46560. /**
  46561. * Add virtual joystick input support to the input manager.
  46562. * @returns the current input manager
  46563. */
  46564. addVirtualJoystick(): FreeCameraInputsManager;
  46565. }
  46566. }
  46567. /**
  46568. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46570. */
  46571. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46572. /**
  46573. * Defines the camera the input is attached to.
  46574. */
  46575. camera: FreeCamera;
  46576. private _leftjoystick;
  46577. private _rightjoystick;
  46578. /**
  46579. * Gets the left stick of the virtual joystick.
  46580. * @returns The virtual Joystick
  46581. */
  46582. getLeftJoystick(): VirtualJoystick;
  46583. /**
  46584. * Gets the right stick of the virtual joystick.
  46585. * @returns The virtual Joystick
  46586. */
  46587. getRightJoystick(): VirtualJoystick;
  46588. /**
  46589. * Update the current camera state depending on the inputs that have been used this frame.
  46590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46591. */
  46592. checkInputs(): void;
  46593. /**
  46594. * Attach the input controls to a specific dom element to get the input from.
  46595. * @param element Defines the element the controls should be listened from
  46596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46597. */
  46598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46599. /**
  46600. * Detach the current controls from the specified dom element.
  46601. * @param element Defines the element to stop listening the inputs from
  46602. */
  46603. detachControl(element: Nullable<HTMLElement>): void;
  46604. /**
  46605. * Gets the class name of the current intput.
  46606. * @returns the class name
  46607. */
  46608. getClassName(): string;
  46609. /**
  46610. * Get the friendly name associated with the input class.
  46611. * @returns the input friendly name
  46612. */
  46613. getSimpleName(): string;
  46614. }
  46615. }
  46616. declare module "babylonjs/Cameras/Inputs/index" {
  46617. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46618. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46619. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46620. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46621. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46622. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46623. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46624. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46625. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46626. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46627. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46628. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46629. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46630. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46631. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46632. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46633. }
  46634. declare module "babylonjs/Cameras/touchCamera" {
  46635. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46636. import { Scene } from "babylonjs/scene";
  46637. import { Vector3 } from "babylonjs/Maths/math.vector";
  46638. /**
  46639. * This represents a FPS type of camera controlled by touch.
  46640. * This is like a universal camera minus the Gamepad controls.
  46641. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46642. */
  46643. export class TouchCamera extends FreeCamera {
  46644. /**
  46645. * Defines the touch sensibility for rotation.
  46646. * The higher the faster.
  46647. */
  46648. get touchAngularSensibility(): number;
  46649. set touchAngularSensibility(value: number);
  46650. /**
  46651. * Defines the touch sensibility for move.
  46652. * The higher the faster.
  46653. */
  46654. get touchMoveSensibility(): number;
  46655. set touchMoveSensibility(value: number);
  46656. /**
  46657. * Instantiates a new touch camera.
  46658. * This represents a FPS type of camera controlled by touch.
  46659. * This is like a universal camera minus the Gamepad controls.
  46660. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46661. * @param name Define the name of the camera in the scene
  46662. * @param position Define the start position of the camera in the scene
  46663. * @param scene Define the scene the camera belongs to
  46664. */
  46665. constructor(name: string, position: Vector3, scene: Scene);
  46666. /**
  46667. * Gets the current object class name.
  46668. * @return the class name
  46669. */
  46670. getClassName(): string;
  46671. /** @hidden */
  46672. _setupInputs(): void;
  46673. }
  46674. }
  46675. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46676. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46677. import { Scene } from "babylonjs/scene";
  46678. import { Vector3 } from "babylonjs/Maths/math.vector";
  46679. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46680. import { Axis } from "babylonjs/Maths/math.axis";
  46681. /**
  46682. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46683. * being tilted forward or back and left or right.
  46684. */
  46685. export class DeviceOrientationCamera extends FreeCamera {
  46686. private _initialQuaternion;
  46687. private _quaternionCache;
  46688. private _tmpDragQuaternion;
  46689. private _disablePointerInputWhenUsingDeviceOrientation;
  46690. /**
  46691. * Creates a new device orientation camera
  46692. * @param name The name of the camera
  46693. * @param position The start position camera
  46694. * @param scene The scene the camera belongs to
  46695. */
  46696. constructor(name: string, position: Vector3, scene: Scene);
  46697. /**
  46698. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46699. */
  46700. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46701. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46702. private _dragFactor;
  46703. /**
  46704. * Enabled turning on the y axis when the orientation sensor is active
  46705. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46706. */
  46707. enableHorizontalDragging(dragFactor?: number): void;
  46708. /**
  46709. * Gets the current instance class name ("DeviceOrientationCamera").
  46710. * This helps avoiding instanceof at run time.
  46711. * @returns the class name
  46712. */
  46713. getClassName(): string;
  46714. /**
  46715. * @hidden
  46716. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46717. */
  46718. _checkInputs(): void;
  46719. /**
  46720. * Reset the camera to its default orientation on the specified axis only.
  46721. * @param axis The axis to reset
  46722. */
  46723. resetToCurrentRotation(axis?: Axis): void;
  46724. }
  46725. }
  46726. declare module "babylonjs/Gamepads/xboxGamepad" {
  46727. import { Observable } from "babylonjs/Misc/observable";
  46728. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46729. /**
  46730. * Defines supported buttons for XBox360 compatible gamepads
  46731. */
  46732. export enum Xbox360Button {
  46733. /** A */
  46734. A = 0,
  46735. /** B */
  46736. B = 1,
  46737. /** X */
  46738. X = 2,
  46739. /** Y */
  46740. Y = 3,
  46741. /** Left button */
  46742. LB = 4,
  46743. /** Right button */
  46744. RB = 5,
  46745. /** Back */
  46746. Back = 8,
  46747. /** Start */
  46748. Start = 9,
  46749. /** Left stick */
  46750. LeftStick = 10,
  46751. /** Right stick */
  46752. RightStick = 11
  46753. }
  46754. /** Defines values for XBox360 DPad */
  46755. export enum Xbox360Dpad {
  46756. /** Up */
  46757. Up = 12,
  46758. /** Down */
  46759. Down = 13,
  46760. /** Left */
  46761. Left = 14,
  46762. /** Right */
  46763. Right = 15
  46764. }
  46765. /**
  46766. * Defines a XBox360 gamepad
  46767. */
  46768. export class Xbox360Pad extends Gamepad {
  46769. private _leftTrigger;
  46770. private _rightTrigger;
  46771. private _onlefttriggerchanged;
  46772. private _onrighttriggerchanged;
  46773. private _onbuttondown;
  46774. private _onbuttonup;
  46775. private _ondpaddown;
  46776. private _ondpadup;
  46777. /** Observable raised when a button is pressed */
  46778. onButtonDownObservable: Observable<Xbox360Button>;
  46779. /** Observable raised when a button is released */
  46780. onButtonUpObservable: Observable<Xbox360Button>;
  46781. /** Observable raised when a pad is pressed */
  46782. onPadDownObservable: Observable<Xbox360Dpad>;
  46783. /** Observable raised when a pad is released */
  46784. onPadUpObservable: Observable<Xbox360Dpad>;
  46785. private _buttonA;
  46786. private _buttonB;
  46787. private _buttonX;
  46788. private _buttonY;
  46789. private _buttonBack;
  46790. private _buttonStart;
  46791. private _buttonLB;
  46792. private _buttonRB;
  46793. private _buttonLeftStick;
  46794. private _buttonRightStick;
  46795. private _dPadUp;
  46796. private _dPadDown;
  46797. private _dPadLeft;
  46798. private _dPadRight;
  46799. private _isXboxOnePad;
  46800. /**
  46801. * Creates a new XBox360 gamepad object
  46802. * @param id defines the id of this gamepad
  46803. * @param index defines its index
  46804. * @param gamepad defines the internal HTML gamepad object
  46805. * @param xboxOne defines if it is a XBox One gamepad
  46806. */
  46807. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46808. /**
  46809. * Defines the callback to call when left trigger is pressed
  46810. * @param callback defines the callback to use
  46811. */
  46812. onlefttriggerchanged(callback: (value: number) => void): void;
  46813. /**
  46814. * Defines the callback to call when right trigger is pressed
  46815. * @param callback defines the callback to use
  46816. */
  46817. onrighttriggerchanged(callback: (value: number) => void): void;
  46818. /**
  46819. * Gets the left trigger value
  46820. */
  46821. get leftTrigger(): number;
  46822. /**
  46823. * Sets the left trigger value
  46824. */
  46825. set leftTrigger(newValue: number);
  46826. /**
  46827. * Gets the right trigger value
  46828. */
  46829. get rightTrigger(): number;
  46830. /**
  46831. * Sets the right trigger value
  46832. */
  46833. set rightTrigger(newValue: number);
  46834. /**
  46835. * Defines the callback to call when a button is pressed
  46836. * @param callback defines the callback to use
  46837. */
  46838. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46839. /**
  46840. * Defines the callback to call when a button is released
  46841. * @param callback defines the callback to use
  46842. */
  46843. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46844. /**
  46845. * Defines the callback to call when a pad is pressed
  46846. * @param callback defines the callback to use
  46847. */
  46848. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46849. /**
  46850. * Defines the callback to call when a pad is released
  46851. * @param callback defines the callback to use
  46852. */
  46853. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46854. private _setButtonValue;
  46855. private _setDPadValue;
  46856. /**
  46857. * Gets the value of the `A` button
  46858. */
  46859. get buttonA(): number;
  46860. /**
  46861. * Sets the value of the `A` button
  46862. */
  46863. set buttonA(value: number);
  46864. /**
  46865. * Gets the value of the `B` button
  46866. */
  46867. get buttonB(): number;
  46868. /**
  46869. * Sets the value of the `B` button
  46870. */
  46871. set buttonB(value: number);
  46872. /**
  46873. * Gets the value of the `X` button
  46874. */
  46875. get buttonX(): number;
  46876. /**
  46877. * Sets the value of the `X` button
  46878. */
  46879. set buttonX(value: number);
  46880. /**
  46881. * Gets the value of the `Y` button
  46882. */
  46883. get buttonY(): number;
  46884. /**
  46885. * Sets the value of the `Y` button
  46886. */
  46887. set buttonY(value: number);
  46888. /**
  46889. * Gets the value of the `Start` button
  46890. */
  46891. get buttonStart(): number;
  46892. /**
  46893. * Sets the value of the `Start` button
  46894. */
  46895. set buttonStart(value: number);
  46896. /**
  46897. * Gets the value of the `Back` button
  46898. */
  46899. get buttonBack(): number;
  46900. /**
  46901. * Sets the value of the `Back` button
  46902. */
  46903. set buttonBack(value: number);
  46904. /**
  46905. * Gets the value of the `Left` button
  46906. */
  46907. get buttonLB(): number;
  46908. /**
  46909. * Sets the value of the `Left` button
  46910. */
  46911. set buttonLB(value: number);
  46912. /**
  46913. * Gets the value of the `Right` button
  46914. */
  46915. get buttonRB(): number;
  46916. /**
  46917. * Sets the value of the `Right` button
  46918. */
  46919. set buttonRB(value: number);
  46920. /**
  46921. * Gets the value of the Left joystick
  46922. */
  46923. get buttonLeftStick(): number;
  46924. /**
  46925. * Sets the value of the Left joystick
  46926. */
  46927. set buttonLeftStick(value: number);
  46928. /**
  46929. * Gets the value of the Right joystick
  46930. */
  46931. get buttonRightStick(): number;
  46932. /**
  46933. * Sets the value of the Right joystick
  46934. */
  46935. set buttonRightStick(value: number);
  46936. /**
  46937. * Gets the value of D-pad up
  46938. */
  46939. get dPadUp(): number;
  46940. /**
  46941. * Sets the value of D-pad up
  46942. */
  46943. set dPadUp(value: number);
  46944. /**
  46945. * Gets the value of D-pad down
  46946. */
  46947. get dPadDown(): number;
  46948. /**
  46949. * Sets the value of D-pad down
  46950. */
  46951. set dPadDown(value: number);
  46952. /**
  46953. * Gets the value of D-pad left
  46954. */
  46955. get dPadLeft(): number;
  46956. /**
  46957. * Sets the value of D-pad left
  46958. */
  46959. set dPadLeft(value: number);
  46960. /**
  46961. * Gets the value of D-pad right
  46962. */
  46963. get dPadRight(): number;
  46964. /**
  46965. * Sets the value of D-pad right
  46966. */
  46967. set dPadRight(value: number);
  46968. /**
  46969. * Force the gamepad to synchronize with device values
  46970. */
  46971. update(): void;
  46972. /**
  46973. * Disposes the gamepad
  46974. */
  46975. dispose(): void;
  46976. }
  46977. }
  46978. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46979. import { Observable } from "babylonjs/Misc/observable";
  46980. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46981. /**
  46982. * Defines supported buttons for DualShock compatible gamepads
  46983. */
  46984. export enum DualShockButton {
  46985. /** Cross */
  46986. Cross = 0,
  46987. /** Circle */
  46988. Circle = 1,
  46989. /** Square */
  46990. Square = 2,
  46991. /** Triangle */
  46992. Triangle = 3,
  46993. /** L1 */
  46994. L1 = 4,
  46995. /** R1 */
  46996. R1 = 5,
  46997. /** Share */
  46998. Share = 8,
  46999. /** Options */
  47000. Options = 9,
  47001. /** Left stick */
  47002. LeftStick = 10,
  47003. /** Right stick */
  47004. RightStick = 11
  47005. }
  47006. /** Defines values for DualShock DPad */
  47007. export enum DualShockDpad {
  47008. /** Up */
  47009. Up = 12,
  47010. /** Down */
  47011. Down = 13,
  47012. /** Left */
  47013. Left = 14,
  47014. /** Right */
  47015. Right = 15
  47016. }
  47017. /**
  47018. * Defines a DualShock gamepad
  47019. */
  47020. export class DualShockPad extends Gamepad {
  47021. private _leftTrigger;
  47022. private _rightTrigger;
  47023. private _onlefttriggerchanged;
  47024. private _onrighttriggerchanged;
  47025. private _onbuttondown;
  47026. private _onbuttonup;
  47027. private _ondpaddown;
  47028. private _ondpadup;
  47029. /** Observable raised when a button is pressed */
  47030. onButtonDownObservable: Observable<DualShockButton>;
  47031. /** Observable raised when a button is released */
  47032. onButtonUpObservable: Observable<DualShockButton>;
  47033. /** Observable raised when a pad is pressed */
  47034. onPadDownObservable: Observable<DualShockDpad>;
  47035. /** Observable raised when a pad is released */
  47036. onPadUpObservable: Observable<DualShockDpad>;
  47037. private _buttonCross;
  47038. private _buttonCircle;
  47039. private _buttonSquare;
  47040. private _buttonTriangle;
  47041. private _buttonShare;
  47042. private _buttonOptions;
  47043. private _buttonL1;
  47044. private _buttonR1;
  47045. private _buttonLeftStick;
  47046. private _buttonRightStick;
  47047. private _dPadUp;
  47048. private _dPadDown;
  47049. private _dPadLeft;
  47050. private _dPadRight;
  47051. /**
  47052. * Creates a new DualShock gamepad object
  47053. * @param id defines the id of this gamepad
  47054. * @param index defines its index
  47055. * @param gamepad defines the internal HTML gamepad object
  47056. */
  47057. constructor(id: string, index: number, gamepad: any);
  47058. /**
  47059. * Defines the callback to call when left trigger is pressed
  47060. * @param callback defines the callback to use
  47061. */
  47062. onlefttriggerchanged(callback: (value: number) => void): void;
  47063. /**
  47064. * Defines the callback to call when right trigger is pressed
  47065. * @param callback defines the callback to use
  47066. */
  47067. onrighttriggerchanged(callback: (value: number) => void): void;
  47068. /**
  47069. * Gets the left trigger value
  47070. */
  47071. get leftTrigger(): number;
  47072. /**
  47073. * Sets the left trigger value
  47074. */
  47075. set leftTrigger(newValue: number);
  47076. /**
  47077. * Gets the right trigger value
  47078. */
  47079. get rightTrigger(): number;
  47080. /**
  47081. * Sets the right trigger value
  47082. */
  47083. set rightTrigger(newValue: number);
  47084. /**
  47085. * Defines the callback to call when a button is pressed
  47086. * @param callback defines the callback to use
  47087. */
  47088. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47089. /**
  47090. * Defines the callback to call when a button is released
  47091. * @param callback defines the callback to use
  47092. */
  47093. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47094. /**
  47095. * Defines the callback to call when a pad is pressed
  47096. * @param callback defines the callback to use
  47097. */
  47098. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47099. /**
  47100. * Defines the callback to call when a pad is released
  47101. * @param callback defines the callback to use
  47102. */
  47103. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47104. private _setButtonValue;
  47105. private _setDPadValue;
  47106. /**
  47107. * Gets the value of the `Cross` button
  47108. */
  47109. get buttonCross(): number;
  47110. /**
  47111. * Sets the value of the `Cross` button
  47112. */
  47113. set buttonCross(value: number);
  47114. /**
  47115. * Gets the value of the `Circle` button
  47116. */
  47117. get buttonCircle(): number;
  47118. /**
  47119. * Sets the value of the `Circle` button
  47120. */
  47121. set buttonCircle(value: number);
  47122. /**
  47123. * Gets the value of the `Square` button
  47124. */
  47125. get buttonSquare(): number;
  47126. /**
  47127. * Sets the value of the `Square` button
  47128. */
  47129. set buttonSquare(value: number);
  47130. /**
  47131. * Gets the value of the `Triangle` button
  47132. */
  47133. get buttonTriangle(): number;
  47134. /**
  47135. * Sets the value of the `Triangle` button
  47136. */
  47137. set buttonTriangle(value: number);
  47138. /**
  47139. * Gets the value of the `Options` button
  47140. */
  47141. get buttonOptions(): number;
  47142. /**
  47143. * Sets the value of the `Options` button
  47144. */
  47145. set buttonOptions(value: number);
  47146. /**
  47147. * Gets the value of the `Share` button
  47148. */
  47149. get buttonShare(): number;
  47150. /**
  47151. * Sets the value of the `Share` button
  47152. */
  47153. set buttonShare(value: number);
  47154. /**
  47155. * Gets the value of the `L1` button
  47156. */
  47157. get buttonL1(): number;
  47158. /**
  47159. * Sets the value of the `L1` button
  47160. */
  47161. set buttonL1(value: number);
  47162. /**
  47163. * Gets the value of the `R1` button
  47164. */
  47165. get buttonR1(): number;
  47166. /**
  47167. * Sets the value of the `R1` button
  47168. */
  47169. set buttonR1(value: number);
  47170. /**
  47171. * Gets the value of the Left joystick
  47172. */
  47173. get buttonLeftStick(): number;
  47174. /**
  47175. * Sets the value of the Left joystick
  47176. */
  47177. set buttonLeftStick(value: number);
  47178. /**
  47179. * Gets the value of the Right joystick
  47180. */
  47181. get buttonRightStick(): number;
  47182. /**
  47183. * Sets the value of the Right joystick
  47184. */
  47185. set buttonRightStick(value: number);
  47186. /**
  47187. * Gets the value of D-pad up
  47188. */
  47189. get dPadUp(): number;
  47190. /**
  47191. * Sets the value of D-pad up
  47192. */
  47193. set dPadUp(value: number);
  47194. /**
  47195. * Gets the value of D-pad down
  47196. */
  47197. get dPadDown(): number;
  47198. /**
  47199. * Sets the value of D-pad down
  47200. */
  47201. set dPadDown(value: number);
  47202. /**
  47203. * Gets the value of D-pad left
  47204. */
  47205. get dPadLeft(): number;
  47206. /**
  47207. * Sets the value of D-pad left
  47208. */
  47209. set dPadLeft(value: number);
  47210. /**
  47211. * Gets the value of D-pad right
  47212. */
  47213. get dPadRight(): number;
  47214. /**
  47215. * Sets the value of D-pad right
  47216. */
  47217. set dPadRight(value: number);
  47218. /**
  47219. * Force the gamepad to synchronize with device values
  47220. */
  47221. update(): void;
  47222. /**
  47223. * Disposes the gamepad
  47224. */
  47225. dispose(): void;
  47226. }
  47227. }
  47228. declare module "babylonjs/Gamepads/gamepadManager" {
  47229. import { Observable } from "babylonjs/Misc/observable";
  47230. import { Nullable } from "babylonjs/types";
  47231. import { Scene } from "babylonjs/scene";
  47232. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47233. /**
  47234. * Manager for handling gamepads
  47235. */
  47236. export class GamepadManager {
  47237. private _scene?;
  47238. private _babylonGamepads;
  47239. private _oneGamepadConnected;
  47240. /** @hidden */
  47241. _isMonitoring: boolean;
  47242. private _gamepadEventSupported;
  47243. private _gamepadSupport?;
  47244. /**
  47245. * observable to be triggered when the gamepad controller has been connected
  47246. */
  47247. onGamepadConnectedObservable: Observable<Gamepad>;
  47248. /**
  47249. * observable to be triggered when the gamepad controller has been disconnected
  47250. */
  47251. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47252. private _onGamepadConnectedEvent;
  47253. private _onGamepadDisconnectedEvent;
  47254. /**
  47255. * Initializes the gamepad manager
  47256. * @param _scene BabylonJS scene
  47257. */
  47258. constructor(_scene?: Scene | undefined);
  47259. /**
  47260. * The gamepads in the game pad manager
  47261. */
  47262. get gamepads(): Gamepad[];
  47263. /**
  47264. * Get the gamepad controllers based on type
  47265. * @param type The type of gamepad controller
  47266. * @returns Nullable gamepad
  47267. */
  47268. getGamepadByType(type?: number): Nullable<Gamepad>;
  47269. /**
  47270. * Disposes the gamepad manager
  47271. */
  47272. dispose(): void;
  47273. private _addNewGamepad;
  47274. private _startMonitoringGamepads;
  47275. private _stopMonitoringGamepads;
  47276. /** @hidden */
  47277. _checkGamepadsStatus(): void;
  47278. private _updateGamepadObjects;
  47279. }
  47280. }
  47281. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47282. import { Nullable } from "babylonjs/types";
  47283. import { Scene } from "babylonjs/scene";
  47284. import { ISceneComponent } from "babylonjs/sceneComponent";
  47285. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47286. module "babylonjs/scene" {
  47287. interface Scene {
  47288. /** @hidden */
  47289. _gamepadManager: Nullable<GamepadManager>;
  47290. /**
  47291. * Gets the gamepad manager associated with the scene
  47292. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47293. */
  47294. gamepadManager: GamepadManager;
  47295. }
  47296. }
  47297. module "babylonjs/Cameras/freeCameraInputsManager" {
  47298. /**
  47299. * Interface representing a free camera inputs manager
  47300. */
  47301. interface FreeCameraInputsManager {
  47302. /**
  47303. * Adds gamepad input support to the FreeCameraInputsManager.
  47304. * @returns the FreeCameraInputsManager
  47305. */
  47306. addGamepad(): FreeCameraInputsManager;
  47307. }
  47308. }
  47309. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47310. /**
  47311. * Interface representing an arc rotate camera inputs manager
  47312. */
  47313. interface ArcRotateCameraInputsManager {
  47314. /**
  47315. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47316. * @returns the camera inputs manager
  47317. */
  47318. addGamepad(): ArcRotateCameraInputsManager;
  47319. }
  47320. }
  47321. /**
  47322. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47323. */
  47324. export class GamepadSystemSceneComponent implements ISceneComponent {
  47325. /**
  47326. * The component name helpfull to identify the component in the list of scene components.
  47327. */
  47328. readonly name: string;
  47329. /**
  47330. * The scene the component belongs to.
  47331. */
  47332. scene: Scene;
  47333. /**
  47334. * Creates a new instance of the component for the given scene
  47335. * @param scene Defines the scene to register the component in
  47336. */
  47337. constructor(scene: Scene);
  47338. /**
  47339. * Registers the component in a given scene
  47340. */
  47341. register(): void;
  47342. /**
  47343. * Rebuilds the elements related to this component in case of
  47344. * context lost for instance.
  47345. */
  47346. rebuild(): void;
  47347. /**
  47348. * Disposes the component and the associated ressources
  47349. */
  47350. dispose(): void;
  47351. private _beforeCameraUpdate;
  47352. }
  47353. }
  47354. declare module "babylonjs/Cameras/universalCamera" {
  47355. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47356. import { Scene } from "babylonjs/scene";
  47357. import { Vector3 } from "babylonjs/Maths/math.vector";
  47358. import "babylonjs/Gamepads/gamepadSceneComponent";
  47359. /**
  47360. * 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,
  47361. * which still works and will still be found in many Playgrounds.
  47362. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47363. */
  47364. export class UniversalCamera extends TouchCamera {
  47365. /**
  47366. * Defines the gamepad rotation sensiblity.
  47367. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47368. */
  47369. get gamepadAngularSensibility(): number;
  47370. set gamepadAngularSensibility(value: number);
  47371. /**
  47372. * Defines the gamepad move sensiblity.
  47373. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47374. */
  47375. get gamepadMoveSensibility(): number;
  47376. set gamepadMoveSensibility(value: number);
  47377. /**
  47378. * 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,
  47379. * which still works and will still be found in many Playgrounds.
  47380. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47381. * @param name Define the name of the camera in the scene
  47382. * @param position Define the start position of the camera in the scene
  47383. * @param scene Define the scene the camera belongs to
  47384. */
  47385. constructor(name: string, position: Vector3, scene: Scene);
  47386. /**
  47387. * Gets the current object class name.
  47388. * @return the class name
  47389. */
  47390. getClassName(): string;
  47391. }
  47392. }
  47393. declare module "babylonjs/Cameras/gamepadCamera" {
  47394. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47395. import { Scene } from "babylonjs/scene";
  47396. import { Vector3 } from "babylonjs/Maths/math.vector";
  47397. /**
  47398. * This represents a FPS type of camera. This is only here for back compat purpose.
  47399. * Please use the UniversalCamera instead as both are identical.
  47400. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47401. */
  47402. export class GamepadCamera extends UniversalCamera {
  47403. /**
  47404. * Instantiates a new Gamepad Camera
  47405. * This represents a FPS type of camera. This is only here for back compat purpose.
  47406. * Please use the UniversalCamera instead as both are identical.
  47407. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47408. * @param name Define the name of the camera in the scene
  47409. * @param position Define the start position of the camera in the scene
  47410. * @param scene Define the scene the camera belongs to
  47411. */
  47412. constructor(name: string, position: Vector3, scene: Scene);
  47413. /**
  47414. * Gets the current object class name.
  47415. * @return the class name
  47416. */
  47417. getClassName(): string;
  47418. }
  47419. }
  47420. declare module "babylonjs/Shaders/pass.fragment" {
  47421. /** @hidden */
  47422. export var passPixelShader: {
  47423. name: string;
  47424. shader: string;
  47425. };
  47426. }
  47427. declare module "babylonjs/Shaders/passCube.fragment" {
  47428. /** @hidden */
  47429. export var passCubePixelShader: {
  47430. name: string;
  47431. shader: string;
  47432. };
  47433. }
  47434. declare module "babylonjs/PostProcesses/passPostProcess" {
  47435. import { Nullable } from "babylonjs/types";
  47436. import { Camera } from "babylonjs/Cameras/camera";
  47437. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47438. import { Engine } from "babylonjs/Engines/engine";
  47439. import "babylonjs/Shaders/pass.fragment";
  47440. import "babylonjs/Shaders/passCube.fragment";
  47441. /**
  47442. * PassPostProcess which produces an output the same as it's input
  47443. */
  47444. export class PassPostProcess extends PostProcess {
  47445. /**
  47446. * Creates the PassPostProcess
  47447. * @param name The name of the effect.
  47448. * @param options The required width/height ratio to downsize to before computing the render pass.
  47449. * @param camera The camera to apply the render pass to.
  47450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47451. * @param engine The engine which the post process will be applied. (default: current engine)
  47452. * @param reusable If the post process can be reused on the same frame. (default: false)
  47453. * @param textureType The type of texture to be used when performing the post processing.
  47454. * @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)
  47455. */
  47456. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47457. }
  47458. /**
  47459. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47460. */
  47461. export class PassCubePostProcess extends PostProcess {
  47462. private _face;
  47463. /**
  47464. * Gets or sets the cube face to display.
  47465. * * 0 is +X
  47466. * * 1 is -X
  47467. * * 2 is +Y
  47468. * * 3 is -Y
  47469. * * 4 is +Z
  47470. * * 5 is -Z
  47471. */
  47472. get face(): number;
  47473. set face(value: number);
  47474. /**
  47475. * Creates the PassCubePostProcess
  47476. * @param name The name of the effect.
  47477. * @param options The required width/height ratio to downsize to before computing the render pass.
  47478. * @param camera The camera to apply the render pass to.
  47479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47480. * @param engine The engine which the post process will be applied. (default: current engine)
  47481. * @param reusable If the post process can be reused on the same frame. (default: false)
  47482. * @param textureType The type of texture to be used when performing the post processing.
  47483. * @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)
  47484. */
  47485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47486. }
  47487. }
  47488. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47489. /** @hidden */
  47490. export var anaglyphPixelShader: {
  47491. name: string;
  47492. shader: string;
  47493. };
  47494. }
  47495. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47496. import { Engine } from "babylonjs/Engines/engine";
  47497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47498. import { Camera } from "babylonjs/Cameras/camera";
  47499. import "babylonjs/Shaders/anaglyph.fragment";
  47500. /**
  47501. * Postprocess used to generate anaglyphic rendering
  47502. */
  47503. export class AnaglyphPostProcess extends PostProcess {
  47504. private _passedProcess;
  47505. /**
  47506. * Creates a new AnaglyphPostProcess
  47507. * @param name defines postprocess name
  47508. * @param options defines creation options or target ratio scale
  47509. * @param rigCameras defines cameras using this postprocess
  47510. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47511. * @param engine defines hosting engine
  47512. * @param reusable defines if the postprocess will be reused multiple times per frame
  47513. */
  47514. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47515. }
  47516. }
  47517. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47518. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47520. import { Scene } from "babylonjs/scene";
  47521. import { Vector3 } from "babylonjs/Maths/math.vector";
  47522. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47523. /**
  47524. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47525. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47526. */
  47527. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47528. /**
  47529. * Creates a new AnaglyphArcRotateCamera
  47530. * @param name defines camera name
  47531. * @param alpha defines alpha angle (in radians)
  47532. * @param beta defines beta angle (in radians)
  47533. * @param radius defines radius
  47534. * @param target defines camera target
  47535. * @param interaxialDistance defines distance between each color axis
  47536. * @param scene defines the hosting scene
  47537. */
  47538. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47539. /**
  47540. * Gets camera class name
  47541. * @returns AnaglyphArcRotateCamera
  47542. */
  47543. getClassName(): string;
  47544. }
  47545. }
  47546. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47547. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47548. import { Scene } from "babylonjs/scene";
  47549. import { Vector3 } from "babylonjs/Maths/math.vector";
  47550. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47551. /**
  47552. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47553. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47554. */
  47555. export class AnaglyphFreeCamera extends FreeCamera {
  47556. /**
  47557. * Creates a new AnaglyphFreeCamera
  47558. * @param name defines camera name
  47559. * @param position defines initial position
  47560. * @param interaxialDistance defines distance between each color axis
  47561. * @param scene defines the hosting scene
  47562. */
  47563. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47564. /**
  47565. * Gets camera class name
  47566. * @returns AnaglyphFreeCamera
  47567. */
  47568. getClassName(): string;
  47569. }
  47570. }
  47571. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47572. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47573. import { Scene } from "babylonjs/scene";
  47574. import { Vector3 } from "babylonjs/Maths/math.vector";
  47575. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47576. /**
  47577. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47578. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47579. */
  47580. export class AnaglyphGamepadCamera extends GamepadCamera {
  47581. /**
  47582. * Creates a new AnaglyphGamepadCamera
  47583. * @param name defines camera name
  47584. * @param position defines initial position
  47585. * @param interaxialDistance defines distance between each color axis
  47586. * @param scene defines the hosting scene
  47587. */
  47588. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47589. /**
  47590. * Gets camera class name
  47591. * @returns AnaglyphGamepadCamera
  47592. */
  47593. getClassName(): string;
  47594. }
  47595. }
  47596. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47597. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47598. import { Scene } from "babylonjs/scene";
  47599. import { Vector3 } from "babylonjs/Maths/math.vector";
  47600. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47601. /**
  47602. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47603. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47604. */
  47605. export class AnaglyphUniversalCamera extends UniversalCamera {
  47606. /**
  47607. * Creates a new AnaglyphUniversalCamera
  47608. * @param name defines camera name
  47609. * @param position defines initial position
  47610. * @param interaxialDistance defines distance between each color axis
  47611. * @param scene defines the hosting scene
  47612. */
  47613. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47614. /**
  47615. * Gets camera class name
  47616. * @returns AnaglyphUniversalCamera
  47617. */
  47618. getClassName(): string;
  47619. }
  47620. }
  47621. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47622. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47623. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47624. import { Scene } from "babylonjs/scene";
  47625. import { Vector3 } from "babylonjs/Maths/math.vector";
  47626. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47627. /**
  47628. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47629. * @see https://doc.babylonjs.com/features/cameras
  47630. */
  47631. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47632. /**
  47633. * Creates a new StereoscopicArcRotateCamera
  47634. * @param name defines camera name
  47635. * @param alpha defines alpha angle (in radians)
  47636. * @param beta defines beta angle (in radians)
  47637. * @param radius defines radius
  47638. * @param target defines camera target
  47639. * @param interaxialDistance defines distance between each color axis
  47640. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47641. * @param scene defines the hosting scene
  47642. */
  47643. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47644. /**
  47645. * Gets camera class name
  47646. * @returns StereoscopicArcRotateCamera
  47647. */
  47648. getClassName(): string;
  47649. }
  47650. }
  47651. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47652. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47653. import { Scene } from "babylonjs/scene";
  47654. import { Vector3 } from "babylonjs/Maths/math.vector";
  47655. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47656. /**
  47657. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47658. * @see https://doc.babylonjs.com/features/cameras
  47659. */
  47660. export class StereoscopicFreeCamera extends FreeCamera {
  47661. /**
  47662. * Creates a new StereoscopicFreeCamera
  47663. * @param name defines camera name
  47664. * @param position defines initial position
  47665. * @param interaxialDistance defines distance between each color axis
  47666. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47667. * @param scene defines the hosting scene
  47668. */
  47669. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47670. /**
  47671. * Gets camera class name
  47672. * @returns StereoscopicFreeCamera
  47673. */
  47674. getClassName(): string;
  47675. }
  47676. }
  47677. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47678. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47679. import { Scene } from "babylonjs/scene";
  47680. import { Vector3 } from "babylonjs/Maths/math.vector";
  47681. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47682. /**
  47683. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47684. * @see https://doc.babylonjs.com/features/cameras
  47685. */
  47686. export class StereoscopicGamepadCamera extends GamepadCamera {
  47687. /**
  47688. * Creates a new StereoscopicGamepadCamera
  47689. * @param name defines camera name
  47690. * @param position defines initial position
  47691. * @param interaxialDistance defines distance between each color axis
  47692. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47693. * @param scene defines the hosting scene
  47694. */
  47695. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47696. /**
  47697. * Gets camera class name
  47698. * @returns StereoscopicGamepadCamera
  47699. */
  47700. getClassName(): string;
  47701. }
  47702. }
  47703. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47704. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47705. import { Scene } from "babylonjs/scene";
  47706. import { Vector3 } from "babylonjs/Maths/math.vector";
  47707. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47708. /**
  47709. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47710. * @see https://doc.babylonjs.com/features/cameras
  47711. */
  47712. export class StereoscopicUniversalCamera extends UniversalCamera {
  47713. /**
  47714. * Creates a new StereoscopicUniversalCamera
  47715. * @param name defines camera name
  47716. * @param position defines initial position
  47717. * @param interaxialDistance defines distance between each color axis
  47718. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47719. * @param scene defines the hosting scene
  47720. */
  47721. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47722. /**
  47723. * Gets camera class name
  47724. * @returns StereoscopicUniversalCamera
  47725. */
  47726. getClassName(): string;
  47727. }
  47728. }
  47729. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47730. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47731. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47732. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47733. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47734. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47735. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47736. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47737. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47738. }
  47739. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47740. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47741. import { Scene } from "babylonjs/scene";
  47742. import { Vector3 } from "babylonjs/Maths/math.vector";
  47743. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47744. /**
  47745. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47746. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47747. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47748. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47749. */
  47750. export class VirtualJoysticksCamera extends FreeCamera {
  47751. /**
  47752. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47753. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47754. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47755. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47756. * @param name Define the name of the camera in the scene
  47757. * @param position Define the start position of the camera in the scene
  47758. * @param scene Define the scene the camera belongs to
  47759. */
  47760. constructor(name: string, position: Vector3, scene: Scene);
  47761. /**
  47762. * Gets the current object class name.
  47763. * @return the class name
  47764. */
  47765. getClassName(): string;
  47766. }
  47767. }
  47768. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47769. import { Matrix } from "babylonjs/Maths/math.vector";
  47770. /**
  47771. * This represents all the required metrics to create a VR camera.
  47772. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47773. */
  47774. export class VRCameraMetrics {
  47775. /**
  47776. * Define the horizontal resolution off the screen.
  47777. */
  47778. hResolution: number;
  47779. /**
  47780. * Define the vertical resolution off the screen.
  47781. */
  47782. vResolution: number;
  47783. /**
  47784. * Define the horizontal screen size.
  47785. */
  47786. hScreenSize: number;
  47787. /**
  47788. * Define the vertical screen size.
  47789. */
  47790. vScreenSize: number;
  47791. /**
  47792. * Define the vertical screen center position.
  47793. */
  47794. vScreenCenter: number;
  47795. /**
  47796. * Define the distance of the eyes to the screen.
  47797. */
  47798. eyeToScreenDistance: number;
  47799. /**
  47800. * Define the distance between both lenses
  47801. */
  47802. lensSeparationDistance: number;
  47803. /**
  47804. * Define the distance between both viewer's eyes.
  47805. */
  47806. interpupillaryDistance: number;
  47807. /**
  47808. * Define the distortion factor of the VR postprocess.
  47809. * Please, touch with care.
  47810. */
  47811. distortionK: number[];
  47812. /**
  47813. * Define the chromatic aberration correction factors for the VR post process.
  47814. */
  47815. chromaAbCorrection: number[];
  47816. /**
  47817. * Define the scale factor of the post process.
  47818. * The smaller the better but the slower.
  47819. */
  47820. postProcessScaleFactor: number;
  47821. /**
  47822. * Define an offset for the lens center.
  47823. */
  47824. lensCenterOffset: number;
  47825. /**
  47826. * Define if the current vr camera should compensate the distortion of the lense or not.
  47827. */
  47828. compensateDistortion: boolean;
  47829. /**
  47830. * Defines if multiview should be enabled when rendering (Default: false)
  47831. */
  47832. multiviewEnabled: boolean;
  47833. /**
  47834. * Gets the rendering aspect ratio based on the provided resolutions.
  47835. */
  47836. get aspectRatio(): number;
  47837. /**
  47838. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47839. */
  47840. get aspectRatioFov(): number;
  47841. /**
  47842. * @hidden
  47843. */
  47844. get leftHMatrix(): Matrix;
  47845. /**
  47846. * @hidden
  47847. */
  47848. get rightHMatrix(): Matrix;
  47849. /**
  47850. * @hidden
  47851. */
  47852. get leftPreViewMatrix(): Matrix;
  47853. /**
  47854. * @hidden
  47855. */
  47856. get rightPreViewMatrix(): Matrix;
  47857. /**
  47858. * Get the default VRMetrics based on the most generic setup.
  47859. * @returns the default vr metrics
  47860. */
  47861. static GetDefault(): VRCameraMetrics;
  47862. }
  47863. }
  47864. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47865. /** @hidden */
  47866. export var vrDistortionCorrectionPixelShader: {
  47867. name: string;
  47868. shader: string;
  47869. };
  47870. }
  47871. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47872. import { Camera } from "babylonjs/Cameras/camera";
  47873. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47874. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47875. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47876. /**
  47877. * VRDistortionCorrectionPostProcess used for mobile VR
  47878. */
  47879. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47880. private _isRightEye;
  47881. private _distortionFactors;
  47882. private _postProcessScaleFactor;
  47883. private _lensCenterOffset;
  47884. private _scaleIn;
  47885. private _scaleFactor;
  47886. private _lensCenter;
  47887. /**
  47888. * Initializes the VRDistortionCorrectionPostProcess
  47889. * @param name The name of the effect.
  47890. * @param camera The camera to apply the render pass to.
  47891. * @param isRightEye If this is for the right eye distortion
  47892. * @param vrMetrics All the required metrics for the VR camera
  47893. */
  47894. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47895. }
  47896. }
  47897. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47898. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47899. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47900. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47901. import { Scene } from "babylonjs/scene";
  47902. import { Vector3 } from "babylonjs/Maths/math.vector";
  47903. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47904. import "babylonjs/Cameras/RigModes/vrRigMode";
  47905. /**
  47906. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47907. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47908. */
  47909. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47910. /**
  47911. * Creates a new VRDeviceOrientationArcRotateCamera
  47912. * @param name defines camera name
  47913. * @param alpha defines the camera rotation along the logitudinal axis
  47914. * @param beta defines the camera rotation along the latitudinal axis
  47915. * @param radius defines the camera distance from its target
  47916. * @param target defines the camera target
  47917. * @param scene defines the scene the camera belongs to
  47918. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47919. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47920. */
  47921. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47922. /**
  47923. * Gets camera class name
  47924. * @returns VRDeviceOrientationArcRotateCamera
  47925. */
  47926. getClassName(): string;
  47927. }
  47928. }
  47929. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47930. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47931. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47932. import { Scene } from "babylonjs/scene";
  47933. import { Vector3 } from "babylonjs/Maths/math.vector";
  47934. import "babylonjs/Cameras/RigModes/vrRigMode";
  47935. /**
  47936. * Camera used to simulate VR rendering (based on FreeCamera)
  47937. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47938. */
  47939. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47940. /**
  47941. * Creates a new VRDeviceOrientationFreeCamera
  47942. * @param name defines camera name
  47943. * @param position defines the start position of the camera
  47944. * @param scene defines the scene the camera belongs to
  47945. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47946. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47947. */
  47948. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47949. /**
  47950. * Gets camera class name
  47951. * @returns VRDeviceOrientationFreeCamera
  47952. */
  47953. getClassName(): string;
  47954. }
  47955. }
  47956. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47957. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47958. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47959. import { Scene } from "babylonjs/scene";
  47960. import { Vector3 } from "babylonjs/Maths/math.vector";
  47961. import "babylonjs/Gamepads/gamepadSceneComponent";
  47962. /**
  47963. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47964. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47965. */
  47966. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47967. /**
  47968. * Creates a new VRDeviceOrientationGamepadCamera
  47969. * @param name defines camera name
  47970. * @param position defines the start position of the camera
  47971. * @param scene defines the scene the camera belongs to
  47972. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47973. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47974. */
  47975. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47976. /**
  47977. * Gets camera class name
  47978. * @returns VRDeviceOrientationGamepadCamera
  47979. */
  47980. getClassName(): string;
  47981. }
  47982. }
  47983. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47984. import { Scene } from "babylonjs/scene";
  47985. import { Texture } from "babylonjs/Materials/Textures/texture";
  47986. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47987. /**
  47988. * A class extending Texture allowing drawing on a texture
  47989. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47990. */
  47991. export class DynamicTexture extends Texture {
  47992. private _generateMipMaps;
  47993. private _canvas;
  47994. private _context;
  47995. /**
  47996. * Creates a DynamicTexture
  47997. * @param name defines the name of the texture
  47998. * @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
  47999. * @param scene defines the scene where you want the texture
  48000. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48001. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48002. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48003. */
  48004. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48005. /**
  48006. * Get the current class name of the texture useful for serialization or dynamic coding.
  48007. * @returns "DynamicTexture"
  48008. */
  48009. getClassName(): string;
  48010. /**
  48011. * Gets the current state of canRescale
  48012. */
  48013. get canRescale(): boolean;
  48014. private _recreate;
  48015. /**
  48016. * Scales the texture
  48017. * @param ratio the scale factor to apply to both width and height
  48018. */
  48019. scale(ratio: number): void;
  48020. /**
  48021. * Resizes the texture
  48022. * @param width the new width
  48023. * @param height the new height
  48024. */
  48025. scaleTo(width: number, height: number): void;
  48026. /**
  48027. * Gets the context of the canvas used by the texture
  48028. * @returns the canvas context of the dynamic texture
  48029. */
  48030. getContext(): CanvasRenderingContext2D;
  48031. /**
  48032. * Clears the texture
  48033. */
  48034. clear(): void;
  48035. /**
  48036. * Updates the texture
  48037. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48038. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48039. */
  48040. update(invertY?: boolean, premulAlpha?: boolean): void;
  48041. /**
  48042. * Draws text onto the texture
  48043. * @param text defines the text to be drawn
  48044. * @param x defines the placement of the text from the left
  48045. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48046. * @param font defines the font to be used with font-style, font-size, font-name
  48047. * @param color defines the color used for the text
  48048. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48049. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48050. * @param update defines whether texture is immediately update (default is true)
  48051. */
  48052. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48053. /**
  48054. * Clones the texture
  48055. * @returns the clone of the texture.
  48056. */
  48057. clone(): DynamicTexture;
  48058. /**
  48059. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48060. * @returns a serialized dynamic texture object
  48061. */
  48062. serialize(): any;
  48063. private _IsCanvasElement;
  48064. /** @hidden */
  48065. _rebuild(): void;
  48066. }
  48067. }
  48068. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48069. import { Scene } from "babylonjs/scene";
  48070. import { Color3 } from "babylonjs/Maths/math.color";
  48071. import { Mesh } from "babylonjs/Meshes/mesh";
  48072. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48073. import { Nullable } from "babylonjs/types";
  48074. /**
  48075. * Class containing static functions to help procedurally build meshes
  48076. */
  48077. export class GroundBuilder {
  48078. /**
  48079. * Creates a ground mesh
  48080. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48081. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48083. * @param name defines the name of the mesh
  48084. * @param options defines the options used to create the mesh
  48085. * @param scene defines the hosting scene
  48086. * @returns the ground mesh
  48087. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48088. */
  48089. static CreateGround(name: string, options: {
  48090. width?: number;
  48091. height?: number;
  48092. subdivisions?: number;
  48093. subdivisionsX?: number;
  48094. subdivisionsY?: number;
  48095. updatable?: boolean;
  48096. }, scene: any): Mesh;
  48097. /**
  48098. * Creates a tiled ground mesh
  48099. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48100. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48101. * * 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
  48102. * * 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
  48103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48104. * @param name defines the name of the mesh
  48105. * @param options defines the options used to create the mesh
  48106. * @param scene defines the hosting scene
  48107. * @returns the tiled ground mesh
  48108. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48109. */
  48110. static CreateTiledGround(name: string, options: {
  48111. xmin: number;
  48112. zmin: number;
  48113. xmax: number;
  48114. zmax: number;
  48115. subdivisions?: {
  48116. w: number;
  48117. h: number;
  48118. };
  48119. precision?: {
  48120. w: number;
  48121. h: number;
  48122. };
  48123. updatable?: boolean;
  48124. }, scene?: Nullable<Scene>): Mesh;
  48125. /**
  48126. * Creates a ground mesh from a height map
  48127. * * The parameter `url` sets the URL of the height map image resource.
  48128. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48129. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48130. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48131. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48132. * * 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.
  48133. * * 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).
  48134. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48136. * @param name defines the name of the mesh
  48137. * @param url defines the url to the height map
  48138. * @param options defines the options used to create the mesh
  48139. * @param scene defines the hosting scene
  48140. * @returns the ground mesh
  48141. * @see https://doc.babylonjs.com/babylon101/height_map
  48142. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48143. */
  48144. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48145. width?: number;
  48146. height?: number;
  48147. subdivisions?: number;
  48148. minHeight?: number;
  48149. maxHeight?: number;
  48150. colorFilter?: Color3;
  48151. alphaFilter?: number;
  48152. updatable?: boolean;
  48153. onReady?: (mesh: GroundMesh) => void;
  48154. }, scene?: Nullable<Scene>): GroundMesh;
  48155. }
  48156. }
  48157. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48158. import { Vector4 } from "babylonjs/Maths/math.vector";
  48159. import { Mesh } from "babylonjs/Meshes/mesh";
  48160. /**
  48161. * Class containing static functions to help procedurally build meshes
  48162. */
  48163. export class TorusBuilder {
  48164. /**
  48165. * Creates a torus mesh
  48166. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48167. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48168. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48172. * @param name defines the name of the mesh
  48173. * @param options defines the options used to create the mesh
  48174. * @param scene defines the hosting scene
  48175. * @returns the torus mesh
  48176. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48177. */
  48178. static CreateTorus(name: string, options: {
  48179. diameter?: number;
  48180. thickness?: number;
  48181. tessellation?: number;
  48182. updatable?: boolean;
  48183. sideOrientation?: number;
  48184. frontUVs?: Vector4;
  48185. backUVs?: Vector4;
  48186. }, scene: any): Mesh;
  48187. }
  48188. }
  48189. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48190. import { Vector4 } from "babylonjs/Maths/math.vector";
  48191. import { Color4 } from "babylonjs/Maths/math.color";
  48192. import { Mesh } from "babylonjs/Meshes/mesh";
  48193. /**
  48194. * Class containing static functions to help procedurally build meshes
  48195. */
  48196. export class CylinderBuilder {
  48197. /**
  48198. * Creates a cylinder or a cone mesh
  48199. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48200. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48201. * * 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.
  48202. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48203. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48204. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48205. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48206. * * 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).
  48207. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48208. * * 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).
  48209. * * 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
  48210. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48211. * * 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
  48212. * * 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.
  48213. * * If `enclose` is false, a ring surface is one element.
  48214. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48215. * * 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
  48216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48219. * @param name defines the name of the mesh
  48220. * @param options defines the options used to create the mesh
  48221. * @param scene defines the hosting scene
  48222. * @returns the cylinder mesh
  48223. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48224. */
  48225. static CreateCylinder(name: string, options: {
  48226. height?: number;
  48227. diameterTop?: number;
  48228. diameterBottom?: number;
  48229. diameter?: number;
  48230. tessellation?: number;
  48231. subdivisions?: number;
  48232. arc?: number;
  48233. faceColors?: Color4[];
  48234. faceUV?: Vector4[];
  48235. updatable?: boolean;
  48236. hasRings?: boolean;
  48237. enclose?: boolean;
  48238. cap?: number;
  48239. sideOrientation?: number;
  48240. frontUVs?: Vector4;
  48241. backUVs?: Vector4;
  48242. }, scene: any): Mesh;
  48243. }
  48244. }
  48245. declare module "babylonjs/XR/webXRTypes" {
  48246. import { Nullable } from "babylonjs/types";
  48247. import { IDisposable } from "babylonjs/scene";
  48248. /**
  48249. * States of the webXR experience
  48250. */
  48251. export enum WebXRState {
  48252. /**
  48253. * Transitioning to being in XR mode
  48254. */
  48255. ENTERING_XR = 0,
  48256. /**
  48257. * Transitioning to non XR mode
  48258. */
  48259. EXITING_XR = 1,
  48260. /**
  48261. * In XR mode and presenting
  48262. */
  48263. IN_XR = 2,
  48264. /**
  48265. * Not entered XR mode
  48266. */
  48267. NOT_IN_XR = 3
  48268. }
  48269. /**
  48270. * Abstraction of the XR render target
  48271. */
  48272. export interface WebXRRenderTarget extends IDisposable {
  48273. /**
  48274. * xrpresent context of the canvas which can be used to display/mirror xr content
  48275. */
  48276. canvasContext: WebGLRenderingContext;
  48277. /**
  48278. * xr layer for the canvas
  48279. */
  48280. xrLayer: Nullable<XRWebGLLayer>;
  48281. /**
  48282. * Initializes the xr layer for the session
  48283. * @param xrSession xr session
  48284. * @returns a promise that will resolve once the XR Layer has been created
  48285. */
  48286. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48287. }
  48288. }
  48289. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48290. import { Nullable } from "babylonjs/types";
  48291. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48292. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48293. import { Observable } from "babylonjs/Misc/observable";
  48294. /**
  48295. * COnfiguration object for WebXR output canvas
  48296. */
  48297. export class WebXRManagedOutputCanvasOptions {
  48298. /**
  48299. * An optional canvas in case you wish to create it yourself and provide it here.
  48300. * If not provided, a new canvas will be created
  48301. */
  48302. canvasElement?: HTMLCanvasElement;
  48303. /**
  48304. * Options for this XR Layer output
  48305. */
  48306. canvasOptions?: XRWebGLLayerOptions;
  48307. /**
  48308. * CSS styling for a newly created canvas (if not provided)
  48309. */
  48310. newCanvasCssStyle?: string;
  48311. /**
  48312. * Get the default values of the configuration object
  48313. * @returns default values of this configuration object
  48314. */
  48315. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48316. }
  48317. /**
  48318. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48319. */
  48320. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48321. private _options;
  48322. private _canvas;
  48323. private _engine;
  48324. private _originalCanvasSize;
  48325. /**
  48326. * Rendering context of the canvas which can be used to display/mirror xr content
  48327. */
  48328. canvasContext: WebGLRenderingContext;
  48329. /**
  48330. * xr layer for the canvas
  48331. */
  48332. xrLayer: Nullable<XRWebGLLayer>;
  48333. /**
  48334. * Obseervers registered here will be triggered when the xr layer was initialized
  48335. */
  48336. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48337. /**
  48338. * Initializes the canvas to be added/removed upon entering/exiting xr
  48339. * @param _xrSessionManager The XR Session manager
  48340. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48341. */
  48342. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48343. /**
  48344. * Disposes of the object
  48345. */
  48346. dispose(): void;
  48347. /**
  48348. * Initializes the xr layer for the session
  48349. * @param xrSession xr session
  48350. * @returns a promise that will resolve once the XR Layer has been created
  48351. */
  48352. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48353. private _addCanvas;
  48354. private _removeCanvas;
  48355. private _setCanvasSize;
  48356. private _setManagedOutputCanvas;
  48357. }
  48358. }
  48359. declare module "babylonjs/XR/webXRSessionManager" {
  48360. import { Observable } from "babylonjs/Misc/observable";
  48361. import { Nullable } from "babylonjs/types";
  48362. import { IDisposable, Scene } from "babylonjs/scene";
  48363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48364. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48365. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48366. /**
  48367. * Manages an XRSession to work with Babylon's engine
  48368. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48369. */
  48370. export class WebXRSessionManager implements IDisposable {
  48371. /** The scene which the session should be created for */
  48372. scene: Scene;
  48373. private _referenceSpace;
  48374. private _rttProvider;
  48375. private _sessionEnded;
  48376. private _xrNavigator;
  48377. private baseLayer;
  48378. /**
  48379. * The base reference space from which the session started. good if you want to reset your
  48380. * reference space
  48381. */
  48382. baseReferenceSpace: XRReferenceSpace;
  48383. /**
  48384. * Current XR frame
  48385. */
  48386. currentFrame: Nullable<XRFrame>;
  48387. /** WebXR timestamp updated every frame */
  48388. currentTimestamp: number;
  48389. /**
  48390. * Used just in case of a failure to initialize an immersive session.
  48391. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48392. */
  48393. defaultHeightCompensation: number;
  48394. /**
  48395. * Fires every time a new xrFrame arrives which can be used to update the camera
  48396. */
  48397. onXRFrameObservable: Observable<XRFrame>;
  48398. /**
  48399. * Fires when the reference space changed
  48400. */
  48401. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48402. /**
  48403. * Fires when the xr session is ended either by the device or manually done
  48404. */
  48405. onXRSessionEnded: Observable<any>;
  48406. /**
  48407. * Fires when the xr session is ended either by the device or manually done
  48408. */
  48409. onXRSessionInit: Observable<XRSession>;
  48410. /**
  48411. * Underlying xr session
  48412. */
  48413. session: XRSession;
  48414. /**
  48415. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48416. * or get the offset the player is currently at.
  48417. */
  48418. viewerReferenceSpace: XRReferenceSpace;
  48419. /**
  48420. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48421. * @param scene The scene which the session should be created for
  48422. */
  48423. constructor(
  48424. /** The scene which the session should be created for */
  48425. scene: Scene);
  48426. /**
  48427. * The current reference space used in this session. This reference space can constantly change!
  48428. * It is mainly used to offset the camera's position.
  48429. */
  48430. get referenceSpace(): XRReferenceSpace;
  48431. /**
  48432. * Set a new reference space and triggers the observable
  48433. */
  48434. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48435. /**
  48436. * Disposes of the session manager
  48437. */
  48438. dispose(): void;
  48439. /**
  48440. * Stops the xrSession and restores the render loop
  48441. * @returns Promise which resolves after it exits XR
  48442. */
  48443. exitXRAsync(): Promise<void>;
  48444. /**
  48445. * Gets the correct render target texture to be rendered this frame for this eye
  48446. * @param eye the eye for which to get the render target
  48447. * @returns the render target for the specified eye
  48448. */
  48449. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48450. /**
  48451. * Creates a WebXRRenderTarget object for the XR session
  48452. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48453. * @param options optional options to provide when creating a new render target
  48454. * @returns a WebXR render target to which the session can render
  48455. */
  48456. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48457. /**
  48458. * Initializes the manager
  48459. * After initialization enterXR can be called to start an XR session
  48460. * @returns Promise which resolves after it is initialized
  48461. */
  48462. initializeAsync(): Promise<void>;
  48463. /**
  48464. * Initializes an xr session
  48465. * @param xrSessionMode mode to initialize
  48466. * @param xrSessionInit defines optional and required values to pass to the session builder
  48467. * @returns a promise which will resolve once the session has been initialized
  48468. */
  48469. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48470. /**
  48471. * Checks if a session would be supported for the creation options specified
  48472. * @param sessionMode session mode to check if supported eg. immersive-vr
  48473. * @returns A Promise that resolves to true if supported and false if not
  48474. */
  48475. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48476. /**
  48477. * Resets the reference space to the one started the session
  48478. */
  48479. resetReferenceSpace(): void;
  48480. /**
  48481. * Starts rendering to the xr layer
  48482. */
  48483. runXRRenderLoop(): void;
  48484. /**
  48485. * Sets the reference space on the xr session
  48486. * @param referenceSpaceType space to set
  48487. * @returns a promise that will resolve once the reference space has been set
  48488. */
  48489. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48490. /**
  48491. * Updates the render state of the session
  48492. * @param state state to set
  48493. * @returns a promise that resolves once the render state has been updated
  48494. */
  48495. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48496. /**
  48497. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48498. * @param sessionMode defines the session to test
  48499. * @returns a promise with boolean as final value
  48500. */
  48501. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48502. private _createRenderTargetTexture;
  48503. }
  48504. }
  48505. declare module "babylonjs/XR/webXRCamera" {
  48506. import { Scene } from "babylonjs/scene";
  48507. import { Camera } from "babylonjs/Cameras/camera";
  48508. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48509. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48510. /**
  48511. * WebXR Camera which holds the views for the xrSession
  48512. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48513. */
  48514. export class WebXRCamera extends FreeCamera {
  48515. private _xrSessionManager;
  48516. private _firstFrame;
  48517. private _referenceQuaternion;
  48518. private _referencedPosition;
  48519. private _xrInvPositionCache;
  48520. private _xrInvQuaternionCache;
  48521. /**
  48522. * Should position compensation execute on first frame.
  48523. * This is used when copying the position from a native (non XR) camera
  48524. */
  48525. compensateOnFirstFrame: boolean;
  48526. /**
  48527. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48528. * @param name the name of the camera
  48529. * @param scene the scene to add the camera to
  48530. * @param _xrSessionManager a constructed xr session manager
  48531. */
  48532. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48533. /**
  48534. * Return the user's height, unrelated to the current ground.
  48535. * This will be the y position of this camera, when ground level is 0.
  48536. */
  48537. get realWorldHeight(): number;
  48538. /** @hidden */
  48539. _updateForDualEyeDebugging(): void;
  48540. /**
  48541. * Sets this camera's transformation based on a non-vr camera
  48542. * @param otherCamera the non-vr camera to copy the transformation from
  48543. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48544. */
  48545. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48546. /**
  48547. * Gets the current instance class name ("WebXRCamera").
  48548. * @returns the class name
  48549. */
  48550. getClassName(): string;
  48551. private _rotate180;
  48552. private _updateFromXRSession;
  48553. private _updateNumberOfRigCameras;
  48554. private _updateReferenceSpace;
  48555. private _updateReferenceSpaceOffset;
  48556. }
  48557. }
  48558. declare module "babylonjs/XR/webXRFeaturesManager" {
  48559. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48560. import { IDisposable } from "babylonjs/scene";
  48561. /**
  48562. * Defining the interface required for a (webxr) feature
  48563. */
  48564. export interface IWebXRFeature extends IDisposable {
  48565. /**
  48566. * Is this feature attached
  48567. */
  48568. attached: boolean;
  48569. /**
  48570. * Should auto-attach be disabled?
  48571. */
  48572. disableAutoAttach: boolean;
  48573. /**
  48574. * Attach the feature to the session
  48575. * Will usually be called by the features manager
  48576. *
  48577. * @param force should attachment be forced (even when already attached)
  48578. * @returns true if successful.
  48579. */
  48580. attach(force?: boolean): boolean;
  48581. /**
  48582. * Detach the feature from the session
  48583. * Will usually be called by the features manager
  48584. *
  48585. * @returns true if successful.
  48586. */
  48587. detach(): boolean;
  48588. /**
  48589. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48590. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48591. *
  48592. * @returns whether or not the feature is compatible in this environment
  48593. */
  48594. isCompatible(): boolean;
  48595. /**
  48596. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48597. */
  48598. xrNativeFeatureName?: string;
  48599. }
  48600. /**
  48601. * A list of the currently available features without referencing them
  48602. */
  48603. export class WebXRFeatureName {
  48604. /**
  48605. * The name of the anchor system feature
  48606. */
  48607. static ANCHOR_SYSTEM: string;
  48608. /**
  48609. * The name of the background remover feature
  48610. */
  48611. static BACKGROUND_REMOVER: string;
  48612. /**
  48613. * The name of the hit test feature
  48614. */
  48615. static HIT_TEST: string;
  48616. /**
  48617. * physics impostors for xr controllers feature
  48618. */
  48619. static PHYSICS_CONTROLLERS: string;
  48620. /**
  48621. * The name of the plane detection feature
  48622. */
  48623. static PLANE_DETECTION: string;
  48624. /**
  48625. * The name of the pointer selection feature
  48626. */
  48627. static POINTER_SELECTION: string;
  48628. /**
  48629. * The name of the teleportation feature
  48630. */
  48631. static TELEPORTATION: string;
  48632. }
  48633. /**
  48634. * Defining the constructor of a feature. Used to register the modules.
  48635. */
  48636. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48637. /**
  48638. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48639. * It is mainly used in AR sessions.
  48640. *
  48641. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48642. */
  48643. export class WebXRFeaturesManager implements IDisposable {
  48644. private _xrSessionManager;
  48645. private static readonly _AvailableFeatures;
  48646. private _features;
  48647. /**
  48648. * constructs a new features manages.
  48649. *
  48650. * @param _xrSessionManager an instance of WebXRSessionManager
  48651. */
  48652. constructor(_xrSessionManager: WebXRSessionManager);
  48653. /**
  48654. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48655. * Mainly used internally.
  48656. *
  48657. * @param featureName the name of the feature to register
  48658. * @param constructorFunction the function used to construct the module
  48659. * @param version the (babylon) version of the module
  48660. * @param stable is that a stable version of this module
  48661. */
  48662. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48663. /**
  48664. * Returns a constructor of a specific feature.
  48665. *
  48666. * @param featureName the name of the feature to construct
  48667. * @param version the version of the feature to load
  48668. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48669. * @param options optional options provided to the module.
  48670. * @returns a function that, when called, will return a new instance of this feature
  48671. */
  48672. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48673. /**
  48674. * Can be used to return the list of features currently registered
  48675. *
  48676. * @returns an Array of available features
  48677. */
  48678. static GetAvailableFeatures(): string[];
  48679. /**
  48680. * Gets the versions available for a specific feature
  48681. * @param featureName the name of the feature
  48682. * @returns an array with the available versions
  48683. */
  48684. static GetAvailableVersions(featureName: string): string[];
  48685. /**
  48686. * Return the latest unstable version of this feature
  48687. * @param featureName the name of the feature to search
  48688. * @returns the version number. if not found will return -1
  48689. */
  48690. static GetLatestVersionOfFeature(featureName: string): number;
  48691. /**
  48692. * Return the latest stable version of this feature
  48693. * @param featureName the name of the feature to search
  48694. * @returns the version number. if not found will return -1
  48695. */
  48696. static GetStableVersionOfFeature(featureName: string): number;
  48697. /**
  48698. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48699. * Can be used during a session to start a feature
  48700. * @param featureName the name of feature to attach
  48701. */
  48702. attachFeature(featureName: string): void;
  48703. /**
  48704. * Can be used inside a session or when the session ends to detach a specific feature
  48705. * @param featureName the name of the feature to detach
  48706. */
  48707. detachFeature(featureName: string): void;
  48708. /**
  48709. * Used to disable an already-enabled feature
  48710. * The feature will be disposed and will be recreated once enabled.
  48711. * @param featureName the feature to disable
  48712. * @returns true if disable was successful
  48713. */
  48714. disableFeature(featureName: string | {
  48715. Name: string;
  48716. }): boolean;
  48717. /**
  48718. * dispose this features manager
  48719. */
  48720. dispose(): void;
  48721. /**
  48722. * 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.
  48723. * 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.
  48724. *
  48725. * @param featureName the name of the feature to load or the class of the feature
  48726. * @param version optional version to load. if not provided the latest version will be enabled
  48727. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48728. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48729. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48730. * @returns a new constructed feature or throws an error if feature not found.
  48731. */
  48732. enableFeature(featureName: string | {
  48733. Name: string;
  48734. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48735. /**
  48736. * get the implementation of an enabled feature.
  48737. * @param featureName the name of the feature to load
  48738. * @returns the feature class, if found
  48739. */
  48740. getEnabledFeature(featureName: string): IWebXRFeature;
  48741. /**
  48742. * Get the list of enabled features
  48743. * @returns an array of enabled features
  48744. */
  48745. getEnabledFeatures(): string[];
  48746. /**
  48747. * This function will exten the session creation configuration object with enabled features.
  48748. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48749. * according to the defined "required" variable, provided during enableFeature call
  48750. * @param xrSessionInit the xr Session init object to extend
  48751. *
  48752. * @returns an extended XRSessionInit object
  48753. */
  48754. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48755. }
  48756. }
  48757. declare module "babylonjs/XR/webXRExperienceHelper" {
  48758. import { Observable } from "babylonjs/Misc/observable";
  48759. import { IDisposable, Scene } from "babylonjs/scene";
  48760. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48761. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48762. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48763. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48764. /**
  48765. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48766. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48767. */
  48768. export class WebXRExperienceHelper implements IDisposable {
  48769. private scene;
  48770. private _nonVRCamera;
  48771. private _originalSceneAutoClear;
  48772. private _supported;
  48773. /**
  48774. * Camera used to render xr content
  48775. */
  48776. camera: WebXRCamera;
  48777. /** A features manager for this xr session */
  48778. featuresManager: WebXRFeaturesManager;
  48779. /**
  48780. * Observers registered here will be triggered after the camera's initial transformation is set
  48781. * This can be used to set a different ground level or an extra rotation.
  48782. *
  48783. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48784. * to the position set after this observable is done executing.
  48785. */
  48786. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48787. /**
  48788. * Fires when the state of the experience helper has changed
  48789. */
  48790. onStateChangedObservable: Observable<WebXRState>;
  48791. /** Session manager used to keep track of xr session */
  48792. sessionManager: WebXRSessionManager;
  48793. /**
  48794. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48795. */
  48796. state: WebXRState;
  48797. /**
  48798. * Creates a WebXRExperienceHelper
  48799. * @param scene The scene the helper should be created in
  48800. */
  48801. private constructor();
  48802. /**
  48803. * Creates the experience helper
  48804. * @param scene the scene to attach the experience helper to
  48805. * @returns a promise for the experience helper
  48806. */
  48807. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48808. /**
  48809. * Disposes of the experience helper
  48810. */
  48811. dispose(): void;
  48812. /**
  48813. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48814. * @param sessionMode options for the XR session
  48815. * @param referenceSpaceType frame of reference of the XR session
  48816. * @param renderTarget the output canvas that will be used to enter XR mode
  48817. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48818. * @returns promise that resolves after xr mode has entered
  48819. */
  48820. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48821. /**
  48822. * Exits XR mode and returns the scene to its original state
  48823. * @returns promise that resolves after xr mode has exited
  48824. */
  48825. exitXRAsync(): Promise<void>;
  48826. private _nonXRToXRCamera;
  48827. private _setState;
  48828. }
  48829. }
  48830. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48831. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48832. import { Observable } from "babylonjs/Misc/observable";
  48833. import { IDisposable } from "babylonjs/scene";
  48834. /**
  48835. * X-Y values for axes in WebXR
  48836. */
  48837. export interface IWebXRMotionControllerAxesValue {
  48838. /**
  48839. * The value of the x axis
  48840. */
  48841. x: number;
  48842. /**
  48843. * The value of the y-axis
  48844. */
  48845. y: number;
  48846. }
  48847. /**
  48848. * changed / previous values for the values of this component
  48849. */
  48850. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48851. /**
  48852. * current (this frame) value
  48853. */
  48854. current: T;
  48855. /**
  48856. * previous (last change) value
  48857. */
  48858. previous: T;
  48859. }
  48860. /**
  48861. * Represents changes in the component between current frame and last values recorded
  48862. */
  48863. export interface IWebXRMotionControllerComponentChanges {
  48864. /**
  48865. * will be populated with previous and current values if axes changed
  48866. */
  48867. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48868. /**
  48869. * will be populated with previous and current values if pressed changed
  48870. */
  48871. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48872. /**
  48873. * will be populated with previous and current values if touched changed
  48874. */
  48875. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48876. /**
  48877. * will be populated with previous and current values if value changed
  48878. */
  48879. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48880. }
  48881. /**
  48882. * This class represents a single component (for example button or thumbstick) of a motion controller
  48883. */
  48884. export class WebXRControllerComponent implements IDisposable {
  48885. /**
  48886. * the id of this component
  48887. */
  48888. id: string;
  48889. /**
  48890. * the type of the component
  48891. */
  48892. type: MotionControllerComponentType;
  48893. private _buttonIndex;
  48894. private _axesIndices;
  48895. private _axes;
  48896. private _changes;
  48897. private _currentValue;
  48898. private _hasChanges;
  48899. private _pressed;
  48900. private _touched;
  48901. /**
  48902. * button component type
  48903. */
  48904. static BUTTON_TYPE: MotionControllerComponentType;
  48905. /**
  48906. * squeeze component type
  48907. */
  48908. static SQUEEZE_TYPE: MotionControllerComponentType;
  48909. /**
  48910. * Thumbstick component type
  48911. */
  48912. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48913. /**
  48914. * Touchpad component type
  48915. */
  48916. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48917. /**
  48918. * trigger component type
  48919. */
  48920. static TRIGGER_TYPE: MotionControllerComponentType;
  48921. /**
  48922. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48923. * the axes data changes
  48924. */
  48925. onAxisValueChangedObservable: Observable<{
  48926. x: number;
  48927. y: number;
  48928. }>;
  48929. /**
  48930. * Observers registered here will be triggered when the state of a button changes
  48931. * State change is either pressed / touched / value
  48932. */
  48933. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48934. /**
  48935. * Creates a new component for a motion controller.
  48936. * It is created by the motion controller itself
  48937. *
  48938. * @param id the id of this component
  48939. * @param type the type of the component
  48940. * @param _buttonIndex index in the buttons array of the gamepad
  48941. * @param _axesIndices indices of the values in the axes array of the gamepad
  48942. */
  48943. constructor(
  48944. /**
  48945. * the id of this component
  48946. */
  48947. id: string,
  48948. /**
  48949. * the type of the component
  48950. */
  48951. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48952. /**
  48953. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48954. */
  48955. get axes(): IWebXRMotionControllerAxesValue;
  48956. /**
  48957. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48958. */
  48959. get changes(): IWebXRMotionControllerComponentChanges;
  48960. /**
  48961. * Return whether or not the component changed the last frame
  48962. */
  48963. get hasChanges(): boolean;
  48964. /**
  48965. * is the button currently pressed
  48966. */
  48967. get pressed(): boolean;
  48968. /**
  48969. * is the button currently touched
  48970. */
  48971. get touched(): boolean;
  48972. /**
  48973. * Get the current value of this component
  48974. */
  48975. get value(): number;
  48976. /**
  48977. * Dispose this component
  48978. */
  48979. dispose(): void;
  48980. /**
  48981. * Are there axes correlating to this component
  48982. * @return true is axes data is available
  48983. */
  48984. isAxes(): boolean;
  48985. /**
  48986. * Is this component a button (hence - pressable)
  48987. * @returns true if can be pressed
  48988. */
  48989. isButton(): boolean;
  48990. /**
  48991. * update this component using the gamepad object it is in. Called on every frame
  48992. * @param nativeController the native gamepad controller object
  48993. */
  48994. update(nativeController: IMinimalMotionControllerObject): void;
  48995. }
  48996. }
  48997. declare module "babylonjs/Loading/sceneLoader" {
  48998. import { Observable } from "babylonjs/Misc/observable";
  48999. import { Nullable } from "babylonjs/types";
  49000. import { Scene } from "babylonjs/scene";
  49001. import { Engine } from "babylonjs/Engines/engine";
  49002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49003. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49004. import { AssetContainer } from "babylonjs/assetContainer";
  49005. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49006. import { Skeleton } from "babylonjs/Bones/skeleton";
  49007. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49008. import { WebRequest } from "babylonjs/Misc/webRequest";
  49009. /**
  49010. * Interface used to represent data loading progression
  49011. */
  49012. export interface ISceneLoaderProgressEvent {
  49013. /**
  49014. * Defines if data length to load can be evaluated
  49015. */
  49016. readonly lengthComputable: boolean;
  49017. /**
  49018. * Defines the loaded data length
  49019. */
  49020. readonly loaded: number;
  49021. /**
  49022. * Defines the data length to load
  49023. */
  49024. readonly total: number;
  49025. }
  49026. /**
  49027. * Interface used by SceneLoader plugins to define supported file extensions
  49028. */
  49029. export interface ISceneLoaderPluginExtensions {
  49030. /**
  49031. * Defines the list of supported extensions
  49032. */
  49033. [extension: string]: {
  49034. isBinary: boolean;
  49035. };
  49036. }
  49037. /**
  49038. * Interface used by SceneLoader plugin factory
  49039. */
  49040. export interface ISceneLoaderPluginFactory {
  49041. /**
  49042. * Defines the name of the factory
  49043. */
  49044. name: string;
  49045. /**
  49046. * Function called to create a new plugin
  49047. * @return the new plugin
  49048. */
  49049. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49050. /**
  49051. * The callback that returns true if the data can be directly loaded.
  49052. * @param data string containing the file data
  49053. * @returns if the data can be loaded directly
  49054. */
  49055. canDirectLoad?(data: string): boolean;
  49056. }
  49057. /**
  49058. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49059. */
  49060. export interface ISceneLoaderPluginBase {
  49061. /**
  49062. * The friendly name of this plugin.
  49063. */
  49064. name: string;
  49065. /**
  49066. * The file extensions supported by this plugin.
  49067. */
  49068. extensions: string | ISceneLoaderPluginExtensions;
  49069. /**
  49070. * The callback called when loading from a url.
  49071. * @param scene scene loading this url
  49072. * @param url url to load
  49073. * @param onSuccess callback called when the file successfully loads
  49074. * @param onProgress callback called while file is loading (if the server supports this mode)
  49075. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49076. * @param onError callback called when the file fails to load
  49077. * @returns a file request object
  49078. */
  49079. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49080. /**
  49081. * The callback called when loading from a file object.
  49082. * @param scene scene loading this file
  49083. * @param file defines the file to load
  49084. * @param onSuccess defines the callback to call when data is loaded
  49085. * @param onProgress defines the callback to call during loading process
  49086. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49087. * @param onError defines the callback to call when an error occurs
  49088. * @returns a file request object
  49089. */
  49090. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49091. /**
  49092. * The callback that returns true if the data can be directly loaded.
  49093. * @param data string containing the file data
  49094. * @returns if the data can be loaded directly
  49095. */
  49096. canDirectLoad?(data: string): boolean;
  49097. /**
  49098. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49099. * @param scene scene loading this data
  49100. * @param data string containing the data
  49101. * @returns data to pass to the plugin
  49102. */
  49103. directLoad?(scene: Scene, data: string): any;
  49104. /**
  49105. * The callback that allows custom handling of the root url based on the response url.
  49106. * @param rootUrl the original root url
  49107. * @param responseURL the response url if available
  49108. * @returns the new root url
  49109. */
  49110. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49111. }
  49112. /**
  49113. * Interface used to define a SceneLoader plugin
  49114. */
  49115. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49116. /**
  49117. * Import meshes into a scene.
  49118. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49119. * @param scene The scene to import into
  49120. * @param data The data to import
  49121. * @param rootUrl The root url for scene and resources
  49122. * @param meshes The meshes array to import into
  49123. * @param particleSystems The particle systems array to import into
  49124. * @param skeletons The skeletons array to import into
  49125. * @param onError The callback when import fails
  49126. * @returns True if successful or false otherwise
  49127. */
  49128. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49129. /**
  49130. * Load into a scene.
  49131. * @param scene The scene to load into
  49132. * @param data The data to import
  49133. * @param rootUrl The root url for scene and resources
  49134. * @param onError The callback when import fails
  49135. * @returns True if successful or false otherwise
  49136. */
  49137. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49138. /**
  49139. * Load into an asset container.
  49140. * @param scene The scene to load into
  49141. * @param data The data to import
  49142. * @param rootUrl The root url for scene and resources
  49143. * @param onError The callback when import fails
  49144. * @returns The loaded asset container
  49145. */
  49146. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49147. }
  49148. /**
  49149. * Interface used to define an async SceneLoader plugin
  49150. */
  49151. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49152. /**
  49153. * Import meshes into a scene.
  49154. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49155. * @param scene The scene to import into
  49156. * @param data The data to import
  49157. * @param rootUrl The root url for scene and resources
  49158. * @param onProgress The callback when the load progresses
  49159. * @param fileName Defines the name of the file to load
  49160. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49161. */
  49162. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49163. meshes: AbstractMesh[];
  49164. particleSystems: IParticleSystem[];
  49165. skeletons: Skeleton[];
  49166. animationGroups: AnimationGroup[];
  49167. }>;
  49168. /**
  49169. * Load into a scene.
  49170. * @param scene The scene to load into
  49171. * @param data The data to import
  49172. * @param rootUrl The root url for scene and resources
  49173. * @param onProgress The callback when the load progresses
  49174. * @param fileName Defines the name of the file to load
  49175. * @returns Nothing
  49176. */
  49177. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49178. /**
  49179. * Load into an asset container.
  49180. * @param scene The scene to load into
  49181. * @param data The data to import
  49182. * @param rootUrl The root url for scene and resources
  49183. * @param onProgress The callback when the load progresses
  49184. * @param fileName Defines the name of the file to load
  49185. * @returns The loaded asset container
  49186. */
  49187. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49188. }
  49189. /**
  49190. * Mode that determines how to handle old animation groups before loading new ones.
  49191. */
  49192. export enum SceneLoaderAnimationGroupLoadingMode {
  49193. /**
  49194. * Reset all old animations to initial state then dispose them.
  49195. */
  49196. Clean = 0,
  49197. /**
  49198. * Stop all old animations.
  49199. */
  49200. Stop = 1,
  49201. /**
  49202. * Restart old animations from first frame.
  49203. */
  49204. Sync = 2,
  49205. /**
  49206. * Old animations remains untouched.
  49207. */
  49208. NoSync = 3
  49209. }
  49210. /**
  49211. * Class used to load scene from various file formats using registered plugins
  49212. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49213. */
  49214. export class SceneLoader {
  49215. /**
  49216. * No logging while loading
  49217. */
  49218. static readonly NO_LOGGING: number;
  49219. /**
  49220. * Minimal logging while loading
  49221. */
  49222. static readonly MINIMAL_LOGGING: number;
  49223. /**
  49224. * Summary logging while loading
  49225. */
  49226. static readonly SUMMARY_LOGGING: number;
  49227. /**
  49228. * Detailled logging while loading
  49229. */
  49230. static readonly DETAILED_LOGGING: number;
  49231. /**
  49232. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49233. */
  49234. static get ForceFullSceneLoadingForIncremental(): boolean;
  49235. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49236. /**
  49237. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49238. */
  49239. static get ShowLoadingScreen(): boolean;
  49240. static set ShowLoadingScreen(value: boolean);
  49241. /**
  49242. * Defines the current logging level (while loading the scene)
  49243. * @ignorenaming
  49244. */
  49245. static get loggingLevel(): number;
  49246. static set loggingLevel(value: number);
  49247. /**
  49248. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49249. */
  49250. static get CleanBoneMatrixWeights(): boolean;
  49251. static set CleanBoneMatrixWeights(value: boolean);
  49252. /**
  49253. * Event raised when a plugin is used to load a scene
  49254. */
  49255. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49256. private static _registeredPlugins;
  49257. private static _showingLoadingScreen;
  49258. private static _getDefaultPlugin;
  49259. private static _getPluginForExtension;
  49260. private static _getPluginForDirectLoad;
  49261. private static _getPluginForFilename;
  49262. private static _getDirectLoad;
  49263. private static _loadData;
  49264. private static _getFileInfo;
  49265. /**
  49266. * Gets a plugin that can load the given extension
  49267. * @param extension defines the extension to load
  49268. * @returns a plugin or null if none works
  49269. */
  49270. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49271. /**
  49272. * Gets a boolean indicating that the given extension can be loaded
  49273. * @param extension defines the extension to load
  49274. * @returns true if the extension is supported
  49275. */
  49276. static IsPluginForExtensionAvailable(extension: string): boolean;
  49277. /**
  49278. * Adds a new plugin to the list of registered plugins
  49279. * @param plugin defines the plugin to add
  49280. */
  49281. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49282. /**
  49283. * Import meshes into a scene
  49284. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49285. * @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)
  49286. * @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)
  49287. * @param scene the instance of BABYLON.Scene to append to
  49288. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49289. * @param onProgress a callback with a progress event for each file being loaded
  49290. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49291. * @param pluginExtension the extension used to determine the plugin
  49292. * @returns The loaded plugin
  49293. */
  49294. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49295. /**
  49296. * Import meshes into a scene
  49297. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49298. * @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)
  49299. * @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)
  49300. * @param scene the instance of BABYLON.Scene to append to
  49301. * @param onProgress a callback with a progress event for each file being loaded
  49302. * @param pluginExtension the extension used to determine the plugin
  49303. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49304. */
  49305. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49306. meshes: AbstractMesh[];
  49307. particleSystems: IParticleSystem[];
  49308. skeletons: Skeleton[];
  49309. animationGroups: AnimationGroup[];
  49310. }>;
  49311. /**
  49312. * Load a scene
  49313. * @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)
  49314. * @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)
  49315. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49316. * @param onSuccess a callback with the scene when import succeeds
  49317. * @param onProgress a callback with a progress event for each file being loaded
  49318. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49319. * @param pluginExtension the extension used to determine the plugin
  49320. * @returns The loaded plugin
  49321. */
  49322. 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>;
  49323. /**
  49324. * Load a scene
  49325. * @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)
  49326. * @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)
  49327. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49328. * @param onProgress a callback with a progress event for each file being loaded
  49329. * @param pluginExtension the extension used to determine the plugin
  49330. * @returns The loaded scene
  49331. */
  49332. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49333. /**
  49334. * Append a scene
  49335. * @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)
  49336. * @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)
  49337. * @param scene is the instance of BABYLON.Scene to append to
  49338. * @param onSuccess a callback with the scene when import succeeds
  49339. * @param onProgress a callback with a progress event for each file being loaded
  49340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49341. * @param pluginExtension the extension used to determine the plugin
  49342. * @returns The loaded plugin
  49343. */
  49344. 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>;
  49345. /**
  49346. * Append a scene
  49347. * @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)
  49348. * @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)
  49349. * @param scene is the instance of BABYLON.Scene to append to
  49350. * @param onProgress a callback with a progress event for each file being loaded
  49351. * @param pluginExtension the extension used to determine the plugin
  49352. * @returns The given scene
  49353. */
  49354. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49355. /**
  49356. * Load a scene into an asset container
  49357. * @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)
  49358. * @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)
  49359. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49360. * @param onSuccess a callback with the scene when import succeeds
  49361. * @param onProgress a callback with a progress event for each file being loaded
  49362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49363. * @param pluginExtension the extension used to determine the plugin
  49364. * @returns The loaded plugin
  49365. */
  49366. 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>;
  49367. /**
  49368. * Load a scene into an asset container
  49369. * @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)
  49370. * @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)
  49371. * @param scene is the instance of Scene to append to
  49372. * @param onProgress a callback with a progress event for each file being loaded
  49373. * @param pluginExtension the extension used to determine the plugin
  49374. * @returns The loaded asset container
  49375. */
  49376. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49377. /**
  49378. * Import animations from a file into a scene
  49379. * @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)
  49380. * @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)
  49381. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49382. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49383. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49384. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49385. * @param onSuccess a callback with the scene when import succeeds
  49386. * @param onProgress a callback with a progress event for each file being loaded
  49387. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49388. * @param pluginExtension the extension used to determine the plugin
  49389. */
  49390. 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;
  49391. /**
  49392. * Import animations from a file into a scene
  49393. * @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)
  49394. * @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)
  49395. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49396. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49397. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49398. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49399. * @param onSuccess a callback with the scene when import succeeds
  49400. * @param onProgress a callback with a progress event for each file being loaded
  49401. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49402. * @param pluginExtension the extension used to determine the plugin
  49403. * @returns the updated scene with imported animations
  49404. */
  49405. 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>;
  49406. }
  49407. }
  49408. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49409. import { IDisposable, Scene } from "babylonjs/scene";
  49410. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49411. import { Observable } from "babylonjs/Misc/observable";
  49412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49413. import { Nullable } from "babylonjs/types";
  49414. /**
  49415. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49416. */
  49417. export type MotionControllerHandedness = "none" | "left" | "right";
  49418. /**
  49419. * The type of components available in motion controllers.
  49420. * This is not the name of the component.
  49421. */
  49422. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49423. /**
  49424. * The state of a controller component
  49425. */
  49426. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49427. /**
  49428. * The schema of motion controller layout.
  49429. * No object will be initialized using this interface
  49430. * This is used just to define the profile.
  49431. */
  49432. export interface IMotionControllerLayout {
  49433. /**
  49434. * Path to load the assets. Usually relative to the base path
  49435. */
  49436. assetPath: string;
  49437. /**
  49438. * Available components (unsorted)
  49439. */
  49440. components: {
  49441. /**
  49442. * A map of component Ids
  49443. */
  49444. [componentId: string]: {
  49445. /**
  49446. * The type of input the component outputs
  49447. */
  49448. type: MotionControllerComponentType;
  49449. /**
  49450. * The indices of this component in the gamepad object
  49451. */
  49452. gamepadIndices: {
  49453. /**
  49454. * Index of button
  49455. */
  49456. button?: number;
  49457. /**
  49458. * If available, index of x-axis
  49459. */
  49460. xAxis?: number;
  49461. /**
  49462. * If available, index of y-axis
  49463. */
  49464. yAxis?: number;
  49465. };
  49466. /**
  49467. * The mesh's root node name
  49468. */
  49469. rootNodeName: string;
  49470. /**
  49471. * Animation definitions for this model
  49472. */
  49473. visualResponses: {
  49474. [stateKey: string]: {
  49475. /**
  49476. * What property will be animated
  49477. */
  49478. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49479. /**
  49480. * What states influence this visual response
  49481. */
  49482. states: MotionControllerComponentStateType[];
  49483. /**
  49484. * Type of animation - movement or visibility
  49485. */
  49486. valueNodeProperty: "transform" | "visibility";
  49487. /**
  49488. * Base node name to move. Its position will be calculated according to the min and max nodes
  49489. */
  49490. valueNodeName?: string;
  49491. /**
  49492. * Minimum movement node
  49493. */
  49494. minNodeName?: string;
  49495. /**
  49496. * Max movement node
  49497. */
  49498. maxNodeName?: string;
  49499. };
  49500. };
  49501. /**
  49502. * If touch enabled, what is the name of node to display user feedback
  49503. */
  49504. touchPointNodeName?: string;
  49505. };
  49506. };
  49507. /**
  49508. * Is it xr standard mapping or not
  49509. */
  49510. gamepadMapping: "" | "xr-standard";
  49511. /**
  49512. * Base root node of this entire model
  49513. */
  49514. rootNodeName: string;
  49515. /**
  49516. * Defines the main button component id
  49517. */
  49518. selectComponentId: string;
  49519. }
  49520. /**
  49521. * A definition for the layout map in the input profile
  49522. */
  49523. export interface IMotionControllerLayoutMap {
  49524. /**
  49525. * Layouts with handedness type as a key
  49526. */
  49527. [handedness: string]: IMotionControllerLayout;
  49528. }
  49529. /**
  49530. * The XR Input profile schema
  49531. * Profiles can be found here:
  49532. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49533. */
  49534. export interface IMotionControllerProfile {
  49535. /**
  49536. * fallback profiles for this profileId
  49537. */
  49538. fallbackProfileIds: string[];
  49539. /**
  49540. * The layout map, with handedness as key
  49541. */
  49542. layouts: IMotionControllerLayoutMap;
  49543. /**
  49544. * The id of this profile
  49545. * correlates to the profile(s) in the xrInput.profiles array
  49546. */
  49547. profileId: string;
  49548. }
  49549. /**
  49550. * A helper-interface for the 3 meshes needed for controller button animation
  49551. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49552. */
  49553. export interface IMotionControllerButtonMeshMap {
  49554. /**
  49555. * the mesh that defines the pressed value mesh position.
  49556. * This is used to find the max-position of this button
  49557. */
  49558. pressedMesh: AbstractMesh;
  49559. /**
  49560. * the mesh that defines the unpressed value mesh position.
  49561. * This is used to find the min (or initial) position of this button
  49562. */
  49563. unpressedMesh: AbstractMesh;
  49564. /**
  49565. * The mesh that will be changed when value changes
  49566. */
  49567. valueMesh: AbstractMesh;
  49568. }
  49569. /**
  49570. * A helper-interface for the 3 meshes needed for controller axis animation.
  49571. * This will be expanded when touchpad animations are fully supported
  49572. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49573. */
  49574. export interface IMotionControllerMeshMap {
  49575. /**
  49576. * the mesh that defines the maximum value mesh position.
  49577. */
  49578. maxMesh?: AbstractMesh;
  49579. /**
  49580. * the mesh that defines the minimum value mesh position.
  49581. */
  49582. minMesh?: AbstractMesh;
  49583. /**
  49584. * The mesh that will be changed when axis value changes
  49585. */
  49586. valueMesh: AbstractMesh;
  49587. }
  49588. /**
  49589. * The elements needed for change-detection of the gamepad objects in motion controllers
  49590. */
  49591. export interface IMinimalMotionControllerObject {
  49592. /**
  49593. * Available axes of this controller
  49594. */
  49595. axes: number[];
  49596. /**
  49597. * An array of available buttons
  49598. */
  49599. buttons: Array<{
  49600. /**
  49601. * Value of the button/trigger
  49602. */
  49603. value: number;
  49604. /**
  49605. * If the button/trigger is currently touched
  49606. */
  49607. touched: boolean;
  49608. /**
  49609. * If the button/trigger is currently pressed
  49610. */
  49611. pressed: boolean;
  49612. }>;
  49613. /**
  49614. * EXPERIMENTAL haptic support.
  49615. */
  49616. hapticActuators?: Array<{
  49617. pulse: (value: number, duration: number) => Promise<boolean>;
  49618. }>;
  49619. }
  49620. /**
  49621. * An Abstract Motion controller
  49622. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49623. * Each component has an observable to check for changes in value and state
  49624. */
  49625. export abstract class WebXRAbstractMotionController implements IDisposable {
  49626. protected scene: Scene;
  49627. protected layout: IMotionControllerLayout;
  49628. /**
  49629. * The gamepad object correlating to this controller
  49630. */
  49631. gamepadObject: IMinimalMotionControllerObject;
  49632. /**
  49633. * handedness (left/right/none) of this controller
  49634. */
  49635. handedness: MotionControllerHandedness;
  49636. private _initComponent;
  49637. private _modelReady;
  49638. /**
  49639. * A map of components (WebXRControllerComponent) in this motion controller
  49640. * Components have a ComponentType and can also have both button and axis definitions
  49641. */
  49642. readonly components: {
  49643. [id: string]: WebXRControllerComponent;
  49644. };
  49645. /**
  49646. * Disable the model's animation. Can be set at any time.
  49647. */
  49648. disableAnimation: boolean;
  49649. /**
  49650. * Observers registered here will be triggered when the model of this controller is done loading
  49651. */
  49652. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49653. /**
  49654. * The profile id of this motion controller
  49655. */
  49656. abstract profileId: string;
  49657. /**
  49658. * The root mesh of the model. It is null if the model was not yet initialized
  49659. */
  49660. rootMesh: Nullable<AbstractMesh>;
  49661. /**
  49662. * constructs a new abstract motion controller
  49663. * @param scene the scene to which the model of the controller will be added
  49664. * @param layout The profile layout to load
  49665. * @param gamepadObject The gamepad object correlating to this controller
  49666. * @param handedness handedness (left/right/none) of this controller
  49667. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49668. */
  49669. constructor(scene: Scene, layout: IMotionControllerLayout,
  49670. /**
  49671. * The gamepad object correlating to this controller
  49672. */
  49673. gamepadObject: IMinimalMotionControllerObject,
  49674. /**
  49675. * handedness (left/right/none) of this controller
  49676. */
  49677. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49678. /**
  49679. * Dispose this controller, the model mesh and all its components
  49680. */
  49681. dispose(): void;
  49682. /**
  49683. * Returns all components of specific type
  49684. * @param type the type to search for
  49685. * @return an array of components with this type
  49686. */
  49687. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49688. /**
  49689. * get a component based an its component id as defined in layout.components
  49690. * @param id the id of the component
  49691. * @returns the component correlates to the id or undefined if not found
  49692. */
  49693. getComponent(id: string): WebXRControllerComponent;
  49694. /**
  49695. * Get the list of components available in this motion controller
  49696. * @returns an array of strings correlating to available components
  49697. */
  49698. getComponentIds(): string[];
  49699. /**
  49700. * Get the first component of specific type
  49701. * @param type type of component to find
  49702. * @return a controller component or null if not found
  49703. */
  49704. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49705. /**
  49706. * Get the main (Select) component of this controller as defined in the layout
  49707. * @returns the main component of this controller
  49708. */
  49709. getMainComponent(): WebXRControllerComponent;
  49710. /**
  49711. * Loads the model correlating to this controller
  49712. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49713. * @returns A promise fulfilled with the result of the model loading
  49714. */
  49715. loadModel(): Promise<boolean>;
  49716. /**
  49717. * Update this model using the current XRFrame
  49718. * @param xrFrame the current xr frame to use and update the model
  49719. */
  49720. updateFromXRFrame(xrFrame: XRFrame): void;
  49721. /**
  49722. * Backwards compatibility due to a deeply-integrated typo
  49723. */
  49724. get handness(): XREye;
  49725. /**
  49726. * Pulse (vibrate) this controller
  49727. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49728. * Consecutive calls to this function will cancel the last pulse call
  49729. *
  49730. * @param value the strength of the pulse in 0.0...1.0 range
  49731. * @param duration Duration of the pulse in milliseconds
  49732. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49733. * @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
  49734. */
  49735. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49736. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49737. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49738. /**
  49739. * Moves the axis on the controller mesh based on its current state
  49740. * @param axis the index of the axis
  49741. * @param axisValue the value of the axis which determines the meshes new position
  49742. * @hidden
  49743. */
  49744. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49745. /**
  49746. * Update the model itself with the current frame data
  49747. * @param xrFrame the frame to use for updating the model mesh
  49748. */
  49749. protected updateModel(xrFrame: XRFrame): void;
  49750. /**
  49751. * Get the filename and path for this controller's model
  49752. * @returns a map of filename and path
  49753. */
  49754. protected abstract _getFilenameAndPath(): {
  49755. filename: string;
  49756. path: string;
  49757. };
  49758. /**
  49759. * This function is called before the mesh is loaded. It checks for loading constraints.
  49760. * For example, this function can check if the GLB loader is available
  49761. * If this function returns false, the generic controller will be loaded instead
  49762. * @returns Is the client ready to load the mesh
  49763. */
  49764. protected abstract _getModelLoadingConstraints(): boolean;
  49765. /**
  49766. * This function will be called after the model was successfully loaded and can be used
  49767. * for mesh transformations before it is available for the user
  49768. * @param meshes the loaded meshes
  49769. */
  49770. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49771. /**
  49772. * Set the root mesh for this controller. Important for the WebXR controller class
  49773. * @param meshes the loaded meshes
  49774. */
  49775. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49776. /**
  49777. * A function executed each frame that updates the mesh (if needed)
  49778. * @param xrFrame the current xrFrame
  49779. */
  49780. protected abstract _updateModel(xrFrame: XRFrame): void;
  49781. private _getGenericFilenameAndPath;
  49782. private _getGenericParentMesh;
  49783. }
  49784. }
  49785. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49786. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49788. import { Scene } from "babylonjs/scene";
  49789. /**
  49790. * A generic trigger-only motion controller for WebXR
  49791. */
  49792. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49793. /**
  49794. * Static version of the profile id of this controller
  49795. */
  49796. static ProfileId: string;
  49797. profileId: string;
  49798. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49799. protected _getFilenameAndPath(): {
  49800. filename: string;
  49801. path: string;
  49802. };
  49803. protected _getModelLoadingConstraints(): boolean;
  49804. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49805. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49806. protected _updateModel(): void;
  49807. }
  49808. }
  49809. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49810. import { Vector4 } from "babylonjs/Maths/math.vector";
  49811. import { Mesh } from "babylonjs/Meshes/mesh";
  49812. import { Scene } from "babylonjs/scene";
  49813. import { Nullable } from "babylonjs/types";
  49814. /**
  49815. * Class containing static functions to help procedurally build meshes
  49816. */
  49817. export class SphereBuilder {
  49818. /**
  49819. * Creates a sphere mesh
  49820. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49821. * * 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`)
  49822. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49823. * * 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
  49824. * * 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)
  49825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49828. * @param name defines the name of the mesh
  49829. * @param options defines the options used to create the mesh
  49830. * @param scene defines the hosting scene
  49831. * @returns the sphere mesh
  49832. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49833. */
  49834. static CreateSphere(name: string, options: {
  49835. segments?: number;
  49836. diameter?: number;
  49837. diameterX?: number;
  49838. diameterY?: number;
  49839. diameterZ?: number;
  49840. arc?: number;
  49841. slice?: number;
  49842. sideOrientation?: number;
  49843. frontUVs?: Vector4;
  49844. backUVs?: Vector4;
  49845. updatable?: boolean;
  49846. }, scene?: Nullable<Scene>): Mesh;
  49847. }
  49848. }
  49849. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49851. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49852. import { Scene } from "babylonjs/scene";
  49853. /**
  49854. * A profiled motion controller has its profile loaded from an online repository.
  49855. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49856. */
  49857. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49858. private _repositoryUrl;
  49859. private _buttonMeshMapping;
  49860. private _touchDots;
  49861. /**
  49862. * The profile ID of this controller. Will be populated when the controller initializes.
  49863. */
  49864. profileId: string;
  49865. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49866. dispose(): void;
  49867. protected _getFilenameAndPath(): {
  49868. filename: string;
  49869. path: string;
  49870. };
  49871. protected _getModelLoadingConstraints(): boolean;
  49872. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49873. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49874. protected _updateModel(_xrFrame: XRFrame): void;
  49875. }
  49876. }
  49877. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49878. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49879. import { Scene } from "babylonjs/scene";
  49880. /**
  49881. * A construction function type to create a new controller based on an xrInput object
  49882. */
  49883. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49884. /**
  49885. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49886. *
  49887. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49888. * it should be replaced with auto-loaded controllers.
  49889. *
  49890. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49891. */
  49892. export class WebXRMotionControllerManager {
  49893. private static _AvailableControllers;
  49894. private static _Fallbacks;
  49895. private static _ProfileLoadingPromises;
  49896. private static _ProfilesList;
  49897. /**
  49898. * The base URL of the online controller repository. Can be changed at any time.
  49899. */
  49900. static BaseRepositoryUrl: string;
  49901. /**
  49902. * Which repository gets priority - local or online
  49903. */
  49904. static PrioritizeOnlineRepository: boolean;
  49905. /**
  49906. * Use the online repository, or use only locally-defined controllers
  49907. */
  49908. static UseOnlineRepository: boolean;
  49909. /**
  49910. * Clear the cache used for profile loading and reload when requested again
  49911. */
  49912. static ClearProfilesCache(): void;
  49913. /**
  49914. * Register the default fallbacks.
  49915. * This function is called automatically when this file is imported.
  49916. */
  49917. static DefaultFallbacks(): void;
  49918. /**
  49919. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49920. * @param profileId the profile to which a fallback needs to be found
  49921. * @return an array with corresponding fallback profiles
  49922. */
  49923. static FindFallbackWithProfileId(profileId: string): string[];
  49924. /**
  49925. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49926. * The order of search:
  49927. *
  49928. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49929. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49930. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49931. * 4) return the generic trigger controller if none were found
  49932. *
  49933. * @param xrInput the xrInput to which a new controller is initialized
  49934. * @param scene the scene to which the model will be added
  49935. * @param forceProfile force a certain profile for this controller
  49936. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49937. */
  49938. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49939. /**
  49940. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49941. *
  49942. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49943. *
  49944. * @param type the profile type to register
  49945. * @param constructFunction the function to be called when loading this profile
  49946. */
  49947. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49948. /**
  49949. * Register a fallback to a specific profile.
  49950. * @param profileId the profileId that will receive the fallbacks
  49951. * @param fallbacks A list of fallback profiles
  49952. */
  49953. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49954. /**
  49955. * Will update the list of profiles available in the repository
  49956. * @return a promise that resolves to a map of profiles available online
  49957. */
  49958. static UpdateProfilesList(): Promise<{
  49959. [profile: string]: string;
  49960. }>;
  49961. private static _LoadProfileFromRepository;
  49962. private static _LoadProfilesFromAvailableControllers;
  49963. }
  49964. }
  49965. declare module "babylonjs/XR/webXRInputSource" {
  49966. import { Observable } from "babylonjs/Misc/observable";
  49967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49968. import { Ray } from "babylonjs/Culling/ray";
  49969. import { Scene } from "babylonjs/scene";
  49970. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49971. /**
  49972. * Configuration options for the WebXR controller creation
  49973. */
  49974. export interface IWebXRControllerOptions {
  49975. /**
  49976. * Should the controller mesh be animated when a user interacts with it
  49977. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49978. */
  49979. disableMotionControllerAnimation?: boolean;
  49980. /**
  49981. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49982. */
  49983. doNotLoadControllerMesh?: boolean;
  49984. /**
  49985. * Force a specific controller type for this controller.
  49986. * This can be used when creating your own profile or when testing different controllers
  49987. */
  49988. forceControllerProfile?: string;
  49989. /**
  49990. * Defines a rendering group ID for meshes that will be loaded.
  49991. * This is for the default controllers only.
  49992. */
  49993. renderingGroupId?: number;
  49994. }
  49995. /**
  49996. * Represents an XR controller
  49997. */
  49998. export class WebXRInputSource {
  49999. private _scene;
  50000. /** The underlying input source for the controller */
  50001. inputSource: XRInputSource;
  50002. private _options;
  50003. private _tmpVector;
  50004. private _uniqueId;
  50005. /**
  50006. * 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
  50007. */
  50008. grip?: AbstractMesh;
  50009. /**
  50010. * If available, this is the gamepad object related to this controller.
  50011. * Using this object it is possible to get click events and trackpad changes of the
  50012. * webxr controller that is currently being used.
  50013. */
  50014. motionController?: WebXRAbstractMotionController;
  50015. /**
  50016. * Event that fires when the controller is removed/disposed.
  50017. * The object provided as event data is this controller, after associated assets were disposed.
  50018. * uniqueId is still available.
  50019. */
  50020. onDisposeObservable: Observable<WebXRInputSource>;
  50021. /**
  50022. * Will be triggered when the mesh associated with the motion controller is done loading.
  50023. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50024. * A shortened version of controller -> motion controller -> on mesh loaded.
  50025. */
  50026. onMeshLoadedObservable: Observable<AbstractMesh>;
  50027. /**
  50028. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50029. */
  50030. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50031. /**
  50032. * Pointer which can be used to select objects or attach a visible laser to
  50033. */
  50034. pointer: AbstractMesh;
  50035. /**
  50036. * Creates the input source object
  50037. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50038. * @param _scene the scene which the controller should be associated to
  50039. * @param inputSource the underlying input source for the controller
  50040. * @param _options options for this controller creation
  50041. */
  50042. constructor(_scene: Scene,
  50043. /** The underlying input source for the controller */
  50044. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50045. /**
  50046. * Get this controllers unique id
  50047. */
  50048. get uniqueId(): string;
  50049. /**
  50050. * Disposes of the object
  50051. */
  50052. dispose(): void;
  50053. /**
  50054. * Gets a world space ray coming from the pointer or grip
  50055. * @param result the resulting ray
  50056. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50057. */
  50058. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50059. /**
  50060. * Updates the controller pose based on the given XRFrame
  50061. * @param xrFrame xr frame to update the pose with
  50062. * @param referenceSpace reference space to use
  50063. */
  50064. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50065. }
  50066. }
  50067. declare module "babylonjs/XR/webXRInput" {
  50068. import { Observable } from "babylonjs/Misc/observable";
  50069. import { IDisposable } from "babylonjs/scene";
  50070. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50071. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50072. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50073. /**
  50074. * The schema for initialization options of the XR Input class
  50075. */
  50076. export interface IWebXRInputOptions {
  50077. /**
  50078. * If set to true no model will be automatically loaded
  50079. */
  50080. doNotLoadControllerMeshes?: boolean;
  50081. /**
  50082. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50083. * If not found, the xr input profile data will be used.
  50084. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50085. */
  50086. forceInputProfile?: string;
  50087. /**
  50088. * Do not send a request to the controller repository to load the profile.
  50089. *
  50090. * Instead, use the controllers available in babylon itself.
  50091. */
  50092. disableOnlineControllerRepository?: boolean;
  50093. /**
  50094. * A custom URL for the controllers repository
  50095. */
  50096. customControllersRepositoryURL?: string;
  50097. /**
  50098. * Should the controller model's components not move according to the user input
  50099. */
  50100. disableControllerAnimation?: boolean;
  50101. /**
  50102. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50103. */
  50104. controllerOptions?: IWebXRControllerOptions;
  50105. }
  50106. /**
  50107. * XR input used to track XR inputs such as controllers/rays
  50108. */
  50109. export class WebXRInput implements IDisposable {
  50110. /**
  50111. * the xr session manager for this session
  50112. */
  50113. xrSessionManager: WebXRSessionManager;
  50114. /**
  50115. * the WebXR camera for this session. Mainly used for teleportation
  50116. */
  50117. xrCamera: WebXRCamera;
  50118. private readonly options;
  50119. /**
  50120. * XR controllers being tracked
  50121. */
  50122. controllers: Array<WebXRInputSource>;
  50123. private _frameObserver;
  50124. private _sessionEndedObserver;
  50125. private _sessionInitObserver;
  50126. /**
  50127. * Event when a controller has been connected/added
  50128. */
  50129. onControllerAddedObservable: Observable<WebXRInputSource>;
  50130. /**
  50131. * Event when a controller has been removed/disconnected
  50132. */
  50133. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50134. /**
  50135. * Initializes the WebXRInput
  50136. * @param xrSessionManager the xr session manager for this session
  50137. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50138. * @param options = initialization options for this xr input
  50139. */
  50140. constructor(
  50141. /**
  50142. * the xr session manager for this session
  50143. */
  50144. xrSessionManager: WebXRSessionManager,
  50145. /**
  50146. * the WebXR camera for this session. Mainly used for teleportation
  50147. */
  50148. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50149. private _onInputSourcesChange;
  50150. private _addAndRemoveControllers;
  50151. /**
  50152. * Disposes of the object
  50153. */
  50154. dispose(): void;
  50155. }
  50156. }
  50157. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50158. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50159. import { Observable, EventState } from "babylonjs/Misc/observable";
  50160. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50161. /**
  50162. * This is the base class for all WebXR features.
  50163. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50164. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50165. */
  50166. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50167. protected _xrSessionManager: WebXRSessionManager;
  50168. private _attached;
  50169. private _removeOnDetach;
  50170. /**
  50171. * Should auto-attach be disabled?
  50172. */
  50173. disableAutoAttach: boolean;
  50174. /**
  50175. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50176. */
  50177. xrNativeFeatureName: string;
  50178. /**
  50179. * Construct a new (abstract) WebXR feature
  50180. * @param _xrSessionManager the xr session manager for this feature
  50181. */
  50182. constructor(_xrSessionManager: WebXRSessionManager);
  50183. /**
  50184. * Is this feature attached
  50185. */
  50186. get attached(): boolean;
  50187. /**
  50188. * attach this feature
  50189. *
  50190. * @param force should attachment be forced (even when already attached)
  50191. * @returns true if successful, false is failed or already attached
  50192. */
  50193. attach(force?: boolean): boolean;
  50194. /**
  50195. * detach this feature.
  50196. *
  50197. * @returns true if successful, false if failed or already detached
  50198. */
  50199. detach(): boolean;
  50200. /**
  50201. * Dispose this feature and all of the resources attached
  50202. */
  50203. dispose(): void;
  50204. /**
  50205. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50206. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50207. *
  50208. * @returns whether or not the feature is compatible in this environment
  50209. */
  50210. isCompatible(): boolean;
  50211. /**
  50212. * This is used to register callbacks that will automatically be removed when detach is called.
  50213. * @param observable the observable to which the observer will be attached
  50214. * @param callback the callback to register
  50215. */
  50216. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50217. /**
  50218. * Code in this function will be executed on each xrFrame received from the browser.
  50219. * This function will not execute after the feature is detached.
  50220. * @param _xrFrame the current frame
  50221. */
  50222. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50223. }
  50224. }
  50225. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50226. import { IDisposable, Scene } from "babylonjs/scene";
  50227. import { Nullable } from "babylonjs/types";
  50228. import { Observable } from "babylonjs/Misc/observable";
  50229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50230. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50231. import { Camera } from "babylonjs/Cameras/camera";
  50232. /**
  50233. * Renders a layer on top of an existing scene
  50234. */
  50235. export class UtilityLayerRenderer implements IDisposable {
  50236. /** the original scene that will be rendered on top of */
  50237. originalScene: Scene;
  50238. private _pointerCaptures;
  50239. private _lastPointerEvents;
  50240. private static _DefaultUtilityLayer;
  50241. private static _DefaultKeepDepthUtilityLayer;
  50242. private _sharedGizmoLight;
  50243. private _renderCamera;
  50244. /**
  50245. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50246. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50247. * @returns the camera that is used when rendering the utility layer
  50248. */
  50249. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50250. /**
  50251. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50252. * @param cam the camera that should be used when rendering the utility layer
  50253. */
  50254. setRenderCamera(cam: Nullable<Camera>): void;
  50255. /**
  50256. * @hidden
  50257. * Light which used by gizmos to get light shading
  50258. */
  50259. _getSharedGizmoLight(): HemisphericLight;
  50260. /**
  50261. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50262. */
  50263. pickUtilitySceneFirst: boolean;
  50264. /**
  50265. * 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)
  50266. */
  50267. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50268. /**
  50269. * 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)
  50270. */
  50271. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50272. /**
  50273. * The scene that is rendered on top of the original scene
  50274. */
  50275. utilityLayerScene: Scene;
  50276. /**
  50277. * If the utility layer should automatically be rendered on top of existing scene
  50278. */
  50279. shouldRender: boolean;
  50280. /**
  50281. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50282. */
  50283. onlyCheckPointerDownEvents: boolean;
  50284. /**
  50285. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50286. */
  50287. processAllEvents: boolean;
  50288. /**
  50289. * Observable raised when the pointer move from the utility layer scene to the main scene
  50290. */
  50291. onPointerOutObservable: Observable<number>;
  50292. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50293. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50294. private _afterRenderObserver;
  50295. private _sceneDisposeObserver;
  50296. private _originalPointerObserver;
  50297. /**
  50298. * Instantiates a UtilityLayerRenderer
  50299. * @param originalScene the original scene that will be rendered on top of
  50300. * @param handleEvents boolean indicating if the utility layer should handle events
  50301. */
  50302. constructor(
  50303. /** the original scene that will be rendered on top of */
  50304. originalScene: Scene, handleEvents?: boolean);
  50305. private _notifyObservers;
  50306. /**
  50307. * Renders the utility layers scene on top of the original scene
  50308. */
  50309. render(): void;
  50310. /**
  50311. * Disposes of the renderer
  50312. */
  50313. dispose(): void;
  50314. private _updateCamera;
  50315. }
  50316. }
  50317. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50318. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50320. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50321. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50322. import { Scene } from "babylonjs/scene";
  50323. import { Nullable } from "babylonjs/types";
  50324. import { Color3 } from "babylonjs/Maths/math.color";
  50325. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50326. /**
  50327. * Options interface for the pointer selection module
  50328. */
  50329. export interface IWebXRControllerPointerSelectionOptions {
  50330. /**
  50331. * if provided, this scene will be used to render meshes.
  50332. */
  50333. customUtilityLayerScene?: Scene;
  50334. /**
  50335. * 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)
  50336. * If not disabled, the last picked point will be used to execute a pointer up event
  50337. * If disabled, pointer up event will be triggered right after the pointer down event.
  50338. * Used in screen and gaze target ray mode only
  50339. */
  50340. disablePointerUpOnTouchOut: boolean;
  50341. /**
  50342. * For gaze mode (time to select instead of press)
  50343. */
  50344. forceGazeMode: boolean;
  50345. /**
  50346. * 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
  50347. * to start a new countdown to the pointer down event.
  50348. * Defaults to 1.
  50349. */
  50350. gazeModePointerMovedFactor?: number;
  50351. /**
  50352. * Different button type to use instead of the main component
  50353. */
  50354. overrideButtonId?: string;
  50355. /**
  50356. * use this rendering group id for the meshes (optional)
  50357. */
  50358. renderingGroupId?: number;
  50359. /**
  50360. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50361. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50362. * 3000 means 3 seconds between pointing at something and selecting it
  50363. */
  50364. timeToSelect?: number;
  50365. /**
  50366. * Should meshes created here be added to a utility layer or the main scene
  50367. */
  50368. useUtilityLayer?: boolean;
  50369. /**
  50370. * the xr input to use with this pointer selection
  50371. */
  50372. xrInput: WebXRInput;
  50373. }
  50374. /**
  50375. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50376. */
  50377. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50378. private readonly _options;
  50379. private static _idCounter;
  50380. private _attachController;
  50381. private _controllers;
  50382. private _scene;
  50383. private _tmpVectorForPickCompare;
  50384. /**
  50385. * The module's name
  50386. */
  50387. static readonly Name: string;
  50388. /**
  50389. * The (Babylon) version of this module.
  50390. * This is an integer representing the implementation version.
  50391. * This number does not correspond to the WebXR specs version
  50392. */
  50393. static readonly Version: number;
  50394. /**
  50395. * Disable lighting on the laser pointer (so it will always be visible)
  50396. */
  50397. disablePointerLighting: boolean;
  50398. /**
  50399. * Disable lighting on the selection mesh (so it will always be visible)
  50400. */
  50401. disableSelectionMeshLighting: boolean;
  50402. /**
  50403. * Should the laser pointer be displayed
  50404. */
  50405. displayLaserPointer: boolean;
  50406. /**
  50407. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50408. */
  50409. displaySelectionMesh: boolean;
  50410. /**
  50411. * This color will be set to the laser pointer when selection is triggered
  50412. */
  50413. laserPointerPickedColor: Color3;
  50414. /**
  50415. * Default color of the laser pointer
  50416. */
  50417. laserPointerDefaultColor: Color3;
  50418. /**
  50419. * default color of the selection ring
  50420. */
  50421. selectionMeshDefaultColor: Color3;
  50422. /**
  50423. * This color will be applied to the selection ring when selection is triggered
  50424. */
  50425. selectionMeshPickedColor: Color3;
  50426. /**
  50427. * Optional filter to be used for ray selection. This predicate shares behavior with
  50428. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50429. */
  50430. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50431. /**
  50432. * constructs a new background remover module
  50433. * @param _xrSessionManager the session manager for this module
  50434. * @param _options read-only options to be used in this module
  50435. */
  50436. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50437. /**
  50438. * attach this feature
  50439. * Will usually be called by the features manager
  50440. *
  50441. * @returns true if successful.
  50442. */
  50443. attach(): boolean;
  50444. /**
  50445. * detach this feature.
  50446. * Will usually be called by the features manager
  50447. *
  50448. * @returns true if successful.
  50449. */
  50450. detach(): boolean;
  50451. /**
  50452. * Will get the mesh under a specific pointer.
  50453. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50454. * @param controllerId the controllerId to check
  50455. * @returns The mesh under pointer or null if no mesh is under the pointer
  50456. */
  50457. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50458. /**
  50459. * Get the xr controller that correlates to the pointer id in the pointer event
  50460. *
  50461. * @param id the pointer id to search for
  50462. * @returns the controller that correlates to this id or null if not found
  50463. */
  50464. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50465. protected _onXRFrame(_xrFrame: XRFrame): void;
  50466. private _attachGazeMode;
  50467. private _attachScreenRayMode;
  50468. private _attachTrackedPointerRayMode;
  50469. private _convertNormalToDirectionOfRay;
  50470. private _detachController;
  50471. private _generateNewMeshPair;
  50472. private _pickingMoved;
  50473. private _updatePointerDistance;
  50474. /** @hidden */
  50475. get lasterPointerDefaultColor(): Color3;
  50476. }
  50477. }
  50478. declare module "babylonjs/XR/webXREnterExitUI" {
  50479. import { Nullable } from "babylonjs/types";
  50480. import { Observable } from "babylonjs/Misc/observable";
  50481. import { IDisposable, Scene } from "babylonjs/scene";
  50482. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50483. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50484. /**
  50485. * Button which can be used to enter a different mode of XR
  50486. */
  50487. export class WebXREnterExitUIButton {
  50488. /** button element */
  50489. element: HTMLElement;
  50490. /** XR initialization options for the button */
  50491. sessionMode: XRSessionMode;
  50492. /** Reference space type */
  50493. referenceSpaceType: XRReferenceSpaceType;
  50494. /**
  50495. * Creates a WebXREnterExitUIButton
  50496. * @param element button element
  50497. * @param sessionMode XR initialization session mode
  50498. * @param referenceSpaceType the type of reference space to be used
  50499. */
  50500. constructor(
  50501. /** button element */
  50502. element: HTMLElement,
  50503. /** XR initialization options for the button */
  50504. sessionMode: XRSessionMode,
  50505. /** Reference space type */
  50506. referenceSpaceType: XRReferenceSpaceType);
  50507. /**
  50508. * Extendable function which can be used to update the button's visuals when the state changes
  50509. * @param activeButton the current active button in the UI
  50510. */
  50511. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50512. }
  50513. /**
  50514. * Options to create the webXR UI
  50515. */
  50516. export class WebXREnterExitUIOptions {
  50517. /**
  50518. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50519. */
  50520. customButtons?: Array<WebXREnterExitUIButton>;
  50521. /**
  50522. * A reference space type to use when creating the default button.
  50523. * Default is local-floor
  50524. */
  50525. referenceSpaceType?: XRReferenceSpaceType;
  50526. /**
  50527. * Context to enter xr with
  50528. */
  50529. renderTarget?: Nullable<WebXRRenderTarget>;
  50530. /**
  50531. * A session mode to use when creating the default button.
  50532. * Default is immersive-vr
  50533. */
  50534. sessionMode?: XRSessionMode;
  50535. /**
  50536. * A list of optional features to init the session with
  50537. */
  50538. optionalFeatures?: string[];
  50539. /**
  50540. * A list of optional features to init the session with
  50541. */
  50542. requiredFeatures?: string[];
  50543. }
  50544. /**
  50545. * UI to allow the user to enter/exit XR mode
  50546. */
  50547. export class WebXREnterExitUI implements IDisposable {
  50548. private scene;
  50549. /** version of the options passed to this UI */
  50550. options: WebXREnterExitUIOptions;
  50551. private _activeButton;
  50552. private _buttons;
  50553. private _overlay;
  50554. /**
  50555. * Fired every time the active button is changed.
  50556. *
  50557. * When xr is entered via a button that launches xr that button will be the callback parameter
  50558. *
  50559. * When exiting xr the callback parameter will be null)
  50560. */
  50561. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50562. /**
  50563. *
  50564. * @param scene babylon scene object to use
  50565. * @param options (read-only) version of the options passed to this UI
  50566. */
  50567. private constructor();
  50568. /**
  50569. * Creates UI to allow the user to enter/exit XR mode
  50570. * @param scene the scene to add the ui to
  50571. * @param helper the xr experience helper to enter/exit xr with
  50572. * @param options options to configure the UI
  50573. * @returns the created ui
  50574. */
  50575. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50576. /**
  50577. * Disposes of the XR UI component
  50578. */
  50579. dispose(): void;
  50580. private _updateButtons;
  50581. }
  50582. }
  50583. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50584. import { Vector3 } from "babylonjs/Maths/math.vector";
  50585. import { Color4 } from "babylonjs/Maths/math.color";
  50586. import { Nullable } from "babylonjs/types";
  50587. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50588. import { Scene } from "babylonjs/scene";
  50589. /**
  50590. * Class containing static functions to help procedurally build meshes
  50591. */
  50592. export class LinesBuilder {
  50593. /**
  50594. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50595. * * 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
  50596. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50597. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50598. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50599. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50600. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50601. * * 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
  50602. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50605. * @param name defines the name of the new line system
  50606. * @param options defines the options used to create the line system
  50607. * @param scene defines the hosting scene
  50608. * @returns a new line system mesh
  50609. */
  50610. static CreateLineSystem(name: string, options: {
  50611. lines: Vector3[][];
  50612. updatable?: boolean;
  50613. instance?: Nullable<LinesMesh>;
  50614. colors?: Nullable<Color4[][]>;
  50615. useVertexAlpha?: boolean;
  50616. }, scene: Nullable<Scene>): LinesMesh;
  50617. /**
  50618. * Creates a line mesh
  50619. * 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
  50620. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50621. * * The parameter `points` is an array successive Vector3
  50622. * * 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
  50623. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50624. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50625. * * When updating an instance, remember that only point positions can change, not the number of points
  50626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50628. * @param name defines the name of the new line system
  50629. * @param options defines the options used to create the line system
  50630. * @param scene defines the hosting scene
  50631. * @returns a new line mesh
  50632. */
  50633. static CreateLines(name: string, options: {
  50634. points: Vector3[];
  50635. updatable?: boolean;
  50636. instance?: Nullable<LinesMesh>;
  50637. colors?: Color4[];
  50638. useVertexAlpha?: boolean;
  50639. }, scene?: Nullable<Scene>): LinesMesh;
  50640. /**
  50641. * Creates a dashed line mesh
  50642. * * 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
  50643. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50644. * * The parameter `points` is an array successive Vector3
  50645. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50646. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50647. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50648. * * 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
  50649. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50650. * * When updating an instance, remember that only point positions can change, not the number of points
  50651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50652. * @param name defines the name of the mesh
  50653. * @param options defines the options used to create the mesh
  50654. * @param scene defines the hosting scene
  50655. * @returns the dashed line mesh
  50656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50657. */
  50658. static CreateDashedLines(name: string, options: {
  50659. points: Vector3[];
  50660. dashSize?: number;
  50661. gapSize?: number;
  50662. dashNb?: number;
  50663. updatable?: boolean;
  50664. instance?: LinesMesh;
  50665. useVertexAlpha?: boolean;
  50666. }, scene?: Nullable<Scene>): LinesMesh;
  50667. }
  50668. }
  50669. declare module "babylonjs/Misc/timer" {
  50670. import { Observable, Observer } from "babylonjs/Misc/observable";
  50671. import { Nullable } from "babylonjs/types";
  50672. import { IDisposable } from "babylonjs/scene";
  50673. /**
  50674. * Construction options for a timer
  50675. */
  50676. export interface ITimerOptions<T> {
  50677. /**
  50678. * Time-to-end
  50679. */
  50680. timeout: number;
  50681. /**
  50682. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50683. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50684. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50685. */
  50686. contextObservable: Observable<T>;
  50687. /**
  50688. * Optional parameters when adding an observer to the observable
  50689. */
  50690. observableParameters?: {
  50691. mask?: number;
  50692. insertFirst?: boolean;
  50693. scope?: any;
  50694. };
  50695. /**
  50696. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50697. */
  50698. breakCondition?: (data?: ITimerData<T>) => boolean;
  50699. /**
  50700. * Will be triggered when the time condition has met
  50701. */
  50702. onEnded?: (data: ITimerData<any>) => void;
  50703. /**
  50704. * Will be triggered when the break condition has met (prematurely ended)
  50705. */
  50706. onAborted?: (data: ITimerData<any>) => void;
  50707. /**
  50708. * Optional function to execute on each tick (or count)
  50709. */
  50710. onTick?: (data: ITimerData<any>) => void;
  50711. }
  50712. /**
  50713. * An interface defining the data sent by the timer
  50714. */
  50715. export interface ITimerData<T> {
  50716. /**
  50717. * When did it start
  50718. */
  50719. startTime: number;
  50720. /**
  50721. * Time now
  50722. */
  50723. currentTime: number;
  50724. /**
  50725. * Time passed since started
  50726. */
  50727. deltaTime: number;
  50728. /**
  50729. * How much is completed, in [0.0...1.0].
  50730. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50731. */
  50732. completeRate: number;
  50733. /**
  50734. * What the registered observable sent in the last count
  50735. */
  50736. payload: T;
  50737. }
  50738. /**
  50739. * The current state of the timer
  50740. */
  50741. export enum TimerState {
  50742. /**
  50743. * Timer initialized, not yet started
  50744. */
  50745. INIT = 0,
  50746. /**
  50747. * Timer started and counting
  50748. */
  50749. STARTED = 1,
  50750. /**
  50751. * Timer ended (whether aborted or time reached)
  50752. */
  50753. ENDED = 2
  50754. }
  50755. /**
  50756. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50757. *
  50758. * @param options options with which to initialize this timer
  50759. */
  50760. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50761. /**
  50762. * An advanced implementation of a timer class
  50763. */
  50764. export class AdvancedTimer<T = any> implements IDisposable {
  50765. /**
  50766. * Will notify each time the timer calculates the remaining time
  50767. */
  50768. onEachCountObservable: Observable<ITimerData<T>>;
  50769. /**
  50770. * Will trigger when the timer was aborted due to the break condition
  50771. */
  50772. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50773. /**
  50774. * Will trigger when the timer ended successfully
  50775. */
  50776. onTimerEndedObservable: Observable<ITimerData<T>>;
  50777. /**
  50778. * Will trigger when the timer state has changed
  50779. */
  50780. onStateChangedObservable: Observable<TimerState>;
  50781. private _observer;
  50782. private _contextObservable;
  50783. private _observableParameters;
  50784. private _startTime;
  50785. private _timer;
  50786. private _state;
  50787. private _breakCondition;
  50788. private _timeToEnd;
  50789. private _breakOnNextTick;
  50790. /**
  50791. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50792. * @param options construction options for this advanced timer
  50793. */
  50794. constructor(options: ITimerOptions<T>);
  50795. /**
  50796. * set a breaking condition for this timer. Default is to never break during count
  50797. * @param predicate the new break condition. Returns true to break, false otherwise
  50798. */
  50799. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50800. /**
  50801. * Reset ALL associated observables in this advanced timer
  50802. */
  50803. clearObservables(): void;
  50804. /**
  50805. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50806. *
  50807. * @param timeToEnd how much time to measure until timer ended
  50808. */
  50809. start(timeToEnd?: number): void;
  50810. /**
  50811. * Will force a stop on the next tick.
  50812. */
  50813. stop(): void;
  50814. /**
  50815. * Dispose this timer, clearing all resources
  50816. */
  50817. dispose(): void;
  50818. private _setState;
  50819. private _tick;
  50820. private _stop;
  50821. }
  50822. }
  50823. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50824. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50825. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50826. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50828. import { Vector3 } from "babylonjs/Maths/math.vector";
  50829. import { Material } from "babylonjs/Materials/material";
  50830. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50831. import { Scene } from "babylonjs/scene";
  50832. /**
  50833. * The options container for the teleportation module
  50834. */
  50835. export interface IWebXRTeleportationOptions {
  50836. /**
  50837. * if provided, this scene will be used to render meshes.
  50838. */
  50839. customUtilityLayerScene?: Scene;
  50840. /**
  50841. * Values to configure the default target mesh
  50842. */
  50843. defaultTargetMeshOptions?: {
  50844. /**
  50845. * Fill color of the teleportation area
  50846. */
  50847. teleportationFillColor?: string;
  50848. /**
  50849. * Border color for the teleportation area
  50850. */
  50851. teleportationBorderColor?: string;
  50852. /**
  50853. * Disable the mesh's animation sequence
  50854. */
  50855. disableAnimation?: boolean;
  50856. /**
  50857. * Disable lighting on the material or the ring and arrow
  50858. */
  50859. disableLighting?: boolean;
  50860. /**
  50861. * Override the default material of the torus and arrow
  50862. */
  50863. torusArrowMaterial?: Material;
  50864. };
  50865. /**
  50866. * A list of meshes to use as floor meshes.
  50867. * Meshes can be added and removed after initializing the feature using the
  50868. * addFloorMesh and removeFloorMesh functions
  50869. * If empty, rotation will still work
  50870. */
  50871. floorMeshes?: AbstractMesh[];
  50872. /**
  50873. * use this rendering group id for the meshes (optional)
  50874. */
  50875. renderingGroupId?: number;
  50876. /**
  50877. * Should teleportation move only to snap points
  50878. */
  50879. snapPointsOnly?: boolean;
  50880. /**
  50881. * An array of points to which the teleportation will snap to.
  50882. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50883. */
  50884. snapPositions?: Vector3[];
  50885. /**
  50886. * How close should the teleportation ray be in order to snap to position.
  50887. * Default to 0.8 units (meters)
  50888. */
  50889. snapToPositionRadius?: number;
  50890. /**
  50891. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50892. * If you want to support rotation, make sure your mesh has a direction indicator.
  50893. *
  50894. * When left untouched, the default mesh will be initialized.
  50895. */
  50896. teleportationTargetMesh?: AbstractMesh;
  50897. /**
  50898. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50899. */
  50900. timeToTeleport?: number;
  50901. /**
  50902. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50903. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50904. */
  50905. useMainComponentOnly?: boolean;
  50906. /**
  50907. * Should meshes created here be added to a utility layer or the main scene
  50908. */
  50909. useUtilityLayer?: boolean;
  50910. /**
  50911. * Babylon XR Input class for controller
  50912. */
  50913. xrInput: WebXRInput;
  50914. }
  50915. /**
  50916. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50917. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50918. * the input of the attached controllers.
  50919. */
  50920. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50921. private _options;
  50922. private _controllers;
  50923. private _currentTeleportationControllerId;
  50924. private _floorMeshes;
  50925. private _quadraticBezierCurve;
  50926. private _selectionFeature;
  50927. private _snapToPositions;
  50928. private _snappedToPoint;
  50929. private _teleportationRingMaterial?;
  50930. private _tmpRay;
  50931. private _tmpVector;
  50932. /**
  50933. * The module's name
  50934. */
  50935. static readonly Name: string;
  50936. /**
  50937. * The (Babylon) version of this module.
  50938. * This is an integer representing the implementation version.
  50939. * This number does not correspond to the webxr specs version
  50940. */
  50941. static readonly Version: number;
  50942. /**
  50943. * Is movement backwards enabled
  50944. */
  50945. backwardsMovementEnabled: boolean;
  50946. /**
  50947. * Distance to travel when moving backwards
  50948. */
  50949. backwardsTeleportationDistance: number;
  50950. /**
  50951. * The distance from the user to the inspection point in the direction of the controller
  50952. * A higher number will allow the user to move further
  50953. * defaults to 5 (meters, in xr units)
  50954. */
  50955. parabolicCheckRadius: number;
  50956. /**
  50957. * Should the module support parabolic ray on top of direct ray
  50958. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50959. * Very helpful when moving between floors / different heights
  50960. */
  50961. parabolicRayEnabled: boolean;
  50962. /**
  50963. * How much rotation should be applied when rotating right and left
  50964. */
  50965. rotationAngle: number;
  50966. /**
  50967. * Is rotation enabled when moving forward?
  50968. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50969. */
  50970. rotationEnabled: boolean;
  50971. /**
  50972. * constructs a new anchor system
  50973. * @param _xrSessionManager an instance of WebXRSessionManager
  50974. * @param _options configuration object for this feature
  50975. */
  50976. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50977. /**
  50978. * Get the snapPointsOnly flag
  50979. */
  50980. get snapPointsOnly(): boolean;
  50981. /**
  50982. * Sets the snapPointsOnly flag
  50983. * @param snapToPoints should teleportation be exclusively to snap points
  50984. */
  50985. set snapPointsOnly(snapToPoints: boolean);
  50986. /**
  50987. * Add a new mesh to the floor meshes array
  50988. * @param mesh the mesh to use as floor mesh
  50989. */
  50990. addFloorMesh(mesh: AbstractMesh): void;
  50991. /**
  50992. * Add a new snap-to point to fix teleportation to this position
  50993. * @param newSnapPoint The new Snap-To point
  50994. */
  50995. addSnapPoint(newSnapPoint: Vector3): void;
  50996. attach(): boolean;
  50997. detach(): boolean;
  50998. dispose(): void;
  50999. /**
  51000. * Remove a mesh from the floor meshes array
  51001. * @param mesh the mesh to remove
  51002. */
  51003. removeFloorMesh(mesh: AbstractMesh): void;
  51004. /**
  51005. * Remove a mesh from the floor meshes array using its name
  51006. * @param name the mesh name to remove
  51007. */
  51008. removeFloorMeshByName(name: string): void;
  51009. /**
  51010. * 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
  51011. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51012. * @returns was the point found and removed or not
  51013. */
  51014. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51015. /**
  51016. * This function sets a selection feature that will be disabled when
  51017. * the forward ray is shown and will be reattached when hidden.
  51018. * This is used to remove the selection rays when moving.
  51019. * @param selectionFeature the feature to disable when forward movement is enabled
  51020. */
  51021. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51022. protected _onXRFrame(_xrFrame: XRFrame): void;
  51023. private _attachController;
  51024. private _createDefaultTargetMesh;
  51025. private _detachController;
  51026. private _findClosestSnapPointWithRadius;
  51027. private _setTargetMeshPosition;
  51028. private _setTargetMeshVisibility;
  51029. private _showParabolicPath;
  51030. private _teleportForward;
  51031. }
  51032. }
  51033. declare module "babylonjs/XR/webXRDefaultExperience" {
  51034. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51035. import { Scene } from "babylonjs/scene";
  51036. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51037. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51038. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51039. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51041. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51042. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51043. /**
  51044. * Options for the default xr helper
  51045. */
  51046. export class WebXRDefaultExperienceOptions {
  51047. /**
  51048. * Enable or disable default UI to enter XR
  51049. */
  51050. disableDefaultUI?: boolean;
  51051. /**
  51052. * Should teleportation not initialize. defaults to false.
  51053. */
  51054. disableTeleportation?: boolean;
  51055. /**
  51056. * Floor meshes that will be used for teleport
  51057. */
  51058. floorMeshes?: Array<AbstractMesh>;
  51059. /**
  51060. * If set to true, the first frame will not be used to reset position
  51061. * The first frame is mainly used when copying transformation from the old camera
  51062. * Mainly used in AR
  51063. */
  51064. ignoreNativeCameraTransformation?: boolean;
  51065. /**
  51066. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51067. */
  51068. inputOptions?: IWebXRInputOptions;
  51069. /**
  51070. * optional configuration for the output canvas
  51071. */
  51072. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51073. /**
  51074. * optional UI options. This can be used among other to change session mode and reference space type
  51075. */
  51076. uiOptions?: WebXREnterExitUIOptions;
  51077. /**
  51078. * When loading teleportation and pointer select, use stable versions instead of latest.
  51079. */
  51080. useStablePlugins?: boolean;
  51081. /**
  51082. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51083. */
  51084. renderingGroupId?: number;
  51085. /**
  51086. * A list of optional features to init the session with
  51087. * If set to true, all features we support will be added
  51088. */
  51089. optionalFeatures?: boolean | string[];
  51090. }
  51091. /**
  51092. * Default experience which provides a similar setup to the previous webVRExperience
  51093. */
  51094. export class WebXRDefaultExperience {
  51095. /**
  51096. * Base experience
  51097. */
  51098. baseExperience: WebXRExperienceHelper;
  51099. /**
  51100. * Enables ui for entering/exiting xr
  51101. */
  51102. enterExitUI: WebXREnterExitUI;
  51103. /**
  51104. * Input experience extension
  51105. */
  51106. input: WebXRInput;
  51107. /**
  51108. * Enables laser pointer and selection
  51109. */
  51110. pointerSelection: WebXRControllerPointerSelection;
  51111. /**
  51112. * Default target xr should render to
  51113. */
  51114. renderTarget: WebXRRenderTarget;
  51115. /**
  51116. * Enables teleportation
  51117. */
  51118. teleportation: WebXRMotionControllerTeleportation;
  51119. private constructor();
  51120. /**
  51121. * Creates the default xr experience
  51122. * @param scene scene
  51123. * @param options options for basic configuration
  51124. * @returns resulting WebXRDefaultExperience
  51125. */
  51126. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51127. /**
  51128. * DIsposes of the experience helper
  51129. */
  51130. dispose(): void;
  51131. }
  51132. }
  51133. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51134. import { Observable } from "babylonjs/Misc/observable";
  51135. import { Nullable } from "babylonjs/types";
  51136. import { Camera } from "babylonjs/Cameras/camera";
  51137. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51138. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51139. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51140. import { Scene } from "babylonjs/scene";
  51141. import { Vector3 } from "babylonjs/Maths/math.vector";
  51142. import { Color3 } from "babylonjs/Maths/math.color";
  51143. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51145. import { Mesh } from "babylonjs/Meshes/mesh";
  51146. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51147. import { EasingFunction } from "babylonjs/Animations/easing";
  51148. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51149. import "babylonjs/Meshes/Builders/groundBuilder";
  51150. import "babylonjs/Meshes/Builders/torusBuilder";
  51151. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51152. import "babylonjs/Gamepads/gamepadSceneComponent";
  51153. import "babylonjs/Animations/animatable";
  51154. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51155. /**
  51156. * Options to modify the vr teleportation behavior.
  51157. */
  51158. export interface VRTeleportationOptions {
  51159. /**
  51160. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51161. */
  51162. floorMeshName?: string;
  51163. /**
  51164. * A list of meshes to be used as the teleportation floor. (default: empty)
  51165. */
  51166. floorMeshes?: Mesh[];
  51167. /**
  51168. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51169. */
  51170. teleportationMode?: number;
  51171. /**
  51172. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51173. */
  51174. teleportationTime?: number;
  51175. /**
  51176. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51177. */
  51178. teleportationSpeed?: number;
  51179. /**
  51180. * The easing function used in the animation or null for Linear. (default CircleEase)
  51181. */
  51182. easingFunction?: EasingFunction;
  51183. }
  51184. /**
  51185. * Options to modify the vr experience helper's behavior.
  51186. */
  51187. export interface VRExperienceHelperOptions extends WebVROptions {
  51188. /**
  51189. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51190. */
  51191. createDeviceOrientationCamera?: boolean;
  51192. /**
  51193. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51194. */
  51195. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51196. /**
  51197. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51198. */
  51199. laserToggle?: boolean;
  51200. /**
  51201. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51202. */
  51203. floorMeshes?: Mesh[];
  51204. /**
  51205. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51206. */
  51207. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51208. /**
  51209. * Defines if WebXR should be used instead of WebVR (if available)
  51210. */
  51211. useXR?: boolean;
  51212. }
  51213. /**
  51214. * Event containing information after VR has been entered
  51215. */
  51216. export class OnAfterEnteringVRObservableEvent {
  51217. /**
  51218. * If entering vr was successful
  51219. */
  51220. success: boolean;
  51221. }
  51222. /**
  51223. * Helps to quickly add VR support to an existing scene.
  51224. * See https://doc.babylonjs.com/how_to/webvr_helper
  51225. */
  51226. export class VRExperienceHelper {
  51227. /** Options to modify the vr experience helper's behavior. */
  51228. webVROptions: VRExperienceHelperOptions;
  51229. private _scene;
  51230. private _position;
  51231. private _btnVR;
  51232. private _btnVRDisplayed;
  51233. private _webVRsupported;
  51234. private _webVRready;
  51235. private _webVRrequesting;
  51236. private _webVRpresenting;
  51237. private _hasEnteredVR;
  51238. private _fullscreenVRpresenting;
  51239. private _inputElement;
  51240. private _webVRCamera;
  51241. private _vrDeviceOrientationCamera;
  51242. private _deviceOrientationCamera;
  51243. private _existingCamera;
  51244. private _onKeyDown;
  51245. private _onVrDisplayPresentChange;
  51246. private _onVRDisplayChanged;
  51247. private _onVRRequestPresentStart;
  51248. private _onVRRequestPresentComplete;
  51249. /**
  51250. * 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)
  51251. */
  51252. enableGazeEvenWhenNoPointerLock: boolean;
  51253. /**
  51254. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51255. */
  51256. exitVROnDoubleTap: boolean;
  51257. /**
  51258. * Observable raised right before entering VR.
  51259. */
  51260. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51261. /**
  51262. * Observable raised when entering VR has completed.
  51263. */
  51264. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51265. /**
  51266. * Observable raised when exiting VR.
  51267. */
  51268. onExitingVRObservable: Observable<VRExperienceHelper>;
  51269. /**
  51270. * Observable raised when controller mesh is loaded.
  51271. */
  51272. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51273. /** Return this.onEnteringVRObservable
  51274. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51275. */
  51276. get onEnteringVR(): Observable<VRExperienceHelper>;
  51277. /** Return this.onExitingVRObservable
  51278. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51279. */
  51280. get onExitingVR(): Observable<VRExperienceHelper>;
  51281. /** Return this.onControllerMeshLoadedObservable
  51282. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51283. */
  51284. get onControllerMeshLoaded(): Observable<WebVRController>;
  51285. private _rayLength;
  51286. private _useCustomVRButton;
  51287. private _teleportationRequested;
  51288. private _teleportActive;
  51289. private _floorMeshName;
  51290. private _floorMeshesCollection;
  51291. private _teleportationMode;
  51292. private _teleportationTime;
  51293. private _teleportationSpeed;
  51294. private _teleportationEasing;
  51295. private _rotationAllowed;
  51296. private _teleportBackwardsVector;
  51297. private _teleportationTarget;
  51298. private _isDefaultTeleportationTarget;
  51299. private _postProcessMove;
  51300. private _teleportationFillColor;
  51301. private _teleportationBorderColor;
  51302. private _rotationAngle;
  51303. private _haloCenter;
  51304. private _cameraGazer;
  51305. private _padSensibilityUp;
  51306. private _padSensibilityDown;
  51307. private _leftController;
  51308. private _rightController;
  51309. private _gazeColor;
  51310. private _laserColor;
  51311. private _pickedLaserColor;
  51312. private _pickedGazeColor;
  51313. /**
  51314. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51315. */
  51316. onNewMeshSelected: Observable<AbstractMesh>;
  51317. /**
  51318. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51319. * This observable will provide the mesh and the controller used to select the mesh
  51320. */
  51321. onMeshSelectedWithController: Observable<{
  51322. mesh: AbstractMesh;
  51323. controller: WebVRController;
  51324. }>;
  51325. /**
  51326. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51327. */
  51328. onNewMeshPicked: Observable<PickingInfo>;
  51329. private _circleEase;
  51330. /**
  51331. * Observable raised before camera teleportation
  51332. */
  51333. onBeforeCameraTeleport: Observable<Vector3>;
  51334. /**
  51335. * Observable raised after camera teleportation
  51336. */
  51337. onAfterCameraTeleport: Observable<Vector3>;
  51338. /**
  51339. * Observable raised when current selected mesh gets unselected
  51340. */
  51341. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51342. private _raySelectionPredicate;
  51343. /**
  51344. * To be optionaly changed by user to define custom ray selection
  51345. */
  51346. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51347. /**
  51348. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51349. */
  51350. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51351. /**
  51352. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51353. */
  51354. teleportationEnabled: boolean;
  51355. private _defaultHeight;
  51356. private _teleportationInitialized;
  51357. private _interactionsEnabled;
  51358. private _interactionsRequested;
  51359. private _displayGaze;
  51360. private _displayLaserPointer;
  51361. /**
  51362. * The mesh used to display where the user is going to teleport.
  51363. */
  51364. get teleportationTarget(): Mesh;
  51365. /**
  51366. * Sets the mesh to be used to display where the user is going to teleport.
  51367. */
  51368. set teleportationTarget(value: Mesh);
  51369. /**
  51370. * 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
  51371. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51372. * See https://doc.babylonjs.com/resources/baking_transformations
  51373. */
  51374. get gazeTrackerMesh(): Mesh;
  51375. set gazeTrackerMesh(value: Mesh);
  51376. /**
  51377. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51378. */
  51379. updateGazeTrackerScale: boolean;
  51380. /**
  51381. * If the gaze trackers color should be updated when selecting meshes
  51382. */
  51383. updateGazeTrackerColor: boolean;
  51384. /**
  51385. * If the controller laser color should be updated when selecting meshes
  51386. */
  51387. updateControllerLaserColor: boolean;
  51388. /**
  51389. * The gaze tracking mesh corresponding to the left controller
  51390. */
  51391. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51392. /**
  51393. * The gaze tracking mesh corresponding to the right controller
  51394. */
  51395. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51396. /**
  51397. * If the ray of the gaze should be displayed.
  51398. */
  51399. get displayGaze(): boolean;
  51400. /**
  51401. * Sets if the ray of the gaze should be displayed.
  51402. */
  51403. set displayGaze(value: boolean);
  51404. /**
  51405. * If the ray of the LaserPointer should be displayed.
  51406. */
  51407. get displayLaserPointer(): boolean;
  51408. /**
  51409. * Sets if the ray of the LaserPointer should be displayed.
  51410. */
  51411. set displayLaserPointer(value: boolean);
  51412. /**
  51413. * The deviceOrientationCamera used as the camera when not in VR.
  51414. */
  51415. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51416. /**
  51417. * Based on the current WebVR support, returns the current VR camera used.
  51418. */
  51419. get currentVRCamera(): Nullable<Camera>;
  51420. /**
  51421. * The webVRCamera which is used when in VR.
  51422. */
  51423. get webVRCamera(): WebVRFreeCamera;
  51424. /**
  51425. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51426. */
  51427. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51428. /**
  51429. * The html button that is used to trigger entering into VR.
  51430. */
  51431. get vrButton(): Nullable<HTMLButtonElement>;
  51432. private get _teleportationRequestInitiated();
  51433. /**
  51434. * Defines whether or not Pointer lock should be requested when switching to
  51435. * full screen.
  51436. */
  51437. requestPointerLockOnFullScreen: boolean;
  51438. /**
  51439. * If asking to force XR, this will be populated with the default xr experience
  51440. */
  51441. xr: WebXRDefaultExperience;
  51442. /**
  51443. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51444. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51445. */
  51446. xrTestDone: boolean;
  51447. /**
  51448. * Instantiates a VRExperienceHelper.
  51449. * Helps to quickly add VR support to an existing scene.
  51450. * @param scene The scene the VRExperienceHelper belongs to.
  51451. * @param webVROptions Options to modify the vr experience helper's behavior.
  51452. */
  51453. constructor(scene: Scene,
  51454. /** Options to modify the vr experience helper's behavior. */
  51455. webVROptions?: VRExperienceHelperOptions);
  51456. private completeVRInit;
  51457. private _onDefaultMeshLoaded;
  51458. private _onResize;
  51459. private _onFullscreenChange;
  51460. /**
  51461. * Gets a value indicating if we are currently in VR mode.
  51462. */
  51463. get isInVRMode(): boolean;
  51464. private onVrDisplayPresentChange;
  51465. private onVRDisplayChanged;
  51466. private moveButtonToBottomRight;
  51467. private displayVRButton;
  51468. private updateButtonVisibility;
  51469. private _cachedAngularSensibility;
  51470. /**
  51471. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51472. * Otherwise, will use the fullscreen API.
  51473. */
  51474. enterVR(): void;
  51475. /**
  51476. * Attempt to exit VR, or fullscreen.
  51477. */
  51478. exitVR(): void;
  51479. /**
  51480. * The position of the vr experience helper.
  51481. */
  51482. get position(): Vector3;
  51483. /**
  51484. * Sets the position of the vr experience helper.
  51485. */
  51486. set position(value: Vector3);
  51487. /**
  51488. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51489. */
  51490. enableInteractions(): void;
  51491. private get _noControllerIsActive();
  51492. private beforeRender;
  51493. private _isTeleportationFloor;
  51494. /**
  51495. * Adds a floor mesh to be used for teleportation.
  51496. * @param floorMesh the mesh to be used for teleportation.
  51497. */
  51498. addFloorMesh(floorMesh: Mesh): void;
  51499. /**
  51500. * Removes a floor mesh from being used for teleportation.
  51501. * @param floorMesh the mesh to be removed.
  51502. */
  51503. removeFloorMesh(floorMesh: Mesh): void;
  51504. /**
  51505. * Enables interactions and teleportation using the VR controllers and gaze.
  51506. * @param vrTeleportationOptions options to modify teleportation behavior.
  51507. */
  51508. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51509. private _onNewGamepadConnected;
  51510. private _tryEnableInteractionOnController;
  51511. private _onNewGamepadDisconnected;
  51512. private _enableInteractionOnController;
  51513. private _checkTeleportWithRay;
  51514. private _checkRotate;
  51515. private _checkTeleportBackwards;
  51516. private _enableTeleportationOnController;
  51517. private _createTeleportationCircles;
  51518. private _displayTeleportationTarget;
  51519. private _hideTeleportationTarget;
  51520. private _rotateCamera;
  51521. private _moveTeleportationSelectorTo;
  51522. private _workingVector;
  51523. private _workingQuaternion;
  51524. private _workingMatrix;
  51525. /**
  51526. * Time Constant Teleportation Mode
  51527. */
  51528. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51529. /**
  51530. * Speed Constant Teleportation Mode
  51531. */
  51532. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51533. /**
  51534. * Teleports the users feet to the desired location
  51535. * @param location The location where the user's feet should be placed
  51536. */
  51537. teleportCamera(location: Vector3): void;
  51538. private _convertNormalToDirectionOfRay;
  51539. private _castRayAndSelectObject;
  51540. private _notifySelectedMeshUnselected;
  51541. /**
  51542. * Permanently set new colors for the laser pointer
  51543. * @param color the new laser color
  51544. * @param pickedColor the new laser color when picked mesh detected
  51545. */
  51546. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51547. /**
  51548. * Set lighting enabled / disabled on the laser pointer of both controllers
  51549. * @param enabled should the lighting be enabled on the laser pointer
  51550. */
  51551. setLaserLightingState(enabled?: boolean): void;
  51552. /**
  51553. * Permanently set new colors for the gaze pointer
  51554. * @param color the new gaze color
  51555. * @param pickedColor the new gaze color when picked mesh detected
  51556. */
  51557. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51558. /**
  51559. * Sets the color of the laser ray from the vr controllers.
  51560. * @param color new color for the ray.
  51561. */
  51562. changeLaserColor(color: Color3): void;
  51563. /**
  51564. * Sets the color of the ray from the vr headsets gaze.
  51565. * @param color new color for the ray.
  51566. */
  51567. changeGazeColor(color: Color3): void;
  51568. /**
  51569. * Exits VR and disposes of the vr experience helper
  51570. */
  51571. dispose(): void;
  51572. /**
  51573. * Gets the name of the VRExperienceHelper class
  51574. * @returns "VRExperienceHelper"
  51575. */
  51576. getClassName(): string;
  51577. }
  51578. }
  51579. declare module "babylonjs/Cameras/VR/index" {
  51580. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51581. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51582. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51583. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51584. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51585. export * from "babylonjs/Cameras/VR/webVRCamera";
  51586. }
  51587. declare module "babylonjs/Cameras/RigModes/index" {
  51588. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51589. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51590. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51591. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51592. }
  51593. declare module "babylonjs/Cameras/index" {
  51594. export * from "babylonjs/Cameras/Inputs/index";
  51595. export * from "babylonjs/Cameras/cameraInputsManager";
  51596. export * from "babylonjs/Cameras/camera";
  51597. export * from "babylonjs/Cameras/targetCamera";
  51598. export * from "babylonjs/Cameras/freeCamera";
  51599. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51600. export * from "babylonjs/Cameras/touchCamera";
  51601. export * from "babylonjs/Cameras/arcRotateCamera";
  51602. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51603. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51604. export * from "babylonjs/Cameras/flyCamera";
  51605. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51606. export * from "babylonjs/Cameras/followCamera";
  51607. export * from "babylonjs/Cameras/followCameraInputsManager";
  51608. export * from "babylonjs/Cameras/gamepadCamera";
  51609. export * from "babylonjs/Cameras/Stereoscopic/index";
  51610. export * from "babylonjs/Cameras/universalCamera";
  51611. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51612. export * from "babylonjs/Cameras/VR/index";
  51613. export * from "babylonjs/Cameras/RigModes/index";
  51614. }
  51615. declare module "babylonjs/Collisions/index" {
  51616. export * from "babylonjs/Collisions/collider";
  51617. export * from "babylonjs/Collisions/collisionCoordinator";
  51618. export * from "babylonjs/Collisions/pickingInfo";
  51619. export * from "babylonjs/Collisions/intersectionInfo";
  51620. export * from "babylonjs/Collisions/meshCollisionData";
  51621. }
  51622. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51623. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51624. import { Vector3 } from "babylonjs/Maths/math.vector";
  51625. import { Ray } from "babylonjs/Culling/ray";
  51626. import { Plane } from "babylonjs/Maths/math.plane";
  51627. /**
  51628. * Contains an array of blocks representing the octree
  51629. */
  51630. export interface IOctreeContainer<T> {
  51631. /**
  51632. * Blocks within the octree
  51633. */
  51634. blocks: Array<OctreeBlock<T>>;
  51635. }
  51636. /**
  51637. * Class used to store a cell in an octree
  51638. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51639. */
  51640. export class OctreeBlock<T> {
  51641. /**
  51642. * Gets the content of the current block
  51643. */
  51644. entries: T[];
  51645. /**
  51646. * Gets the list of block children
  51647. */
  51648. blocks: Array<OctreeBlock<T>>;
  51649. private _depth;
  51650. private _maxDepth;
  51651. private _capacity;
  51652. private _minPoint;
  51653. private _maxPoint;
  51654. private _boundingVectors;
  51655. private _creationFunc;
  51656. /**
  51657. * Creates a new block
  51658. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51659. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51660. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51661. * @param depth defines the current depth of this block in the octree
  51662. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51663. * @param creationFunc defines a callback to call when an element is added to the block
  51664. */
  51665. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51666. /**
  51667. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51668. */
  51669. get capacity(): number;
  51670. /**
  51671. * Gets the minimum vector (in world space) of the block's bounding box
  51672. */
  51673. get minPoint(): Vector3;
  51674. /**
  51675. * Gets the maximum vector (in world space) of the block's bounding box
  51676. */
  51677. get maxPoint(): Vector3;
  51678. /**
  51679. * Add a new element to this block
  51680. * @param entry defines the element to add
  51681. */
  51682. addEntry(entry: T): void;
  51683. /**
  51684. * Remove an element from this block
  51685. * @param entry defines the element to remove
  51686. */
  51687. removeEntry(entry: T): void;
  51688. /**
  51689. * Add an array of elements to this block
  51690. * @param entries defines the array of elements to add
  51691. */
  51692. addEntries(entries: T[]): void;
  51693. /**
  51694. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51695. * @param frustumPlanes defines the frustum planes to test
  51696. * @param selection defines the array to store current content if selection is positive
  51697. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51698. */
  51699. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51700. /**
  51701. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51702. * @param sphereCenter defines the bounding sphere center
  51703. * @param sphereRadius defines the bounding sphere radius
  51704. * @param selection defines the array to store current content if selection is positive
  51705. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51706. */
  51707. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51708. /**
  51709. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51710. * @param ray defines the ray to test with
  51711. * @param selection defines the array to store current content if selection is positive
  51712. */
  51713. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51714. /**
  51715. * Subdivide the content into child blocks (this block will then be empty)
  51716. */
  51717. createInnerBlocks(): void;
  51718. /**
  51719. * @hidden
  51720. */
  51721. 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;
  51722. }
  51723. }
  51724. declare module "babylonjs/Culling/Octrees/octree" {
  51725. import { SmartArray } from "babylonjs/Misc/smartArray";
  51726. import { Vector3 } from "babylonjs/Maths/math.vector";
  51727. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51729. import { Ray } from "babylonjs/Culling/ray";
  51730. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51731. import { Plane } from "babylonjs/Maths/math.plane";
  51732. /**
  51733. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51734. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51735. */
  51736. export class Octree<T> {
  51737. /** 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.) */
  51738. maxDepth: number;
  51739. /**
  51740. * Blocks within the octree containing objects
  51741. */
  51742. blocks: Array<OctreeBlock<T>>;
  51743. /**
  51744. * Content stored in the octree
  51745. */
  51746. dynamicContent: T[];
  51747. private _maxBlockCapacity;
  51748. private _selectionContent;
  51749. private _creationFunc;
  51750. /**
  51751. * Creates a octree
  51752. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51753. * @param creationFunc function to be used to instatiate the octree
  51754. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51755. * @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.)
  51756. */
  51757. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51758. /** 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.) */
  51759. maxDepth?: number);
  51760. /**
  51761. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51762. * @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);
  51763. * @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);
  51764. * @param entries meshes to be added to the octree blocks
  51765. */
  51766. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51767. /**
  51768. * Adds a mesh to the octree
  51769. * @param entry Mesh to add to the octree
  51770. */
  51771. addMesh(entry: T): void;
  51772. /**
  51773. * Remove an element from the octree
  51774. * @param entry defines the element to remove
  51775. */
  51776. removeMesh(entry: T): void;
  51777. /**
  51778. * Selects an array of meshes within the frustum
  51779. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51780. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51781. * @returns array of meshes within the frustum
  51782. */
  51783. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51784. /**
  51785. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51786. * @param sphereCenter defines the bounding sphere center
  51787. * @param sphereRadius defines the bounding sphere radius
  51788. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51789. * @returns an array of objects that intersect the sphere
  51790. */
  51791. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51792. /**
  51793. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51794. * @param ray defines the ray to test with
  51795. * @returns array of intersected objects
  51796. */
  51797. intersectsRay(ray: Ray): SmartArray<T>;
  51798. /**
  51799. * Adds a mesh into the octree block if it intersects the block
  51800. */
  51801. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51802. /**
  51803. * Adds a submesh into the octree block if it intersects the block
  51804. */
  51805. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51806. }
  51807. }
  51808. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51809. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51810. import { Scene } from "babylonjs/scene";
  51811. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51813. import { Ray } from "babylonjs/Culling/ray";
  51814. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51815. import { Collider } from "babylonjs/Collisions/collider";
  51816. module "babylonjs/scene" {
  51817. interface Scene {
  51818. /**
  51819. * @hidden
  51820. * Backing Filed
  51821. */
  51822. _selectionOctree: Octree<AbstractMesh>;
  51823. /**
  51824. * Gets the octree used to boost mesh selection (picking)
  51825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51826. */
  51827. selectionOctree: Octree<AbstractMesh>;
  51828. /**
  51829. * Creates or updates the octree used to boost selection (picking)
  51830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51831. * @param maxCapacity defines the maximum capacity per leaf
  51832. * @param maxDepth defines the maximum depth of the octree
  51833. * @returns an octree of AbstractMesh
  51834. */
  51835. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51836. }
  51837. }
  51838. module "babylonjs/Meshes/abstractMesh" {
  51839. interface AbstractMesh {
  51840. /**
  51841. * @hidden
  51842. * Backing Field
  51843. */
  51844. _submeshesOctree: Octree<SubMesh>;
  51845. /**
  51846. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51847. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51848. * @param maxCapacity defines the maximum size of each block (64 by default)
  51849. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51850. * @returns the new octree
  51851. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51852. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51853. */
  51854. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51855. }
  51856. }
  51857. /**
  51858. * Defines the octree scene component responsible to manage any octrees
  51859. * in a given scene.
  51860. */
  51861. export class OctreeSceneComponent {
  51862. /**
  51863. * The component name help to identify the component in the list of scene components.
  51864. */
  51865. readonly name: string;
  51866. /**
  51867. * The scene the component belongs to.
  51868. */
  51869. scene: Scene;
  51870. /**
  51871. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51872. */
  51873. readonly checksIsEnabled: boolean;
  51874. /**
  51875. * Creates a new instance of the component for the given scene
  51876. * @param scene Defines the scene to register the component in
  51877. */
  51878. constructor(scene: Scene);
  51879. /**
  51880. * Registers the component in a given scene
  51881. */
  51882. register(): void;
  51883. /**
  51884. * Return the list of active meshes
  51885. * @returns the list of active meshes
  51886. */
  51887. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51888. /**
  51889. * Return the list of active sub meshes
  51890. * @param mesh The mesh to get the candidates sub meshes from
  51891. * @returns the list of active sub meshes
  51892. */
  51893. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51894. private _tempRay;
  51895. /**
  51896. * Return the list of sub meshes intersecting with a given local ray
  51897. * @param mesh defines the mesh to find the submesh for
  51898. * @param localRay defines the ray in local space
  51899. * @returns the list of intersecting sub meshes
  51900. */
  51901. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51902. /**
  51903. * Return the list of sub meshes colliding with a collider
  51904. * @param mesh defines the mesh to find the submesh for
  51905. * @param collider defines the collider to evaluate the collision against
  51906. * @returns the list of colliding sub meshes
  51907. */
  51908. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51909. /**
  51910. * Rebuilds the elements related to this component in case of
  51911. * context lost for instance.
  51912. */
  51913. rebuild(): void;
  51914. /**
  51915. * Disposes the component and the associated ressources.
  51916. */
  51917. dispose(): void;
  51918. }
  51919. }
  51920. declare module "babylonjs/Culling/Octrees/index" {
  51921. export * from "babylonjs/Culling/Octrees/octree";
  51922. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51923. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51924. }
  51925. declare module "babylonjs/Culling/index" {
  51926. export * from "babylonjs/Culling/boundingBox";
  51927. export * from "babylonjs/Culling/boundingInfo";
  51928. export * from "babylonjs/Culling/boundingSphere";
  51929. export * from "babylonjs/Culling/Octrees/index";
  51930. export * from "babylonjs/Culling/ray";
  51931. }
  51932. declare module "babylonjs/Gizmos/gizmo" {
  51933. import { Nullable } from "babylonjs/types";
  51934. import { IDisposable } from "babylonjs/scene";
  51935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51936. import { Mesh } from "babylonjs/Meshes/mesh";
  51937. import { Node } from "babylonjs/node";
  51938. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51939. /**
  51940. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51941. */
  51942. export class Gizmo implements IDisposable {
  51943. /** The utility layer the gizmo will be added to */
  51944. gizmoLayer: UtilityLayerRenderer;
  51945. /**
  51946. * The root mesh of the gizmo
  51947. */
  51948. _rootMesh: Mesh;
  51949. private _attachedMesh;
  51950. private _attachedNode;
  51951. /**
  51952. * Ratio for the scale of the gizmo (Default: 1)
  51953. */
  51954. scaleRatio: number;
  51955. /**
  51956. * If a custom mesh has been set (Default: false)
  51957. */
  51958. protected _customMeshSet: boolean;
  51959. /**
  51960. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51961. * * When set, interactions will be enabled
  51962. */
  51963. get attachedMesh(): Nullable<AbstractMesh>;
  51964. set attachedMesh(value: Nullable<AbstractMesh>);
  51965. /**
  51966. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  51967. * * When set, interactions will be enabled
  51968. */
  51969. get attachedNode(): Nullable<Node>;
  51970. set attachedNode(value: Nullable<Node>);
  51971. /**
  51972. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51973. * @param mesh The mesh to replace the default mesh of the gizmo
  51974. */
  51975. setCustomMesh(mesh: Mesh): void;
  51976. /**
  51977. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51978. */
  51979. updateGizmoRotationToMatchAttachedMesh: boolean;
  51980. /**
  51981. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51982. */
  51983. updateGizmoPositionToMatchAttachedMesh: boolean;
  51984. /**
  51985. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51986. */
  51987. updateScale: boolean;
  51988. protected _interactionsEnabled: boolean;
  51989. protected _attachedNodeChanged(value: Nullable<Node>): void;
  51990. private _beforeRenderObserver;
  51991. private _tempVector;
  51992. /**
  51993. * Creates a gizmo
  51994. * @param gizmoLayer The utility layer the gizmo will be added to
  51995. */
  51996. constructor(
  51997. /** The utility layer the gizmo will be added to */
  51998. gizmoLayer?: UtilityLayerRenderer);
  51999. /**
  52000. * Updates the gizmo to match the attached mesh's position/rotation
  52001. */
  52002. protected _update(): void;
  52003. /**
  52004. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52005. * @param value Node, TransformNode or mesh
  52006. */
  52007. protected _matrixChanged(): void;
  52008. /**
  52009. * Disposes of the gizmo
  52010. */
  52011. dispose(): void;
  52012. }
  52013. }
  52014. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52015. import { Observable } from "babylonjs/Misc/observable";
  52016. import { Nullable } from "babylonjs/types";
  52017. import { Vector3 } from "babylonjs/Maths/math.vector";
  52018. import { Color3 } from "babylonjs/Maths/math.color";
  52019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52020. import { Node } from "babylonjs/node";
  52021. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52022. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52023. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52024. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52025. import { Scene } from "babylonjs/scene";
  52026. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52027. /**
  52028. * Single plane drag gizmo
  52029. */
  52030. export class PlaneDragGizmo extends Gizmo {
  52031. /**
  52032. * Drag behavior responsible for the gizmos dragging interactions
  52033. */
  52034. dragBehavior: PointerDragBehavior;
  52035. private _pointerObserver;
  52036. /**
  52037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52038. */
  52039. snapDistance: number;
  52040. /**
  52041. * Event that fires each time the gizmo snaps to a new location.
  52042. * * snapDistance is the the change in distance
  52043. */
  52044. onSnapObservable: Observable<{
  52045. snapDistance: number;
  52046. }>;
  52047. private _plane;
  52048. private _coloredMaterial;
  52049. private _hoverMaterial;
  52050. private _isEnabled;
  52051. private _parent;
  52052. /** @hidden */
  52053. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52054. /** @hidden */
  52055. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52056. /**
  52057. * Creates a PlaneDragGizmo
  52058. * @param gizmoLayer The utility layer the gizmo will be added to
  52059. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52060. * @param color The color of the gizmo
  52061. */
  52062. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52063. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52064. /**
  52065. * If the gizmo is enabled
  52066. */
  52067. set isEnabled(value: boolean);
  52068. get isEnabled(): boolean;
  52069. /**
  52070. * Disposes of the gizmo
  52071. */
  52072. dispose(): void;
  52073. }
  52074. }
  52075. declare module "babylonjs/Gizmos/positionGizmo" {
  52076. import { Observable } from "babylonjs/Misc/observable";
  52077. import { Nullable } from "babylonjs/types";
  52078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52079. import { Node } from "babylonjs/node";
  52080. import { Mesh } from "babylonjs/Meshes/mesh";
  52081. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52082. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52083. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52084. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52085. /**
  52086. * Gizmo that enables dragging a mesh along 3 axis
  52087. */
  52088. export class PositionGizmo extends Gizmo {
  52089. /**
  52090. * Internal gizmo used for interactions on the x axis
  52091. */
  52092. xGizmo: AxisDragGizmo;
  52093. /**
  52094. * Internal gizmo used for interactions on the y axis
  52095. */
  52096. yGizmo: AxisDragGizmo;
  52097. /**
  52098. * Internal gizmo used for interactions on the z axis
  52099. */
  52100. zGizmo: AxisDragGizmo;
  52101. /**
  52102. * Internal gizmo used for interactions on the yz plane
  52103. */
  52104. xPlaneGizmo: PlaneDragGizmo;
  52105. /**
  52106. * Internal gizmo used for interactions on the xz plane
  52107. */
  52108. yPlaneGizmo: PlaneDragGizmo;
  52109. /**
  52110. * Internal gizmo used for interactions on the xy plane
  52111. */
  52112. zPlaneGizmo: PlaneDragGizmo;
  52113. /**
  52114. * private variables
  52115. */
  52116. private _meshAttached;
  52117. private _nodeAttached;
  52118. private _updateGizmoRotationToMatchAttachedMesh;
  52119. private _snapDistance;
  52120. private _scaleRatio;
  52121. /** Fires an event when any of it's sub gizmos are dragged */
  52122. onDragStartObservable: Observable<unknown>;
  52123. /** Fires an event when any of it's sub gizmos are released from dragging */
  52124. onDragEndObservable: Observable<unknown>;
  52125. /**
  52126. * If set to true, planar drag is enabled
  52127. */
  52128. private _planarGizmoEnabled;
  52129. get attachedMesh(): Nullable<AbstractMesh>;
  52130. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52131. get attachedNode(): Nullable<Node>;
  52132. set attachedNode(node: Nullable<Node>);
  52133. /**
  52134. * Creates a PositionGizmo
  52135. * @param gizmoLayer The utility layer the gizmo will be added to
  52136. @param thickness display gizmo axis thickness
  52137. */
  52138. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52139. /**
  52140. * If the planar drag gizmo is enabled
  52141. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52142. */
  52143. set planarGizmoEnabled(value: boolean);
  52144. get planarGizmoEnabled(): boolean;
  52145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52147. /**
  52148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52149. */
  52150. set snapDistance(value: number);
  52151. get snapDistance(): number;
  52152. /**
  52153. * Ratio for the scale of the gizmo (Default: 1)
  52154. */
  52155. set scaleRatio(value: number);
  52156. get scaleRatio(): number;
  52157. /**
  52158. * Disposes of the gizmo
  52159. */
  52160. dispose(): void;
  52161. /**
  52162. * CustomMeshes are not supported by this gizmo
  52163. * @param mesh The mesh to replace the default mesh of the gizmo
  52164. */
  52165. setCustomMesh(mesh: Mesh): void;
  52166. }
  52167. }
  52168. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52169. import { Observable } from "babylonjs/Misc/observable";
  52170. import { Nullable } from "babylonjs/types";
  52171. import { Vector3 } from "babylonjs/Maths/math.vector";
  52172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52173. import { Node } from "babylonjs/node";
  52174. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52175. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52176. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52177. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52178. import { Scene } from "babylonjs/scene";
  52179. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52180. import { Color3 } from "babylonjs/Maths/math.color";
  52181. /**
  52182. * Single axis drag gizmo
  52183. */
  52184. export class AxisDragGizmo extends Gizmo {
  52185. /**
  52186. * Drag behavior responsible for the gizmos dragging interactions
  52187. */
  52188. dragBehavior: PointerDragBehavior;
  52189. private _pointerObserver;
  52190. /**
  52191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52192. */
  52193. snapDistance: number;
  52194. /**
  52195. * Event that fires each time the gizmo snaps to a new location.
  52196. * * snapDistance is the the change in distance
  52197. */
  52198. onSnapObservable: Observable<{
  52199. snapDistance: number;
  52200. }>;
  52201. private _isEnabled;
  52202. private _parent;
  52203. private _arrow;
  52204. private _coloredMaterial;
  52205. private _hoverMaterial;
  52206. /** @hidden */
  52207. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52208. /** @hidden */
  52209. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52210. /**
  52211. * Creates an AxisDragGizmo
  52212. * @param gizmoLayer The utility layer the gizmo will be added to
  52213. * @param dragAxis The axis which the gizmo will be able to drag on
  52214. * @param color The color of the gizmo
  52215. * @param thickness display gizmo axis thickness
  52216. */
  52217. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52218. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52219. /**
  52220. * If the gizmo is enabled
  52221. */
  52222. set isEnabled(value: boolean);
  52223. get isEnabled(): boolean;
  52224. /**
  52225. * Disposes of the gizmo
  52226. */
  52227. dispose(): void;
  52228. }
  52229. }
  52230. declare module "babylonjs/Debug/axesViewer" {
  52231. import { Vector3 } from "babylonjs/Maths/math.vector";
  52232. import { Nullable } from "babylonjs/types";
  52233. import { Scene } from "babylonjs/scene";
  52234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52235. /**
  52236. * The Axes viewer will show 3 axes in a specific point in space
  52237. */
  52238. export class AxesViewer {
  52239. private _xAxis;
  52240. private _yAxis;
  52241. private _zAxis;
  52242. private _scaleLinesFactor;
  52243. private _instanced;
  52244. /**
  52245. * Gets the hosting scene
  52246. */
  52247. scene: Scene;
  52248. /**
  52249. * Gets or sets a number used to scale line length
  52250. */
  52251. scaleLines: number;
  52252. /** Gets the node hierarchy used to render x-axis */
  52253. get xAxis(): TransformNode;
  52254. /** Gets the node hierarchy used to render y-axis */
  52255. get yAxis(): TransformNode;
  52256. /** Gets the node hierarchy used to render z-axis */
  52257. get zAxis(): TransformNode;
  52258. /**
  52259. * Creates a new AxesViewer
  52260. * @param scene defines the hosting scene
  52261. * @param scaleLines defines a number used to scale line length (1 by default)
  52262. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52263. * @param xAxis defines the node hierarchy used to render the x-axis
  52264. * @param yAxis defines the node hierarchy used to render the y-axis
  52265. * @param zAxis defines the node hierarchy used to render the z-axis
  52266. */
  52267. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52268. /**
  52269. * Force the viewer to update
  52270. * @param position defines the position of the viewer
  52271. * @param xaxis defines the x axis of the viewer
  52272. * @param yaxis defines the y axis of the viewer
  52273. * @param zaxis defines the z axis of the viewer
  52274. */
  52275. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52276. /**
  52277. * Creates an instance of this axes viewer.
  52278. * @returns a new axes viewer with instanced meshes
  52279. */
  52280. createInstance(): AxesViewer;
  52281. /** Releases resources */
  52282. dispose(): void;
  52283. private static _SetRenderingGroupId;
  52284. }
  52285. }
  52286. declare module "babylonjs/Debug/boneAxesViewer" {
  52287. import { Nullable } from "babylonjs/types";
  52288. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52289. import { Vector3 } from "babylonjs/Maths/math.vector";
  52290. import { Mesh } from "babylonjs/Meshes/mesh";
  52291. import { Bone } from "babylonjs/Bones/bone";
  52292. import { Scene } from "babylonjs/scene";
  52293. /**
  52294. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52295. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52296. */
  52297. export class BoneAxesViewer extends AxesViewer {
  52298. /**
  52299. * Gets or sets the target mesh where to display the axes viewer
  52300. */
  52301. mesh: Nullable<Mesh>;
  52302. /**
  52303. * Gets or sets the target bone where to display the axes viewer
  52304. */
  52305. bone: Nullable<Bone>;
  52306. /** Gets current position */
  52307. pos: Vector3;
  52308. /** Gets direction of X axis */
  52309. xaxis: Vector3;
  52310. /** Gets direction of Y axis */
  52311. yaxis: Vector3;
  52312. /** Gets direction of Z axis */
  52313. zaxis: Vector3;
  52314. /**
  52315. * Creates a new BoneAxesViewer
  52316. * @param scene defines the hosting scene
  52317. * @param bone defines the target bone
  52318. * @param mesh defines the target mesh
  52319. * @param scaleLines defines a scaling factor for line length (1 by default)
  52320. */
  52321. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52322. /**
  52323. * Force the viewer to update
  52324. */
  52325. update(): void;
  52326. /** Releases resources */
  52327. dispose(): void;
  52328. }
  52329. }
  52330. declare module "babylonjs/Debug/debugLayer" {
  52331. import { Scene } from "babylonjs/scene";
  52332. /**
  52333. * Interface used to define scene explorer extensibility option
  52334. */
  52335. export interface IExplorerExtensibilityOption {
  52336. /**
  52337. * Define the option label
  52338. */
  52339. label: string;
  52340. /**
  52341. * Defines the action to execute on click
  52342. */
  52343. action: (entity: any) => void;
  52344. }
  52345. /**
  52346. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52347. */
  52348. export interface IExplorerExtensibilityGroup {
  52349. /**
  52350. * Defines a predicate to test if a given type mut be extended
  52351. */
  52352. predicate: (entity: any) => boolean;
  52353. /**
  52354. * Gets the list of options added to a type
  52355. */
  52356. entries: IExplorerExtensibilityOption[];
  52357. }
  52358. /**
  52359. * Interface used to define the options to use to create the Inspector
  52360. */
  52361. export interface IInspectorOptions {
  52362. /**
  52363. * Display in overlay mode (default: false)
  52364. */
  52365. overlay?: boolean;
  52366. /**
  52367. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52368. */
  52369. globalRoot?: HTMLElement;
  52370. /**
  52371. * Display the Scene explorer
  52372. */
  52373. showExplorer?: boolean;
  52374. /**
  52375. * Display the property inspector
  52376. */
  52377. showInspector?: boolean;
  52378. /**
  52379. * Display in embed mode (both panes on the right)
  52380. */
  52381. embedMode?: boolean;
  52382. /**
  52383. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52384. */
  52385. handleResize?: boolean;
  52386. /**
  52387. * Allow the panes to popup (default: true)
  52388. */
  52389. enablePopup?: boolean;
  52390. /**
  52391. * Allow the panes to be closed by users (default: true)
  52392. */
  52393. enableClose?: boolean;
  52394. /**
  52395. * Optional list of extensibility entries
  52396. */
  52397. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52398. /**
  52399. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52400. */
  52401. inspectorURL?: string;
  52402. /**
  52403. * Optional initial tab (default to DebugLayerTab.Properties)
  52404. */
  52405. initialTab?: DebugLayerTab;
  52406. }
  52407. module "babylonjs/scene" {
  52408. interface Scene {
  52409. /**
  52410. * @hidden
  52411. * Backing field
  52412. */
  52413. _debugLayer: DebugLayer;
  52414. /**
  52415. * Gets the debug layer (aka Inspector) associated with the scene
  52416. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52417. */
  52418. debugLayer: DebugLayer;
  52419. }
  52420. }
  52421. /**
  52422. * Enum of inspector action tab
  52423. */
  52424. export enum DebugLayerTab {
  52425. /**
  52426. * Properties tag (default)
  52427. */
  52428. Properties = 0,
  52429. /**
  52430. * Debug tab
  52431. */
  52432. Debug = 1,
  52433. /**
  52434. * Statistics tab
  52435. */
  52436. Statistics = 2,
  52437. /**
  52438. * Tools tab
  52439. */
  52440. Tools = 3,
  52441. /**
  52442. * Settings tab
  52443. */
  52444. Settings = 4
  52445. }
  52446. /**
  52447. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52448. * what is happening in your scene
  52449. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52450. */
  52451. export class DebugLayer {
  52452. /**
  52453. * Define the url to get the inspector script from.
  52454. * By default it uses the babylonjs CDN.
  52455. * @ignoreNaming
  52456. */
  52457. static InspectorURL: string;
  52458. private _scene;
  52459. private BJSINSPECTOR;
  52460. private _onPropertyChangedObservable?;
  52461. /**
  52462. * Observable triggered when a property is changed through the inspector.
  52463. */
  52464. get onPropertyChangedObservable(): any;
  52465. /**
  52466. * Instantiates a new debug layer.
  52467. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52468. * what is happening in your scene
  52469. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52470. * @param scene Defines the scene to inspect
  52471. */
  52472. constructor(scene: Scene);
  52473. /** Creates the inspector window. */
  52474. private _createInspector;
  52475. /**
  52476. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52477. * @param entity defines the entity to select
  52478. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52479. */
  52480. select(entity: any, lineContainerTitles?: string | string[]): void;
  52481. /** Get the inspector from bundle or global */
  52482. private _getGlobalInspector;
  52483. /**
  52484. * Get if the inspector is visible or not.
  52485. * @returns true if visible otherwise, false
  52486. */
  52487. isVisible(): boolean;
  52488. /**
  52489. * Hide the inspector and close its window.
  52490. */
  52491. hide(): void;
  52492. /**
  52493. * Update the scene in the inspector
  52494. */
  52495. setAsActiveScene(): void;
  52496. /**
  52497. * Launch the debugLayer.
  52498. * @param config Define the configuration of the inspector
  52499. * @return a promise fulfilled when the debug layer is visible
  52500. */
  52501. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52502. }
  52503. }
  52504. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52505. import { Nullable } from "babylonjs/types";
  52506. import { Scene } from "babylonjs/scene";
  52507. import { Vector4 } from "babylonjs/Maths/math.vector";
  52508. import { Color4 } from "babylonjs/Maths/math.color";
  52509. import { Mesh } from "babylonjs/Meshes/mesh";
  52510. /**
  52511. * Class containing static functions to help procedurally build meshes
  52512. */
  52513. export class BoxBuilder {
  52514. /**
  52515. * Creates a box mesh
  52516. * * The parameter `size` sets the size (float) of each box side (default 1)
  52517. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52518. * * 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)
  52519. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52523. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52524. * @param name defines the name of the mesh
  52525. * @param options defines the options used to create the mesh
  52526. * @param scene defines the hosting scene
  52527. * @returns the box mesh
  52528. */
  52529. static CreateBox(name: string, options: {
  52530. size?: number;
  52531. width?: number;
  52532. height?: number;
  52533. depth?: number;
  52534. faceUV?: Vector4[];
  52535. faceColors?: Color4[];
  52536. sideOrientation?: number;
  52537. frontUVs?: Vector4;
  52538. backUVs?: Vector4;
  52539. wrap?: boolean;
  52540. topBaseAt?: number;
  52541. bottomBaseAt?: number;
  52542. updatable?: boolean;
  52543. }, scene?: Nullable<Scene>): Mesh;
  52544. }
  52545. }
  52546. declare module "babylonjs/Debug/physicsViewer" {
  52547. import { Nullable } from "babylonjs/types";
  52548. import { Scene } from "babylonjs/scene";
  52549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52550. import { Mesh } from "babylonjs/Meshes/mesh";
  52551. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52552. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52553. /**
  52554. * Used to show the physics impostor around the specific mesh
  52555. */
  52556. export class PhysicsViewer {
  52557. /** @hidden */
  52558. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52559. /** @hidden */
  52560. protected _meshes: Array<Nullable<AbstractMesh>>;
  52561. /** @hidden */
  52562. protected _scene: Nullable<Scene>;
  52563. /** @hidden */
  52564. protected _numMeshes: number;
  52565. /** @hidden */
  52566. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52567. private _renderFunction;
  52568. private _utilityLayer;
  52569. private _debugBoxMesh;
  52570. private _debugSphereMesh;
  52571. private _debugCylinderMesh;
  52572. private _debugMaterial;
  52573. private _debugMeshMeshes;
  52574. /**
  52575. * Creates a new PhysicsViewer
  52576. * @param scene defines the hosting scene
  52577. */
  52578. constructor(scene: Scene);
  52579. /** @hidden */
  52580. protected _updateDebugMeshes(): void;
  52581. /**
  52582. * Renders a specified physic impostor
  52583. * @param impostor defines the impostor to render
  52584. * @param targetMesh defines the mesh represented by the impostor
  52585. * @returns the new debug mesh used to render the impostor
  52586. */
  52587. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52588. /**
  52589. * Hides a specified physic impostor
  52590. * @param impostor defines the impostor to hide
  52591. */
  52592. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52593. private _getDebugMaterial;
  52594. private _getDebugBoxMesh;
  52595. private _getDebugSphereMesh;
  52596. private _getDebugCylinderMesh;
  52597. private _getDebugMeshMesh;
  52598. private _getDebugMesh;
  52599. /** Releases all resources */
  52600. dispose(): void;
  52601. }
  52602. }
  52603. declare module "babylonjs/Debug/rayHelper" {
  52604. import { Nullable } from "babylonjs/types";
  52605. import { Ray } from "babylonjs/Culling/ray";
  52606. import { Vector3 } from "babylonjs/Maths/math.vector";
  52607. import { Color3 } from "babylonjs/Maths/math.color";
  52608. import { Scene } from "babylonjs/scene";
  52609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52610. import "babylonjs/Meshes/Builders/linesBuilder";
  52611. /**
  52612. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52613. * in order to better appreciate the issue one might have.
  52614. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52615. */
  52616. export class RayHelper {
  52617. /**
  52618. * Defines the ray we are currently tryin to visualize.
  52619. */
  52620. ray: Nullable<Ray>;
  52621. private _renderPoints;
  52622. private _renderLine;
  52623. private _renderFunction;
  52624. private _scene;
  52625. private _updateToMeshFunction;
  52626. private _attachedToMesh;
  52627. private _meshSpaceDirection;
  52628. private _meshSpaceOrigin;
  52629. /**
  52630. * Helper function to create a colored helper in a scene in one line.
  52631. * @param ray Defines the ray we are currently tryin to visualize
  52632. * @param scene Defines the scene the ray is used in
  52633. * @param color Defines the color we want to see the ray in
  52634. * @returns The newly created ray helper.
  52635. */
  52636. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52637. /**
  52638. * Instantiate a new ray helper.
  52639. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52640. * in order to better appreciate the issue one might have.
  52641. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52642. * @param ray Defines the ray we are currently tryin to visualize
  52643. */
  52644. constructor(ray: Ray);
  52645. /**
  52646. * Shows the ray we are willing to debug.
  52647. * @param scene Defines the scene the ray needs to be rendered in
  52648. * @param color Defines the color the ray needs to be rendered in
  52649. */
  52650. show(scene: Scene, color?: Color3): void;
  52651. /**
  52652. * Hides the ray we are debugging.
  52653. */
  52654. hide(): void;
  52655. private _render;
  52656. /**
  52657. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52658. * @param mesh Defines the mesh we want the helper attached to
  52659. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52660. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52661. * @param length Defines the length of the ray
  52662. */
  52663. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52664. /**
  52665. * Detach the ray helper from the mesh it has previously been attached to.
  52666. */
  52667. detachFromMesh(): void;
  52668. private _updateToMesh;
  52669. /**
  52670. * Dispose the helper and release its associated resources.
  52671. */
  52672. dispose(): void;
  52673. }
  52674. }
  52675. declare module "babylonjs/Debug/skeletonViewer" {
  52676. import { Color3 } from "babylonjs/Maths/math.color";
  52677. import { Scene } from "babylonjs/scene";
  52678. import { Nullable } from "babylonjs/types";
  52679. import { Skeleton } from "babylonjs/Bones/skeleton";
  52680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52681. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52682. /**
  52683. * Class used to render a debug view of a given skeleton
  52684. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52685. */
  52686. export class SkeletonViewer {
  52687. /** defines the skeleton to render */
  52688. skeleton: Skeleton;
  52689. /** defines the mesh attached to the skeleton */
  52690. mesh: AbstractMesh;
  52691. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52692. autoUpdateBonesMatrices: boolean;
  52693. /** defines the rendering group id to use with the viewer */
  52694. renderingGroupId: number;
  52695. /** Gets or sets the color used to render the skeleton */
  52696. color: Color3;
  52697. private _scene;
  52698. private _debugLines;
  52699. private _debugMesh;
  52700. private _isEnabled;
  52701. private _renderFunction;
  52702. private _utilityLayer;
  52703. /**
  52704. * Returns the mesh used to render the bones
  52705. */
  52706. get debugMesh(): Nullable<LinesMesh>;
  52707. /**
  52708. * Creates a new SkeletonViewer
  52709. * @param skeleton defines the skeleton to render
  52710. * @param mesh defines the mesh attached to the skeleton
  52711. * @param scene defines the hosting scene
  52712. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52713. * @param renderingGroupId defines the rendering group id to use with the viewer
  52714. */
  52715. constructor(
  52716. /** defines the skeleton to render */
  52717. skeleton: Skeleton,
  52718. /** defines the mesh attached to the skeleton */
  52719. mesh: AbstractMesh, scene: Scene,
  52720. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52721. autoUpdateBonesMatrices?: boolean,
  52722. /** defines the rendering group id to use with the viewer */
  52723. renderingGroupId?: number);
  52724. /** Gets or sets a boolean indicating if the viewer is enabled */
  52725. set isEnabled(value: boolean);
  52726. get isEnabled(): boolean;
  52727. private _getBonePosition;
  52728. private _getLinesForBonesWithLength;
  52729. private _getLinesForBonesNoLength;
  52730. /** Update the viewer to sync with current skeleton state */
  52731. update(): void;
  52732. /** Release associated resources */
  52733. dispose(): void;
  52734. }
  52735. }
  52736. declare module "babylonjs/Debug/index" {
  52737. export * from "babylonjs/Debug/axesViewer";
  52738. export * from "babylonjs/Debug/boneAxesViewer";
  52739. export * from "babylonjs/Debug/debugLayer";
  52740. export * from "babylonjs/Debug/physicsViewer";
  52741. export * from "babylonjs/Debug/rayHelper";
  52742. export * from "babylonjs/Debug/skeletonViewer";
  52743. }
  52744. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52745. /**
  52746. * Enum for Device Types
  52747. */
  52748. export enum DeviceType {
  52749. /** Generic */
  52750. Generic = 0,
  52751. /** Keyboard */
  52752. Keyboard = 1,
  52753. /** Mouse */
  52754. Mouse = 2,
  52755. /** Touch Pointers */
  52756. Touch = 3,
  52757. /** PS4 Dual Shock */
  52758. DualShock = 4,
  52759. /** Xbox */
  52760. Xbox = 5,
  52761. /** Switch Controller */
  52762. Switch = 6
  52763. }
  52764. /**
  52765. * Enum for All Pointers (Touch/Mouse)
  52766. */
  52767. export enum PointerInput {
  52768. /** Horizontal Axis */
  52769. Horizontal = 0,
  52770. /** Vertical Axis */
  52771. Vertical = 1,
  52772. /** Left Click or Touch */
  52773. LeftClick = 2,
  52774. /** Middle Click */
  52775. MiddleClick = 3,
  52776. /** Right Click */
  52777. RightClick = 4,
  52778. /** Browser Back */
  52779. BrowserBack = 5,
  52780. /** Browser Forward */
  52781. BrowserForward = 6
  52782. }
  52783. /**
  52784. * Enum for Dual Shock Gamepad
  52785. */
  52786. export enum DualShockInput {
  52787. /** Cross */
  52788. Cross = 0,
  52789. /** Circle */
  52790. Circle = 1,
  52791. /** Square */
  52792. Square = 2,
  52793. /** Triangle */
  52794. Triangle = 3,
  52795. /** L1 */
  52796. L1 = 4,
  52797. /** R1 */
  52798. R1 = 5,
  52799. /** L2 */
  52800. L2 = 6,
  52801. /** R2 */
  52802. R2 = 7,
  52803. /** Share */
  52804. Share = 8,
  52805. /** Options */
  52806. Options = 9,
  52807. /** L3 */
  52808. L3 = 10,
  52809. /** R3 */
  52810. R3 = 11,
  52811. /** DPadUp */
  52812. DPadUp = 12,
  52813. /** DPadDown */
  52814. DPadDown = 13,
  52815. /** DPadLeft */
  52816. DPadLeft = 14,
  52817. /** DRight */
  52818. DPadRight = 15,
  52819. /** Home */
  52820. Home = 16,
  52821. /** TouchPad */
  52822. TouchPad = 17,
  52823. /** LStickXAxis */
  52824. LStickXAxis = 18,
  52825. /** LStickYAxis */
  52826. LStickYAxis = 19,
  52827. /** RStickXAxis */
  52828. RStickXAxis = 20,
  52829. /** RStickYAxis */
  52830. RStickYAxis = 21
  52831. }
  52832. /**
  52833. * Enum for Xbox Gamepad
  52834. */
  52835. export enum XboxInput {
  52836. /** A */
  52837. A = 0,
  52838. /** B */
  52839. B = 1,
  52840. /** X */
  52841. X = 2,
  52842. /** Y */
  52843. Y = 3,
  52844. /** LB */
  52845. LB = 4,
  52846. /** RB */
  52847. RB = 5,
  52848. /** LT */
  52849. LT = 6,
  52850. /** RT */
  52851. RT = 7,
  52852. /** Back */
  52853. Back = 8,
  52854. /** Start */
  52855. Start = 9,
  52856. /** LS */
  52857. LS = 10,
  52858. /** RS */
  52859. RS = 11,
  52860. /** DPadUp */
  52861. DPadUp = 12,
  52862. /** DPadDown */
  52863. DPadDown = 13,
  52864. /** DPadLeft */
  52865. DPadLeft = 14,
  52866. /** DRight */
  52867. DPadRight = 15,
  52868. /** Home */
  52869. Home = 16,
  52870. /** LStickXAxis */
  52871. LStickXAxis = 17,
  52872. /** LStickYAxis */
  52873. LStickYAxis = 18,
  52874. /** RStickXAxis */
  52875. RStickXAxis = 19,
  52876. /** RStickYAxis */
  52877. RStickYAxis = 20
  52878. }
  52879. /**
  52880. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52881. */
  52882. export enum SwitchInput {
  52883. /** B */
  52884. B = 0,
  52885. /** A */
  52886. A = 1,
  52887. /** Y */
  52888. Y = 2,
  52889. /** X */
  52890. X = 3,
  52891. /** L */
  52892. L = 4,
  52893. /** R */
  52894. R = 5,
  52895. /** ZL */
  52896. ZL = 6,
  52897. /** ZR */
  52898. ZR = 7,
  52899. /** Minus */
  52900. Minus = 8,
  52901. /** Plus */
  52902. Plus = 9,
  52903. /** LS */
  52904. LS = 10,
  52905. /** RS */
  52906. RS = 11,
  52907. /** DPadUp */
  52908. DPadUp = 12,
  52909. /** DPadDown */
  52910. DPadDown = 13,
  52911. /** DPadLeft */
  52912. DPadLeft = 14,
  52913. /** DRight */
  52914. DPadRight = 15,
  52915. /** Home */
  52916. Home = 16,
  52917. /** Capture */
  52918. Capture = 17,
  52919. /** LStickXAxis */
  52920. LStickXAxis = 18,
  52921. /** LStickYAxis */
  52922. LStickYAxis = 19,
  52923. /** RStickXAxis */
  52924. RStickXAxis = 20,
  52925. /** RStickYAxis */
  52926. RStickYAxis = 21
  52927. }
  52928. }
  52929. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52930. import { Engine } from "babylonjs/Engines/engine";
  52931. import { IDisposable } from "babylonjs/scene";
  52932. import { Nullable } from "babylonjs/types";
  52933. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52934. /**
  52935. * This class will take all inputs from Keyboard, Pointer, and
  52936. * any Gamepads and provide a polling system that all devices
  52937. * will use. This class assumes that there will only be one
  52938. * pointer device and one keyboard.
  52939. */
  52940. export class DeviceInputSystem implements IDisposable {
  52941. /**
  52942. * Callback to be triggered when a device is connected
  52943. */
  52944. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52945. /**
  52946. * Callback to be triggered when a device is disconnected
  52947. */
  52948. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52949. /**
  52950. * Callback to be triggered when event driven input is updated
  52951. */
  52952. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52953. private _inputs;
  52954. private _gamepads;
  52955. private _keyboardActive;
  52956. private _pointerActive;
  52957. private _elementToAttachTo;
  52958. private _keyboardDownEvent;
  52959. private _keyboardUpEvent;
  52960. private _pointerMoveEvent;
  52961. private _pointerDownEvent;
  52962. private _pointerUpEvent;
  52963. private _gamepadConnectedEvent;
  52964. private _gamepadDisconnectedEvent;
  52965. private static _MAX_KEYCODES;
  52966. private static _MAX_POINTER_INPUTS;
  52967. private constructor();
  52968. /**
  52969. * Creates a new DeviceInputSystem instance
  52970. * @param engine Engine to pull input element from
  52971. * @returns The new instance
  52972. */
  52973. static Create(engine: Engine): DeviceInputSystem;
  52974. /**
  52975. * Checks for current device input value, given an id and input index
  52976. * @param deviceName Id of connected device
  52977. * @param inputIndex Index of device input
  52978. * @returns Current value of input
  52979. */
  52980. /**
  52981. * Checks for current device input value, given an id and input index
  52982. * @param deviceType Enum specifiying device type
  52983. * @param deviceSlot "Slot" or index that device is referenced in
  52984. * @param inputIndex Id of input to be checked
  52985. * @returns Current value of input
  52986. */
  52987. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52988. /**
  52989. * Dispose of all the eventlisteners
  52990. */
  52991. dispose(): void;
  52992. /**
  52993. * Add device and inputs to device array
  52994. * @param deviceType Enum specifiying device type
  52995. * @param deviceSlot "Slot" or index that device is referenced in
  52996. * @param numberOfInputs Number of input entries to create for given device
  52997. */
  52998. private _registerDevice;
  52999. /**
  53000. * Given a specific device name, remove that device from the device map
  53001. * @param deviceType Enum specifiying device type
  53002. * @param deviceSlot "Slot" or index that device is referenced in
  53003. */
  53004. private _unregisterDevice;
  53005. /**
  53006. * Handle all actions that come from keyboard interaction
  53007. */
  53008. private _handleKeyActions;
  53009. /**
  53010. * Handle all actions that come from pointer interaction
  53011. */
  53012. private _handlePointerActions;
  53013. /**
  53014. * Handle all actions that come from gamepad interaction
  53015. */
  53016. private _handleGamepadActions;
  53017. /**
  53018. * Update all non-event based devices with each frame
  53019. * @param deviceType Enum specifiying device type
  53020. * @param deviceSlot "Slot" or index that device is referenced in
  53021. * @param inputIndex Id of input to be checked
  53022. */
  53023. private _updateDevice;
  53024. /**
  53025. * Gets DeviceType from the device name
  53026. * @param deviceName Name of Device from DeviceInputSystem
  53027. * @returns DeviceType enum value
  53028. */
  53029. private _getGamepadDeviceType;
  53030. }
  53031. }
  53032. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53033. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53034. /**
  53035. * Type to handle enforcement of inputs
  53036. */
  53037. 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;
  53038. }
  53039. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53040. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53041. import { Engine } from "babylonjs/Engines/engine";
  53042. import { IDisposable } from "babylonjs/scene";
  53043. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53044. import { Nullable } from "babylonjs/types";
  53045. import { Observable } from "babylonjs/Misc/observable";
  53046. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53047. /**
  53048. * Class that handles all input for a specific device
  53049. */
  53050. export class DeviceSource<T extends DeviceType> {
  53051. /** Type of device */
  53052. readonly deviceType: DeviceType;
  53053. /** "Slot" or index that device is referenced in */
  53054. readonly deviceSlot: number;
  53055. /**
  53056. * Observable to handle device input changes per device
  53057. */
  53058. readonly onInputChangedObservable: Observable<{
  53059. inputIndex: DeviceInput<T>;
  53060. previousState: Nullable<number>;
  53061. currentState: Nullable<number>;
  53062. }>;
  53063. private readonly _deviceInputSystem;
  53064. /**
  53065. * Default Constructor
  53066. * @param deviceInputSystem Reference to DeviceInputSystem
  53067. * @param deviceType Type of device
  53068. * @param deviceSlot "Slot" or index that device is referenced in
  53069. */
  53070. constructor(deviceInputSystem: DeviceInputSystem,
  53071. /** Type of device */
  53072. deviceType: DeviceType,
  53073. /** "Slot" or index that device is referenced in */
  53074. deviceSlot?: number);
  53075. /**
  53076. * Get input for specific input
  53077. * @param inputIndex index of specific input on device
  53078. * @returns Input value from DeviceInputSystem
  53079. */
  53080. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53081. }
  53082. /**
  53083. * Class to keep track of devices
  53084. */
  53085. export class DeviceSourceManager implements IDisposable {
  53086. /**
  53087. * Observable to be triggered when before a device is connected
  53088. */
  53089. readonly onBeforeDeviceConnectedObservable: Observable<{
  53090. deviceType: DeviceType;
  53091. deviceSlot: number;
  53092. }>;
  53093. /**
  53094. * Observable to be triggered when before a device is disconnected
  53095. */
  53096. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53097. deviceType: DeviceType;
  53098. deviceSlot: number;
  53099. }>;
  53100. /**
  53101. * Observable to be triggered when after a device is connected
  53102. */
  53103. readonly onAfterDeviceConnectedObservable: Observable<{
  53104. deviceType: DeviceType;
  53105. deviceSlot: number;
  53106. }>;
  53107. /**
  53108. * Observable to be triggered when after a device is disconnected
  53109. */
  53110. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53111. deviceType: DeviceType;
  53112. deviceSlot: number;
  53113. }>;
  53114. private readonly _devices;
  53115. private readonly _firstDevice;
  53116. private readonly _deviceInputSystem;
  53117. /**
  53118. * Default Constructor
  53119. * @param engine engine to pull input element from
  53120. */
  53121. constructor(engine: Engine);
  53122. /**
  53123. * Gets a DeviceSource, given a type and slot
  53124. * @param deviceType Enum specifying device type
  53125. * @param deviceSlot "Slot" or index that device is referenced in
  53126. * @returns DeviceSource object
  53127. */
  53128. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53129. /**
  53130. * Gets an array of DeviceSource objects for a given device type
  53131. * @param deviceType Enum specifying device type
  53132. * @returns Array of DeviceSource objects
  53133. */
  53134. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53135. /**
  53136. * Dispose of DeviceInputSystem and other parts
  53137. */
  53138. dispose(): void;
  53139. /**
  53140. * Function to add device name to device list
  53141. * @param deviceType Enum specifying device type
  53142. * @param deviceSlot "Slot" or index that device is referenced in
  53143. */
  53144. private _addDevice;
  53145. /**
  53146. * Function to remove device name to device list
  53147. * @param deviceType Enum specifying device type
  53148. * @param deviceSlot "Slot" or index that device is referenced in
  53149. */
  53150. private _removeDevice;
  53151. /**
  53152. * Updates array storing first connected device of each type
  53153. * @param type Type of Device
  53154. */
  53155. private _updateFirstDevices;
  53156. }
  53157. }
  53158. declare module "babylonjs/DeviceInput/index" {
  53159. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53160. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53161. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53162. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53163. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53164. }
  53165. declare module "babylonjs/Engines/nullEngine" {
  53166. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53167. import { Engine } from "babylonjs/Engines/engine";
  53168. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53169. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53171. import { Effect } from "babylonjs/Materials/effect";
  53172. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53173. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53174. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53175. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53176. /**
  53177. * Options to create the null engine
  53178. */
  53179. export class NullEngineOptions {
  53180. /**
  53181. * Render width (Default: 512)
  53182. */
  53183. renderWidth: number;
  53184. /**
  53185. * Render height (Default: 256)
  53186. */
  53187. renderHeight: number;
  53188. /**
  53189. * Texture size (Default: 512)
  53190. */
  53191. textureSize: number;
  53192. /**
  53193. * If delta time between frames should be constant
  53194. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53195. */
  53196. deterministicLockstep: boolean;
  53197. /**
  53198. * Maximum about of steps between frames (Default: 4)
  53199. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53200. */
  53201. lockstepMaxSteps: number;
  53202. /**
  53203. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53204. */
  53205. useHighPrecisionMatrix?: boolean;
  53206. }
  53207. /**
  53208. * The null engine class provides support for headless version of babylon.js.
  53209. * This can be used in server side scenario or for testing purposes
  53210. */
  53211. export class NullEngine extends Engine {
  53212. private _options;
  53213. /**
  53214. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53216. * @returns true if engine is in deterministic lock step mode
  53217. */
  53218. isDeterministicLockStep(): boolean;
  53219. /**
  53220. * Gets the max steps when engine is running in deterministic lock step
  53221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53222. * @returns the max steps
  53223. */
  53224. getLockstepMaxSteps(): number;
  53225. /**
  53226. * Gets the current hardware scaling level.
  53227. * By default the hardware scaling level is computed from the window device ratio.
  53228. * 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.
  53229. * @returns a number indicating the current hardware scaling level
  53230. */
  53231. getHardwareScalingLevel(): number;
  53232. constructor(options?: NullEngineOptions);
  53233. /**
  53234. * Creates a vertex buffer
  53235. * @param vertices the data for the vertex buffer
  53236. * @returns the new WebGL static buffer
  53237. */
  53238. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53239. /**
  53240. * Creates a new index buffer
  53241. * @param indices defines the content of the index buffer
  53242. * @param updatable defines if the index buffer must be updatable
  53243. * @returns a new webGL buffer
  53244. */
  53245. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53246. /**
  53247. * Clear the current render buffer or the current render target (if any is set up)
  53248. * @param color defines the color to use
  53249. * @param backBuffer defines if the back buffer must be cleared
  53250. * @param depth defines if the depth buffer must be cleared
  53251. * @param stencil defines if the stencil buffer must be cleared
  53252. */
  53253. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53254. /**
  53255. * Gets the current render width
  53256. * @param useScreen defines if screen size must be used (or the current render target if any)
  53257. * @returns a number defining the current render width
  53258. */
  53259. getRenderWidth(useScreen?: boolean): number;
  53260. /**
  53261. * Gets the current render height
  53262. * @param useScreen defines if screen size must be used (or the current render target if any)
  53263. * @returns a number defining the current render height
  53264. */
  53265. getRenderHeight(useScreen?: boolean): number;
  53266. /**
  53267. * Set the WebGL's viewport
  53268. * @param viewport defines the viewport element to be used
  53269. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53270. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53271. */
  53272. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53273. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53274. /**
  53275. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53276. * @param pipelineContext defines the pipeline context to use
  53277. * @param uniformsNames defines the list of uniform names
  53278. * @returns an array of webGL uniform locations
  53279. */
  53280. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53281. /**
  53282. * Gets the lsit of active attributes for a given webGL program
  53283. * @param pipelineContext defines the pipeline context to use
  53284. * @param attributesNames defines the list of attribute names to get
  53285. * @returns an array of indices indicating the offset of each attribute
  53286. */
  53287. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53288. /**
  53289. * Binds an effect to the webGL context
  53290. * @param effect defines the effect to bind
  53291. */
  53292. bindSamplers(effect: Effect): void;
  53293. /**
  53294. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53295. * @param effect defines the effect to activate
  53296. */
  53297. enableEffect(effect: Effect): void;
  53298. /**
  53299. * Set various states to the webGL context
  53300. * @param culling defines backface culling state
  53301. * @param zOffset defines the value to apply to zOffset (0 by default)
  53302. * @param force defines if states must be applied even if cache is up to date
  53303. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53304. */
  53305. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53306. /**
  53307. * Set the value of an uniform to an array of int32
  53308. * @param uniform defines the webGL uniform location where to store the value
  53309. * @param array defines the array of int32 to store
  53310. */
  53311. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53312. /**
  53313. * Set the value of an uniform to an array of int32 (stored as vec2)
  53314. * @param uniform defines the webGL uniform location where to store the value
  53315. * @param array defines the array of int32 to store
  53316. */
  53317. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53318. /**
  53319. * Set the value of an uniform to an array of int32 (stored as vec3)
  53320. * @param uniform defines the webGL uniform location where to store the value
  53321. * @param array defines the array of int32 to store
  53322. */
  53323. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53324. /**
  53325. * Set the value of an uniform to an array of int32 (stored as vec4)
  53326. * @param uniform defines the webGL uniform location where to store the value
  53327. * @param array defines the array of int32 to store
  53328. */
  53329. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53330. /**
  53331. * Set the value of an uniform to an array of float32
  53332. * @param uniform defines the webGL uniform location where to store the value
  53333. * @param array defines the array of float32 to store
  53334. */
  53335. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53336. /**
  53337. * Set the value of an uniform to an array of float32 (stored as vec2)
  53338. * @param uniform defines the webGL uniform location where to store the value
  53339. * @param array defines the array of float32 to store
  53340. */
  53341. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53342. /**
  53343. * Set the value of an uniform to an array of float32 (stored as vec3)
  53344. * @param uniform defines the webGL uniform location where to store the value
  53345. * @param array defines the array of float32 to store
  53346. */
  53347. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53348. /**
  53349. * Set the value of an uniform to an array of float32 (stored as vec4)
  53350. * @param uniform defines the webGL uniform location where to store the value
  53351. * @param array defines the array of float32 to store
  53352. */
  53353. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53354. /**
  53355. * Set the value of an uniform to an array of number
  53356. * @param uniform defines the webGL uniform location where to store the value
  53357. * @param array defines the array of number to store
  53358. */
  53359. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53360. /**
  53361. * Set the value of an uniform to an array of number (stored as vec2)
  53362. * @param uniform defines the webGL uniform location where to store the value
  53363. * @param array defines the array of number to store
  53364. */
  53365. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53366. /**
  53367. * Set the value of an uniform to an array of number (stored as vec3)
  53368. * @param uniform defines the webGL uniform location where to store the value
  53369. * @param array defines the array of number to store
  53370. */
  53371. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53372. /**
  53373. * Set the value of an uniform to an array of number (stored as vec4)
  53374. * @param uniform defines the webGL uniform location where to store the value
  53375. * @param array defines the array of number to store
  53376. */
  53377. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53378. /**
  53379. * Set the value of an uniform to an array of float32 (stored as matrices)
  53380. * @param uniform defines the webGL uniform location where to store the value
  53381. * @param matrices defines the array of float32 to store
  53382. */
  53383. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53384. /**
  53385. * Set the value of an uniform to a matrix (3x3)
  53386. * @param uniform defines the webGL uniform location where to store the value
  53387. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53388. */
  53389. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53390. /**
  53391. * Set the value of an uniform to a matrix (2x2)
  53392. * @param uniform defines the webGL uniform location where to store the value
  53393. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53394. */
  53395. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53396. /**
  53397. * Set the value of an uniform to a number (float)
  53398. * @param uniform defines the webGL uniform location where to store the value
  53399. * @param value defines the float number to store
  53400. */
  53401. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53402. /**
  53403. * Set the value of an uniform to a vec2
  53404. * @param uniform defines the webGL uniform location where to store the value
  53405. * @param x defines the 1st component of the value
  53406. * @param y defines the 2nd component of the value
  53407. */
  53408. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53409. /**
  53410. * Set the value of an uniform to a vec3
  53411. * @param uniform defines the webGL uniform location where to store the value
  53412. * @param x defines the 1st component of the value
  53413. * @param y defines the 2nd component of the value
  53414. * @param z defines the 3rd component of the value
  53415. */
  53416. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53417. /**
  53418. * Set the value of an uniform to a boolean
  53419. * @param uniform defines the webGL uniform location where to store the value
  53420. * @param bool defines the boolean to store
  53421. */
  53422. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53423. /**
  53424. * Set the value of an uniform to a vec4
  53425. * @param uniform defines the webGL uniform location where to store the value
  53426. * @param x defines the 1st component of the value
  53427. * @param y defines the 2nd component of the value
  53428. * @param z defines the 3rd component of the value
  53429. * @param w defines the 4th component of the value
  53430. */
  53431. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53432. /**
  53433. * Sets the current alpha mode
  53434. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53435. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53436. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53437. */
  53438. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53439. /**
  53440. * Bind webGl buffers directly to the webGL context
  53441. * @param vertexBuffers defines the vertex buffer to bind
  53442. * @param indexBuffer defines the index buffer to bind
  53443. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53444. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53445. * @param effect defines the effect associated with the vertex buffer
  53446. */
  53447. bindBuffers(vertexBuffers: {
  53448. [key: string]: VertexBuffer;
  53449. }, indexBuffer: DataBuffer, effect: Effect): void;
  53450. /**
  53451. * Force the entire cache to be cleared
  53452. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53453. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53454. */
  53455. wipeCaches(bruteForce?: boolean): void;
  53456. /**
  53457. * Send a draw order
  53458. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53459. * @param indexStart defines the starting index
  53460. * @param indexCount defines the number of index to draw
  53461. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53462. */
  53463. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53464. /**
  53465. * Draw a list of indexed primitives
  53466. * @param fillMode defines the primitive to use
  53467. * @param indexStart defines the starting index
  53468. * @param indexCount defines the number of index to draw
  53469. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53470. */
  53471. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53472. /**
  53473. * Draw a list of unindexed primitives
  53474. * @param fillMode defines the primitive to use
  53475. * @param verticesStart defines the index of first vertex to draw
  53476. * @param verticesCount defines the count of vertices to draw
  53477. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53478. */
  53479. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53480. /** @hidden */
  53481. _createTexture(): WebGLTexture;
  53482. /** @hidden */
  53483. _releaseTexture(texture: InternalTexture): void;
  53484. /**
  53485. * Usually called from Texture.ts.
  53486. * Passed information to create a WebGLTexture
  53487. * @param urlArg defines a value which contains one of the following:
  53488. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53489. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53490. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53491. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53492. * @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)
  53493. * @param scene needed for loading to the correct scene
  53494. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53495. * @param onLoad optional callback to be called upon successful completion
  53496. * @param onError optional callback to be called upon failure
  53497. * @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
  53498. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53499. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53500. * @param forcedExtension defines the extension to use to pick the right loader
  53501. * @param mimeType defines an optional mime type
  53502. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53503. */
  53504. 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;
  53505. /**
  53506. * Creates a new render target texture
  53507. * @param size defines the size of the texture
  53508. * @param options defines the options used to create the texture
  53509. * @returns a new render target texture stored in an InternalTexture
  53510. */
  53511. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53512. /**
  53513. * Update the sampling mode of a given texture
  53514. * @param samplingMode defines the required sampling mode
  53515. * @param texture defines the texture to update
  53516. */
  53517. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53518. /**
  53519. * Binds the frame buffer to the specified texture.
  53520. * @param texture The texture to render to or null for the default canvas
  53521. * @param faceIndex The face of the texture to render to in case of cube texture
  53522. * @param requiredWidth The width of the target to render to
  53523. * @param requiredHeight The height of the target to render to
  53524. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53525. * @param lodLevel defines le lod level to bind to the frame buffer
  53526. */
  53527. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53528. /**
  53529. * Unbind the current render target texture from the webGL context
  53530. * @param texture defines the render target texture to unbind
  53531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53533. */
  53534. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53535. /**
  53536. * Creates a dynamic vertex buffer
  53537. * @param vertices the data for the dynamic vertex buffer
  53538. * @returns the new WebGL dynamic buffer
  53539. */
  53540. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53541. /**
  53542. * Update the content of a dynamic texture
  53543. * @param texture defines the texture to update
  53544. * @param canvas defines the canvas containing the source
  53545. * @param invertY defines if data must be stored with Y axis inverted
  53546. * @param premulAlpha defines if alpha is stored as premultiplied
  53547. * @param format defines the format of the data
  53548. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53549. */
  53550. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53551. /**
  53552. * Gets a boolean indicating if all created effects are ready
  53553. * @returns true if all effects are ready
  53554. */
  53555. areAllEffectsReady(): boolean;
  53556. /**
  53557. * @hidden
  53558. * Get the current error code of the webGL context
  53559. * @returns the error code
  53560. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53561. */
  53562. getError(): number;
  53563. /** @hidden */
  53564. _getUnpackAlignement(): number;
  53565. /** @hidden */
  53566. _unpackFlipY(value: boolean): void;
  53567. /**
  53568. * Update a dynamic index buffer
  53569. * @param indexBuffer defines the target index buffer
  53570. * @param indices defines the data to update
  53571. * @param offset defines the offset in the target index buffer where update should start
  53572. */
  53573. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53574. /**
  53575. * Updates a dynamic vertex buffer.
  53576. * @param vertexBuffer the vertex buffer to update
  53577. * @param vertices the data used to update the vertex buffer
  53578. * @param byteOffset the byte offset of the data (optional)
  53579. * @param byteLength the byte length of the data (optional)
  53580. */
  53581. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53582. /** @hidden */
  53583. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53584. /** @hidden */
  53585. _bindTexture(channel: number, texture: InternalTexture): void;
  53586. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53587. /**
  53588. * 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
  53589. */
  53590. releaseEffects(): void;
  53591. displayLoadingUI(): void;
  53592. hideLoadingUI(): void;
  53593. /** @hidden */
  53594. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53595. /** @hidden */
  53596. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53597. /** @hidden */
  53598. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53599. /** @hidden */
  53600. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53601. }
  53602. }
  53603. declare module "babylonjs/Instrumentation/timeToken" {
  53604. import { Nullable } from "babylonjs/types";
  53605. /**
  53606. * @hidden
  53607. **/
  53608. export class _TimeToken {
  53609. _startTimeQuery: Nullable<WebGLQuery>;
  53610. _endTimeQuery: Nullable<WebGLQuery>;
  53611. _timeElapsedQuery: Nullable<WebGLQuery>;
  53612. _timeElapsedQueryEnded: boolean;
  53613. }
  53614. }
  53615. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53616. import { Nullable, int } from "babylonjs/types";
  53617. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53618. /** @hidden */
  53619. export class _OcclusionDataStorage {
  53620. /** @hidden */
  53621. occlusionInternalRetryCounter: number;
  53622. /** @hidden */
  53623. isOcclusionQueryInProgress: boolean;
  53624. /** @hidden */
  53625. isOccluded: boolean;
  53626. /** @hidden */
  53627. occlusionRetryCount: number;
  53628. /** @hidden */
  53629. occlusionType: number;
  53630. /** @hidden */
  53631. occlusionQueryAlgorithmType: number;
  53632. }
  53633. module "babylonjs/Engines/engine" {
  53634. interface Engine {
  53635. /**
  53636. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53637. * @return the new query
  53638. */
  53639. createQuery(): WebGLQuery;
  53640. /**
  53641. * Delete and release a webGL query
  53642. * @param query defines the query to delete
  53643. * @return the current engine
  53644. */
  53645. deleteQuery(query: WebGLQuery): Engine;
  53646. /**
  53647. * Check if a given query has resolved and got its value
  53648. * @param query defines the query to check
  53649. * @returns true if the query got its value
  53650. */
  53651. isQueryResultAvailable(query: WebGLQuery): boolean;
  53652. /**
  53653. * Gets the value of a given query
  53654. * @param query defines the query to check
  53655. * @returns the value of the query
  53656. */
  53657. getQueryResult(query: WebGLQuery): number;
  53658. /**
  53659. * Initiates an occlusion query
  53660. * @param algorithmType defines the algorithm to use
  53661. * @param query defines the query to use
  53662. * @returns the current engine
  53663. * @see https://doc.babylonjs.com/features/occlusionquery
  53664. */
  53665. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53666. /**
  53667. * Ends an occlusion query
  53668. * @see https://doc.babylonjs.com/features/occlusionquery
  53669. * @param algorithmType defines the algorithm to use
  53670. * @returns the current engine
  53671. */
  53672. endOcclusionQuery(algorithmType: number): Engine;
  53673. /**
  53674. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53675. * Please note that only one query can be issued at a time
  53676. * @returns a time token used to track the time span
  53677. */
  53678. startTimeQuery(): Nullable<_TimeToken>;
  53679. /**
  53680. * Ends a time query
  53681. * @param token defines the token used to measure the time span
  53682. * @returns the time spent (in ns)
  53683. */
  53684. endTimeQuery(token: _TimeToken): int;
  53685. /** @hidden */
  53686. _currentNonTimestampToken: Nullable<_TimeToken>;
  53687. /** @hidden */
  53688. _createTimeQuery(): WebGLQuery;
  53689. /** @hidden */
  53690. _deleteTimeQuery(query: WebGLQuery): void;
  53691. /** @hidden */
  53692. _getGlAlgorithmType(algorithmType: number): number;
  53693. /** @hidden */
  53694. _getTimeQueryResult(query: WebGLQuery): any;
  53695. /** @hidden */
  53696. _getTimeQueryAvailability(query: WebGLQuery): any;
  53697. }
  53698. }
  53699. module "babylonjs/Meshes/abstractMesh" {
  53700. interface AbstractMesh {
  53701. /**
  53702. * Backing filed
  53703. * @hidden
  53704. */
  53705. __occlusionDataStorage: _OcclusionDataStorage;
  53706. /**
  53707. * Access property
  53708. * @hidden
  53709. */
  53710. _occlusionDataStorage: _OcclusionDataStorage;
  53711. /**
  53712. * 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.
  53713. * The default value is -1 which means don't break the query and wait till the result
  53714. * @see https://doc.babylonjs.com/features/occlusionquery
  53715. */
  53716. occlusionRetryCount: number;
  53717. /**
  53718. * 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:
  53719. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53720. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53721. * * 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.
  53722. * @see https://doc.babylonjs.com/features/occlusionquery
  53723. */
  53724. occlusionType: number;
  53725. /**
  53726. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53727. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53728. * * 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.
  53729. * @see https://doc.babylonjs.com/features/occlusionquery
  53730. */
  53731. occlusionQueryAlgorithmType: number;
  53732. /**
  53733. * 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
  53734. * @see https://doc.babylonjs.com/features/occlusionquery
  53735. */
  53736. isOccluded: boolean;
  53737. /**
  53738. * Flag to check the progress status of the query
  53739. * @see https://doc.babylonjs.com/features/occlusionquery
  53740. */
  53741. isOcclusionQueryInProgress: boolean;
  53742. }
  53743. }
  53744. }
  53745. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53746. import { Nullable } from "babylonjs/types";
  53747. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53748. /** @hidden */
  53749. export var _forceTransformFeedbackToBundle: boolean;
  53750. module "babylonjs/Engines/engine" {
  53751. interface Engine {
  53752. /**
  53753. * Creates a webGL transform feedback object
  53754. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53755. * @returns the webGL transform feedback object
  53756. */
  53757. createTransformFeedback(): WebGLTransformFeedback;
  53758. /**
  53759. * Delete a webGL transform feedback object
  53760. * @param value defines the webGL transform feedback object to delete
  53761. */
  53762. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53763. /**
  53764. * Bind a webGL transform feedback object to the webgl context
  53765. * @param value defines the webGL transform feedback object to bind
  53766. */
  53767. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53768. /**
  53769. * Begins a transform feedback operation
  53770. * @param usePoints defines if points or triangles must be used
  53771. */
  53772. beginTransformFeedback(usePoints: boolean): void;
  53773. /**
  53774. * Ends a transform feedback operation
  53775. */
  53776. endTransformFeedback(): void;
  53777. /**
  53778. * Specify the varyings to use with transform feedback
  53779. * @param program defines the associated webGL program
  53780. * @param value defines the list of strings representing the varying names
  53781. */
  53782. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53783. /**
  53784. * Bind a webGL buffer for a transform feedback operation
  53785. * @param value defines the webGL buffer to bind
  53786. */
  53787. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53788. }
  53789. }
  53790. }
  53791. declare module "babylonjs/Engines/Extensions/engine.views" {
  53792. import { Camera } from "babylonjs/Cameras/camera";
  53793. import { Nullable } from "babylonjs/types";
  53794. /**
  53795. * Class used to define an additional view for the engine
  53796. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53797. */
  53798. export class EngineView {
  53799. /** Defines the canvas where to render the view */
  53800. target: HTMLCanvasElement;
  53801. /** Defines an optional camera used to render the view (will use active camera else) */
  53802. camera?: Camera;
  53803. }
  53804. module "babylonjs/Engines/engine" {
  53805. interface Engine {
  53806. /**
  53807. * Gets or sets the HTML element to use for attaching events
  53808. */
  53809. inputElement: Nullable<HTMLElement>;
  53810. /**
  53811. * Gets the current engine view
  53812. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53813. */
  53814. activeView: Nullable<EngineView>;
  53815. /** Gets or sets the list of views */
  53816. views: EngineView[];
  53817. /**
  53818. * Register a new child canvas
  53819. * @param canvas defines the canvas to register
  53820. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53821. * @returns the associated view
  53822. */
  53823. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53824. /**
  53825. * Remove a registered child canvas
  53826. * @param canvas defines the canvas to remove
  53827. * @returns the current engine
  53828. */
  53829. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53830. }
  53831. }
  53832. }
  53833. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53834. import { Nullable } from "babylonjs/types";
  53835. module "babylonjs/Engines/engine" {
  53836. interface Engine {
  53837. /** @hidden */
  53838. _excludedCompressedTextures: string[];
  53839. /** @hidden */
  53840. _textureFormatInUse: string;
  53841. /**
  53842. * Gets the list of texture formats supported
  53843. */
  53844. readonly texturesSupported: Array<string>;
  53845. /**
  53846. * Gets the texture format in use
  53847. */
  53848. readonly textureFormatInUse: Nullable<string>;
  53849. /**
  53850. * Set the compressed texture extensions or file names to skip.
  53851. *
  53852. * @param skippedFiles defines the list of those texture files you want to skip
  53853. * Example: [".dds", ".env", "myfile.png"]
  53854. */
  53855. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53856. /**
  53857. * Set the compressed texture format to use, based on the formats you have, and the formats
  53858. * supported by the hardware / browser.
  53859. *
  53860. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53861. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53862. * to API arguments needed to compressed textures. This puts the burden on the container
  53863. * generator to house the arcane code for determining these for current & future formats.
  53864. *
  53865. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53866. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53867. *
  53868. * Note: The result of this call is not taken into account when a texture is base64.
  53869. *
  53870. * @param formatsAvailable defines the list of those format families you have created
  53871. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53872. *
  53873. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53874. * @returns The extension selected.
  53875. */
  53876. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53877. }
  53878. }
  53879. }
  53880. declare module "babylonjs/Engines/Extensions/index" {
  53881. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53882. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53883. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53884. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53885. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53886. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53887. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53888. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53889. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53890. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53891. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53892. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53893. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53894. export * from "babylonjs/Engines/Extensions/engine.views";
  53895. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53896. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53897. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53898. }
  53899. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53900. import { Nullable } from "babylonjs/types";
  53901. /**
  53902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53903. */
  53904. export interface CubeMapInfo {
  53905. /**
  53906. * The pixel array for the front face.
  53907. * This is stored in format, left to right, up to down format.
  53908. */
  53909. front: Nullable<ArrayBufferView>;
  53910. /**
  53911. * The pixel array for the back face.
  53912. * This is stored in format, left to right, up to down format.
  53913. */
  53914. back: Nullable<ArrayBufferView>;
  53915. /**
  53916. * The pixel array for the left face.
  53917. * This is stored in format, left to right, up to down format.
  53918. */
  53919. left: Nullable<ArrayBufferView>;
  53920. /**
  53921. * The pixel array for the right face.
  53922. * This is stored in format, left to right, up to down format.
  53923. */
  53924. right: Nullable<ArrayBufferView>;
  53925. /**
  53926. * The pixel array for the up face.
  53927. * This is stored in format, left to right, up to down format.
  53928. */
  53929. up: Nullable<ArrayBufferView>;
  53930. /**
  53931. * The pixel array for the down face.
  53932. * This is stored in format, left to right, up to down format.
  53933. */
  53934. down: Nullable<ArrayBufferView>;
  53935. /**
  53936. * The size of the cubemap stored.
  53937. *
  53938. * Each faces will be size * size pixels.
  53939. */
  53940. size: number;
  53941. /**
  53942. * The format of the texture.
  53943. *
  53944. * RGBA, RGB.
  53945. */
  53946. format: number;
  53947. /**
  53948. * The type of the texture data.
  53949. *
  53950. * UNSIGNED_INT, FLOAT.
  53951. */
  53952. type: number;
  53953. /**
  53954. * Specifies whether the texture is in gamma space.
  53955. */
  53956. gammaSpace: boolean;
  53957. }
  53958. /**
  53959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53960. */
  53961. export class PanoramaToCubeMapTools {
  53962. private static FACE_LEFT;
  53963. private static FACE_RIGHT;
  53964. private static FACE_FRONT;
  53965. private static FACE_BACK;
  53966. private static FACE_DOWN;
  53967. private static FACE_UP;
  53968. /**
  53969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53970. *
  53971. * @param float32Array The source data.
  53972. * @param inputWidth The width of the input panorama.
  53973. * @param inputHeight The height of the input panorama.
  53974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53975. * @return The cubemap data
  53976. */
  53977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53978. private static CreateCubemapTexture;
  53979. private static CalcProjectionSpherical;
  53980. }
  53981. }
  53982. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53983. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53985. import { Nullable } from "babylonjs/types";
  53986. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53987. /**
  53988. * Helper class dealing with the extraction of spherical polynomial dataArray
  53989. * from a cube map.
  53990. */
  53991. export class CubeMapToSphericalPolynomialTools {
  53992. private static FileFaces;
  53993. /**
  53994. * Converts a texture to the according Spherical Polynomial data.
  53995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53996. *
  53997. * @param texture The texture to extract the information from.
  53998. * @return The Spherical Polynomial data.
  53999. */
  54000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54001. /**
  54002. * Converts a cubemap to the according Spherical Polynomial data.
  54003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54004. *
  54005. * @param cubeInfo The Cube map to extract the information from.
  54006. * @return The Spherical Polynomial data.
  54007. */
  54008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54009. }
  54010. }
  54011. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54012. import { Nullable } from "babylonjs/types";
  54013. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54014. module "babylonjs/Materials/Textures/baseTexture" {
  54015. interface BaseTexture {
  54016. /**
  54017. * Get the polynomial representation of the texture data.
  54018. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54019. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54020. */
  54021. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54022. }
  54023. }
  54024. }
  54025. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54026. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54027. /** @hidden */
  54028. export var rgbdEncodePixelShader: {
  54029. name: string;
  54030. shader: string;
  54031. };
  54032. }
  54033. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54035. /** @hidden */
  54036. export var rgbdDecodePixelShader: {
  54037. name: string;
  54038. shader: string;
  54039. };
  54040. }
  54041. declare module "babylonjs/Misc/environmentTextureTools" {
  54042. import { Nullable } from "babylonjs/types";
  54043. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54046. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54047. import "babylonjs/Engines/Extensions/engine.readTexture";
  54048. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54049. import "babylonjs/Shaders/rgbdEncode.fragment";
  54050. import "babylonjs/Shaders/rgbdDecode.fragment";
  54051. /**
  54052. * Raw texture data and descriptor sufficient for WebGL texture upload
  54053. */
  54054. export interface EnvironmentTextureInfo {
  54055. /**
  54056. * Version of the environment map
  54057. */
  54058. version: number;
  54059. /**
  54060. * Width of image
  54061. */
  54062. width: number;
  54063. /**
  54064. * Irradiance information stored in the file.
  54065. */
  54066. irradiance: any;
  54067. /**
  54068. * Specular information stored in the file.
  54069. */
  54070. specular: any;
  54071. }
  54072. /**
  54073. * Defines One Image in the file. It requires only the position in the file
  54074. * as well as the length.
  54075. */
  54076. interface BufferImageData {
  54077. /**
  54078. * Length of the image data.
  54079. */
  54080. length: number;
  54081. /**
  54082. * Position of the data from the null terminator delimiting the end of the JSON.
  54083. */
  54084. position: number;
  54085. }
  54086. /**
  54087. * Defines the specular data enclosed in the file.
  54088. * This corresponds to the version 1 of the data.
  54089. */
  54090. export interface EnvironmentTextureSpecularInfoV1 {
  54091. /**
  54092. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54093. */
  54094. specularDataPosition?: number;
  54095. /**
  54096. * This contains all the images data needed to reconstruct the cubemap.
  54097. */
  54098. mipmaps: Array<BufferImageData>;
  54099. /**
  54100. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54101. */
  54102. lodGenerationScale: number;
  54103. }
  54104. /**
  54105. * Sets of helpers addressing the serialization and deserialization of environment texture
  54106. * stored in a BabylonJS env file.
  54107. * Those files are usually stored as .env files.
  54108. */
  54109. export class EnvironmentTextureTools {
  54110. /**
  54111. * Magic number identifying the env file.
  54112. */
  54113. private static _MagicBytes;
  54114. /**
  54115. * Gets the environment info from an env file.
  54116. * @param data The array buffer containing the .env bytes.
  54117. * @returns the environment file info (the json header) if successfully parsed.
  54118. */
  54119. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54120. /**
  54121. * Creates an environment texture from a loaded cube texture.
  54122. * @param texture defines the cube texture to convert in env file
  54123. * @return a promise containing the environment data if succesfull.
  54124. */
  54125. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54126. /**
  54127. * Creates a JSON representation of the spherical data.
  54128. * @param texture defines the texture containing the polynomials
  54129. * @return the JSON representation of the spherical info
  54130. */
  54131. private static _CreateEnvTextureIrradiance;
  54132. /**
  54133. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54134. * @param data the image data
  54135. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54136. * @return the views described by info providing access to the underlying buffer
  54137. */
  54138. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54139. /**
  54140. * Uploads the texture info contained in the env file to the GPU.
  54141. * @param texture defines the internal texture to upload to
  54142. * @param data defines the data to load
  54143. * @param info defines the texture info retrieved through the GetEnvInfo method
  54144. * @returns a promise
  54145. */
  54146. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54147. private static _OnImageReadyAsync;
  54148. /**
  54149. * Uploads the levels of image data to the GPU.
  54150. * @param texture defines the internal texture to upload to
  54151. * @param imageData defines the array buffer views of image data [mipmap][face]
  54152. * @returns a promise
  54153. */
  54154. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54155. /**
  54156. * Uploads spherical polynomials information to the texture.
  54157. * @param texture defines the texture we are trying to upload the information to
  54158. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54159. */
  54160. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54161. /** @hidden */
  54162. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54163. }
  54164. }
  54165. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54166. /**
  54167. * Class used to inline functions in shader code
  54168. */
  54169. export class ShaderCodeInliner {
  54170. private static readonly _RegexpFindFunctionNameAndType;
  54171. private _sourceCode;
  54172. private _functionDescr;
  54173. private _numMaxIterations;
  54174. /** Gets or sets the token used to mark the functions to inline */
  54175. inlineToken: string;
  54176. /** Gets or sets the debug mode */
  54177. debug: boolean;
  54178. /** Gets the code after the inlining process */
  54179. get code(): string;
  54180. /**
  54181. * Initializes the inliner
  54182. * @param sourceCode shader code source to inline
  54183. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54184. */
  54185. constructor(sourceCode: string, numMaxIterations?: number);
  54186. /**
  54187. * Start the processing of the shader code
  54188. */
  54189. processCode(): void;
  54190. private _collectFunctions;
  54191. private _processInlining;
  54192. private _extractBetweenMarkers;
  54193. private _skipWhitespaces;
  54194. private _removeComments;
  54195. private _replaceFunctionCallsByCode;
  54196. private _findBackward;
  54197. private _escapeRegExp;
  54198. private _replaceNames;
  54199. }
  54200. }
  54201. declare module "babylonjs/Engines/nativeEngine" {
  54202. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54203. import { Engine } from "babylonjs/Engines/engine";
  54204. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54207. import { Effect } from "babylonjs/Materials/effect";
  54208. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54209. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54210. import { IColor4Like } from "babylonjs/Maths/math.like";
  54211. import { Scene } from "babylonjs/scene";
  54212. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54213. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54214. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54215. /**
  54216. * Container for accessors for natively-stored mesh data buffers.
  54217. */
  54218. class NativeDataBuffer extends DataBuffer {
  54219. /**
  54220. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54221. */
  54222. nativeIndexBuffer?: any;
  54223. /**
  54224. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54225. */
  54226. nativeVertexBuffer?: any;
  54227. }
  54228. /** @hidden */
  54229. class NativeTexture extends InternalTexture {
  54230. getInternalTexture(): InternalTexture;
  54231. getViewCount(): number;
  54232. }
  54233. /** @hidden */
  54234. export class NativeEngine extends Engine {
  54235. private readonly _native;
  54236. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54237. private readonly INVALID_HANDLE;
  54238. getHardwareScalingLevel(): number;
  54239. constructor();
  54240. dispose(): void;
  54241. /**
  54242. * Can be used to override the current requestAnimationFrame requester.
  54243. * @hidden
  54244. */
  54245. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54246. /**
  54247. * Override default engine behavior.
  54248. * @param color
  54249. * @param backBuffer
  54250. * @param depth
  54251. * @param stencil
  54252. */
  54253. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54254. /**
  54255. * Gets host document
  54256. * @returns the host document object
  54257. */
  54258. getHostDocument(): Nullable<Document>;
  54259. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54260. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54261. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54262. recordVertexArrayObject(vertexBuffers: {
  54263. [key: string]: VertexBuffer;
  54264. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54265. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54266. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54267. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54268. /**
  54269. * Draw a list of indexed primitives
  54270. * @param fillMode defines the primitive to use
  54271. * @param indexStart defines the starting index
  54272. * @param indexCount defines the number of index to draw
  54273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54274. */
  54275. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54276. /**
  54277. * Draw a list of unindexed primitives
  54278. * @param fillMode defines the primitive to use
  54279. * @param verticesStart defines the index of first vertex to draw
  54280. * @param verticesCount defines the count of vertices to draw
  54281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54282. */
  54283. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54284. createPipelineContext(): IPipelineContext;
  54285. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54286. /** @hidden */
  54287. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54288. /** @hidden */
  54289. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54290. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54291. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54292. protected _setProgram(program: WebGLProgram): void;
  54293. _releaseEffect(effect: Effect): void;
  54294. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54295. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54296. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54297. bindSamplers(effect: Effect): void;
  54298. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54299. getRenderWidth(useScreen?: boolean): number;
  54300. getRenderHeight(useScreen?: boolean): number;
  54301. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54302. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54303. /**
  54304. * Set the z offset to apply to current rendering
  54305. * @param value defines the offset to apply
  54306. */
  54307. setZOffset(value: number): void;
  54308. /**
  54309. * Gets the current value of the zOffset
  54310. * @returns the current zOffset state
  54311. */
  54312. getZOffset(): number;
  54313. /**
  54314. * Enable or disable depth buffering
  54315. * @param enable defines the state to set
  54316. */
  54317. setDepthBuffer(enable: boolean): void;
  54318. /**
  54319. * Gets a boolean indicating if depth writing is enabled
  54320. * @returns the current depth writing state
  54321. */
  54322. getDepthWrite(): boolean;
  54323. /**
  54324. * Enable or disable depth writing
  54325. * @param enable defines the state to set
  54326. */
  54327. setDepthWrite(enable: boolean): void;
  54328. /**
  54329. * Enable or disable color writing
  54330. * @param enable defines the state to set
  54331. */
  54332. setColorWrite(enable: boolean): void;
  54333. /**
  54334. * Gets a boolean indicating if color writing is enabled
  54335. * @returns the current color writing state
  54336. */
  54337. getColorWrite(): boolean;
  54338. /**
  54339. * Sets alpha constants used by some alpha blending modes
  54340. * @param r defines the red component
  54341. * @param g defines the green component
  54342. * @param b defines the blue component
  54343. * @param a defines the alpha component
  54344. */
  54345. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54346. /**
  54347. * Sets the current alpha mode
  54348. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54349. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54350. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54351. */
  54352. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54353. /**
  54354. * Gets the current alpha mode
  54355. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54356. * @returns the current alpha mode
  54357. */
  54358. getAlphaMode(): number;
  54359. setInt(uniform: WebGLUniformLocation, int: number): void;
  54360. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54361. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54362. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54363. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54364. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54365. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54366. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54367. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54368. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54369. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54370. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54371. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54372. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54373. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54374. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54375. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54376. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54377. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54378. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54379. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54380. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54381. wipeCaches(bruteForce?: boolean): void;
  54382. _createTexture(): WebGLTexture;
  54383. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54384. /**
  54385. * Usually called from Texture.ts.
  54386. * Passed information to create a WebGLTexture
  54387. * @param url defines a value which contains one of the following:
  54388. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54389. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54390. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54391. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54392. * @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)
  54393. * @param scene needed for loading to the correct scene
  54394. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54395. * @param onLoad optional callback to be called upon successful completion
  54396. * @param onError optional callback to be called upon failure
  54397. * @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
  54398. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54399. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54400. * @param forcedExtension defines the extension to use to pick the right loader
  54401. * @param mimeType defines an optional mime type
  54402. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54403. */
  54404. 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): InternalTexture;
  54405. /**
  54406. * Creates a cube texture
  54407. * @param rootUrl defines the url where the files to load is located
  54408. * @param scene defines the current scene
  54409. * @param files defines the list of files to load (1 per face)
  54410. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54411. * @param onLoad defines an optional callback raised when the texture is loaded
  54412. * @param onError defines an optional callback raised if there is an issue to load the texture
  54413. * @param format defines the format of the data
  54414. * @param forcedExtension defines the extension to use to pick the right loader
  54415. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54416. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54417. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54418. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54419. * @returns the cube texture as an InternalTexture
  54420. */
  54421. 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;
  54422. private _getSamplingFilter;
  54423. private static _GetNativeTextureFormat;
  54424. createRenderTargetTexture(size: number | {
  54425. width: number;
  54426. height: number;
  54427. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54428. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54429. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54430. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54431. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54432. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54433. /**
  54434. * Updates a dynamic vertex buffer.
  54435. * @param vertexBuffer the vertex buffer to update
  54436. * @param data the data used to update the vertex buffer
  54437. * @param byteOffset the byte offset of the data (optional)
  54438. * @param byteLength the byte length of the data (optional)
  54439. */
  54440. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54441. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54442. private _updateAnisotropicLevel;
  54443. private _getAddressMode;
  54444. /** @hidden */
  54445. _bindTexture(channel: number, texture: InternalTexture): void;
  54446. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54447. releaseEffects(): void;
  54448. /** @hidden */
  54449. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54450. /** @hidden */
  54451. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54452. /** @hidden */
  54453. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54454. /** @hidden */
  54455. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54456. }
  54457. }
  54458. declare module "babylonjs/Engines/index" {
  54459. export * from "babylonjs/Engines/constants";
  54460. export * from "babylonjs/Engines/engineCapabilities";
  54461. export * from "babylonjs/Engines/instancingAttributeInfo";
  54462. export * from "babylonjs/Engines/thinEngine";
  54463. export * from "babylonjs/Engines/engine";
  54464. export * from "babylonjs/Engines/engineStore";
  54465. export * from "babylonjs/Engines/nullEngine";
  54466. export * from "babylonjs/Engines/Extensions/index";
  54467. export * from "babylonjs/Engines/IPipelineContext";
  54468. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54469. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54470. export * from "babylonjs/Engines/nativeEngine";
  54471. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54472. export * from "babylonjs/Engines/performanceConfigurator";
  54473. }
  54474. declare module "babylonjs/Events/clipboardEvents" {
  54475. /**
  54476. * Gather the list of clipboard event types as constants.
  54477. */
  54478. export class ClipboardEventTypes {
  54479. /**
  54480. * The clipboard event is fired when a copy command is active (pressed).
  54481. */
  54482. static readonly COPY: number;
  54483. /**
  54484. * The clipboard event is fired when a cut command is active (pressed).
  54485. */
  54486. static readonly CUT: number;
  54487. /**
  54488. * The clipboard event is fired when a paste command is active (pressed).
  54489. */
  54490. static readonly PASTE: number;
  54491. }
  54492. /**
  54493. * This class is used to store clipboard related info for the onClipboardObservable event.
  54494. */
  54495. export class ClipboardInfo {
  54496. /**
  54497. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54498. */
  54499. type: number;
  54500. /**
  54501. * Defines the related dom event
  54502. */
  54503. event: ClipboardEvent;
  54504. /**
  54505. *Creates an instance of ClipboardInfo.
  54506. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54507. * @param event Defines the related dom event
  54508. */
  54509. constructor(
  54510. /**
  54511. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54512. */
  54513. type: number,
  54514. /**
  54515. * Defines the related dom event
  54516. */
  54517. event: ClipboardEvent);
  54518. /**
  54519. * Get the clipboard event's type from the keycode.
  54520. * @param keyCode Defines the keyCode for the current keyboard event.
  54521. * @return {number}
  54522. */
  54523. static GetTypeFromCharacter(keyCode: number): number;
  54524. }
  54525. }
  54526. declare module "babylonjs/Events/index" {
  54527. export * from "babylonjs/Events/keyboardEvents";
  54528. export * from "babylonjs/Events/pointerEvents";
  54529. export * from "babylonjs/Events/clipboardEvents";
  54530. }
  54531. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54532. import { Scene } from "babylonjs/scene";
  54533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54534. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54535. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54536. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54537. /**
  54538. * Google Daydream controller
  54539. */
  54540. export class DaydreamController extends WebVRController {
  54541. /**
  54542. * Base Url for the controller model.
  54543. */
  54544. static MODEL_BASE_URL: string;
  54545. /**
  54546. * File name for the controller model.
  54547. */
  54548. static MODEL_FILENAME: string;
  54549. /**
  54550. * Gamepad Id prefix used to identify Daydream Controller.
  54551. */
  54552. static readonly GAMEPAD_ID_PREFIX: string;
  54553. /**
  54554. * Creates a new DaydreamController from a gamepad
  54555. * @param vrGamepad the gamepad that the controller should be created from
  54556. */
  54557. constructor(vrGamepad: any);
  54558. /**
  54559. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54560. * @param scene scene in which to add meshes
  54561. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54562. */
  54563. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54564. /**
  54565. * Called once for each button that changed state since the last frame
  54566. * @param buttonIdx Which button index changed
  54567. * @param state New state of the button
  54568. * @param changes Which properties on the state changed since last frame
  54569. */
  54570. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54571. }
  54572. }
  54573. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54574. import { Scene } from "babylonjs/scene";
  54575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54576. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54577. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54578. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54579. /**
  54580. * Gear VR Controller
  54581. */
  54582. export class GearVRController extends WebVRController {
  54583. /**
  54584. * Base Url for the controller model.
  54585. */
  54586. static MODEL_BASE_URL: string;
  54587. /**
  54588. * File name for the controller model.
  54589. */
  54590. static MODEL_FILENAME: string;
  54591. /**
  54592. * Gamepad Id prefix used to identify this controller.
  54593. */
  54594. static readonly GAMEPAD_ID_PREFIX: string;
  54595. private readonly _buttonIndexToObservableNameMap;
  54596. /**
  54597. * Creates a new GearVRController from a gamepad
  54598. * @param vrGamepad the gamepad that the controller should be created from
  54599. */
  54600. constructor(vrGamepad: any);
  54601. /**
  54602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54603. * @param scene scene in which to add meshes
  54604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54605. */
  54606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54607. /**
  54608. * Called once for each button that changed state since the last frame
  54609. * @param buttonIdx Which button index changed
  54610. * @param state New state of the button
  54611. * @param changes Which properties on the state changed since last frame
  54612. */
  54613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54614. }
  54615. }
  54616. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54617. import { Scene } from "babylonjs/scene";
  54618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54619. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54620. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54621. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54622. /**
  54623. * Generic Controller
  54624. */
  54625. export class GenericController extends WebVRController {
  54626. /**
  54627. * Base Url for the controller model.
  54628. */
  54629. static readonly MODEL_BASE_URL: string;
  54630. /**
  54631. * File name for the controller model.
  54632. */
  54633. static readonly MODEL_FILENAME: string;
  54634. /**
  54635. * Creates a new GenericController from a gamepad
  54636. * @param vrGamepad the gamepad that the controller should be created from
  54637. */
  54638. constructor(vrGamepad: any);
  54639. /**
  54640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54641. * @param scene scene in which to add meshes
  54642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54643. */
  54644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54645. /**
  54646. * Called once for each button that changed state since the last frame
  54647. * @param buttonIdx Which button index changed
  54648. * @param state New state of the button
  54649. * @param changes Which properties on the state changed since last frame
  54650. */
  54651. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54652. }
  54653. }
  54654. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54655. import { Observable } from "babylonjs/Misc/observable";
  54656. import { Scene } from "babylonjs/scene";
  54657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54658. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54659. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54660. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54661. /**
  54662. * Oculus Touch Controller
  54663. */
  54664. export class OculusTouchController extends WebVRController {
  54665. /**
  54666. * Base Url for the controller model.
  54667. */
  54668. static MODEL_BASE_URL: string;
  54669. /**
  54670. * File name for the left controller model.
  54671. */
  54672. static MODEL_LEFT_FILENAME: string;
  54673. /**
  54674. * File name for the right controller model.
  54675. */
  54676. static MODEL_RIGHT_FILENAME: string;
  54677. /**
  54678. * Base Url for the Quest controller model.
  54679. */
  54680. static QUEST_MODEL_BASE_URL: string;
  54681. /**
  54682. * @hidden
  54683. * If the controllers are running on a device that needs the updated Quest controller models
  54684. */
  54685. static _IsQuest: boolean;
  54686. /**
  54687. * Fired when the secondary trigger on this controller is modified
  54688. */
  54689. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54690. /**
  54691. * Fired when the thumb rest on this controller is modified
  54692. */
  54693. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54694. /**
  54695. * Creates a new OculusTouchController from a gamepad
  54696. * @param vrGamepad the gamepad that the controller should be created from
  54697. */
  54698. constructor(vrGamepad: any);
  54699. /**
  54700. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54701. * @param scene scene in which to add meshes
  54702. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54703. */
  54704. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54705. /**
  54706. * Fired when the A button on this controller is modified
  54707. */
  54708. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54709. /**
  54710. * Fired when the B button on this controller is modified
  54711. */
  54712. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54713. /**
  54714. * Fired when the X button on this controller is modified
  54715. */
  54716. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54717. /**
  54718. * Fired when the Y button on this controller is modified
  54719. */
  54720. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54721. /**
  54722. * Called once for each button that changed state since the last frame
  54723. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54724. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54725. * 2) secondary trigger (same)
  54726. * 3) A (right) X (left), touch, pressed = value
  54727. * 4) B / Y
  54728. * 5) thumb rest
  54729. * @param buttonIdx Which button index changed
  54730. * @param state New state of the button
  54731. * @param changes Which properties on the state changed since last frame
  54732. */
  54733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54734. }
  54735. }
  54736. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54737. import { Scene } from "babylonjs/scene";
  54738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54739. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54740. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54741. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54742. import { Observable } from "babylonjs/Misc/observable";
  54743. /**
  54744. * Vive Controller
  54745. */
  54746. export class ViveController extends WebVRController {
  54747. /**
  54748. * Base Url for the controller model.
  54749. */
  54750. static MODEL_BASE_URL: string;
  54751. /**
  54752. * File name for the controller model.
  54753. */
  54754. static MODEL_FILENAME: string;
  54755. /**
  54756. * Creates a new ViveController from a gamepad
  54757. * @param vrGamepad the gamepad that the controller should be created from
  54758. */
  54759. constructor(vrGamepad: any);
  54760. /**
  54761. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54762. * @param scene scene in which to add meshes
  54763. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54764. */
  54765. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54766. /**
  54767. * Fired when the left button on this controller is modified
  54768. */
  54769. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54770. /**
  54771. * Fired when the right button on this controller is modified
  54772. */
  54773. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54774. /**
  54775. * Fired when the menu button on this controller is modified
  54776. */
  54777. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54778. /**
  54779. * Called once for each button that changed state since the last frame
  54780. * Vive mapping:
  54781. * 0: touchpad
  54782. * 1: trigger
  54783. * 2: left AND right buttons
  54784. * 3: menu button
  54785. * @param buttonIdx Which button index changed
  54786. * @param state New state of the button
  54787. * @param changes Which properties on the state changed since last frame
  54788. */
  54789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54790. }
  54791. }
  54792. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54793. import { Observable } from "babylonjs/Misc/observable";
  54794. import { Scene } from "babylonjs/scene";
  54795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54796. import { Ray } from "babylonjs/Culling/ray";
  54797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54798. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54799. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54800. /**
  54801. * Defines the WindowsMotionController object that the state of the windows motion controller
  54802. */
  54803. export class WindowsMotionController extends WebVRController {
  54804. /**
  54805. * The base url used to load the left and right controller models
  54806. */
  54807. static MODEL_BASE_URL: string;
  54808. /**
  54809. * The name of the left controller model file
  54810. */
  54811. static MODEL_LEFT_FILENAME: string;
  54812. /**
  54813. * The name of the right controller model file
  54814. */
  54815. static MODEL_RIGHT_FILENAME: string;
  54816. /**
  54817. * The controller name prefix for this controller type
  54818. */
  54819. static readonly GAMEPAD_ID_PREFIX: string;
  54820. /**
  54821. * The controller id pattern for this controller type
  54822. */
  54823. private static readonly GAMEPAD_ID_PATTERN;
  54824. private _loadedMeshInfo;
  54825. protected readonly _mapping: {
  54826. buttons: string[];
  54827. buttonMeshNames: {
  54828. trigger: string;
  54829. menu: string;
  54830. grip: string;
  54831. thumbstick: string;
  54832. trackpad: string;
  54833. };
  54834. buttonObservableNames: {
  54835. trigger: string;
  54836. menu: string;
  54837. grip: string;
  54838. thumbstick: string;
  54839. trackpad: string;
  54840. };
  54841. axisMeshNames: string[];
  54842. pointingPoseMeshName: string;
  54843. };
  54844. /**
  54845. * Fired when the trackpad on this controller is clicked
  54846. */
  54847. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54848. /**
  54849. * Fired when the trackpad on this controller is modified
  54850. */
  54851. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54852. /**
  54853. * The current x and y values of this controller's trackpad
  54854. */
  54855. trackpad: StickValues;
  54856. /**
  54857. * Creates a new WindowsMotionController from a gamepad
  54858. * @param vrGamepad the gamepad that the controller should be created from
  54859. */
  54860. constructor(vrGamepad: any);
  54861. /**
  54862. * Fired when the trigger on this controller is modified
  54863. */
  54864. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54865. /**
  54866. * Fired when the menu button on this controller is modified
  54867. */
  54868. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54869. /**
  54870. * Fired when the grip button on this controller is modified
  54871. */
  54872. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54873. /**
  54874. * Fired when the thumbstick button on this controller is modified
  54875. */
  54876. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54877. /**
  54878. * Fired when the touchpad button on this controller is modified
  54879. */
  54880. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54881. /**
  54882. * Fired when the touchpad values on this controller are modified
  54883. */
  54884. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54885. protected _updateTrackpad(): void;
  54886. /**
  54887. * Called once per frame by the engine.
  54888. */
  54889. update(): void;
  54890. /**
  54891. * Called once for each button that changed state since the last frame
  54892. * @param buttonIdx Which button index changed
  54893. * @param state New state of the button
  54894. * @param changes Which properties on the state changed since last frame
  54895. */
  54896. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54897. /**
  54898. * Moves the buttons on the controller mesh based on their current state
  54899. * @param buttonName the name of the button to move
  54900. * @param buttonValue the value of the button which determines the buttons new position
  54901. */
  54902. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54903. /**
  54904. * Moves the axis on the controller mesh based on its current state
  54905. * @param axis the index of the axis
  54906. * @param axisValue the value of the axis which determines the meshes new position
  54907. * @hidden
  54908. */
  54909. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54910. /**
  54911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54912. * @param scene scene in which to add meshes
  54913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54914. */
  54915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54916. /**
  54917. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54918. * can be transformed by button presses and axes values, based on this._mapping.
  54919. *
  54920. * @param scene scene in which the meshes exist
  54921. * @param meshes list of meshes that make up the controller model to process
  54922. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54923. */
  54924. private processModel;
  54925. private createMeshInfo;
  54926. /**
  54927. * Gets the ray of the controller in the direction the controller is pointing
  54928. * @param length the length the resulting ray should be
  54929. * @returns a ray in the direction the controller is pointing
  54930. */
  54931. getForwardRay(length?: number): Ray;
  54932. /**
  54933. * Disposes of the controller
  54934. */
  54935. dispose(): void;
  54936. }
  54937. /**
  54938. * This class represents a new windows motion controller in XR.
  54939. */
  54940. export class XRWindowsMotionController extends WindowsMotionController {
  54941. /**
  54942. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54943. */
  54944. protected readonly _mapping: {
  54945. buttons: string[];
  54946. buttonMeshNames: {
  54947. trigger: string;
  54948. menu: string;
  54949. grip: string;
  54950. thumbstick: string;
  54951. trackpad: string;
  54952. };
  54953. buttonObservableNames: {
  54954. trigger: string;
  54955. menu: string;
  54956. grip: string;
  54957. thumbstick: string;
  54958. trackpad: string;
  54959. };
  54960. axisMeshNames: string[];
  54961. pointingPoseMeshName: string;
  54962. };
  54963. /**
  54964. * Construct a new XR-Based windows motion controller
  54965. *
  54966. * @param gamepadInfo the gamepad object from the browser
  54967. */
  54968. constructor(gamepadInfo: any);
  54969. /**
  54970. * holds the thumbstick values (X,Y)
  54971. */
  54972. thumbstickValues: StickValues;
  54973. /**
  54974. * Fired when the thumbstick on this controller is clicked
  54975. */
  54976. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54977. /**
  54978. * Fired when the thumbstick on this controller is modified
  54979. */
  54980. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54981. /**
  54982. * Fired when the touchpad button on this controller is modified
  54983. */
  54984. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54985. /**
  54986. * Fired when the touchpad values on this controller are modified
  54987. */
  54988. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54989. /**
  54990. * Fired when the thumbstick button on this controller is modified
  54991. * here to prevent breaking changes
  54992. */
  54993. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54994. /**
  54995. * updating the thumbstick(!) and not the trackpad.
  54996. * This is named this way due to the difference between WebVR and XR and to avoid
  54997. * changing the parent class.
  54998. */
  54999. protected _updateTrackpad(): void;
  55000. /**
  55001. * Disposes the class with joy
  55002. */
  55003. dispose(): void;
  55004. }
  55005. }
  55006. declare module "babylonjs/Gamepads/Controllers/index" {
  55007. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55008. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55009. export * from "babylonjs/Gamepads/Controllers/genericController";
  55010. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55011. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55012. export * from "babylonjs/Gamepads/Controllers/viveController";
  55013. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55014. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55015. }
  55016. declare module "babylonjs/Gamepads/index" {
  55017. export * from "babylonjs/Gamepads/Controllers/index";
  55018. export * from "babylonjs/Gamepads/gamepad";
  55019. export * from "babylonjs/Gamepads/gamepadManager";
  55020. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55021. export * from "babylonjs/Gamepads/xboxGamepad";
  55022. export * from "babylonjs/Gamepads/dualShockGamepad";
  55023. }
  55024. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55025. import { Scene } from "babylonjs/scene";
  55026. import { Vector4 } from "babylonjs/Maths/math.vector";
  55027. import { Color4 } from "babylonjs/Maths/math.color";
  55028. import { Mesh } from "babylonjs/Meshes/mesh";
  55029. import { Nullable } from "babylonjs/types";
  55030. /**
  55031. * Class containing static functions to help procedurally build meshes
  55032. */
  55033. export class PolyhedronBuilder {
  55034. /**
  55035. * Creates a polyhedron mesh
  55036. * * 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
  55037. * * The parameter `size` (positive float, default 1) sets the polygon size
  55038. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55039. * * 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`
  55040. * * 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
  55041. * * 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)`)
  55042. * * 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
  55043. * * 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
  55044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55047. * @param name defines the name of the mesh
  55048. * @param options defines the options used to create the mesh
  55049. * @param scene defines the hosting scene
  55050. * @returns the polyhedron mesh
  55051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55052. */
  55053. static CreatePolyhedron(name: string, options: {
  55054. type?: number;
  55055. size?: number;
  55056. sizeX?: number;
  55057. sizeY?: number;
  55058. sizeZ?: number;
  55059. custom?: any;
  55060. faceUV?: Vector4[];
  55061. faceColors?: Color4[];
  55062. flat?: boolean;
  55063. updatable?: boolean;
  55064. sideOrientation?: number;
  55065. frontUVs?: Vector4;
  55066. backUVs?: Vector4;
  55067. }, scene?: Nullable<Scene>): Mesh;
  55068. }
  55069. }
  55070. declare module "babylonjs/Gizmos/scaleGizmo" {
  55071. import { Observable } from "babylonjs/Misc/observable";
  55072. import { Nullable } from "babylonjs/types";
  55073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55074. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55075. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55076. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55077. import { Node } from "babylonjs/node";
  55078. /**
  55079. * Gizmo that enables scaling a mesh along 3 axis
  55080. */
  55081. export class ScaleGizmo extends Gizmo {
  55082. /**
  55083. * Internal gizmo used for interactions on the x axis
  55084. */
  55085. xGizmo: AxisScaleGizmo;
  55086. /**
  55087. * Internal gizmo used for interactions on the y axis
  55088. */
  55089. yGizmo: AxisScaleGizmo;
  55090. /**
  55091. * Internal gizmo used for interactions on the z axis
  55092. */
  55093. zGizmo: AxisScaleGizmo;
  55094. /**
  55095. * Internal gizmo used to scale all axis equally
  55096. */
  55097. uniformScaleGizmo: AxisScaleGizmo;
  55098. private _meshAttached;
  55099. private _nodeAttached;
  55100. private _updateGizmoRotationToMatchAttachedMesh;
  55101. private _snapDistance;
  55102. private _scaleRatio;
  55103. private _uniformScalingMesh;
  55104. private _octahedron;
  55105. private _sensitivity;
  55106. /** Fires an event when any of it's sub gizmos are dragged */
  55107. onDragStartObservable: Observable<unknown>;
  55108. /** Fires an event when any of it's sub gizmos are released from dragging */
  55109. onDragEndObservable: Observable<unknown>;
  55110. get attachedMesh(): Nullable<AbstractMesh>;
  55111. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55112. get attachedNode(): Nullable<Node>;
  55113. set attachedNode(node: Nullable<Node>);
  55114. /**
  55115. * Creates a ScaleGizmo
  55116. * @param gizmoLayer The utility layer the gizmo will be added to
  55117. * @param thickness display gizmo axis thickness
  55118. */
  55119. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55120. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55121. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55122. /**
  55123. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55124. */
  55125. set snapDistance(value: number);
  55126. get snapDistance(): number;
  55127. /**
  55128. * Ratio for the scale of the gizmo (Default: 1)
  55129. */
  55130. set scaleRatio(value: number);
  55131. get scaleRatio(): number;
  55132. /**
  55133. * Sensitivity factor for dragging (Default: 1)
  55134. */
  55135. set sensitivity(value: number);
  55136. get sensitivity(): number;
  55137. /**
  55138. * Disposes of the gizmo
  55139. */
  55140. dispose(): void;
  55141. }
  55142. }
  55143. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55144. import { Observable } from "babylonjs/Misc/observable";
  55145. import { Nullable } from "babylonjs/types";
  55146. import { Vector3 } from "babylonjs/Maths/math.vector";
  55147. import { Node } from "babylonjs/node";
  55148. import { Mesh } from "babylonjs/Meshes/mesh";
  55149. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55150. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55151. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55152. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55153. import { Color3 } from "babylonjs/Maths/math.color";
  55154. /**
  55155. * Single axis scale gizmo
  55156. */
  55157. export class AxisScaleGizmo extends Gizmo {
  55158. /**
  55159. * Drag behavior responsible for the gizmos dragging interactions
  55160. */
  55161. dragBehavior: PointerDragBehavior;
  55162. private _pointerObserver;
  55163. /**
  55164. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55165. */
  55166. snapDistance: number;
  55167. /**
  55168. * Event that fires each time the gizmo snaps to a new location.
  55169. * * snapDistance is the the change in distance
  55170. */
  55171. onSnapObservable: Observable<{
  55172. snapDistance: number;
  55173. }>;
  55174. /**
  55175. * If the scaling operation should be done on all axis (default: false)
  55176. */
  55177. uniformScaling: boolean;
  55178. /**
  55179. * Custom sensitivity value for the drag strength
  55180. */
  55181. sensitivity: number;
  55182. private _isEnabled;
  55183. private _parent;
  55184. private _arrow;
  55185. private _coloredMaterial;
  55186. private _hoverMaterial;
  55187. /**
  55188. * Creates an AxisScaleGizmo
  55189. * @param gizmoLayer The utility layer the gizmo will be added to
  55190. * @param dragAxis The axis which the gizmo will be able to scale on
  55191. * @param color The color of the gizmo
  55192. * @param thickness display gizmo axis thickness
  55193. */
  55194. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55195. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55196. /**
  55197. * If the gizmo is enabled
  55198. */
  55199. set isEnabled(value: boolean);
  55200. get isEnabled(): boolean;
  55201. /**
  55202. * Disposes of the gizmo
  55203. */
  55204. dispose(): void;
  55205. /**
  55206. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55207. * @param mesh The mesh to replace the default mesh of the gizmo
  55208. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55209. */
  55210. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55211. }
  55212. }
  55213. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55214. import { Observable } from "babylonjs/Misc/observable";
  55215. import { Nullable } from "babylonjs/types";
  55216. import { Vector3 } from "babylonjs/Maths/math.vector";
  55217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55218. import { Mesh } from "babylonjs/Meshes/mesh";
  55219. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55220. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55221. import { Color3 } from "babylonjs/Maths/math.color";
  55222. import "babylonjs/Meshes/Builders/boxBuilder";
  55223. /**
  55224. * Bounding box gizmo
  55225. */
  55226. export class BoundingBoxGizmo extends Gizmo {
  55227. private _lineBoundingBox;
  55228. private _rotateSpheresParent;
  55229. private _scaleBoxesParent;
  55230. private _boundingDimensions;
  55231. private _renderObserver;
  55232. private _pointerObserver;
  55233. private _scaleDragSpeed;
  55234. private _tmpQuaternion;
  55235. private _tmpVector;
  55236. private _tmpRotationMatrix;
  55237. /**
  55238. * 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)
  55239. */
  55240. ignoreChildren: boolean;
  55241. /**
  55242. * 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)
  55243. */
  55244. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55245. /**
  55246. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55247. */
  55248. rotationSphereSize: number;
  55249. /**
  55250. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55251. */
  55252. scaleBoxSize: number;
  55253. /**
  55254. * 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)
  55255. */
  55256. fixedDragMeshScreenSize: boolean;
  55257. /**
  55258. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55259. */
  55260. fixedDragMeshScreenSizeDistanceFactor: number;
  55261. /**
  55262. * Fired when a rotation sphere or scale box is dragged
  55263. */
  55264. onDragStartObservable: Observable<{}>;
  55265. /**
  55266. * Fired when a scale box is dragged
  55267. */
  55268. onScaleBoxDragObservable: Observable<{}>;
  55269. /**
  55270. * Fired when a scale box drag is ended
  55271. */
  55272. onScaleBoxDragEndObservable: Observable<{}>;
  55273. /**
  55274. * Fired when a rotation sphere is dragged
  55275. */
  55276. onRotationSphereDragObservable: Observable<{}>;
  55277. /**
  55278. * Fired when a rotation sphere drag is ended
  55279. */
  55280. onRotationSphereDragEndObservable: Observable<{}>;
  55281. /**
  55282. * 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)
  55283. */
  55284. scalePivot: Nullable<Vector3>;
  55285. /**
  55286. * Mesh used as a pivot to rotate the attached node
  55287. */
  55288. private _anchorMesh;
  55289. private _existingMeshScale;
  55290. private _dragMesh;
  55291. private pointerDragBehavior;
  55292. private coloredMaterial;
  55293. private hoverColoredMaterial;
  55294. /**
  55295. * Sets the color of the bounding box gizmo
  55296. * @param color the color to set
  55297. */
  55298. setColor(color: Color3): void;
  55299. /**
  55300. * Creates an BoundingBoxGizmo
  55301. * @param gizmoLayer The utility layer the gizmo will be added to
  55302. * @param color The color of the gizmo
  55303. */
  55304. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55305. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55306. private _selectNode;
  55307. /**
  55308. * Updates the bounding box information for the Gizmo
  55309. */
  55310. updateBoundingBox(): void;
  55311. private _updateRotationSpheres;
  55312. private _updateScaleBoxes;
  55313. /**
  55314. * Enables rotation on the specified axis and disables rotation on the others
  55315. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55316. */
  55317. setEnabledRotationAxis(axis: string): void;
  55318. /**
  55319. * Enables/disables scaling
  55320. * @param enable if scaling should be enabled
  55321. * @param homogeneousScaling defines if scaling should only be homogeneous
  55322. */
  55323. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55324. private _updateDummy;
  55325. /**
  55326. * Enables a pointer drag behavior on the bounding box of the gizmo
  55327. */
  55328. enableDragBehavior(): void;
  55329. /**
  55330. * Disposes of the gizmo
  55331. */
  55332. dispose(): void;
  55333. /**
  55334. * 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)
  55335. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55336. * @returns the bounding box mesh with the passed in mesh as a child
  55337. */
  55338. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55339. /**
  55340. * CustomMeshes are not supported by this gizmo
  55341. * @param mesh The mesh to replace the default mesh of the gizmo
  55342. */
  55343. setCustomMesh(mesh: Mesh): void;
  55344. }
  55345. }
  55346. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55347. import { Observable } from "babylonjs/Misc/observable";
  55348. import { Nullable } from "babylonjs/types";
  55349. import { Vector3 } from "babylonjs/Maths/math.vector";
  55350. import { Color3 } from "babylonjs/Maths/math.color";
  55351. import { Node } from "babylonjs/node";
  55352. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55353. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55354. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55355. import "babylonjs/Meshes/Builders/linesBuilder";
  55356. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55357. /**
  55358. * Single plane rotation gizmo
  55359. */
  55360. export class PlaneRotationGizmo extends Gizmo {
  55361. /**
  55362. * Drag behavior responsible for the gizmos dragging interactions
  55363. */
  55364. dragBehavior: PointerDragBehavior;
  55365. private _pointerObserver;
  55366. /**
  55367. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55368. */
  55369. snapDistance: number;
  55370. /**
  55371. * Event that fires each time the gizmo snaps to a new location.
  55372. * * snapDistance is the the change in distance
  55373. */
  55374. onSnapObservable: Observable<{
  55375. snapDistance: number;
  55376. }>;
  55377. private _isEnabled;
  55378. private _parent;
  55379. /**
  55380. * Creates a PlaneRotationGizmo
  55381. * @param gizmoLayer The utility layer the gizmo will be added to
  55382. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55383. * @param color The color of the gizmo
  55384. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55385. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55386. * @param thickness display gizmo axis thickness
  55387. */
  55388. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55389. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55390. /**
  55391. * If the gizmo is enabled
  55392. */
  55393. set isEnabled(value: boolean);
  55394. get isEnabled(): boolean;
  55395. /**
  55396. * Disposes of the gizmo
  55397. */
  55398. dispose(): void;
  55399. }
  55400. }
  55401. declare module "babylonjs/Gizmos/rotationGizmo" {
  55402. import { Observable } from "babylonjs/Misc/observable";
  55403. import { Nullable } from "babylonjs/types";
  55404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55405. import { Mesh } from "babylonjs/Meshes/mesh";
  55406. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55407. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55408. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55409. import { Node } from "babylonjs/node";
  55410. /**
  55411. * Gizmo that enables rotating a mesh along 3 axis
  55412. */
  55413. export class RotationGizmo extends Gizmo {
  55414. /**
  55415. * Internal gizmo used for interactions on the x axis
  55416. */
  55417. xGizmo: PlaneRotationGizmo;
  55418. /**
  55419. * Internal gizmo used for interactions on the y axis
  55420. */
  55421. yGizmo: PlaneRotationGizmo;
  55422. /**
  55423. * Internal gizmo used for interactions on the z axis
  55424. */
  55425. zGizmo: PlaneRotationGizmo;
  55426. /** Fires an event when any of it's sub gizmos are dragged */
  55427. onDragStartObservable: Observable<unknown>;
  55428. /** Fires an event when any of it's sub gizmos are released from dragging */
  55429. onDragEndObservable: Observable<unknown>;
  55430. private _meshAttached;
  55431. private _nodeAttached;
  55432. get attachedMesh(): Nullable<AbstractMesh>;
  55433. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55434. get attachedNode(): Nullable<Node>;
  55435. set attachedNode(node: Nullable<Node>);
  55436. /**
  55437. * Creates a RotationGizmo
  55438. * @param gizmoLayer The utility layer the gizmo will be added to
  55439. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55440. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55441. * @param thickness display gizmo axis thickness
  55442. */
  55443. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55444. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55445. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55446. /**
  55447. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55448. */
  55449. set snapDistance(value: number);
  55450. get snapDistance(): number;
  55451. /**
  55452. * Ratio for the scale of the gizmo (Default: 1)
  55453. */
  55454. set scaleRatio(value: number);
  55455. get scaleRatio(): number;
  55456. /**
  55457. * Disposes of the gizmo
  55458. */
  55459. dispose(): void;
  55460. /**
  55461. * CustomMeshes are not supported by this gizmo
  55462. * @param mesh The mesh to replace the default mesh of the gizmo
  55463. */
  55464. setCustomMesh(mesh: Mesh): void;
  55465. }
  55466. }
  55467. declare module "babylonjs/Gizmos/gizmoManager" {
  55468. import { Observable } from "babylonjs/Misc/observable";
  55469. import { Nullable } from "babylonjs/types";
  55470. import { Scene, IDisposable } from "babylonjs/scene";
  55471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55472. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55473. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55474. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55475. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55476. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55477. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55478. /**
  55479. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55480. */
  55481. export class GizmoManager implements IDisposable {
  55482. private scene;
  55483. /**
  55484. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55485. */
  55486. gizmos: {
  55487. positionGizmo: Nullable<PositionGizmo>;
  55488. rotationGizmo: Nullable<RotationGizmo>;
  55489. scaleGizmo: Nullable<ScaleGizmo>;
  55490. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55491. };
  55492. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55493. clearGizmoOnEmptyPointerEvent: boolean;
  55494. /** Fires an event when the manager is attached to a mesh */
  55495. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55496. private _gizmosEnabled;
  55497. private _pointerObserver;
  55498. private _attachedMesh;
  55499. private _boundingBoxColor;
  55500. private _defaultUtilityLayer;
  55501. private _defaultKeepDepthUtilityLayer;
  55502. private _thickness;
  55503. /**
  55504. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55505. */
  55506. boundingBoxDragBehavior: SixDofDragBehavior;
  55507. /**
  55508. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55509. */
  55510. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55511. /**
  55512. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55513. */
  55514. usePointerToAttachGizmos: boolean;
  55515. /**
  55516. * Utility layer that the bounding box gizmo belongs to
  55517. */
  55518. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55519. /**
  55520. * Utility layer that all gizmos besides bounding box belong to
  55521. */
  55522. get utilityLayer(): UtilityLayerRenderer;
  55523. /**
  55524. * Instatiates a gizmo manager
  55525. * @param scene the scene to overlay the gizmos on top of
  55526. * @param thickness display gizmo axis thickness
  55527. */
  55528. constructor(scene: Scene, thickness?: number);
  55529. /**
  55530. * Attaches a set of gizmos to the specified mesh
  55531. * @param mesh The mesh the gizmo's should be attached to
  55532. */
  55533. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55534. /**
  55535. * If the position gizmo is enabled
  55536. */
  55537. set positionGizmoEnabled(value: boolean);
  55538. get positionGizmoEnabled(): boolean;
  55539. /**
  55540. * If the rotation gizmo is enabled
  55541. */
  55542. set rotationGizmoEnabled(value: boolean);
  55543. get rotationGizmoEnabled(): boolean;
  55544. /**
  55545. * If the scale gizmo is enabled
  55546. */
  55547. set scaleGizmoEnabled(value: boolean);
  55548. get scaleGizmoEnabled(): boolean;
  55549. /**
  55550. * If the boundingBox gizmo is enabled
  55551. */
  55552. set boundingBoxGizmoEnabled(value: boolean);
  55553. get boundingBoxGizmoEnabled(): boolean;
  55554. /**
  55555. * Disposes of the gizmo manager
  55556. */
  55557. dispose(): void;
  55558. }
  55559. }
  55560. declare module "babylonjs/Lights/directionalLight" {
  55561. import { Camera } from "babylonjs/Cameras/camera";
  55562. import { Scene } from "babylonjs/scene";
  55563. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55565. import { Light } from "babylonjs/Lights/light";
  55566. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55567. import { Effect } from "babylonjs/Materials/effect";
  55568. /**
  55569. * A directional light is defined by a direction (what a surprise!).
  55570. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55571. * 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.
  55572. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55573. */
  55574. export class DirectionalLight extends ShadowLight {
  55575. private _shadowFrustumSize;
  55576. /**
  55577. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55578. */
  55579. get shadowFrustumSize(): number;
  55580. /**
  55581. * Specifies a fix frustum size for the shadow generation.
  55582. */
  55583. set shadowFrustumSize(value: number);
  55584. private _shadowOrthoScale;
  55585. /**
  55586. * Gets the shadow projection scale against the optimal computed one.
  55587. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55588. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55589. */
  55590. get shadowOrthoScale(): number;
  55591. /**
  55592. * Sets the shadow projection scale against the optimal computed one.
  55593. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55594. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55595. */
  55596. set shadowOrthoScale(value: number);
  55597. /**
  55598. * Automatically compute the projection matrix to best fit (including all the casters)
  55599. * on each frame.
  55600. */
  55601. autoUpdateExtends: boolean;
  55602. /**
  55603. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55604. * on each frame. autoUpdateExtends must be set to true for this to work
  55605. */
  55606. autoCalcShadowZBounds: boolean;
  55607. private _orthoLeft;
  55608. private _orthoRight;
  55609. private _orthoTop;
  55610. private _orthoBottom;
  55611. /**
  55612. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55613. * The directional light is emitted from everywhere in the given direction.
  55614. * It can cast shadows.
  55615. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55616. * @param name The friendly name of the light
  55617. * @param direction The direction of the light
  55618. * @param scene The scene the light belongs to
  55619. */
  55620. constructor(name: string, direction: Vector3, scene: Scene);
  55621. /**
  55622. * Returns the string "DirectionalLight".
  55623. * @return The class name
  55624. */
  55625. getClassName(): string;
  55626. /**
  55627. * Returns the integer 1.
  55628. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55629. */
  55630. getTypeID(): number;
  55631. /**
  55632. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55633. * Returns the DirectionalLight Shadow projection matrix.
  55634. */
  55635. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55636. /**
  55637. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55638. * Returns the DirectionalLight Shadow projection matrix.
  55639. */
  55640. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55641. /**
  55642. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55643. * Returns the DirectionalLight Shadow projection matrix.
  55644. */
  55645. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55646. protected _buildUniformLayout(): void;
  55647. /**
  55648. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55649. * @param effect The effect to update
  55650. * @param lightIndex The index of the light in the effect to update
  55651. * @returns The directional light
  55652. */
  55653. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55654. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55655. /**
  55656. * Gets the minZ used for shadow according to both the scene and the light.
  55657. *
  55658. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55659. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55660. * @param activeCamera The camera we are returning the min for
  55661. * @returns the depth min z
  55662. */
  55663. getDepthMinZ(activeCamera: Camera): number;
  55664. /**
  55665. * Gets the maxZ used for shadow according to both the scene and the light.
  55666. *
  55667. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55668. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55669. * @param activeCamera The camera we are returning the max for
  55670. * @returns the depth max z
  55671. */
  55672. getDepthMaxZ(activeCamera: Camera): number;
  55673. /**
  55674. * Prepares the list of defines specific to the light type.
  55675. * @param defines the list of defines
  55676. * @param lightIndex defines the index of the light for the effect
  55677. */
  55678. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55679. }
  55680. }
  55681. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55682. import { Mesh } from "babylonjs/Meshes/mesh";
  55683. /**
  55684. * Class containing static functions to help procedurally build meshes
  55685. */
  55686. export class HemisphereBuilder {
  55687. /**
  55688. * Creates a hemisphere mesh
  55689. * @param name defines the name of the mesh
  55690. * @param options defines the options used to create the mesh
  55691. * @param scene defines the hosting scene
  55692. * @returns the hemisphere mesh
  55693. */
  55694. static CreateHemisphere(name: string, options: {
  55695. segments?: number;
  55696. diameter?: number;
  55697. sideOrientation?: number;
  55698. }, scene: any): Mesh;
  55699. }
  55700. }
  55701. declare module "babylonjs/Lights/spotLight" {
  55702. import { Nullable } from "babylonjs/types";
  55703. import { Scene } from "babylonjs/scene";
  55704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55706. import { Effect } from "babylonjs/Materials/effect";
  55707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55708. import { Light } from "babylonjs/Lights/light";
  55709. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55710. /**
  55711. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55712. * These values define a cone of light starting from the position, emitting toward the direction.
  55713. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55714. * and the exponent defines the speed of the decay of the light with distance (reach).
  55715. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55716. */
  55717. export class SpotLight extends ShadowLight {
  55718. private _angle;
  55719. private _innerAngle;
  55720. private _cosHalfAngle;
  55721. private _lightAngleScale;
  55722. private _lightAngleOffset;
  55723. /**
  55724. * Gets the cone angle of the spot light in Radians.
  55725. */
  55726. get angle(): number;
  55727. /**
  55728. * Sets the cone angle of the spot light in Radians.
  55729. */
  55730. set angle(value: number);
  55731. /**
  55732. * Only used in gltf falloff mode, this defines the angle where
  55733. * the directional falloff will start before cutting at angle which could be seen
  55734. * as outer angle.
  55735. */
  55736. get innerAngle(): number;
  55737. /**
  55738. * Only used in gltf falloff mode, this defines the angle where
  55739. * the directional falloff will start before cutting at angle which could be seen
  55740. * as outer angle.
  55741. */
  55742. set innerAngle(value: number);
  55743. private _shadowAngleScale;
  55744. /**
  55745. * Allows scaling the angle of the light for shadow generation only.
  55746. */
  55747. get shadowAngleScale(): number;
  55748. /**
  55749. * Allows scaling the angle of the light for shadow generation only.
  55750. */
  55751. set shadowAngleScale(value: number);
  55752. /**
  55753. * The light decay speed with the distance from the emission spot.
  55754. */
  55755. exponent: number;
  55756. private _projectionTextureMatrix;
  55757. /**
  55758. * Allows reading the projecton texture
  55759. */
  55760. get projectionTextureMatrix(): Matrix;
  55761. protected _projectionTextureLightNear: number;
  55762. /**
  55763. * Gets the near clip of the Spotlight for texture projection.
  55764. */
  55765. get projectionTextureLightNear(): number;
  55766. /**
  55767. * Sets the near clip of the Spotlight for texture projection.
  55768. */
  55769. set projectionTextureLightNear(value: number);
  55770. protected _projectionTextureLightFar: number;
  55771. /**
  55772. * Gets the far clip of the Spotlight for texture projection.
  55773. */
  55774. get projectionTextureLightFar(): number;
  55775. /**
  55776. * Sets the far clip of the Spotlight for texture projection.
  55777. */
  55778. set projectionTextureLightFar(value: number);
  55779. protected _projectionTextureUpDirection: Vector3;
  55780. /**
  55781. * Gets the Up vector of the Spotlight for texture projection.
  55782. */
  55783. get projectionTextureUpDirection(): Vector3;
  55784. /**
  55785. * Sets the Up vector of the Spotlight for texture projection.
  55786. */
  55787. set projectionTextureUpDirection(value: Vector3);
  55788. private _projectionTexture;
  55789. /**
  55790. * Gets the projection texture of the light.
  55791. */
  55792. get projectionTexture(): Nullable<BaseTexture>;
  55793. /**
  55794. * Sets the projection texture of the light.
  55795. */
  55796. set projectionTexture(value: Nullable<BaseTexture>);
  55797. private _projectionTextureViewLightDirty;
  55798. private _projectionTextureProjectionLightDirty;
  55799. private _projectionTextureDirty;
  55800. private _projectionTextureViewTargetVector;
  55801. private _projectionTextureViewLightMatrix;
  55802. private _projectionTextureProjectionLightMatrix;
  55803. private _projectionTextureScalingMatrix;
  55804. /**
  55805. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55806. * It can cast shadows.
  55807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55808. * @param name The light friendly name
  55809. * @param position The position of the spot light in the scene
  55810. * @param direction The direction of the light in the scene
  55811. * @param angle The cone angle of the light in Radians
  55812. * @param exponent The light decay speed with the distance from the emission spot
  55813. * @param scene The scene the lights belongs to
  55814. */
  55815. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55816. /**
  55817. * Returns the string "SpotLight".
  55818. * @returns the class name
  55819. */
  55820. getClassName(): string;
  55821. /**
  55822. * Returns the integer 2.
  55823. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55824. */
  55825. getTypeID(): number;
  55826. /**
  55827. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55828. */
  55829. protected _setDirection(value: Vector3): void;
  55830. /**
  55831. * Overrides the position setter to recompute the projection texture view light Matrix.
  55832. */
  55833. protected _setPosition(value: Vector3): void;
  55834. /**
  55835. * 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.
  55836. * Returns the SpotLight.
  55837. */
  55838. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55839. protected _computeProjectionTextureViewLightMatrix(): void;
  55840. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55841. /**
  55842. * Main function for light texture projection matrix computing.
  55843. */
  55844. protected _computeProjectionTextureMatrix(): void;
  55845. protected _buildUniformLayout(): void;
  55846. private _computeAngleValues;
  55847. /**
  55848. * Sets the passed Effect "effect" with the Light textures.
  55849. * @param effect The effect to update
  55850. * @param lightIndex The index of the light in the effect to update
  55851. * @returns The light
  55852. */
  55853. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55854. /**
  55855. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55856. * @param effect The effect to update
  55857. * @param lightIndex The index of the light in the effect to update
  55858. * @returns The spot light
  55859. */
  55860. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55861. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55862. /**
  55863. * Disposes the light and the associated resources.
  55864. */
  55865. dispose(): void;
  55866. /**
  55867. * Prepares the list of defines specific to the light type.
  55868. * @param defines the list of defines
  55869. * @param lightIndex defines the index of the light for the effect
  55870. */
  55871. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55872. }
  55873. }
  55874. declare module "babylonjs/Gizmos/lightGizmo" {
  55875. import { Nullable } from "babylonjs/types";
  55876. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55877. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55878. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55879. import { Light } from "babylonjs/Lights/light";
  55880. /**
  55881. * Gizmo that enables viewing a light
  55882. */
  55883. export class LightGizmo extends Gizmo {
  55884. private _lightMesh;
  55885. private _material;
  55886. private _cachedPosition;
  55887. private _cachedForward;
  55888. private _attachedMeshParent;
  55889. /**
  55890. * Creates a LightGizmo
  55891. * @param gizmoLayer The utility layer the gizmo will be added to
  55892. */
  55893. constructor(gizmoLayer?: UtilityLayerRenderer);
  55894. private _light;
  55895. /**
  55896. * The light that the gizmo is attached to
  55897. */
  55898. set light(light: Nullable<Light>);
  55899. get light(): Nullable<Light>;
  55900. /**
  55901. * Gets the material used to render the light gizmo
  55902. */
  55903. get material(): StandardMaterial;
  55904. /**
  55905. * @hidden
  55906. * Updates the gizmo to match the attached mesh's position/rotation
  55907. */
  55908. protected _update(): void;
  55909. private static _Scale;
  55910. /**
  55911. * Creates the lines for a light mesh
  55912. */
  55913. private static _CreateLightLines;
  55914. /**
  55915. * Disposes of the light gizmo
  55916. */
  55917. dispose(): void;
  55918. private static _CreateHemisphericLightMesh;
  55919. private static _CreatePointLightMesh;
  55920. private static _CreateSpotLightMesh;
  55921. private static _CreateDirectionalLightMesh;
  55922. }
  55923. }
  55924. declare module "babylonjs/Gizmos/index" {
  55925. export * from "babylonjs/Gizmos/axisDragGizmo";
  55926. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55927. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55928. export * from "babylonjs/Gizmos/gizmo";
  55929. export * from "babylonjs/Gizmos/gizmoManager";
  55930. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55931. export * from "babylonjs/Gizmos/positionGizmo";
  55932. export * from "babylonjs/Gizmos/rotationGizmo";
  55933. export * from "babylonjs/Gizmos/scaleGizmo";
  55934. export * from "babylonjs/Gizmos/lightGizmo";
  55935. export * from "babylonjs/Gizmos/planeDragGizmo";
  55936. }
  55937. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55938. /** @hidden */
  55939. export var backgroundFragmentDeclaration: {
  55940. name: string;
  55941. shader: string;
  55942. };
  55943. }
  55944. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55945. /** @hidden */
  55946. export var backgroundUboDeclaration: {
  55947. name: string;
  55948. shader: string;
  55949. };
  55950. }
  55951. declare module "babylonjs/Shaders/background.fragment" {
  55952. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55953. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55954. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55955. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55956. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55957. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55959. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55960. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55961. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55963. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55964. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55965. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55966. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55967. /** @hidden */
  55968. export var backgroundPixelShader: {
  55969. name: string;
  55970. shader: string;
  55971. };
  55972. }
  55973. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55974. /** @hidden */
  55975. export var backgroundVertexDeclaration: {
  55976. name: string;
  55977. shader: string;
  55978. };
  55979. }
  55980. declare module "babylonjs/Shaders/background.vertex" {
  55981. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55982. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55984. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55985. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55986. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55987. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55988. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55989. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55990. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55991. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55992. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55993. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55994. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55995. /** @hidden */
  55996. export var backgroundVertexShader: {
  55997. name: string;
  55998. shader: string;
  55999. };
  56000. }
  56001. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56002. import { Nullable, int, float } from "babylonjs/types";
  56003. import { Scene } from "babylonjs/scene";
  56004. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56005. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56007. import { Mesh } from "babylonjs/Meshes/mesh";
  56008. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56009. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56010. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56012. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56013. import { Color3 } from "babylonjs/Maths/math.color";
  56014. import "babylonjs/Shaders/background.fragment";
  56015. import "babylonjs/Shaders/background.vertex";
  56016. /**
  56017. * Background material used to create an efficient environement around your scene.
  56018. */
  56019. export class BackgroundMaterial extends PushMaterial {
  56020. /**
  56021. * Standard reflectance value at parallel view angle.
  56022. */
  56023. static StandardReflectance0: number;
  56024. /**
  56025. * Standard reflectance value at grazing angle.
  56026. */
  56027. static StandardReflectance90: number;
  56028. protected _primaryColor: Color3;
  56029. /**
  56030. * Key light Color (multiply against the environement texture)
  56031. */
  56032. primaryColor: Color3;
  56033. protected __perceptualColor: Nullable<Color3>;
  56034. /**
  56035. * Experimental Internal Use Only.
  56036. *
  56037. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56038. * This acts as a helper to set the primary color to a more "human friendly" value.
  56039. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56040. * output color as close as possible from the chosen value.
  56041. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56042. * part of lighting setup.)
  56043. */
  56044. get _perceptualColor(): Nullable<Color3>;
  56045. set _perceptualColor(value: Nullable<Color3>);
  56046. protected _primaryColorShadowLevel: float;
  56047. /**
  56048. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56049. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56050. */
  56051. get primaryColorShadowLevel(): float;
  56052. set primaryColorShadowLevel(value: float);
  56053. protected _primaryColorHighlightLevel: float;
  56054. /**
  56055. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56056. * The primary color is used at the level chosen to define what the white area would look.
  56057. */
  56058. get primaryColorHighlightLevel(): float;
  56059. set primaryColorHighlightLevel(value: float);
  56060. protected _reflectionTexture: Nullable<BaseTexture>;
  56061. /**
  56062. * Reflection Texture used in the material.
  56063. * Should be author in a specific way for the best result (refer to the documentation).
  56064. */
  56065. reflectionTexture: Nullable<BaseTexture>;
  56066. protected _reflectionBlur: float;
  56067. /**
  56068. * Reflection Texture level of blur.
  56069. *
  56070. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56071. * texture twice.
  56072. */
  56073. reflectionBlur: float;
  56074. protected _diffuseTexture: Nullable<BaseTexture>;
  56075. /**
  56076. * Diffuse Texture used in the material.
  56077. * Should be author in a specific way for the best result (refer to the documentation).
  56078. */
  56079. diffuseTexture: Nullable<BaseTexture>;
  56080. protected _shadowLights: Nullable<IShadowLight[]>;
  56081. /**
  56082. * Specify the list of lights casting shadow on the material.
  56083. * All scene shadow lights will be included if null.
  56084. */
  56085. shadowLights: Nullable<IShadowLight[]>;
  56086. protected _shadowLevel: float;
  56087. /**
  56088. * Helps adjusting the shadow to a softer level if required.
  56089. * 0 means black shadows and 1 means no shadows.
  56090. */
  56091. shadowLevel: float;
  56092. protected _sceneCenter: Vector3;
  56093. /**
  56094. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56095. * It is usually zero but might be interesting to modify according to your setup.
  56096. */
  56097. sceneCenter: Vector3;
  56098. protected _opacityFresnel: boolean;
  56099. /**
  56100. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56101. * This helps ensuring a nice transition when the camera goes under the ground.
  56102. */
  56103. opacityFresnel: boolean;
  56104. protected _reflectionFresnel: boolean;
  56105. /**
  56106. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56107. * This helps adding a mirror texture on the ground.
  56108. */
  56109. reflectionFresnel: boolean;
  56110. protected _reflectionFalloffDistance: number;
  56111. /**
  56112. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56113. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56114. */
  56115. reflectionFalloffDistance: number;
  56116. protected _reflectionAmount: number;
  56117. /**
  56118. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56119. */
  56120. reflectionAmount: number;
  56121. protected _reflectionReflectance0: number;
  56122. /**
  56123. * This specifies the weight of the reflection at grazing angle.
  56124. */
  56125. reflectionReflectance0: number;
  56126. protected _reflectionReflectance90: number;
  56127. /**
  56128. * This specifies the weight of the reflection at a perpendicular point of view.
  56129. */
  56130. reflectionReflectance90: number;
  56131. /**
  56132. * Sets the reflection reflectance fresnel values according to the default standard
  56133. * empirically know to work well :-)
  56134. */
  56135. set reflectionStandardFresnelWeight(value: number);
  56136. protected _useRGBColor: boolean;
  56137. /**
  56138. * Helps to directly use the maps channels instead of their level.
  56139. */
  56140. useRGBColor: boolean;
  56141. protected _enableNoise: boolean;
  56142. /**
  56143. * This helps reducing the banding effect that could occur on the background.
  56144. */
  56145. enableNoise: boolean;
  56146. /**
  56147. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56148. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56149. * Recommended to be keep at 1.0 except for special cases.
  56150. */
  56151. get fovMultiplier(): number;
  56152. set fovMultiplier(value: number);
  56153. private _fovMultiplier;
  56154. /**
  56155. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56156. */
  56157. useEquirectangularFOV: boolean;
  56158. private _maxSimultaneousLights;
  56159. /**
  56160. * Number of Simultaneous lights allowed on the material.
  56161. */
  56162. maxSimultaneousLights: int;
  56163. private _shadowOnly;
  56164. /**
  56165. * Make the material only render shadows
  56166. */
  56167. shadowOnly: boolean;
  56168. /**
  56169. * Default configuration related to image processing available in the Background Material.
  56170. */
  56171. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56172. /**
  56173. * Keep track of the image processing observer to allow dispose and replace.
  56174. */
  56175. private _imageProcessingObserver;
  56176. /**
  56177. * Attaches a new image processing configuration to the PBR Material.
  56178. * @param configuration (if null the scene configuration will be use)
  56179. */
  56180. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56181. /**
  56182. * Gets the image processing configuration used either in this material.
  56183. */
  56184. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56185. /**
  56186. * Sets the Default image processing configuration used either in the this material.
  56187. *
  56188. * If sets to null, the scene one is in use.
  56189. */
  56190. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56191. /**
  56192. * Gets wether the color curves effect is enabled.
  56193. */
  56194. get cameraColorCurvesEnabled(): boolean;
  56195. /**
  56196. * Sets wether the color curves effect is enabled.
  56197. */
  56198. set cameraColorCurvesEnabled(value: boolean);
  56199. /**
  56200. * Gets wether the color grading effect is enabled.
  56201. */
  56202. get cameraColorGradingEnabled(): boolean;
  56203. /**
  56204. * Gets wether the color grading effect is enabled.
  56205. */
  56206. set cameraColorGradingEnabled(value: boolean);
  56207. /**
  56208. * Gets wether tonemapping is enabled or not.
  56209. */
  56210. get cameraToneMappingEnabled(): boolean;
  56211. /**
  56212. * Sets wether tonemapping is enabled or not
  56213. */
  56214. set cameraToneMappingEnabled(value: boolean);
  56215. /**
  56216. * The camera exposure used on this material.
  56217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56218. * This corresponds to a photographic exposure.
  56219. */
  56220. get cameraExposure(): float;
  56221. /**
  56222. * The camera exposure used on this material.
  56223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56224. * This corresponds to a photographic exposure.
  56225. */
  56226. set cameraExposure(value: float);
  56227. /**
  56228. * Gets The camera contrast used on this material.
  56229. */
  56230. get cameraContrast(): float;
  56231. /**
  56232. * Sets The camera contrast used on this material.
  56233. */
  56234. set cameraContrast(value: float);
  56235. /**
  56236. * Gets the Color Grading 2D Lookup Texture.
  56237. */
  56238. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56239. /**
  56240. * Sets the Color Grading 2D Lookup Texture.
  56241. */
  56242. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56243. /**
  56244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56246. * 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;
  56247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56248. */
  56249. get cameraColorCurves(): Nullable<ColorCurves>;
  56250. /**
  56251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56253. * 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;
  56254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56255. */
  56256. set cameraColorCurves(value: Nullable<ColorCurves>);
  56257. /**
  56258. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56259. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56260. */
  56261. switchToBGR: boolean;
  56262. private _renderTargets;
  56263. private _reflectionControls;
  56264. private _white;
  56265. private _primaryShadowColor;
  56266. private _primaryHighlightColor;
  56267. /**
  56268. * Instantiates a Background Material in the given scene
  56269. * @param name The friendly name of the material
  56270. * @param scene The scene to add the material to
  56271. */
  56272. constructor(name: string, scene: Scene);
  56273. /**
  56274. * Gets a boolean indicating that current material needs to register RTT
  56275. */
  56276. get hasRenderTargetTextures(): boolean;
  56277. /**
  56278. * The entire material has been created in order to prevent overdraw.
  56279. * @returns false
  56280. */
  56281. needAlphaTesting(): boolean;
  56282. /**
  56283. * The entire material has been created in order to prevent overdraw.
  56284. * @returns true if blending is enable
  56285. */
  56286. needAlphaBlending(): boolean;
  56287. /**
  56288. * Checks wether the material is ready to be rendered for a given mesh.
  56289. * @param mesh The mesh to render
  56290. * @param subMesh The submesh to check against
  56291. * @param useInstances Specify wether or not the material is used with instances
  56292. * @returns true if all the dependencies are ready (Textures, Effects...)
  56293. */
  56294. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56295. /**
  56296. * Compute the primary color according to the chosen perceptual color.
  56297. */
  56298. private _computePrimaryColorFromPerceptualColor;
  56299. /**
  56300. * Compute the highlights and shadow colors according to their chosen levels.
  56301. */
  56302. private _computePrimaryColors;
  56303. /**
  56304. * Build the uniform buffer used in the material.
  56305. */
  56306. buildUniformLayout(): void;
  56307. /**
  56308. * Unbind the material.
  56309. */
  56310. unbind(): void;
  56311. /**
  56312. * Bind only the world matrix to the material.
  56313. * @param world The world matrix to bind.
  56314. */
  56315. bindOnlyWorldMatrix(world: Matrix): void;
  56316. /**
  56317. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56318. * @param world The world matrix to bind.
  56319. * @param subMesh The submesh to bind for.
  56320. */
  56321. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56322. /**
  56323. * Checks to see if a texture is used in the material.
  56324. * @param texture - Base texture to use.
  56325. * @returns - Boolean specifying if a texture is used in the material.
  56326. */
  56327. hasTexture(texture: BaseTexture): boolean;
  56328. /**
  56329. * Dispose the material.
  56330. * @param forceDisposeEffect Force disposal of the associated effect.
  56331. * @param forceDisposeTextures Force disposal of the associated textures.
  56332. */
  56333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56334. /**
  56335. * Clones the material.
  56336. * @param name The cloned name.
  56337. * @returns The cloned material.
  56338. */
  56339. clone(name: string): BackgroundMaterial;
  56340. /**
  56341. * Serializes the current material to its JSON representation.
  56342. * @returns The JSON representation.
  56343. */
  56344. serialize(): any;
  56345. /**
  56346. * Gets the class name of the material
  56347. * @returns "BackgroundMaterial"
  56348. */
  56349. getClassName(): string;
  56350. /**
  56351. * Parse a JSON input to create back a background material.
  56352. * @param source The JSON data to parse
  56353. * @param scene The scene to create the parsed material in
  56354. * @param rootUrl The root url of the assets the material depends upon
  56355. * @returns the instantiated BackgroundMaterial.
  56356. */
  56357. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56358. }
  56359. }
  56360. declare module "babylonjs/Helpers/environmentHelper" {
  56361. import { Observable } from "babylonjs/Misc/observable";
  56362. import { Nullable } from "babylonjs/types";
  56363. import { Scene } from "babylonjs/scene";
  56364. import { Vector3 } from "babylonjs/Maths/math.vector";
  56365. import { Color3 } from "babylonjs/Maths/math.color";
  56366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56367. import { Mesh } from "babylonjs/Meshes/mesh";
  56368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56369. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56370. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56371. import "babylonjs/Meshes/Builders/planeBuilder";
  56372. import "babylonjs/Meshes/Builders/boxBuilder";
  56373. /**
  56374. * Represents the different options available during the creation of
  56375. * a Environment helper.
  56376. *
  56377. * This can control the default ground, skybox and image processing setup of your scene.
  56378. */
  56379. export interface IEnvironmentHelperOptions {
  56380. /**
  56381. * Specifies whether or not to create a ground.
  56382. * True by default.
  56383. */
  56384. createGround: boolean;
  56385. /**
  56386. * Specifies the ground size.
  56387. * 15 by default.
  56388. */
  56389. groundSize: number;
  56390. /**
  56391. * The texture used on the ground for the main color.
  56392. * Comes from the BabylonJS CDN by default.
  56393. *
  56394. * Remarks: Can be either a texture or a url.
  56395. */
  56396. groundTexture: string | BaseTexture;
  56397. /**
  56398. * The color mixed in the ground texture by default.
  56399. * BabylonJS clearColor by default.
  56400. */
  56401. groundColor: Color3;
  56402. /**
  56403. * Specifies the ground opacity.
  56404. * 1 by default.
  56405. */
  56406. groundOpacity: number;
  56407. /**
  56408. * Enables the ground to receive shadows.
  56409. * True by default.
  56410. */
  56411. enableGroundShadow: boolean;
  56412. /**
  56413. * Helps preventing the shadow to be fully black on the ground.
  56414. * 0.5 by default.
  56415. */
  56416. groundShadowLevel: number;
  56417. /**
  56418. * Creates a mirror texture attach to the ground.
  56419. * false by default.
  56420. */
  56421. enableGroundMirror: boolean;
  56422. /**
  56423. * Specifies the ground mirror size ratio.
  56424. * 0.3 by default as the default kernel is 64.
  56425. */
  56426. groundMirrorSizeRatio: number;
  56427. /**
  56428. * Specifies the ground mirror blur kernel size.
  56429. * 64 by default.
  56430. */
  56431. groundMirrorBlurKernel: number;
  56432. /**
  56433. * Specifies the ground mirror visibility amount.
  56434. * 1 by default
  56435. */
  56436. groundMirrorAmount: number;
  56437. /**
  56438. * Specifies the ground mirror reflectance weight.
  56439. * This uses the standard weight of the background material to setup the fresnel effect
  56440. * of the mirror.
  56441. * 1 by default.
  56442. */
  56443. groundMirrorFresnelWeight: number;
  56444. /**
  56445. * Specifies the ground mirror Falloff distance.
  56446. * This can helps reducing the size of the reflection.
  56447. * 0 by Default.
  56448. */
  56449. groundMirrorFallOffDistance: number;
  56450. /**
  56451. * Specifies the ground mirror texture type.
  56452. * Unsigned Int by Default.
  56453. */
  56454. groundMirrorTextureType: number;
  56455. /**
  56456. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56457. * the shown objects.
  56458. */
  56459. groundYBias: number;
  56460. /**
  56461. * Specifies whether or not to create a skybox.
  56462. * True by default.
  56463. */
  56464. createSkybox: boolean;
  56465. /**
  56466. * Specifies the skybox size.
  56467. * 20 by default.
  56468. */
  56469. skyboxSize: number;
  56470. /**
  56471. * The texture used on the skybox for the main color.
  56472. * Comes from the BabylonJS CDN by default.
  56473. *
  56474. * Remarks: Can be either a texture or a url.
  56475. */
  56476. skyboxTexture: string | BaseTexture;
  56477. /**
  56478. * The color mixed in the skybox texture by default.
  56479. * BabylonJS clearColor by default.
  56480. */
  56481. skyboxColor: Color3;
  56482. /**
  56483. * The background rotation around the Y axis of the scene.
  56484. * This helps aligning the key lights of your scene with the background.
  56485. * 0 by default.
  56486. */
  56487. backgroundYRotation: number;
  56488. /**
  56489. * Compute automatically the size of the elements to best fit with the scene.
  56490. */
  56491. sizeAuto: boolean;
  56492. /**
  56493. * Default position of the rootMesh if autoSize is not true.
  56494. */
  56495. rootPosition: Vector3;
  56496. /**
  56497. * Sets up the image processing in the scene.
  56498. * true by default.
  56499. */
  56500. setupImageProcessing: boolean;
  56501. /**
  56502. * The texture used as your environment texture in the scene.
  56503. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56504. *
  56505. * Remarks: Can be either a texture or a url.
  56506. */
  56507. environmentTexture: string | BaseTexture;
  56508. /**
  56509. * The value of the exposure to apply to the scene.
  56510. * 0.6 by default if setupImageProcessing is true.
  56511. */
  56512. cameraExposure: number;
  56513. /**
  56514. * The value of the contrast to apply to the scene.
  56515. * 1.6 by default if setupImageProcessing is true.
  56516. */
  56517. cameraContrast: number;
  56518. /**
  56519. * Specifies whether or not tonemapping should be enabled in the scene.
  56520. * true by default if setupImageProcessing is true.
  56521. */
  56522. toneMappingEnabled: boolean;
  56523. }
  56524. /**
  56525. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56526. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56527. * It also helps with the default setup of your imageProcessing configuration.
  56528. */
  56529. export class EnvironmentHelper {
  56530. /**
  56531. * Default ground texture URL.
  56532. */
  56533. private static _groundTextureCDNUrl;
  56534. /**
  56535. * Default skybox texture URL.
  56536. */
  56537. private static _skyboxTextureCDNUrl;
  56538. /**
  56539. * Default environment texture URL.
  56540. */
  56541. private static _environmentTextureCDNUrl;
  56542. /**
  56543. * Creates the default options for the helper.
  56544. */
  56545. private static _getDefaultOptions;
  56546. private _rootMesh;
  56547. /**
  56548. * Gets the root mesh created by the helper.
  56549. */
  56550. get rootMesh(): Mesh;
  56551. private _skybox;
  56552. /**
  56553. * Gets the skybox created by the helper.
  56554. */
  56555. get skybox(): Nullable<Mesh>;
  56556. private _skyboxTexture;
  56557. /**
  56558. * Gets the skybox texture created by the helper.
  56559. */
  56560. get skyboxTexture(): Nullable<BaseTexture>;
  56561. private _skyboxMaterial;
  56562. /**
  56563. * Gets the skybox material created by the helper.
  56564. */
  56565. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56566. private _ground;
  56567. /**
  56568. * Gets the ground mesh created by the helper.
  56569. */
  56570. get ground(): Nullable<Mesh>;
  56571. private _groundTexture;
  56572. /**
  56573. * Gets the ground texture created by the helper.
  56574. */
  56575. get groundTexture(): Nullable<BaseTexture>;
  56576. private _groundMirror;
  56577. /**
  56578. * Gets the ground mirror created by the helper.
  56579. */
  56580. get groundMirror(): Nullable<MirrorTexture>;
  56581. /**
  56582. * Gets the ground mirror render list to helps pushing the meshes
  56583. * you wish in the ground reflection.
  56584. */
  56585. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56586. private _groundMaterial;
  56587. /**
  56588. * Gets the ground material created by the helper.
  56589. */
  56590. get groundMaterial(): Nullable<BackgroundMaterial>;
  56591. /**
  56592. * Stores the creation options.
  56593. */
  56594. private readonly _scene;
  56595. private _options;
  56596. /**
  56597. * This observable will be notified with any error during the creation of the environment,
  56598. * mainly texture creation errors.
  56599. */
  56600. onErrorObservable: Observable<{
  56601. message?: string;
  56602. exception?: any;
  56603. }>;
  56604. /**
  56605. * constructor
  56606. * @param options Defines the options we want to customize the helper
  56607. * @param scene The scene to add the material to
  56608. */
  56609. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56610. /**
  56611. * Updates the background according to the new options
  56612. * @param options
  56613. */
  56614. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56615. /**
  56616. * Sets the primary color of all the available elements.
  56617. * @param color the main color to affect to the ground and the background
  56618. */
  56619. setMainColor(color: Color3): void;
  56620. /**
  56621. * Setup the image processing according to the specified options.
  56622. */
  56623. private _setupImageProcessing;
  56624. /**
  56625. * Setup the environment texture according to the specified options.
  56626. */
  56627. private _setupEnvironmentTexture;
  56628. /**
  56629. * Setup the background according to the specified options.
  56630. */
  56631. private _setupBackground;
  56632. /**
  56633. * Get the scene sizes according to the setup.
  56634. */
  56635. private _getSceneSize;
  56636. /**
  56637. * Setup the ground according to the specified options.
  56638. */
  56639. private _setupGround;
  56640. /**
  56641. * Setup the ground material according to the specified options.
  56642. */
  56643. private _setupGroundMaterial;
  56644. /**
  56645. * Setup the ground diffuse texture according to the specified options.
  56646. */
  56647. private _setupGroundDiffuseTexture;
  56648. /**
  56649. * Setup the ground mirror texture according to the specified options.
  56650. */
  56651. private _setupGroundMirrorTexture;
  56652. /**
  56653. * Setup the ground to receive the mirror texture.
  56654. */
  56655. private _setupMirrorInGroundMaterial;
  56656. /**
  56657. * Setup the skybox according to the specified options.
  56658. */
  56659. private _setupSkybox;
  56660. /**
  56661. * Setup the skybox material according to the specified options.
  56662. */
  56663. private _setupSkyboxMaterial;
  56664. /**
  56665. * Setup the skybox reflection texture according to the specified options.
  56666. */
  56667. private _setupSkyboxReflectionTexture;
  56668. private _errorHandler;
  56669. /**
  56670. * Dispose all the elements created by the Helper.
  56671. */
  56672. dispose(): void;
  56673. }
  56674. }
  56675. declare module "babylonjs/Helpers/photoDome" {
  56676. import { Observable } from "babylonjs/Misc/observable";
  56677. import { Nullable } from "babylonjs/types";
  56678. import { Scene } from "babylonjs/scene";
  56679. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56680. import { Mesh } from "babylonjs/Meshes/mesh";
  56681. import { Texture } from "babylonjs/Materials/Textures/texture";
  56682. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56683. import "babylonjs/Meshes/Builders/sphereBuilder";
  56684. /**
  56685. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56686. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56687. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56688. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56689. */
  56690. export class PhotoDome extends TransformNode {
  56691. /**
  56692. * Define the image as a Monoscopic panoramic 360 image.
  56693. */
  56694. static readonly MODE_MONOSCOPIC: number;
  56695. /**
  56696. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56697. */
  56698. static readonly MODE_TOPBOTTOM: number;
  56699. /**
  56700. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56701. */
  56702. static readonly MODE_SIDEBYSIDE: number;
  56703. private _useDirectMapping;
  56704. /**
  56705. * The texture being displayed on the sphere
  56706. */
  56707. protected _photoTexture: Texture;
  56708. /**
  56709. * Gets or sets the texture being displayed on the sphere
  56710. */
  56711. get photoTexture(): Texture;
  56712. set photoTexture(value: Texture);
  56713. /**
  56714. * Observable raised when an error occured while loading the 360 image
  56715. */
  56716. onLoadErrorObservable: Observable<string>;
  56717. /**
  56718. * The skybox material
  56719. */
  56720. protected _material: BackgroundMaterial;
  56721. /**
  56722. * The surface used for the skybox
  56723. */
  56724. protected _mesh: Mesh;
  56725. /**
  56726. * Gets the mesh used for the skybox.
  56727. */
  56728. get mesh(): Mesh;
  56729. /**
  56730. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56731. * Also see the options.resolution property.
  56732. */
  56733. get fovMultiplier(): number;
  56734. set fovMultiplier(value: number);
  56735. private _imageMode;
  56736. /**
  56737. * Gets or set the current video mode for the video. It can be:
  56738. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56739. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56740. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56741. */
  56742. get imageMode(): number;
  56743. set imageMode(value: number);
  56744. /**
  56745. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56746. * @param name Element's name, child elements will append suffixes for their own names.
  56747. * @param urlsOfPhoto defines the url of the photo to display
  56748. * @param options defines an object containing optional or exposed sub element properties
  56749. * @param onError defines a callback called when an error occured while loading the texture
  56750. */
  56751. constructor(name: string, urlOfPhoto: string, options: {
  56752. resolution?: number;
  56753. size?: number;
  56754. useDirectMapping?: boolean;
  56755. faceForward?: boolean;
  56756. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56757. private _onBeforeCameraRenderObserver;
  56758. private _changeImageMode;
  56759. /**
  56760. * Releases resources associated with this node.
  56761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56763. */
  56764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56765. }
  56766. }
  56767. declare module "babylonjs/Misc/rgbdTextureTools" {
  56768. import "babylonjs/Shaders/rgbdDecode.fragment";
  56769. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56770. import { Texture } from "babylonjs/Materials/Textures/texture";
  56771. /**
  56772. * Class used to host RGBD texture specific utilities
  56773. */
  56774. export class RGBDTextureTools {
  56775. /**
  56776. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56777. * @param texture the texture to expand.
  56778. */
  56779. static ExpandRGBDTexture(texture: Texture): void;
  56780. }
  56781. }
  56782. declare module "babylonjs/Misc/brdfTextureTools" {
  56783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56784. import { Scene } from "babylonjs/scene";
  56785. /**
  56786. * Class used to host texture specific utilities
  56787. */
  56788. export class BRDFTextureTools {
  56789. /**
  56790. * Prevents texture cache collision
  56791. */
  56792. private static _instanceNumber;
  56793. /**
  56794. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56795. * @param scene defines the hosting scene
  56796. * @returns the environment BRDF texture
  56797. */
  56798. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56799. private static _environmentBRDFBase64Texture;
  56800. }
  56801. }
  56802. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56803. import { Nullable } from "babylonjs/types";
  56804. import { Color3 } from "babylonjs/Maths/math.color";
  56805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56808. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56809. import { Engine } from "babylonjs/Engines/engine";
  56810. import { Scene } from "babylonjs/scene";
  56811. /**
  56812. * @hidden
  56813. */
  56814. export interface IMaterialClearCoatDefines {
  56815. CLEARCOAT: boolean;
  56816. CLEARCOAT_DEFAULTIOR: boolean;
  56817. CLEARCOAT_TEXTURE: boolean;
  56818. CLEARCOAT_TEXTUREDIRECTUV: number;
  56819. CLEARCOAT_BUMP: boolean;
  56820. CLEARCOAT_BUMPDIRECTUV: number;
  56821. CLEARCOAT_TINT: boolean;
  56822. CLEARCOAT_TINT_TEXTURE: boolean;
  56823. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56824. /** @hidden */
  56825. _areTexturesDirty: boolean;
  56826. }
  56827. /**
  56828. * Define the code related to the clear coat parameters of the pbr material.
  56829. */
  56830. export class PBRClearCoatConfiguration {
  56831. /**
  56832. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56833. * The default fits with a polyurethane material.
  56834. */
  56835. private static readonly _DefaultIndexOfRefraction;
  56836. private _isEnabled;
  56837. /**
  56838. * Defines if the clear coat is enabled in the material.
  56839. */
  56840. isEnabled: boolean;
  56841. /**
  56842. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56843. */
  56844. intensity: number;
  56845. /**
  56846. * Defines the clear coat layer roughness.
  56847. */
  56848. roughness: number;
  56849. private _indexOfRefraction;
  56850. /**
  56851. * Defines the index of refraction of the clear coat.
  56852. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56853. * The default fits with a polyurethane material.
  56854. * Changing the default value is more performance intensive.
  56855. */
  56856. indexOfRefraction: number;
  56857. private _texture;
  56858. /**
  56859. * Stores the clear coat values in a texture.
  56860. */
  56861. texture: Nullable<BaseTexture>;
  56862. private _bumpTexture;
  56863. /**
  56864. * Define the clear coat specific bump texture.
  56865. */
  56866. bumpTexture: Nullable<BaseTexture>;
  56867. private _isTintEnabled;
  56868. /**
  56869. * Defines if the clear coat tint is enabled in the material.
  56870. */
  56871. isTintEnabled: boolean;
  56872. /**
  56873. * Defines the clear coat tint of the material.
  56874. * This is only use if tint is enabled
  56875. */
  56876. tintColor: Color3;
  56877. /**
  56878. * Defines the distance at which the tint color should be found in the
  56879. * clear coat media.
  56880. * This is only use if tint is enabled
  56881. */
  56882. tintColorAtDistance: number;
  56883. /**
  56884. * Defines the clear coat layer thickness.
  56885. * This is only use if tint is enabled
  56886. */
  56887. tintThickness: number;
  56888. private _tintTexture;
  56889. /**
  56890. * Stores the clear tint values in a texture.
  56891. * rgb is tint
  56892. * a is a thickness factor
  56893. */
  56894. tintTexture: Nullable<BaseTexture>;
  56895. /** @hidden */
  56896. private _internalMarkAllSubMeshesAsTexturesDirty;
  56897. /** @hidden */
  56898. _markAllSubMeshesAsTexturesDirty(): void;
  56899. /**
  56900. * Instantiate a new istance of clear coat configuration.
  56901. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56902. */
  56903. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56904. /**
  56905. * Gets wehter the submesh is ready to be used or not.
  56906. * @param defines the list of "defines" to update.
  56907. * @param scene defines the scene the material belongs to.
  56908. * @param engine defines the engine the material belongs to.
  56909. * @param disableBumpMap defines wether the material disables bump or not.
  56910. * @returns - boolean indicating that the submesh is ready or not.
  56911. */
  56912. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56913. /**
  56914. * Checks to see if a texture is used in the material.
  56915. * @param defines the list of "defines" to update.
  56916. * @param scene defines the scene to the material belongs to.
  56917. */
  56918. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56919. /**
  56920. * Binds the material data.
  56921. * @param uniformBuffer defines the Uniform buffer to fill in.
  56922. * @param scene defines the scene the material belongs to.
  56923. * @param engine defines the engine the material belongs to.
  56924. * @param disableBumpMap defines wether the material disables bump or not.
  56925. * @param isFrozen defines wether the material is frozen or not.
  56926. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56927. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56928. */
  56929. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56930. /**
  56931. * Checks to see if a texture is used in the material.
  56932. * @param texture - Base texture to use.
  56933. * @returns - Boolean specifying if a texture is used in the material.
  56934. */
  56935. hasTexture(texture: BaseTexture): boolean;
  56936. /**
  56937. * Returns an array of the actively used textures.
  56938. * @param activeTextures Array of BaseTextures
  56939. */
  56940. getActiveTextures(activeTextures: BaseTexture[]): void;
  56941. /**
  56942. * Returns the animatable textures.
  56943. * @param animatables Array of animatable textures.
  56944. */
  56945. getAnimatables(animatables: IAnimatable[]): void;
  56946. /**
  56947. * Disposes the resources of the material.
  56948. * @param forceDisposeTextures - Forces the disposal of all textures.
  56949. */
  56950. dispose(forceDisposeTextures?: boolean): void;
  56951. /**
  56952. * Get the current class name of the texture useful for serialization or dynamic coding.
  56953. * @returns "PBRClearCoatConfiguration"
  56954. */
  56955. getClassName(): string;
  56956. /**
  56957. * Add fallbacks to the effect fallbacks list.
  56958. * @param defines defines the Base texture to use.
  56959. * @param fallbacks defines the current fallback list.
  56960. * @param currentRank defines the current fallback rank.
  56961. * @returns the new fallback rank.
  56962. */
  56963. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56964. /**
  56965. * Add the required uniforms to the current list.
  56966. * @param uniforms defines the current uniform list.
  56967. */
  56968. static AddUniforms(uniforms: string[]): void;
  56969. /**
  56970. * Add the required samplers to the current list.
  56971. * @param samplers defines the current sampler list.
  56972. */
  56973. static AddSamplers(samplers: string[]): void;
  56974. /**
  56975. * Add the required uniforms to the current buffer.
  56976. * @param uniformBuffer defines the current uniform buffer.
  56977. */
  56978. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56979. /**
  56980. * Makes a duplicate of the current configuration into another one.
  56981. * @param clearCoatConfiguration define the config where to copy the info
  56982. */
  56983. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56984. /**
  56985. * Serializes this clear coat configuration.
  56986. * @returns - An object with the serialized config.
  56987. */
  56988. serialize(): any;
  56989. /**
  56990. * Parses a anisotropy Configuration from a serialized object.
  56991. * @param source - Serialized object.
  56992. * @param scene Defines the scene we are parsing for
  56993. * @param rootUrl Defines the rootUrl to load from
  56994. */
  56995. parse(source: any, scene: Scene, rootUrl: string): void;
  56996. }
  56997. }
  56998. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56999. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57001. import { Vector2 } from "babylonjs/Maths/math.vector";
  57002. import { Scene } from "babylonjs/scene";
  57003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57004. import { Nullable } from "babylonjs/types";
  57005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57006. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57007. /**
  57008. * @hidden
  57009. */
  57010. export interface IMaterialAnisotropicDefines {
  57011. ANISOTROPIC: boolean;
  57012. ANISOTROPIC_TEXTURE: boolean;
  57013. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57014. MAINUV1: boolean;
  57015. _areTexturesDirty: boolean;
  57016. _needUVs: boolean;
  57017. }
  57018. /**
  57019. * Define the code related to the anisotropic parameters of the pbr material.
  57020. */
  57021. export class PBRAnisotropicConfiguration {
  57022. private _isEnabled;
  57023. /**
  57024. * Defines if the anisotropy is enabled in the material.
  57025. */
  57026. isEnabled: boolean;
  57027. /**
  57028. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57029. */
  57030. intensity: number;
  57031. /**
  57032. * Defines if the effect is along the tangents, bitangents or in between.
  57033. * By default, the effect is "strectching" the highlights along the tangents.
  57034. */
  57035. direction: Vector2;
  57036. private _texture;
  57037. /**
  57038. * Stores the anisotropy values in a texture.
  57039. * rg is direction (like normal from -1 to 1)
  57040. * b is a intensity
  57041. */
  57042. texture: Nullable<BaseTexture>;
  57043. /** @hidden */
  57044. private _internalMarkAllSubMeshesAsTexturesDirty;
  57045. /** @hidden */
  57046. _markAllSubMeshesAsTexturesDirty(): void;
  57047. /**
  57048. * Instantiate a new istance of anisotropy configuration.
  57049. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57050. */
  57051. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57052. /**
  57053. * Specifies that the submesh is ready to be used.
  57054. * @param defines the list of "defines" to update.
  57055. * @param scene defines the scene the material belongs to.
  57056. * @returns - boolean indicating that the submesh is ready or not.
  57057. */
  57058. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57059. /**
  57060. * Checks to see if a texture is used in the material.
  57061. * @param defines the list of "defines" to update.
  57062. * @param mesh the mesh we are preparing the defines for.
  57063. * @param scene defines the scene the material belongs to.
  57064. */
  57065. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57066. /**
  57067. * Binds the material data.
  57068. * @param uniformBuffer defines the Uniform buffer to fill in.
  57069. * @param scene defines the scene the material belongs to.
  57070. * @param isFrozen defines wether the material is frozen or not.
  57071. */
  57072. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57073. /**
  57074. * Checks to see if a texture is used in the material.
  57075. * @param texture - Base texture to use.
  57076. * @returns - Boolean specifying if a texture is used in the material.
  57077. */
  57078. hasTexture(texture: BaseTexture): boolean;
  57079. /**
  57080. * Returns an array of the actively used textures.
  57081. * @param activeTextures Array of BaseTextures
  57082. */
  57083. getActiveTextures(activeTextures: BaseTexture[]): void;
  57084. /**
  57085. * Returns the animatable textures.
  57086. * @param animatables Array of animatable textures.
  57087. */
  57088. getAnimatables(animatables: IAnimatable[]): void;
  57089. /**
  57090. * Disposes the resources of the material.
  57091. * @param forceDisposeTextures - Forces the disposal of all textures.
  57092. */
  57093. dispose(forceDisposeTextures?: boolean): void;
  57094. /**
  57095. * Get the current class name of the texture useful for serialization or dynamic coding.
  57096. * @returns "PBRAnisotropicConfiguration"
  57097. */
  57098. getClassName(): string;
  57099. /**
  57100. * Add fallbacks to the effect fallbacks list.
  57101. * @param defines defines the Base texture to use.
  57102. * @param fallbacks defines the current fallback list.
  57103. * @param currentRank defines the current fallback rank.
  57104. * @returns the new fallback rank.
  57105. */
  57106. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57107. /**
  57108. * Add the required uniforms to the current list.
  57109. * @param uniforms defines the current uniform list.
  57110. */
  57111. static AddUniforms(uniforms: string[]): void;
  57112. /**
  57113. * Add the required uniforms to the current buffer.
  57114. * @param uniformBuffer defines the current uniform buffer.
  57115. */
  57116. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57117. /**
  57118. * Add the required samplers to the current list.
  57119. * @param samplers defines the current sampler list.
  57120. */
  57121. static AddSamplers(samplers: string[]): void;
  57122. /**
  57123. * Makes a duplicate of the current configuration into another one.
  57124. * @param anisotropicConfiguration define the config where to copy the info
  57125. */
  57126. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57127. /**
  57128. * Serializes this anisotropy configuration.
  57129. * @returns - An object with the serialized config.
  57130. */
  57131. serialize(): any;
  57132. /**
  57133. * Parses a anisotropy Configuration from a serialized object.
  57134. * @param source - Serialized object.
  57135. * @param scene Defines the scene we are parsing for
  57136. * @param rootUrl Defines the rootUrl to load from
  57137. */
  57138. parse(source: any, scene: Scene, rootUrl: string): void;
  57139. }
  57140. }
  57141. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57142. import { Scene } from "babylonjs/scene";
  57143. /**
  57144. * @hidden
  57145. */
  57146. export interface IMaterialBRDFDefines {
  57147. BRDF_V_HEIGHT_CORRELATED: boolean;
  57148. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57149. SPHERICAL_HARMONICS: boolean;
  57150. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57151. /** @hidden */
  57152. _areMiscDirty: boolean;
  57153. }
  57154. /**
  57155. * Define the code related to the BRDF parameters of the pbr material.
  57156. */
  57157. export class PBRBRDFConfiguration {
  57158. /**
  57159. * Default value used for the energy conservation.
  57160. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57161. */
  57162. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57163. /**
  57164. * Default value used for the Smith Visibility Height Correlated mode.
  57165. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57166. */
  57167. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57168. /**
  57169. * Default value used for the IBL diffuse part.
  57170. * This can help switching back to the polynomials mode globally which is a tiny bit
  57171. * less GPU intensive at the drawback of a lower quality.
  57172. */
  57173. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57174. /**
  57175. * Default value used for activating energy conservation for the specular workflow.
  57176. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57177. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57178. */
  57179. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57180. private _useEnergyConservation;
  57181. /**
  57182. * Defines if the material uses energy conservation.
  57183. */
  57184. useEnergyConservation: boolean;
  57185. private _useSmithVisibilityHeightCorrelated;
  57186. /**
  57187. * LEGACY Mode set to false
  57188. * Defines if the material uses height smith correlated visibility term.
  57189. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57190. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57191. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57192. * Not relying on height correlated will also disable energy conservation.
  57193. */
  57194. useSmithVisibilityHeightCorrelated: boolean;
  57195. private _useSphericalHarmonics;
  57196. /**
  57197. * LEGACY Mode set to false
  57198. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57199. * diffuse part of the IBL.
  57200. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57201. * to the ground truth.
  57202. */
  57203. useSphericalHarmonics: boolean;
  57204. private _useSpecularGlossinessInputEnergyConservation;
  57205. /**
  57206. * Defines if the material uses energy conservation, when the specular workflow is active.
  57207. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57208. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57209. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57210. */
  57211. useSpecularGlossinessInputEnergyConservation: boolean;
  57212. /** @hidden */
  57213. private _internalMarkAllSubMeshesAsMiscDirty;
  57214. /** @hidden */
  57215. _markAllSubMeshesAsMiscDirty(): void;
  57216. /**
  57217. * Instantiate a new istance of clear coat configuration.
  57218. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57219. */
  57220. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57221. /**
  57222. * Checks to see if a texture is used in the material.
  57223. * @param defines the list of "defines" to update.
  57224. */
  57225. prepareDefines(defines: IMaterialBRDFDefines): void;
  57226. /**
  57227. * Get the current class name of the texture useful for serialization or dynamic coding.
  57228. * @returns "PBRClearCoatConfiguration"
  57229. */
  57230. getClassName(): string;
  57231. /**
  57232. * Makes a duplicate of the current configuration into another one.
  57233. * @param brdfConfiguration define the config where to copy the info
  57234. */
  57235. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57236. /**
  57237. * Serializes this BRDF configuration.
  57238. * @returns - An object with the serialized config.
  57239. */
  57240. serialize(): any;
  57241. /**
  57242. * Parses a anisotropy Configuration from a serialized object.
  57243. * @param source - Serialized object.
  57244. * @param scene Defines the scene we are parsing for
  57245. * @param rootUrl Defines the rootUrl to load from
  57246. */
  57247. parse(source: any, scene: Scene, rootUrl: string): void;
  57248. }
  57249. }
  57250. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57251. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57252. import { Color3 } from "babylonjs/Maths/math.color";
  57253. import { Scene } from "babylonjs/scene";
  57254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57255. import { Nullable } from "babylonjs/types";
  57256. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57257. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57258. /**
  57259. * @hidden
  57260. */
  57261. export interface IMaterialSheenDefines {
  57262. SHEEN: boolean;
  57263. SHEEN_TEXTURE: boolean;
  57264. SHEEN_TEXTUREDIRECTUV: number;
  57265. SHEEN_LINKWITHALBEDO: boolean;
  57266. SHEEN_ROUGHNESS: boolean;
  57267. SHEEN_ALBEDOSCALING: boolean;
  57268. /** @hidden */
  57269. _areTexturesDirty: boolean;
  57270. }
  57271. /**
  57272. * Define the code related to the Sheen parameters of the pbr material.
  57273. */
  57274. export class PBRSheenConfiguration {
  57275. private _isEnabled;
  57276. /**
  57277. * Defines if the material uses sheen.
  57278. */
  57279. isEnabled: boolean;
  57280. private _linkSheenWithAlbedo;
  57281. /**
  57282. * Defines if the sheen is linked to the sheen color.
  57283. */
  57284. linkSheenWithAlbedo: boolean;
  57285. /**
  57286. * Defines the sheen intensity.
  57287. */
  57288. intensity: number;
  57289. /**
  57290. * Defines the sheen color.
  57291. */
  57292. color: Color3;
  57293. private _texture;
  57294. /**
  57295. * Stores the sheen tint values in a texture.
  57296. * rgb is tint
  57297. * a is a intensity or roughness if roughness has been defined
  57298. */
  57299. texture: Nullable<BaseTexture>;
  57300. private _roughness;
  57301. /**
  57302. * Defines the sheen roughness.
  57303. * It is not taken into account if linkSheenWithAlbedo is true.
  57304. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57305. */
  57306. roughness: Nullable<number>;
  57307. private _albedoScaling;
  57308. /**
  57309. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57310. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57311. * making it easier to setup and tweak the effect
  57312. */
  57313. albedoScaling: boolean;
  57314. /** @hidden */
  57315. private _internalMarkAllSubMeshesAsTexturesDirty;
  57316. /** @hidden */
  57317. _markAllSubMeshesAsTexturesDirty(): void;
  57318. /**
  57319. * Instantiate a new istance of clear coat configuration.
  57320. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57321. */
  57322. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57323. /**
  57324. * Specifies that the submesh is ready to be used.
  57325. * @param defines the list of "defines" to update.
  57326. * @param scene defines the scene the material belongs to.
  57327. * @returns - boolean indicating that the submesh is ready or not.
  57328. */
  57329. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57330. /**
  57331. * Checks to see if a texture is used in the material.
  57332. * @param defines the list of "defines" to update.
  57333. * @param scene defines the scene the material belongs to.
  57334. */
  57335. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57336. /**
  57337. * Binds the material data.
  57338. * @param uniformBuffer defines the Uniform buffer to fill in.
  57339. * @param scene defines the scene the material belongs to.
  57340. * @param isFrozen defines wether the material is frozen or not.
  57341. */
  57342. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57343. /**
  57344. * Checks to see if a texture is used in the material.
  57345. * @param texture - Base texture to use.
  57346. * @returns - Boolean specifying if a texture is used in the material.
  57347. */
  57348. hasTexture(texture: BaseTexture): boolean;
  57349. /**
  57350. * Returns an array of the actively used textures.
  57351. * @param activeTextures Array of BaseTextures
  57352. */
  57353. getActiveTextures(activeTextures: BaseTexture[]): void;
  57354. /**
  57355. * Returns the animatable textures.
  57356. * @param animatables Array of animatable textures.
  57357. */
  57358. getAnimatables(animatables: IAnimatable[]): void;
  57359. /**
  57360. * Disposes the resources of the material.
  57361. * @param forceDisposeTextures - Forces the disposal of all textures.
  57362. */
  57363. dispose(forceDisposeTextures?: boolean): void;
  57364. /**
  57365. * Get the current class name of the texture useful for serialization or dynamic coding.
  57366. * @returns "PBRSheenConfiguration"
  57367. */
  57368. getClassName(): string;
  57369. /**
  57370. * Add fallbacks to the effect fallbacks list.
  57371. * @param defines defines the Base texture to use.
  57372. * @param fallbacks defines the current fallback list.
  57373. * @param currentRank defines the current fallback rank.
  57374. * @returns the new fallback rank.
  57375. */
  57376. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57377. /**
  57378. * Add the required uniforms to the current list.
  57379. * @param uniforms defines the current uniform list.
  57380. */
  57381. static AddUniforms(uniforms: string[]): void;
  57382. /**
  57383. * Add the required uniforms to the current buffer.
  57384. * @param uniformBuffer defines the current uniform buffer.
  57385. */
  57386. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57387. /**
  57388. * Add the required samplers to the current list.
  57389. * @param samplers defines the current sampler list.
  57390. */
  57391. static AddSamplers(samplers: string[]): void;
  57392. /**
  57393. * Makes a duplicate of the current configuration into another one.
  57394. * @param sheenConfiguration define the config where to copy the info
  57395. */
  57396. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57397. /**
  57398. * Serializes this BRDF configuration.
  57399. * @returns - An object with the serialized config.
  57400. */
  57401. serialize(): any;
  57402. /**
  57403. * Parses a anisotropy Configuration from a serialized object.
  57404. * @param source - Serialized object.
  57405. * @param scene Defines the scene we are parsing for
  57406. * @param rootUrl Defines the rootUrl to load from
  57407. */
  57408. parse(source: any, scene: Scene, rootUrl: string): void;
  57409. }
  57410. }
  57411. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57412. import { Nullable } from "babylonjs/types";
  57413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57414. import { Color3 } from "babylonjs/Maths/math.color";
  57415. import { SmartArray } from "babylonjs/Misc/smartArray";
  57416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57418. import { Effect } from "babylonjs/Materials/effect";
  57419. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57420. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57421. import { Engine } from "babylonjs/Engines/engine";
  57422. import { Scene } from "babylonjs/scene";
  57423. /**
  57424. * @hidden
  57425. */
  57426. export interface IMaterialSubSurfaceDefines {
  57427. SUBSURFACE: boolean;
  57428. SS_REFRACTION: boolean;
  57429. SS_TRANSLUCENCY: boolean;
  57430. SS_SCATTERING: boolean;
  57431. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57432. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57433. SS_REFRACTIONMAP_3D: boolean;
  57434. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57435. SS_LODINREFRACTIONALPHA: boolean;
  57436. SS_GAMMAREFRACTION: boolean;
  57437. SS_RGBDREFRACTION: boolean;
  57438. SS_LINEARSPECULARREFRACTION: boolean;
  57439. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57440. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57441. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57442. /** @hidden */
  57443. _areTexturesDirty: boolean;
  57444. }
  57445. /**
  57446. * Define the code related to the sub surface parameters of the pbr material.
  57447. */
  57448. export class PBRSubSurfaceConfiguration {
  57449. private _isRefractionEnabled;
  57450. /**
  57451. * Defines if the refraction is enabled in the material.
  57452. */
  57453. isRefractionEnabled: boolean;
  57454. private _isTranslucencyEnabled;
  57455. /**
  57456. * Defines if the translucency is enabled in the material.
  57457. */
  57458. isTranslucencyEnabled: boolean;
  57459. private _isScatteringEnabled;
  57460. /**
  57461. * Defines if the sub surface scattering is enabled in the material.
  57462. */
  57463. isScatteringEnabled: boolean;
  57464. private _scatteringDiffusionProfileIndex;
  57465. /**
  57466. * Diffusion profile for subsurface scattering.
  57467. * Useful for better scattering in the skins or foliages.
  57468. */
  57469. get scatteringDiffusionProfile(): Nullable<Color3>;
  57470. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57471. /**
  57472. * Defines the refraction intensity of the material.
  57473. * The refraction when enabled replaces the Diffuse part of the material.
  57474. * The intensity helps transitionning between diffuse and refraction.
  57475. */
  57476. refractionIntensity: number;
  57477. /**
  57478. * Defines the translucency intensity of the material.
  57479. * When translucency has been enabled, this defines how much of the "translucency"
  57480. * is addded to the diffuse part of the material.
  57481. */
  57482. translucencyIntensity: number;
  57483. /**
  57484. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57485. */
  57486. useAlbedoToTintRefraction: boolean;
  57487. private _thicknessTexture;
  57488. /**
  57489. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57490. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57491. * 0 would mean minimumThickness
  57492. * 1 would mean maximumThickness
  57493. * The other channels might be use as a mask to vary the different effects intensity.
  57494. */
  57495. thicknessTexture: Nullable<BaseTexture>;
  57496. private _refractionTexture;
  57497. /**
  57498. * Defines the texture to use for refraction.
  57499. */
  57500. refractionTexture: Nullable<BaseTexture>;
  57501. private _indexOfRefraction;
  57502. /**
  57503. * Index of refraction of the material base layer.
  57504. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57505. *
  57506. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57507. *
  57508. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57509. */
  57510. indexOfRefraction: number;
  57511. private _volumeIndexOfRefraction;
  57512. /**
  57513. * Index of refraction of the material's volume.
  57514. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57515. *
  57516. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57517. * the volume will use the same IOR as the surface.
  57518. */
  57519. get volumeIndexOfRefraction(): number;
  57520. set volumeIndexOfRefraction(value: number);
  57521. private _invertRefractionY;
  57522. /**
  57523. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57524. */
  57525. invertRefractionY: boolean;
  57526. private _linkRefractionWithTransparency;
  57527. /**
  57528. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57529. * Materials half opaque for instance using refraction could benefit from this control.
  57530. */
  57531. linkRefractionWithTransparency: boolean;
  57532. /**
  57533. * Defines the minimum thickness stored in the thickness map.
  57534. * If no thickness map is defined, this value will be used to simulate thickness.
  57535. */
  57536. minimumThickness: number;
  57537. /**
  57538. * Defines the maximum thickness stored in the thickness map.
  57539. */
  57540. maximumThickness: number;
  57541. /**
  57542. * Defines the volume tint of the material.
  57543. * This is used for both translucency and scattering.
  57544. */
  57545. tintColor: Color3;
  57546. /**
  57547. * Defines the distance at which the tint color should be found in the media.
  57548. * This is used for refraction only.
  57549. */
  57550. tintColorAtDistance: number;
  57551. /**
  57552. * Defines how far each channel transmit through the media.
  57553. * It is defined as a color to simplify it selection.
  57554. */
  57555. diffusionDistance: Color3;
  57556. private _useMaskFromThicknessTexture;
  57557. /**
  57558. * Stores the intensity of the different subsurface effects in the thickness texture.
  57559. * * the green channel is the translucency intensity.
  57560. * * the blue channel is the scattering intensity.
  57561. * * the alpha channel is the refraction intensity.
  57562. */
  57563. useMaskFromThicknessTexture: boolean;
  57564. private _scene;
  57565. /** @hidden */
  57566. private _internalMarkAllSubMeshesAsTexturesDirty;
  57567. private _internalMarkScenePrePassDirty;
  57568. /** @hidden */
  57569. _markAllSubMeshesAsTexturesDirty(): void;
  57570. /** @hidden */
  57571. _markScenePrePassDirty(): void;
  57572. /**
  57573. * Instantiate a new istance of sub surface configuration.
  57574. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57575. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57576. * @param scene The scene
  57577. */
  57578. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57579. /**
  57580. * Gets wehter the submesh is ready to be used or not.
  57581. * @param defines the list of "defines" to update.
  57582. * @param scene defines the scene the material belongs to.
  57583. * @returns - boolean indicating that the submesh is ready or not.
  57584. */
  57585. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57586. /**
  57587. * Checks to see if a texture is used in the material.
  57588. * @param defines the list of "defines" to update.
  57589. * @param scene defines the scene to the material belongs to.
  57590. */
  57591. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57592. /**
  57593. * Binds the material data.
  57594. * @param uniformBuffer defines the Uniform buffer to fill in.
  57595. * @param scene defines the scene the material belongs to.
  57596. * @param engine defines the engine the material belongs to.
  57597. * @param isFrozen defines whether the material is frozen or not.
  57598. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57599. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57600. */
  57601. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57602. /**
  57603. * Unbinds the material from the mesh.
  57604. * @param activeEffect defines the effect that should be unbound from.
  57605. * @returns true if unbound, otherwise false
  57606. */
  57607. unbind(activeEffect: Effect): boolean;
  57608. /**
  57609. * Returns the texture used for refraction or null if none is used.
  57610. * @param scene defines the scene the material belongs to.
  57611. * @returns - Refraction texture if present. If no refraction texture and refraction
  57612. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57613. */
  57614. private _getRefractionTexture;
  57615. /**
  57616. * Returns true if alpha blending should be disabled.
  57617. */
  57618. get disableAlphaBlending(): boolean;
  57619. /**
  57620. * Fills the list of render target textures.
  57621. * @param renderTargets the list of render targets to update
  57622. */
  57623. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57624. /**
  57625. * Checks to see if a texture is used in the material.
  57626. * @param texture - Base texture to use.
  57627. * @returns - Boolean specifying if a texture is used in the material.
  57628. */
  57629. hasTexture(texture: BaseTexture): boolean;
  57630. /**
  57631. * Gets a boolean indicating that current material needs to register RTT
  57632. * @returns true if this uses a render target otherwise false.
  57633. */
  57634. hasRenderTargetTextures(): boolean;
  57635. /**
  57636. * Returns an array of the actively used textures.
  57637. * @param activeTextures Array of BaseTextures
  57638. */
  57639. getActiveTextures(activeTextures: BaseTexture[]): void;
  57640. /**
  57641. * Returns the animatable textures.
  57642. * @param animatables Array of animatable textures.
  57643. */
  57644. getAnimatables(animatables: IAnimatable[]): void;
  57645. /**
  57646. * Disposes the resources of the material.
  57647. * @param forceDisposeTextures - Forces the disposal of all textures.
  57648. */
  57649. dispose(forceDisposeTextures?: boolean): void;
  57650. /**
  57651. * Get the current class name of the texture useful for serialization or dynamic coding.
  57652. * @returns "PBRSubSurfaceConfiguration"
  57653. */
  57654. getClassName(): string;
  57655. /**
  57656. * Add fallbacks to the effect fallbacks list.
  57657. * @param defines defines the Base texture to use.
  57658. * @param fallbacks defines the current fallback list.
  57659. * @param currentRank defines the current fallback rank.
  57660. * @returns the new fallback rank.
  57661. */
  57662. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57663. /**
  57664. * Add the required uniforms to the current list.
  57665. * @param uniforms defines the current uniform list.
  57666. */
  57667. static AddUniforms(uniforms: string[]): void;
  57668. /**
  57669. * Add the required samplers to the current list.
  57670. * @param samplers defines the current sampler list.
  57671. */
  57672. static AddSamplers(samplers: string[]): void;
  57673. /**
  57674. * Add the required uniforms to the current buffer.
  57675. * @param uniformBuffer defines the current uniform buffer.
  57676. */
  57677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57678. /**
  57679. * Makes a duplicate of the current configuration into another one.
  57680. * @param configuration define the config where to copy the info
  57681. */
  57682. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57683. /**
  57684. * Serializes this Sub Surface configuration.
  57685. * @returns - An object with the serialized config.
  57686. */
  57687. serialize(): any;
  57688. /**
  57689. * Parses a anisotropy Configuration from a serialized object.
  57690. * @param source - Serialized object.
  57691. * @param scene Defines the scene we are parsing for
  57692. * @param rootUrl Defines the rootUrl to load from
  57693. */
  57694. parse(source: any, scene: Scene, rootUrl: string): void;
  57695. }
  57696. }
  57697. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57698. /** @hidden */
  57699. export var pbrFragmentDeclaration: {
  57700. name: string;
  57701. shader: string;
  57702. };
  57703. }
  57704. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57705. /** @hidden */
  57706. export var pbrUboDeclaration: {
  57707. name: string;
  57708. shader: string;
  57709. };
  57710. }
  57711. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57712. /** @hidden */
  57713. export var pbrFragmentExtraDeclaration: {
  57714. name: string;
  57715. shader: string;
  57716. };
  57717. }
  57718. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57719. /** @hidden */
  57720. export var pbrFragmentSamplersDeclaration: {
  57721. name: string;
  57722. shader: string;
  57723. };
  57724. }
  57725. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57726. /** @hidden */
  57727. export var importanceSampling: {
  57728. name: string;
  57729. shader: string;
  57730. };
  57731. }
  57732. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57733. /** @hidden */
  57734. export var pbrHelperFunctions: {
  57735. name: string;
  57736. shader: string;
  57737. };
  57738. }
  57739. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57740. /** @hidden */
  57741. export var harmonicsFunctions: {
  57742. name: string;
  57743. shader: string;
  57744. };
  57745. }
  57746. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57747. /** @hidden */
  57748. export var pbrDirectLightingSetupFunctions: {
  57749. name: string;
  57750. shader: string;
  57751. };
  57752. }
  57753. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57754. /** @hidden */
  57755. export var pbrDirectLightingFalloffFunctions: {
  57756. name: string;
  57757. shader: string;
  57758. };
  57759. }
  57760. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57761. /** @hidden */
  57762. export var pbrBRDFFunctions: {
  57763. name: string;
  57764. shader: string;
  57765. };
  57766. }
  57767. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57768. /** @hidden */
  57769. export var hdrFilteringFunctions: {
  57770. name: string;
  57771. shader: string;
  57772. };
  57773. }
  57774. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57775. /** @hidden */
  57776. export var pbrDirectLightingFunctions: {
  57777. name: string;
  57778. shader: string;
  57779. };
  57780. }
  57781. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57782. /** @hidden */
  57783. export var pbrIBLFunctions: {
  57784. name: string;
  57785. shader: string;
  57786. };
  57787. }
  57788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57789. /** @hidden */
  57790. export var pbrBlockAlbedoOpacity: {
  57791. name: string;
  57792. shader: string;
  57793. };
  57794. }
  57795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57796. /** @hidden */
  57797. export var pbrBlockReflectivity: {
  57798. name: string;
  57799. shader: string;
  57800. };
  57801. }
  57802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57803. /** @hidden */
  57804. export var pbrBlockAmbientOcclusion: {
  57805. name: string;
  57806. shader: string;
  57807. };
  57808. }
  57809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57810. /** @hidden */
  57811. export var pbrBlockAlphaFresnel: {
  57812. name: string;
  57813. shader: string;
  57814. };
  57815. }
  57816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57817. /** @hidden */
  57818. export var pbrBlockAnisotropic: {
  57819. name: string;
  57820. shader: string;
  57821. };
  57822. }
  57823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57824. /** @hidden */
  57825. export var pbrBlockReflection: {
  57826. name: string;
  57827. shader: string;
  57828. };
  57829. }
  57830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57831. /** @hidden */
  57832. export var pbrBlockSheen: {
  57833. name: string;
  57834. shader: string;
  57835. };
  57836. }
  57837. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57838. /** @hidden */
  57839. export var pbrBlockClearcoat: {
  57840. name: string;
  57841. shader: string;
  57842. };
  57843. }
  57844. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57845. /** @hidden */
  57846. export var pbrBlockSubSurface: {
  57847. name: string;
  57848. shader: string;
  57849. };
  57850. }
  57851. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57852. /** @hidden */
  57853. export var pbrBlockNormalGeometric: {
  57854. name: string;
  57855. shader: string;
  57856. };
  57857. }
  57858. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57859. /** @hidden */
  57860. export var pbrBlockNormalFinal: {
  57861. name: string;
  57862. shader: string;
  57863. };
  57864. }
  57865. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  57866. /** @hidden */
  57867. export var pbrBlockLightmapInit: {
  57868. name: string;
  57869. shader: string;
  57870. };
  57871. }
  57872. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57873. /** @hidden */
  57874. export var pbrBlockGeometryInfo: {
  57875. name: string;
  57876. shader: string;
  57877. };
  57878. }
  57879. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57880. /** @hidden */
  57881. export var pbrBlockReflectance0: {
  57882. name: string;
  57883. shader: string;
  57884. };
  57885. }
  57886. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57887. /** @hidden */
  57888. export var pbrBlockReflectance: {
  57889. name: string;
  57890. shader: string;
  57891. };
  57892. }
  57893. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57894. /** @hidden */
  57895. export var pbrBlockDirectLighting: {
  57896. name: string;
  57897. shader: string;
  57898. };
  57899. }
  57900. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57901. /** @hidden */
  57902. export var pbrBlockFinalLitComponents: {
  57903. name: string;
  57904. shader: string;
  57905. };
  57906. }
  57907. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57908. /** @hidden */
  57909. export var pbrBlockFinalUnlitComponents: {
  57910. name: string;
  57911. shader: string;
  57912. };
  57913. }
  57914. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57915. /** @hidden */
  57916. export var pbrBlockFinalColorComposition: {
  57917. name: string;
  57918. shader: string;
  57919. };
  57920. }
  57921. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57922. /** @hidden */
  57923. export var pbrBlockImageProcessing: {
  57924. name: string;
  57925. shader: string;
  57926. };
  57927. }
  57928. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57929. /** @hidden */
  57930. export var pbrDebug: {
  57931. name: string;
  57932. shader: string;
  57933. };
  57934. }
  57935. declare module "babylonjs/Shaders/pbr.fragment" {
  57936. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57937. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57938. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57939. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57940. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57941. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57942. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57943. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57944. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57945. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57946. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57947. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57948. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57949. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57950. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57951. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57952. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57953. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57954. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57955. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57956. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57957. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57958. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57959. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57960. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57961. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57962. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57963. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57964. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57965. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57966. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57967. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57968. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57969. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57970. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57971. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57972. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57973. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57974. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57975. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57976. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57977. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  57978. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57979. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57980. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57981. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57982. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57983. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57984. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57985. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57986. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57987. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57988. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57989. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57990. /** @hidden */
  57991. export var pbrPixelShader: {
  57992. name: string;
  57993. shader: string;
  57994. };
  57995. }
  57996. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57997. /** @hidden */
  57998. export var pbrVertexDeclaration: {
  57999. name: string;
  58000. shader: string;
  58001. };
  58002. }
  58003. declare module "babylonjs/Shaders/pbr.vertex" {
  58004. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58005. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58006. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58007. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58008. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58009. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58010. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58011. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58012. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58013. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58014. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58016. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58017. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58018. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58019. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58020. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58021. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58022. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58023. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58024. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58025. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58026. /** @hidden */
  58027. export var pbrVertexShader: {
  58028. name: string;
  58029. shader: string;
  58030. };
  58031. }
  58032. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58033. import { Nullable } from "babylonjs/types";
  58034. import { Scene } from "babylonjs/scene";
  58035. import { Matrix } from "babylonjs/Maths/math.vector";
  58036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58038. import { Mesh } from "babylonjs/Meshes/mesh";
  58039. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58040. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58041. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58042. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58043. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58044. import { Color3 } from "babylonjs/Maths/math.color";
  58045. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58046. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58048. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58050. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58051. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58052. import "babylonjs/Shaders/pbr.fragment";
  58053. import "babylonjs/Shaders/pbr.vertex";
  58054. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58055. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58056. /**
  58057. * Manages the defines for the PBR Material.
  58058. * @hidden
  58059. */
  58060. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58061. PBR: boolean;
  58062. NUM_SAMPLES: string;
  58063. REALTIME_FILTERING: boolean;
  58064. MAINUV1: boolean;
  58065. MAINUV2: boolean;
  58066. UV1: boolean;
  58067. UV2: boolean;
  58068. ALBEDO: boolean;
  58069. GAMMAALBEDO: boolean;
  58070. ALBEDODIRECTUV: number;
  58071. VERTEXCOLOR: boolean;
  58072. DETAIL: boolean;
  58073. DETAILDIRECTUV: number;
  58074. DETAIL_NORMALBLENDMETHOD: number;
  58075. AMBIENT: boolean;
  58076. AMBIENTDIRECTUV: number;
  58077. AMBIENTINGRAYSCALE: boolean;
  58078. OPACITY: boolean;
  58079. VERTEXALPHA: boolean;
  58080. OPACITYDIRECTUV: number;
  58081. OPACITYRGB: boolean;
  58082. ALPHATEST: boolean;
  58083. DEPTHPREPASS: boolean;
  58084. ALPHABLEND: boolean;
  58085. ALPHAFROMALBEDO: boolean;
  58086. ALPHATESTVALUE: string;
  58087. SPECULAROVERALPHA: boolean;
  58088. RADIANCEOVERALPHA: boolean;
  58089. ALPHAFRESNEL: boolean;
  58090. LINEARALPHAFRESNEL: boolean;
  58091. PREMULTIPLYALPHA: boolean;
  58092. EMISSIVE: boolean;
  58093. EMISSIVEDIRECTUV: number;
  58094. REFLECTIVITY: boolean;
  58095. REFLECTIVITYDIRECTUV: number;
  58096. SPECULARTERM: boolean;
  58097. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58098. MICROSURFACEAUTOMATIC: boolean;
  58099. LODBASEDMICROSFURACE: boolean;
  58100. MICROSURFACEMAP: boolean;
  58101. MICROSURFACEMAPDIRECTUV: number;
  58102. METALLICWORKFLOW: boolean;
  58103. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58104. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58105. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58106. AOSTOREINMETALMAPRED: boolean;
  58107. METALLIC_REFLECTANCE: boolean;
  58108. METALLIC_REFLECTANCEDIRECTUV: number;
  58109. ENVIRONMENTBRDF: boolean;
  58110. ENVIRONMENTBRDF_RGBD: boolean;
  58111. NORMAL: boolean;
  58112. TANGENT: boolean;
  58113. BUMP: boolean;
  58114. BUMPDIRECTUV: number;
  58115. OBJECTSPACE_NORMALMAP: boolean;
  58116. PARALLAX: boolean;
  58117. PARALLAXOCCLUSION: boolean;
  58118. NORMALXYSCALE: boolean;
  58119. LIGHTMAP: boolean;
  58120. LIGHTMAPDIRECTUV: number;
  58121. USELIGHTMAPASSHADOWMAP: boolean;
  58122. GAMMALIGHTMAP: boolean;
  58123. RGBDLIGHTMAP: boolean;
  58124. REFLECTION: boolean;
  58125. REFLECTIONMAP_3D: boolean;
  58126. REFLECTIONMAP_SPHERICAL: boolean;
  58127. REFLECTIONMAP_PLANAR: boolean;
  58128. REFLECTIONMAP_CUBIC: boolean;
  58129. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58130. REFLECTIONMAP_PROJECTION: boolean;
  58131. REFLECTIONMAP_SKYBOX: boolean;
  58132. REFLECTIONMAP_EXPLICIT: boolean;
  58133. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58134. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58135. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58136. INVERTCUBICMAP: boolean;
  58137. USESPHERICALFROMREFLECTIONMAP: boolean;
  58138. USEIRRADIANCEMAP: boolean;
  58139. SPHERICAL_HARMONICS: boolean;
  58140. USESPHERICALINVERTEX: boolean;
  58141. REFLECTIONMAP_OPPOSITEZ: boolean;
  58142. LODINREFLECTIONALPHA: boolean;
  58143. GAMMAREFLECTION: boolean;
  58144. RGBDREFLECTION: boolean;
  58145. LINEARSPECULARREFLECTION: boolean;
  58146. RADIANCEOCCLUSION: boolean;
  58147. HORIZONOCCLUSION: boolean;
  58148. INSTANCES: boolean;
  58149. THIN_INSTANCES: boolean;
  58150. PREPASS: boolean;
  58151. SCENE_MRT_COUNT: number;
  58152. NUM_BONE_INFLUENCERS: number;
  58153. BonesPerMesh: number;
  58154. BONETEXTURE: boolean;
  58155. NONUNIFORMSCALING: boolean;
  58156. MORPHTARGETS: boolean;
  58157. MORPHTARGETS_NORMAL: boolean;
  58158. MORPHTARGETS_TANGENT: boolean;
  58159. MORPHTARGETS_UV: boolean;
  58160. NUM_MORPH_INFLUENCERS: number;
  58161. IMAGEPROCESSING: boolean;
  58162. VIGNETTE: boolean;
  58163. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58164. VIGNETTEBLENDMODEOPAQUE: boolean;
  58165. TONEMAPPING: boolean;
  58166. TONEMAPPING_ACES: boolean;
  58167. CONTRAST: boolean;
  58168. COLORCURVES: boolean;
  58169. COLORGRADING: boolean;
  58170. COLORGRADING3D: boolean;
  58171. SAMPLER3DGREENDEPTH: boolean;
  58172. SAMPLER3DBGRMAP: boolean;
  58173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58174. EXPOSURE: boolean;
  58175. MULTIVIEW: boolean;
  58176. USEPHYSICALLIGHTFALLOFF: boolean;
  58177. USEGLTFLIGHTFALLOFF: boolean;
  58178. TWOSIDEDLIGHTING: boolean;
  58179. SHADOWFLOAT: boolean;
  58180. CLIPPLANE: boolean;
  58181. CLIPPLANE2: boolean;
  58182. CLIPPLANE3: boolean;
  58183. CLIPPLANE4: boolean;
  58184. CLIPPLANE5: boolean;
  58185. CLIPPLANE6: boolean;
  58186. POINTSIZE: boolean;
  58187. FOG: boolean;
  58188. LOGARITHMICDEPTH: boolean;
  58189. FORCENORMALFORWARD: boolean;
  58190. SPECULARAA: boolean;
  58191. CLEARCOAT: boolean;
  58192. CLEARCOAT_DEFAULTIOR: boolean;
  58193. CLEARCOAT_TEXTURE: boolean;
  58194. CLEARCOAT_TEXTUREDIRECTUV: number;
  58195. CLEARCOAT_BUMP: boolean;
  58196. CLEARCOAT_BUMPDIRECTUV: number;
  58197. CLEARCOAT_TINT: boolean;
  58198. CLEARCOAT_TINT_TEXTURE: boolean;
  58199. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58200. ANISOTROPIC: boolean;
  58201. ANISOTROPIC_TEXTURE: boolean;
  58202. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58203. BRDF_V_HEIGHT_CORRELATED: boolean;
  58204. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58205. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58206. SHEEN: boolean;
  58207. SHEEN_TEXTURE: boolean;
  58208. SHEEN_TEXTUREDIRECTUV: number;
  58209. SHEEN_LINKWITHALBEDO: boolean;
  58210. SHEEN_ROUGHNESS: boolean;
  58211. SHEEN_ALBEDOSCALING: boolean;
  58212. SUBSURFACE: boolean;
  58213. SS_REFRACTION: boolean;
  58214. SS_TRANSLUCENCY: boolean;
  58215. SS_SCATTERING: boolean;
  58216. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58217. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58218. SS_REFRACTIONMAP_3D: boolean;
  58219. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58220. SS_LODINREFRACTIONALPHA: boolean;
  58221. SS_GAMMAREFRACTION: boolean;
  58222. SS_RGBDREFRACTION: boolean;
  58223. SS_LINEARSPECULARREFRACTION: boolean;
  58224. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58225. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58226. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58227. UNLIT: boolean;
  58228. DEBUGMODE: number;
  58229. /**
  58230. * Initializes the PBR Material defines.
  58231. */
  58232. constructor();
  58233. /**
  58234. * Resets the PBR Material defines.
  58235. */
  58236. reset(): void;
  58237. }
  58238. /**
  58239. * The Physically based material base class of BJS.
  58240. *
  58241. * This offers the main features of a standard PBR material.
  58242. * For more information, please refer to the documentation :
  58243. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58244. */
  58245. export abstract class PBRBaseMaterial extends PushMaterial {
  58246. /**
  58247. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58248. */
  58249. static readonly PBRMATERIAL_OPAQUE: number;
  58250. /**
  58251. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58252. */
  58253. static readonly PBRMATERIAL_ALPHATEST: number;
  58254. /**
  58255. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58256. */
  58257. static readonly PBRMATERIAL_ALPHABLEND: number;
  58258. /**
  58259. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58260. * They are also discarded below the alpha cutoff threshold to improve performances.
  58261. */
  58262. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58263. /**
  58264. * Defines the default value of how much AO map is occluding the analytical lights
  58265. * (point spot...).
  58266. */
  58267. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58268. /**
  58269. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58270. */
  58271. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58272. /**
  58273. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58274. * to enhance interoperability with other engines.
  58275. */
  58276. static readonly LIGHTFALLOFF_GLTF: number;
  58277. /**
  58278. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58279. * to enhance interoperability with other materials.
  58280. */
  58281. static readonly LIGHTFALLOFF_STANDARD: number;
  58282. /**
  58283. * Intensity of the direct lights e.g. the four lights available in your scene.
  58284. * This impacts both the direct diffuse and specular highlights.
  58285. */
  58286. protected _directIntensity: number;
  58287. /**
  58288. * Intensity of the emissive part of the material.
  58289. * This helps controlling the emissive effect without modifying the emissive color.
  58290. */
  58291. protected _emissiveIntensity: number;
  58292. /**
  58293. * Intensity of the environment e.g. how much the environment will light the object
  58294. * either through harmonics for rough material or through the refelction for shiny ones.
  58295. */
  58296. protected _environmentIntensity: number;
  58297. /**
  58298. * This is a special control allowing the reduction of the specular highlights coming from the
  58299. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58300. */
  58301. protected _specularIntensity: number;
  58302. /**
  58303. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58304. */
  58305. private _lightingInfos;
  58306. /**
  58307. * Debug Control allowing disabling the bump map on this material.
  58308. */
  58309. protected _disableBumpMap: boolean;
  58310. /**
  58311. * AKA Diffuse Texture in standard nomenclature.
  58312. */
  58313. protected _albedoTexture: Nullable<BaseTexture>;
  58314. /**
  58315. * AKA Occlusion Texture in other nomenclature.
  58316. */
  58317. protected _ambientTexture: Nullable<BaseTexture>;
  58318. /**
  58319. * AKA Occlusion Texture Intensity in other nomenclature.
  58320. */
  58321. protected _ambientTextureStrength: number;
  58322. /**
  58323. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58324. * 1 means it completely occludes it
  58325. * 0 mean it has no impact
  58326. */
  58327. protected _ambientTextureImpactOnAnalyticalLights: number;
  58328. /**
  58329. * Stores the alpha values in a texture.
  58330. */
  58331. protected _opacityTexture: Nullable<BaseTexture>;
  58332. /**
  58333. * Stores the reflection values in a texture.
  58334. */
  58335. protected _reflectionTexture: Nullable<BaseTexture>;
  58336. /**
  58337. * Stores the emissive values in a texture.
  58338. */
  58339. protected _emissiveTexture: Nullable<BaseTexture>;
  58340. /**
  58341. * AKA Specular texture in other nomenclature.
  58342. */
  58343. protected _reflectivityTexture: Nullable<BaseTexture>;
  58344. /**
  58345. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58346. */
  58347. protected _metallicTexture: Nullable<BaseTexture>;
  58348. /**
  58349. * Specifies the metallic scalar of the metallic/roughness workflow.
  58350. * Can also be used to scale the metalness values of the metallic texture.
  58351. */
  58352. protected _metallic: Nullable<number>;
  58353. /**
  58354. * Specifies the roughness scalar of the metallic/roughness workflow.
  58355. * Can also be used to scale the roughness values of the metallic texture.
  58356. */
  58357. protected _roughness: Nullable<number>;
  58358. /**
  58359. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58360. * By default the indexOfrefraction is used to compute F0;
  58361. *
  58362. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58363. *
  58364. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58365. * F90 = metallicReflectanceColor;
  58366. */
  58367. protected _metallicF0Factor: number;
  58368. /**
  58369. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58370. * By default the F90 is always 1;
  58371. *
  58372. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58373. *
  58374. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58375. * F90 = metallicReflectanceColor;
  58376. */
  58377. protected _metallicReflectanceColor: Color3;
  58378. /**
  58379. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58380. * This is multiply against the scalar values defined in the material.
  58381. */
  58382. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58383. /**
  58384. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58385. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58386. */
  58387. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58388. /**
  58389. * Stores surface normal data used to displace a mesh in a texture.
  58390. */
  58391. protected _bumpTexture: Nullable<BaseTexture>;
  58392. /**
  58393. * Stores the pre-calculated light information of a mesh in a texture.
  58394. */
  58395. protected _lightmapTexture: Nullable<BaseTexture>;
  58396. /**
  58397. * The color of a material in ambient lighting.
  58398. */
  58399. protected _ambientColor: Color3;
  58400. /**
  58401. * AKA Diffuse Color in other nomenclature.
  58402. */
  58403. protected _albedoColor: Color3;
  58404. /**
  58405. * AKA Specular Color in other nomenclature.
  58406. */
  58407. protected _reflectivityColor: Color3;
  58408. /**
  58409. * The color applied when light is reflected from a material.
  58410. */
  58411. protected _reflectionColor: Color3;
  58412. /**
  58413. * The color applied when light is emitted from a material.
  58414. */
  58415. protected _emissiveColor: Color3;
  58416. /**
  58417. * AKA Glossiness in other nomenclature.
  58418. */
  58419. protected _microSurface: number;
  58420. /**
  58421. * Specifies that the material will use the light map as a show map.
  58422. */
  58423. protected _useLightmapAsShadowmap: boolean;
  58424. /**
  58425. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58426. * makes the reflect vector face the model (under horizon).
  58427. */
  58428. protected _useHorizonOcclusion: boolean;
  58429. /**
  58430. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58431. * too much the area relying on ambient texture to define their ambient occlusion.
  58432. */
  58433. protected _useRadianceOcclusion: boolean;
  58434. /**
  58435. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58436. */
  58437. protected _useAlphaFromAlbedoTexture: boolean;
  58438. /**
  58439. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58440. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58441. */
  58442. protected _useSpecularOverAlpha: boolean;
  58443. /**
  58444. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58445. */
  58446. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58447. /**
  58448. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58449. */
  58450. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58451. /**
  58452. * Specifies if the metallic texture contains the roughness information in its green channel.
  58453. */
  58454. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58455. /**
  58456. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58457. */
  58458. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58459. /**
  58460. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58461. */
  58462. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58463. /**
  58464. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58465. */
  58466. protected _useAmbientInGrayScale: boolean;
  58467. /**
  58468. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58469. * The material will try to infer what glossiness each pixel should be.
  58470. */
  58471. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58472. /**
  58473. * Defines the falloff type used in this material.
  58474. * It by default is Physical.
  58475. */
  58476. protected _lightFalloff: number;
  58477. /**
  58478. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58479. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58480. */
  58481. protected _useRadianceOverAlpha: boolean;
  58482. /**
  58483. * Allows using an object space normal map (instead of tangent space).
  58484. */
  58485. protected _useObjectSpaceNormalMap: boolean;
  58486. /**
  58487. * Allows using the bump map in parallax mode.
  58488. */
  58489. protected _useParallax: boolean;
  58490. /**
  58491. * Allows using the bump map in parallax occlusion mode.
  58492. */
  58493. protected _useParallaxOcclusion: boolean;
  58494. /**
  58495. * Controls the scale bias of the parallax mode.
  58496. */
  58497. protected _parallaxScaleBias: number;
  58498. /**
  58499. * If sets to true, disables all the lights affecting the material.
  58500. */
  58501. protected _disableLighting: boolean;
  58502. /**
  58503. * Number of Simultaneous lights allowed on the material.
  58504. */
  58505. protected _maxSimultaneousLights: number;
  58506. /**
  58507. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58508. */
  58509. protected _invertNormalMapX: boolean;
  58510. /**
  58511. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58512. */
  58513. protected _invertNormalMapY: boolean;
  58514. /**
  58515. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58516. */
  58517. protected _twoSidedLighting: boolean;
  58518. /**
  58519. * Defines the alpha limits in alpha test mode.
  58520. */
  58521. protected _alphaCutOff: number;
  58522. /**
  58523. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58524. */
  58525. protected _forceAlphaTest: boolean;
  58526. /**
  58527. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58528. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58529. */
  58530. protected _useAlphaFresnel: boolean;
  58531. /**
  58532. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58533. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58534. */
  58535. protected _useLinearAlphaFresnel: boolean;
  58536. /**
  58537. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58538. * from cos thetav and roughness:
  58539. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58540. */
  58541. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58542. /**
  58543. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58544. */
  58545. protected _forceIrradianceInFragment: boolean;
  58546. private _realTimeFiltering;
  58547. /**
  58548. * Enables realtime filtering on the texture.
  58549. */
  58550. get realTimeFiltering(): boolean;
  58551. set realTimeFiltering(b: boolean);
  58552. private _realTimeFilteringQuality;
  58553. /**
  58554. * Quality switch for realtime filtering
  58555. */
  58556. get realTimeFilteringQuality(): number;
  58557. set realTimeFilteringQuality(n: number);
  58558. /**
  58559. * Can this material render to several textures at once
  58560. */
  58561. get canRenderToMRT(): boolean;
  58562. /**
  58563. * Force normal to face away from face.
  58564. */
  58565. protected _forceNormalForward: boolean;
  58566. /**
  58567. * Enables specular anti aliasing in the PBR shader.
  58568. * It will both interacts on the Geometry for analytical and IBL lighting.
  58569. * It also prefilter the roughness map based on the bump values.
  58570. */
  58571. protected _enableSpecularAntiAliasing: boolean;
  58572. /**
  58573. * Default configuration related to image processing available in the PBR Material.
  58574. */
  58575. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58576. /**
  58577. * Keep track of the image processing observer to allow dispose and replace.
  58578. */
  58579. private _imageProcessingObserver;
  58580. /**
  58581. * Attaches a new image processing configuration to the PBR Material.
  58582. * @param configuration
  58583. */
  58584. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58585. /**
  58586. * Stores the available render targets.
  58587. */
  58588. private _renderTargets;
  58589. /**
  58590. * Sets the global ambient color for the material used in lighting calculations.
  58591. */
  58592. private _globalAmbientColor;
  58593. /**
  58594. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58595. */
  58596. private _useLogarithmicDepth;
  58597. /**
  58598. * If set to true, no lighting calculations will be applied.
  58599. */
  58600. private _unlit;
  58601. private _debugMode;
  58602. /**
  58603. * @hidden
  58604. * This is reserved for the inspector.
  58605. * Defines the material debug mode.
  58606. * It helps seeing only some components of the material while troubleshooting.
  58607. */
  58608. debugMode: number;
  58609. /**
  58610. * @hidden
  58611. * This is reserved for the inspector.
  58612. * Specify from where on screen the debug mode should start.
  58613. * The value goes from -1 (full screen) to 1 (not visible)
  58614. * It helps with side by side comparison against the final render
  58615. * This defaults to -1
  58616. */
  58617. private debugLimit;
  58618. /**
  58619. * @hidden
  58620. * This is reserved for the inspector.
  58621. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58622. * You can use the factor to better multiply the final value.
  58623. */
  58624. private debugFactor;
  58625. /**
  58626. * Defines the clear coat layer parameters for the material.
  58627. */
  58628. readonly clearCoat: PBRClearCoatConfiguration;
  58629. /**
  58630. * Defines the anisotropic parameters for the material.
  58631. */
  58632. readonly anisotropy: PBRAnisotropicConfiguration;
  58633. /**
  58634. * Defines the BRDF parameters for the material.
  58635. */
  58636. readonly brdf: PBRBRDFConfiguration;
  58637. /**
  58638. * Defines the Sheen parameters for the material.
  58639. */
  58640. readonly sheen: PBRSheenConfiguration;
  58641. /**
  58642. * Defines the SubSurface parameters for the material.
  58643. */
  58644. readonly subSurface: PBRSubSurfaceConfiguration;
  58645. /**
  58646. * Defines the detail map parameters for the material.
  58647. */
  58648. readonly detailMap: DetailMapConfiguration;
  58649. protected _rebuildInParallel: boolean;
  58650. /**
  58651. * Instantiates a new PBRMaterial instance.
  58652. *
  58653. * @param name The material name
  58654. * @param scene The scene the material will be use in.
  58655. */
  58656. constructor(name: string, scene: Scene);
  58657. /**
  58658. * Gets a boolean indicating that current material needs to register RTT
  58659. */
  58660. get hasRenderTargetTextures(): boolean;
  58661. /**
  58662. * Gets the name of the material class.
  58663. */
  58664. getClassName(): string;
  58665. /**
  58666. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58667. */
  58668. get useLogarithmicDepth(): boolean;
  58669. /**
  58670. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58671. */
  58672. set useLogarithmicDepth(value: boolean);
  58673. /**
  58674. * Returns true if alpha blending should be disabled.
  58675. */
  58676. protected get _disableAlphaBlending(): boolean;
  58677. /**
  58678. * Specifies whether or not this material should be rendered in alpha blend mode.
  58679. */
  58680. needAlphaBlending(): boolean;
  58681. /**
  58682. * Specifies whether or not this material should be rendered in alpha test mode.
  58683. */
  58684. needAlphaTesting(): boolean;
  58685. /**
  58686. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58687. */
  58688. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58689. /**
  58690. * Gets the texture used for the alpha test.
  58691. */
  58692. getAlphaTestTexture(): Nullable<BaseTexture>;
  58693. /**
  58694. * Specifies that the submesh is ready to be used.
  58695. * @param mesh - BJS mesh.
  58696. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58697. * @param useInstances - Specifies that instances should be used.
  58698. * @returns - boolean indicating that the submesh is ready or not.
  58699. */
  58700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58701. /**
  58702. * Specifies if the material uses metallic roughness workflow.
  58703. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58704. */
  58705. isMetallicWorkflow(): boolean;
  58706. private _prepareEffect;
  58707. private _prepareDefines;
  58708. /**
  58709. * Force shader compilation
  58710. */
  58711. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58712. /**
  58713. * Initializes the uniform buffer layout for the shader.
  58714. */
  58715. buildUniformLayout(): void;
  58716. /**
  58717. * Unbinds the material from the mesh
  58718. */
  58719. unbind(): void;
  58720. /**
  58721. * Binds the submesh data.
  58722. * @param world - The world matrix.
  58723. * @param mesh - The BJS mesh.
  58724. * @param subMesh - A submesh of the BJS mesh.
  58725. */
  58726. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58727. /**
  58728. * Returns the animatable textures.
  58729. * @returns - Array of animatable textures.
  58730. */
  58731. getAnimatables(): IAnimatable[];
  58732. /**
  58733. * Returns the texture used for reflections.
  58734. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58735. */
  58736. private _getReflectionTexture;
  58737. /**
  58738. * Returns an array of the actively used textures.
  58739. * @returns - Array of BaseTextures
  58740. */
  58741. getActiveTextures(): BaseTexture[];
  58742. /**
  58743. * Checks to see if a texture is used in the material.
  58744. * @param texture - Base texture to use.
  58745. * @returns - Boolean specifying if a texture is used in the material.
  58746. */
  58747. hasTexture(texture: BaseTexture): boolean;
  58748. /**
  58749. * Sets the required values to the prepass renderer.
  58750. * @param prePassRenderer defines the prepass renderer to setup
  58751. */
  58752. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  58753. /**
  58754. * Disposes the resources of the material.
  58755. * @param forceDisposeEffect - Forces the disposal of effects.
  58756. * @param forceDisposeTextures - Forces the disposal of all textures.
  58757. */
  58758. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58759. }
  58760. }
  58761. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58762. import { Nullable } from "babylonjs/types";
  58763. import { Scene } from "babylonjs/scene";
  58764. import { Color3 } from "babylonjs/Maths/math.color";
  58765. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58766. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58768. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58769. /**
  58770. * The Physically based material of BJS.
  58771. *
  58772. * This offers the main features of a standard PBR material.
  58773. * For more information, please refer to the documentation :
  58774. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58775. */
  58776. export class PBRMaterial extends PBRBaseMaterial {
  58777. /**
  58778. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58779. */
  58780. static readonly PBRMATERIAL_OPAQUE: number;
  58781. /**
  58782. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58783. */
  58784. static readonly PBRMATERIAL_ALPHATEST: number;
  58785. /**
  58786. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58787. */
  58788. static readonly PBRMATERIAL_ALPHABLEND: number;
  58789. /**
  58790. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58791. * They are also discarded below the alpha cutoff threshold to improve performances.
  58792. */
  58793. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58794. /**
  58795. * Defines the default value of how much AO map is occluding the analytical lights
  58796. * (point spot...).
  58797. */
  58798. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58799. /**
  58800. * Intensity of the direct lights e.g. the four lights available in your scene.
  58801. * This impacts both the direct diffuse and specular highlights.
  58802. */
  58803. directIntensity: number;
  58804. /**
  58805. * Intensity of the emissive part of the material.
  58806. * This helps controlling the emissive effect without modifying the emissive color.
  58807. */
  58808. emissiveIntensity: number;
  58809. /**
  58810. * Intensity of the environment e.g. how much the environment will light the object
  58811. * either through harmonics for rough material or through the refelction for shiny ones.
  58812. */
  58813. environmentIntensity: number;
  58814. /**
  58815. * This is a special control allowing the reduction of the specular highlights coming from the
  58816. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58817. */
  58818. specularIntensity: number;
  58819. /**
  58820. * Debug Control allowing disabling the bump map on this material.
  58821. */
  58822. disableBumpMap: boolean;
  58823. /**
  58824. * AKA Diffuse Texture in standard nomenclature.
  58825. */
  58826. albedoTexture: BaseTexture;
  58827. /**
  58828. * AKA Occlusion Texture in other nomenclature.
  58829. */
  58830. ambientTexture: BaseTexture;
  58831. /**
  58832. * AKA Occlusion Texture Intensity in other nomenclature.
  58833. */
  58834. ambientTextureStrength: number;
  58835. /**
  58836. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58837. * 1 means it completely occludes it
  58838. * 0 mean it has no impact
  58839. */
  58840. ambientTextureImpactOnAnalyticalLights: number;
  58841. /**
  58842. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58843. */
  58844. opacityTexture: BaseTexture;
  58845. /**
  58846. * Stores the reflection values in a texture.
  58847. */
  58848. reflectionTexture: Nullable<BaseTexture>;
  58849. /**
  58850. * Stores the emissive values in a texture.
  58851. */
  58852. emissiveTexture: BaseTexture;
  58853. /**
  58854. * AKA Specular texture in other nomenclature.
  58855. */
  58856. reflectivityTexture: BaseTexture;
  58857. /**
  58858. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58859. */
  58860. metallicTexture: BaseTexture;
  58861. /**
  58862. * Specifies the metallic scalar of the metallic/roughness workflow.
  58863. * Can also be used to scale the metalness values of the metallic texture.
  58864. */
  58865. metallic: Nullable<number>;
  58866. /**
  58867. * Specifies the roughness scalar of the metallic/roughness workflow.
  58868. * Can also be used to scale the roughness values of the metallic texture.
  58869. */
  58870. roughness: Nullable<number>;
  58871. /**
  58872. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58873. * By default the indexOfrefraction is used to compute F0;
  58874. *
  58875. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58876. *
  58877. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58878. * F90 = metallicReflectanceColor;
  58879. */
  58880. metallicF0Factor: number;
  58881. /**
  58882. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58883. * By default the F90 is always 1;
  58884. *
  58885. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58886. *
  58887. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58888. * F90 = metallicReflectanceColor;
  58889. */
  58890. metallicReflectanceColor: Color3;
  58891. /**
  58892. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58893. * This is multiply against the scalar values defined in the material.
  58894. */
  58895. metallicReflectanceTexture: Nullable<BaseTexture>;
  58896. /**
  58897. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58898. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58899. */
  58900. microSurfaceTexture: BaseTexture;
  58901. /**
  58902. * Stores surface normal data used to displace a mesh in a texture.
  58903. */
  58904. bumpTexture: BaseTexture;
  58905. /**
  58906. * Stores the pre-calculated light information of a mesh in a texture.
  58907. */
  58908. lightmapTexture: BaseTexture;
  58909. /**
  58910. * Stores the refracted light information in a texture.
  58911. */
  58912. get refractionTexture(): Nullable<BaseTexture>;
  58913. set refractionTexture(value: Nullable<BaseTexture>);
  58914. /**
  58915. * The color of a material in ambient lighting.
  58916. */
  58917. ambientColor: Color3;
  58918. /**
  58919. * AKA Diffuse Color in other nomenclature.
  58920. */
  58921. albedoColor: Color3;
  58922. /**
  58923. * AKA Specular Color in other nomenclature.
  58924. */
  58925. reflectivityColor: Color3;
  58926. /**
  58927. * The color reflected from the material.
  58928. */
  58929. reflectionColor: Color3;
  58930. /**
  58931. * The color emitted from the material.
  58932. */
  58933. emissiveColor: Color3;
  58934. /**
  58935. * AKA Glossiness in other nomenclature.
  58936. */
  58937. microSurface: number;
  58938. /**
  58939. * Index of refraction of the material base layer.
  58940. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58941. *
  58942. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58943. *
  58944. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58945. */
  58946. get indexOfRefraction(): number;
  58947. set indexOfRefraction(value: number);
  58948. /**
  58949. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58950. */
  58951. get invertRefractionY(): boolean;
  58952. set invertRefractionY(value: boolean);
  58953. /**
  58954. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58955. * Materials half opaque for instance using refraction could benefit from this control.
  58956. */
  58957. get linkRefractionWithTransparency(): boolean;
  58958. set linkRefractionWithTransparency(value: boolean);
  58959. /**
  58960. * If true, the light map contains occlusion information instead of lighting info.
  58961. */
  58962. useLightmapAsShadowmap: boolean;
  58963. /**
  58964. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58965. */
  58966. useAlphaFromAlbedoTexture: boolean;
  58967. /**
  58968. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58969. */
  58970. forceAlphaTest: boolean;
  58971. /**
  58972. * Defines the alpha limits in alpha test mode.
  58973. */
  58974. alphaCutOff: number;
  58975. /**
  58976. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58977. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58978. */
  58979. useSpecularOverAlpha: boolean;
  58980. /**
  58981. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58982. */
  58983. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58984. /**
  58985. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58986. */
  58987. useRoughnessFromMetallicTextureAlpha: boolean;
  58988. /**
  58989. * Specifies if the metallic texture contains the roughness information in its green channel.
  58990. */
  58991. useRoughnessFromMetallicTextureGreen: boolean;
  58992. /**
  58993. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58994. */
  58995. useMetallnessFromMetallicTextureBlue: boolean;
  58996. /**
  58997. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58998. */
  58999. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59000. /**
  59001. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59002. */
  59003. useAmbientInGrayScale: boolean;
  59004. /**
  59005. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59006. * The material will try to infer what glossiness each pixel should be.
  59007. */
  59008. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59009. /**
  59010. * BJS is using an harcoded light falloff based on a manually sets up range.
  59011. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59012. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59013. */
  59014. get usePhysicalLightFalloff(): boolean;
  59015. /**
  59016. * BJS is using an harcoded light falloff based on a manually sets up range.
  59017. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59018. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59019. */
  59020. set usePhysicalLightFalloff(value: boolean);
  59021. /**
  59022. * In order to support the falloff compatibility with gltf, a special mode has been added
  59023. * to reproduce the gltf light falloff.
  59024. */
  59025. get useGLTFLightFalloff(): boolean;
  59026. /**
  59027. * In order to support the falloff compatibility with gltf, a special mode has been added
  59028. * to reproduce the gltf light falloff.
  59029. */
  59030. set useGLTFLightFalloff(value: boolean);
  59031. /**
  59032. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59033. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59034. */
  59035. useRadianceOverAlpha: boolean;
  59036. /**
  59037. * Allows using an object space normal map (instead of tangent space).
  59038. */
  59039. useObjectSpaceNormalMap: boolean;
  59040. /**
  59041. * Allows using the bump map in parallax mode.
  59042. */
  59043. useParallax: boolean;
  59044. /**
  59045. * Allows using the bump map in parallax occlusion mode.
  59046. */
  59047. useParallaxOcclusion: boolean;
  59048. /**
  59049. * Controls the scale bias of the parallax mode.
  59050. */
  59051. parallaxScaleBias: number;
  59052. /**
  59053. * If sets to true, disables all the lights affecting the material.
  59054. */
  59055. disableLighting: boolean;
  59056. /**
  59057. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59058. */
  59059. forceIrradianceInFragment: boolean;
  59060. /**
  59061. * Number of Simultaneous lights allowed on the material.
  59062. */
  59063. maxSimultaneousLights: number;
  59064. /**
  59065. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59066. */
  59067. invertNormalMapX: boolean;
  59068. /**
  59069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59070. */
  59071. invertNormalMapY: boolean;
  59072. /**
  59073. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59074. */
  59075. twoSidedLighting: boolean;
  59076. /**
  59077. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59078. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59079. */
  59080. useAlphaFresnel: boolean;
  59081. /**
  59082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59083. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59084. */
  59085. useLinearAlphaFresnel: boolean;
  59086. /**
  59087. * Let user defines the brdf lookup texture used for IBL.
  59088. * A default 8bit version is embedded but you could point at :
  59089. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59090. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59091. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59092. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59093. */
  59094. environmentBRDFTexture: Nullable<BaseTexture>;
  59095. /**
  59096. * Force normal to face away from face.
  59097. */
  59098. forceNormalForward: boolean;
  59099. /**
  59100. * Enables specular anti aliasing in the PBR shader.
  59101. * It will both interacts on the Geometry for analytical and IBL lighting.
  59102. * It also prefilter the roughness map based on the bump values.
  59103. */
  59104. enableSpecularAntiAliasing: boolean;
  59105. /**
  59106. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59107. * makes the reflect vector face the model (under horizon).
  59108. */
  59109. useHorizonOcclusion: boolean;
  59110. /**
  59111. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59112. * too much the area relying on ambient texture to define their ambient occlusion.
  59113. */
  59114. useRadianceOcclusion: boolean;
  59115. /**
  59116. * If set to true, no lighting calculations will be applied.
  59117. */
  59118. unlit: boolean;
  59119. /**
  59120. * Gets the image processing configuration used either in this material.
  59121. */
  59122. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59123. /**
  59124. * Sets the Default image processing configuration used either in the this material.
  59125. *
  59126. * If sets to null, the scene one is in use.
  59127. */
  59128. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59129. /**
  59130. * Gets wether the color curves effect is enabled.
  59131. */
  59132. get cameraColorCurvesEnabled(): boolean;
  59133. /**
  59134. * Sets wether the color curves effect is enabled.
  59135. */
  59136. set cameraColorCurvesEnabled(value: boolean);
  59137. /**
  59138. * Gets wether the color grading effect is enabled.
  59139. */
  59140. get cameraColorGradingEnabled(): boolean;
  59141. /**
  59142. * Gets wether the color grading effect is enabled.
  59143. */
  59144. set cameraColorGradingEnabled(value: boolean);
  59145. /**
  59146. * Gets wether tonemapping is enabled or not.
  59147. */
  59148. get cameraToneMappingEnabled(): boolean;
  59149. /**
  59150. * Sets wether tonemapping is enabled or not
  59151. */
  59152. set cameraToneMappingEnabled(value: boolean);
  59153. /**
  59154. * The camera exposure used on this material.
  59155. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59156. * This corresponds to a photographic exposure.
  59157. */
  59158. get cameraExposure(): number;
  59159. /**
  59160. * The camera exposure used on this material.
  59161. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59162. * This corresponds to a photographic exposure.
  59163. */
  59164. set cameraExposure(value: number);
  59165. /**
  59166. * Gets The camera contrast used on this material.
  59167. */
  59168. get cameraContrast(): number;
  59169. /**
  59170. * Sets The camera contrast used on this material.
  59171. */
  59172. set cameraContrast(value: number);
  59173. /**
  59174. * Gets the Color Grading 2D Lookup Texture.
  59175. */
  59176. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59177. /**
  59178. * Sets the Color Grading 2D Lookup Texture.
  59179. */
  59180. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59181. /**
  59182. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59183. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59184. * 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;
  59185. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59186. */
  59187. get cameraColorCurves(): Nullable<ColorCurves>;
  59188. /**
  59189. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59190. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59191. * 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;
  59192. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59193. */
  59194. set cameraColorCurves(value: Nullable<ColorCurves>);
  59195. /**
  59196. * Instantiates a new PBRMaterial instance.
  59197. *
  59198. * @param name The material name
  59199. * @param scene The scene the material will be use in.
  59200. */
  59201. constructor(name: string, scene: Scene);
  59202. /**
  59203. * Returns the name of this material class.
  59204. */
  59205. getClassName(): string;
  59206. /**
  59207. * Makes a duplicate of the current material.
  59208. * @param name - name to use for the new material.
  59209. */
  59210. clone(name: string): PBRMaterial;
  59211. /**
  59212. * Serializes this PBR Material.
  59213. * @returns - An object with the serialized material.
  59214. */
  59215. serialize(): any;
  59216. /**
  59217. * Parses a PBR Material from a serialized object.
  59218. * @param source - Serialized object.
  59219. * @param scene - BJS scene instance.
  59220. * @param rootUrl - url for the scene object
  59221. * @returns - PBRMaterial
  59222. */
  59223. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59224. }
  59225. }
  59226. declare module "babylonjs/Misc/dds" {
  59227. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59229. import { Nullable } from "babylonjs/types";
  59230. import { Scene } from "babylonjs/scene";
  59231. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59232. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59233. /**
  59234. * Direct draw surface info
  59235. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59236. */
  59237. export interface DDSInfo {
  59238. /**
  59239. * Width of the texture
  59240. */
  59241. width: number;
  59242. /**
  59243. * Width of the texture
  59244. */
  59245. height: number;
  59246. /**
  59247. * Number of Mipmaps for the texture
  59248. * @see https://en.wikipedia.org/wiki/Mipmap
  59249. */
  59250. mipmapCount: number;
  59251. /**
  59252. * If the textures format is a known fourCC format
  59253. * @see https://www.fourcc.org/
  59254. */
  59255. isFourCC: boolean;
  59256. /**
  59257. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59258. */
  59259. isRGB: boolean;
  59260. /**
  59261. * If the texture is a lumincance format
  59262. */
  59263. isLuminance: boolean;
  59264. /**
  59265. * If this is a cube texture
  59266. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59267. */
  59268. isCube: boolean;
  59269. /**
  59270. * If the texture is a compressed format eg. FOURCC_DXT1
  59271. */
  59272. isCompressed: boolean;
  59273. /**
  59274. * The dxgiFormat of the texture
  59275. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59276. */
  59277. dxgiFormat: number;
  59278. /**
  59279. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59280. */
  59281. textureType: number;
  59282. /**
  59283. * Sphericle polynomial created for the dds texture
  59284. */
  59285. sphericalPolynomial?: SphericalPolynomial;
  59286. }
  59287. /**
  59288. * Class used to provide DDS decompression tools
  59289. */
  59290. export class DDSTools {
  59291. /**
  59292. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59293. */
  59294. static StoreLODInAlphaChannel: boolean;
  59295. /**
  59296. * Gets DDS information from an array buffer
  59297. * @param data defines the array buffer view to read data from
  59298. * @returns the DDS information
  59299. */
  59300. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59301. private static _FloatView;
  59302. private static _Int32View;
  59303. private static _ToHalfFloat;
  59304. private static _FromHalfFloat;
  59305. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59306. private static _GetHalfFloatRGBAArrayBuffer;
  59307. private static _GetFloatRGBAArrayBuffer;
  59308. private static _GetFloatAsUIntRGBAArrayBuffer;
  59309. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59310. private static _GetRGBAArrayBuffer;
  59311. private static _ExtractLongWordOrder;
  59312. private static _GetRGBArrayBuffer;
  59313. private static _GetLuminanceArrayBuffer;
  59314. /**
  59315. * Uploads DDS Levels to a Babylon Texture
  59316. * @hidden
  59317. */
  59318. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59319. }
  59320. module "babylonjs/Engines/thinEngine" {
  59321. interface ThinEngine {
  59322. /**
  59323. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59324. * @param rootUrl defines the url where the file to load is located
  59325. * @param scene defines the current scene
  59326. * @param lodScale defines scale to apply to the mip map selection
  59327. * @param lodOffset defines offset to apply to the mip map selection
  59328. * @param onLoad defines an optional callback raised when the texture is loaded
  59329. * @param onError defines an optional callback raised if there is an issue to load the texture
  59330. * @param format defines the format of the data
  59331. * @param forcedExtension defines the extension to use to pick the right loader
  59332. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59333. * @returns the cube texture as an InternalTexture
  59334. */
  59335. 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;
  59336. }
  59337. }
  59338. }
  59339. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59340. import { Nullable } from "babylonjs/types";
  59341. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59342. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59343. /**
  59344. * Implementation of the DDS Texture Loader.
  59345. * @hidden
  59346. */
  59347. export class _DDSTextureLoader implements IInternalTextureLoader {
  59348. /**
  59349. * Defines wether the loader supports cascade loading the different faces.
  59350. */
  59351. readonly supportCascades: boolean;
  59352. /**
  59353. * This returns if the loader support the current file information.
  59354. * @param extension defines the file extension of the file being loaded
  59355. * @returns true if the loader can load the specified file
  59356. */
  59357. canLoad(extension: string): boolean;
  59358. /**
  59359. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59360. * @param data contains the texture data
  59361. * @param texture defines the BabylonJS internal texture
  59362. * @param createPolynomials will be true if polynomials have been requested
  59363. * @param onLoad defines the callback to trigger once the texture is ready
  59364. * @param onError defines the callback to trigger in case of error
  59365. */
  59366. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59367. /**
  59368. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59369. * @param data contains the texture data
  59370. * @param texture defines the BabylonJS internal texture
  59371. * @param callback defines the method to call once ready to upload
  59372. */
  59373. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59374. }
  59375. }
  59376. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59377. import { Nullable } from "babylonjs/types";
  59378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59379. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59380. /**
  59381. * Implementation of the ENV Texture Loader.
  59382. * @hidden
  59383. */
  59384. export class _ENVTextureLoader implements IInternalTextureLoader {
  59385. /**
  59386. * Defines wether the loader supports cascade loading the different faces.
  59387. */
  59388. readonly supportCascades: boolean;
  59389. /**
  59390. * This returns if the loader support the current file information.
  59391. * @param extension defines the file extension of the file being loaded
  59392. * @returns true if the loader can load the specified file
  59393. */
  59394. canLoad(extension: string): boolean;
  59395. /**
  59396. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59397. * @param data contains the texture data
  59398. * @param texture defines the BabylonJS internal texture
  59399. * @param createPolynomials will be true if polynomials have been requested
  59400. * @param onLoad defines the callback to trigger once the texture is ready
  59401. * @param onError defines the callback to trigger in case of error
  59402. */
  59403. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59404. /**
  59405. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59406. * @param data contains the texture data
  59407. * @param texture defines the BabylonJS internal texture
  59408. * @param callback defines the method to call once ready to upload
  59409. */
  59410. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59411. }
  59412. }
  59413. declare module "babylonjs/Misc/khronosTextureContainer" {
  59414. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59415. /**
  59416. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59417. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59418. */
  59419. export class KhronosTextureContainer {
  59420. /** contents of the KTX container file */
  59421. data: ArrayBufferView;
  59422. private static HEADER_LEN;
  59423. private static COMPRESSED_2D;
  59424. private static COMPRESSED_3D;
  59425. private static TEX_2D;
  59426. private static TEX_3D;
  59427. /**
  59428. * Gets the openGL type
  59429. */
  59430. glType: number;
  59431. /**
  59432. * Gets the openGL type size
  59433. */
  59434. glTypeSize: number;
  59435. /**
  59436. * Gets the openGL format
  59437. */
  59438. glFormat: number;
  59439. /**
  59440. * Gets the openGL internal format
  59441. */
  59442. glInternalFormat: number;
  59443. /**
  59444. * Gets the base internal format
  59445. */
  59446. glBaseInternalFormat: number;
  59447. /**
  59448. * Gets image width in pixel
  59449. */
  59450. pixelWidth: number;
  59451. /**
  59452. * Gets image height in pixel
  59453. */
  59454. pixelHeight: number;
  59455. /**
  59456. * Gets image depth in pixels
  59457. */
  59458. pixelDepth: number;
  59459. /**
  59460. * Gets the number of array elements
  59461. */
  59462. numberOfArrayElements: number;
  59463. /**
  59464. * Gets the number of faces
  59465. */
  59466. numberOfFaces: number;
  59467. /**
  59468. * Gets the number of mipmap levels
  59469. */
  59470. numberOfMipmapLevels: number;
  59471. /**
  59472. * Gets the bytes of key value data
  59473. */
  59474. bytesOfKeyValueData: number;
  59475. /**
  59476. * Gets the load type
  59477. */
  59478. loadType: number;
  59479. /**
  59480. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59481. */
  59482. isInvalid: boolean;
  59483. /**
  59484. * Creates a new KhronosTextureContainer
  59485. * @param data contents of the KTX container file
  59486. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59487. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59488. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59489. */
  59490. constructor(
  59491. /** contents of the KTX container file */
  59492. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59493. /**
  59494. * Uploads KTX content to a Babylon Texture.
  59495. * It is assumed that the texture has already been created & is currently bound
  59496. * @hidden
  59497. */
  59498. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59499. private _upload2DCompressedLevels;
  59500. /**
  59501. * Checks if the given data starts with a KTX file identifier.
  59502. * @param data the data to check
  59503. * @returns true if the data is a KTX file or false otherwise
  59504. */
  59505. static IsValid(data: ArrayBufferView): boolean;
  59506. }
  59507. }
  59508. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59509. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59510. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59511. /**
  59512. * Class for loading KTX2 files
  59513. * !!! Experimental Extension Subject to Changes !!!
  59514. * @hidden
  59515. */
  59516. export class KhronosTextureContainer2 {
  59517. private static _ModulePromise;
  59518. private static _TranscodeFormat;
  59519. constructor(engine: ThinEngine);
  59520. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59521. private _determineTranscodeFormat;
  59522. /**
  59523. * Checks if the given data starts with a KTX2 file identifier.
  59524. * @param data the data to check
  59525. * @returns true if the data is a KTX2 file or false otherwise
  59526. */
  59527. static IsValid(data: ArrayBufferView): boolean;
  59528. }
  59529. }
  59530. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59531. import { Nullable } from "babylonjs/types";
  59532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59533. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59534. /**
  59535. * Implementation of the KTX Texture Loader.
  59536. * @hidden
  59537. */
  59538. export class _KTXTextureLoader implements IInternalTextureLoader {
  59539. /**
  59540. * Defines wether the loader supports cascade loading the different faces.
  59541. */
  59542. readonly supportCascades: boolean;
  59543. /**
  59544. * This returns if the loader support the current file information.
  59545. * @param extension defines the file extension of the file being loaded
  59546. * @param mimeType defines the optional mime type of the file being loaded
  59547. * @returns true if the loader can load the specified file
  59548. */
  59549. canLoad(extension: string, mimeType?: string): boolean;
  59550. /**
  59551. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59552. * @param data contains the texture data
  59553. * @param texture defines the BabylonJS internal texture
  59554. * @param createPolynomials will be true if polynomials have been requested
  59555. * @param onLoad defines the callback to trigger once the texture is ready
  59556. * @param onError defines the callback to trigger in case of error
  59557. */
  59558. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59559. /**
  59560. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59561. * @param data contains the texture data
  59562. * @param texture defines the BabylonJS internal texture
  59563. * @param callback defines the method to call once ready to upload
  59564. */
  59565. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59566. }
  59567. }
  59568. declare module "babylonjs/Helpers/sceneHelpers" {
  59569. import { Nullable } from "babylonjs/types";
  59570. import { Mesh } from "babylonjs/Meshes/mesh";
  59571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59572. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59573. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59574. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59575. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59576. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59577. import "babylonjs/Meshes/Builders/boxBuilder";
  59578. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59579. /** @hidden */
  59580. export var _forceSceneHelpersToBundle: boolean;
  59581. module "babylonjs/scene" {
  59582. interface Scene {
  59583. /**
  59584. * Creates a default light for the scene.
  59585. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59586. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59587. */
  59588. createDefaultLight(replace?: boolean): void;
  59589. /**
  59590. * Creates a default camera for the scene.
  59591. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59592. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59593. * @param replace has default false, when true replaces the active camera in the scene
  59594. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59595. */
  59596. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59597. /**
  59598. * Creates a default camera and a default light.
  59599. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59600. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59601. * @param replace has the default false, when true replaces the active camera/light in the scene
  59602. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59603. */
  59604. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59605. /**
  59606. * Creates a new sky box
  59607. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59608. * @param environmentTexture defines the texture to use as environment texture
  59609. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59610. * @param scale defines the overall scale of the skybox
  59611. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59612. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59613. * @returns a new mesh holding the sky box
  59614. */
  59615. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59616. /**
  59617. * Creates a new environment
  59618. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59619. * @param options defines the options you can use to configure the environment
  59620. * @returns the new EnvironmentHelper
  59621. */
  59622. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59623. /**
  59624. * Creates a new VREXperienceHelper
  59625. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59626. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59627. * @returns a new VREXperienceHelper
  59628. */
  59629. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59630. /**
  59631. * Creates a new WebXRDefaultExperience
  59632. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59633. * @param options experience options
  59634. * @returns a promise for a new WebXRDefaultExperience
  59635. */
  59636. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59637. }
  59638. }
  59639. }
  59640. declare module "babylonjs/Helpers/videoDome" {
  59641. import { Scene } from "babylonjs/scene";
  59642. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59643. import { Mesh } from "babylonjs/Meshes/mesh";
  59644. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59645. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59646. import "babylonjs/Meshes/Builders/sphereBuilder";
  59647. /**
  59648. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59649. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59650. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59651. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59652. */
  59653. export class VideoDome extends TransformNode {
  59654. /**
  59655. * Define the video source as a Monoscopic panoramic 360 video.
  59656. */
  59657. static readonly MODE_MONOSCOPIC: number;
  59658. /**
  59659. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59660. */
  59661. static readonly MODE_TOPBOTTOM: number;
  59662. /**
  59663. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59664. */
  59665. static readonly MODE_SIDEBYSIDE: number;
  59666. private _halfDome;
  59667. private _useDirectMapping;
  59668. /**
  59669. * The video texture being displayed on the sphere
  59670. */
  59671. protected _videoTexture: VideoTexture;
  59672. /**
  59673. * Gets the video texture being displayed on the sphere
  59674. */
  59675. get videoTexture(): VideoTexture;
  59676. /**
  59677. * The skybox material
  59678. */
  59679. protected _material: BackgroundMaterial;
  59680. /**
  59681. * The surface used for the video dome
  59682. */
  59683. protected _mesh: Mesh;
  59684. /**
  59685. * Gets the mesh used for the video dome.
  59686. */
  59687. get mesh(): Mesh;
  59688. /**
  59689. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59690. */
  59691. private _halfDomeMask;
  59692. /**
  59693. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59694. * Also see the options.resolution property.
  59695. */
  59696. get fovMultiplier(): number;
  59697. set fovMultiplier(value: number);
  59698. private _videoMode;
  59699. /**
  59700. * Gets or set the current video mode for the video. It can be:
  59701. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59702. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59703. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59704. */
  59705. get videoMode(): number;
  59706. set videoMode(value: number);
  59707. /**
  59708. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59709. *
  59710. */
  59711. get halfDome(): boolean;
  59712. /**
  59713. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59714. */
  59715. set halfDome(enabled: boolean);
  59716. /**
  59717. * Oberserver used in Stereoscopic VR Mode.
  59718. */
  59719. private _onBeforeCameraRenderObserver;
  59720. /**
  59721. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59722. * @param name Element's name, child elements will append suffixes for their own names.
  59723. * @param urlsOrVideo defines the url(s) or the video element to use
  59724. * @param options An object containing optional or exposed sub element properties
  59725. */
  59726. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59727. resolution?: number;
  59728. clickToPlay?: boolean;
  59729. autoPlay?: boolean;
  59730. loop?: boolean;
  59731. size?: number;
  59732. poster?: string;
  59733. faceForward?: boolean;
  59734. useDirectMapping?: boolean;
  59735. halfDomeMode?: boolean;
  59736. }, scene: Scene);
  59737. private _changeVideoMode;
  59738. /**
  59739. * Releases resources associated with this node.
  59740. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59741. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59742. */
  59743. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59744. }
  59745. }
  59746. declare module "babylonjs/Helpers/index" {
  59747. export * from "babylonjs/Helpers/environmentHelper";
  59748. export * from "babylonjs/Helpers/photoDome";
  59749. export * from "babylonjs/Helpers/sceneHelpers";
  59750. export * from "babylonjs/Helpers/videoDome";
  59751. }
  59752. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59753. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59754. import { IDisposable } from "babylonjs/scene";
  59755. import { Engine } from "babylonjs/Engines/engine";
  59756. /**
  59757. * This class can be used to get instrumentation data from a Babylon engine
  59758. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59759. */
  59760. export class EngineInstrumentation implements IDisposable {
  59761. /**
  59762. * Define the instrumented engine.
  59763. */
  59764. engine: Engine;
  59765. private _captureGPUFrameTime;
  59766. private _gpuFrameTimeToken;
  59767. private _gpuFrameTime;
  59768. private _captureShaderCompilationTime;
  59769. private _shaderCompilationTime;
  59770. private _onBeginFrameObserver;
  59771. private _onEndFrameObserver;
  59772. private _onBeforeShaderCompilationObserver;
  59773. private _onAfterShaderCompilationObserver;
  59774. /**
  59775. * Gets the perf counter used for GPU frame time
  59776. */
  59777. get gpuFrameTimeCounter(): PerfCounter;
  59778. /**
  59779. * Gets the GPU frame time capture status
  59780. */
  59781. get captureGPUFrameTime(): boolean;
  59782. /**
  59783. * Enable or disable the GPU frame time capture
  59784. */
  59785. set captureGPUFrameTime(value: boolean);
  59786. /**
  59787. * Gets the perf counter used for shader compilation time
  59788. */
  59789. get shaderCompilationTimeCounter(): PerfCounter;
  59790. /**
  59791. * Gets the shader compilation time capture status
  59792. */
  59793. get captureShaderCompilationTime(): boolean;
  59794. /**
  59795. * Enable or disable the shader compilation time capture
  59796. */
  59797. set captureShaderCompilationTime(value: boolean);
  59798. /**
  59799. * Instantiates a new engine instrumentation.
  59800. * This class can be used to get instrumentation data from a Babylon engine
  59801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59802. * @param engine Defines the engine to instrument
  59803. */
  59804. constructor(
  59805. /**
  59806. * Define the instrumented engine.
  59807. */
  59808. engine: Engine);
  59809. /**
  59810. * Dispose and release associated resources.
  59811. */
  59812. dispose(): void;
  59813. }
  59814. }
  59815. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59816. import { Scene, IDisposable } from "babylonjs/scene";
  59817. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59818. /**
  59819. * This class can be used to get instrumentation data from a Babylon engine
  59820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59821. */
  59822. export class SceneInstrumentation implements IDisposable {
  59823. /**
  59824. * Defines the scene to instrument
  59825. */
  59826. scene: Scene;
  59827. private _captureActiveMeshesEvaluationTime;
  59828. private _activeMeshesEvaluationTime;
  59829. private _captureRenderTargetsRenderTime;
  59830. private _renderTargetsRenderTime;
  59831. private _captureFrameTime;
  59832. private _frameTime;
  59833. private _captureRenderTime;
  59834. private _renderTime;
  59835. private _captureInterFrameTime;
  59836. private _interFrameTime;
  59837. private _captureParticlesRenderTime;
  59838. private _particlesRenderTime;
  59839. private _captureSpritesRenderTime;
  59840. private _spritesRenderTime;
  59841. private _capturePhysicsTime;
  59842. private _physicsTime;
  59843. private _captureAnimationsTime;
  59844. private _animationsTime;
  59845. private _captureCameraRenderTime;
  59846. private _cameraRenderTime;
  59847. private _onBeforeActiveMeshesEvaluationObserver;
  59848. private _onAfterActiveMeshesEvaluationObserver;
  59849. private _onBeforeRenderTargetsRenderObserver;
  59850. private _onAfterRenderTargetsRenderObserver;
  59851. private _onAfterRenderObserver;
  59852. private _onBeforeDrawPhaseObserver;
  59853. private _onAfterDrawPhaseObserver;
  59854. private _onBeforeAnimationsObserver;
  59855. private _onBeforeParticlesRenderingObserver;
  59856. private _onAfterParticlesRenderingObserver;
  59857. private _onBeforeSpritesRenderingObserver;
  59858. private _onAfterSpritesRenderingObserver;
  59859. private _onBeforePhysicsObserver;
  59860. private _onAfterPhysicsObserver;
  59861. private _onAfterAnimationsObserver;
  59862. private _onBeforeCameraRenderObserver;
  59863. private _onAfterCameraRenderObserver;
  59864. /**
  59865. * Gets the perf counter used for active meshes evaluation time
  59866. */
  59867. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59868. /**
  59869. * Gets the active meshes evaluation time capture status
  59870. */
  59871. get captureActiveMeshesEvaluationTime(): boolean;
  59872. /**
  59873. * Enable or disable the active meshes evaluation time capture
  59874. */
  59875. set captureActiveMeshesEvaluationTime(value: boolean);
  59876. /**
  59877. * Gets the perf counter used for render targets render time
  59878. */
  59879. get renderTargetsRenderTimeCounter(): PerfCounter;
  59880. /**
  59881. * Gets the render targets render time capture status
  59882. */
  59883. get captureRenderTargetsRenderTime(): boolean;
  59884. /**
  59885. * Enable or disable the render targets render time capture
  59886. */
  59887. set captureRenderTargetsRenderTime(value: boolean);
  59888. /**
  59889. * Gets the perf counter used for particles render time
  59890. */
  59891. get particlesRenderTimeCounter(): PerfCounter;
  59892. /**
  59893. * Gets the particles render time capture status
  59894. */
  59895. get captureParticlesRenderTime(): boolean;
  59896. /**
  59897. * Enable or disable the particles render time capture
  59898. */
  59899. set captureParticlesRenderTime(value: boolean);
  59900. /**
  59901. * Gets the perf counter used for sprites render time
  59902. */
  59903. get spritesRenderTimeCounter(): PerfCounter;
  59904. /**
  59905. * Gets the sprites render time capture status
  59906. */
  59907. get captureSpritesRenderTime(): boolean;
  59908. /**
  59909. * Enable or disable the sprites render time capture
  59910. */
  59911. set captureSpritesRenderTime(value: boolean);
  59912. /**
  59913. * Gets the perf counter used for physics time
  59914. */
  59915. get physicsTimeCounter(): PerfCounter;
  59916. /**
  59917. * Gets the physics time capture status
  59918. */
  59919. get capturePhysicsTime(): boolean;
  59920. /**
  59921. * Enable or disable the physics time capture
  59922. */
  59923. set capturePhysicsTime(value: boolean);
  59924. /**
  59925. * Gets the perf counter used for animations time
  59926. */
  59927. get animationsTimeCounter(): PerfCounter;
  59928. /**
  59929. * Gets the animations time capture status
  59930. */
  59931. get captureAnimationsTime(): boolean;
  59932. /**
  59933. * Enable or disable the animations time capture
  59934. */
  59935. set captureAnimationsTime(value: boolean);
  59936. /**
  59937. * Gets the perf counter used for frame time capture
  59938. */
  59939. get frameTimeCounter(): PerfCounter;
  59940. /**
  59941. * Gets the frame time capture status
  59942. */
  59943. get captureFrameTime(): boolean;
  59944. /**
  59945. * Enable or disable the frame time capture
  59946. */
  59947. set captureFrameTime(value: boolean);
  59948. /**
  59949. * Gets the perf counter used for inter-frames time capture
  59950. */
  59951. get interFrameTimeCounter(): PerfCounter;
  59952. /**
  59953. * Gets the inter-frames time capture status
  59954. */
  59955. get captureInterFrameTime(): boolean;
  59956. /**
  59957. * Enable or disable the inter-frames time capture
  59958. */
  59959. set captureInterFrameTime(value: boolean);
  59960. /**
  59961. * Gets the perf counter used for render time capture
  59962. */
  59963. get renderTimeCounter(): PerfCounter;
  59964. /**
  59965. * Gets the render time capture status
  59966. */
  59967. get captureRenderTime(): boolean;
  59968. /**
  59969. * Enable or disable the render time capture
  59970. */
  59971. set captureRenderTime(value: boolean);
  59972. /**
  59973. * Gets the perf counter used for camera render time capture
  59974. */
  59975. get cameraRenderTimeCounter(): PerfCounter;
  59976. /**
  59977. * Gets the camera render time capture status
  59978. */
  59979. get captureCameraRenderTime(): boolean;
  59980. /**
  59981. * Enable or disable the camera render time capture
  59982. */
  59983. set captureCameraRenderTime(value: boolean);
  59984. /**
  59985. * Gets the perf counter used for draw calls
  59986. */
  59987. get drawCallsCounter(): PerfCounter;
  59988. /**
  59989. * Instantiates a new scene instrumentation.
  59990. * This class can be used to get instrumentation data from a Babylon engine
  59991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59992. * @param scene Defines the scene to instrument
  59993. */
  59994. constructor(
  59995. /**
  59996. * Defines the scene to instrument
  59997. */
  59998. scene: Scene);
  59999. /**
  60000. * Dispose and release associated resources.
  60001. */
  60002. dispose(): void;
  60003. }
  60004. }
  60005. declare module "babylonjs/Instrumentation/index" {
  60006. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60007. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60008. export * from "babylonjs/Instrumentation/timeToken";
  60009. }
  60010. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60011. /** @hidden */
  60012. export var glowMapGenerationPixelShader: {
  60013. name: string;
  60014. shader: string;
  60015. };
  60016. }
  60017. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60018. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60019. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60020. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60021. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60022. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60023. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60024. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60025. /** @hidden */
  60026. export var glowMapGenerationVertexShader: {
  60027. name: string;
  60028. shader: string;
  60029. };
  60030. }
  60031. declare module "babylonjs/Layers/effectLayer" {
  60032. import { Observable } from "babylonjs/Misc/observable";
  60033. import { Nullable } from "babylonjs/types";
  60034. import { Camera } from "babylonjs/Cameras/camera";
  60035. import { Scene } from "babylonjs/scene";
  60036. import { ISize } from "babylonjs/Maths/math.size";
  60037. import { Color4 } from "babylonjs/Maths/math.color";
  60038. import { Engine } from "babylonjs/Engines/engine";
  60039. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60041. import { Mesh } from "babylonjs/Meshes/mesh";
  60042. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60045. import { Effect } from "babylonjs/Materials/effect";
  60046. import { Material } from "babylonjs/Materials/material";
  60047. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60048. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60049. /**
  60050. * Effect layer options. This helps customizing the behaviour
  60051. * of the effect layer.
  60052. */
  60053. export interface IEffectLayerOptions {
  60054. /**
  60055. * Multiplication factor apply to the canvas size to compute the render target size
  60056. * used to generated the objects (the smaller the faster).
  60057. */
  60058. mainTextureRatio: number;
  60059. /**
  60060. * Enforces a fixed size texture to ensure effect stability across devices.
  60061. */
  60062. mainTextureFixedSize?: number;
  60063. /**
  60064. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60065. */
  60066. alphaBlendingMode: number;
  60067. /**
  60068. * The camera attached to the layer.
  60069. */
  60070. camera: Nullable<Camera>;
  60071. /**
  60072. * The rendering group to draw the layer in.
  60073. */
  60074. renderingGroupId: number;
  60075. }
  60076. /**
  60077. * The effect layer Helps adding post process effect blended with the main pass.
  60078. *
  60079. * This can be for instance use to generate glow or higlight effects on the scene.
  60080. *
  60081. * The effect layer class can not be used directly and is intented to inherited from to be
  60082. * customized per effects.
  60083. */
  60084. export abstract class EffectLayer {
  60085. private _vertexBuffers;
  60086. private _indexBuffer;
  60087. private _cachedDefines;
  60088. private _effectLayerMapGenerationEffect;
  60089. private _effectLayerOptions;
  60090. private _mergeEffect;
  60091. protected _scene: Scene;
  60092. protected _engine: Engine;
  60093. protected _maxSize: number;
  60094. protected _mainTextureDesiredSize: ISize;
  60095. protected _mainTexture: RenderTargetTexture;
  60096. protected _shouldRender: boolean;
  60097. protected _postProcesses: PostProcess[];
  60098. protected _textures: BaseTexture[];
  60099. protected _emissiveTextureAndColor: {
  60100. texture: Nullable<BaseTexture>;
  60101. color: Color4;
  60102. };
  60103. /**
  60104. * The name of the layer
  60105. */
  60106. name: string;
  60107. /**
  60108. * The clear color of the texture used to generate the glow map.
  60109. */
  60110. neutralColor: Color4;
  60111. /**
  60112. * Specifies whether the highlight layer is enabled or not.
  60113. */
  60114. isEnabled: boolean;
  60115. /**
  60116. * Gets the camera attached to the layer.
  60117. */
  60118. get camera(): Nullable<Camera>;
  60119. /**
  60120. * Gets the rendering group id the layer should render in.
  60121. */
  60122. get renderingGroupId(): number;
  60123. set renderingGroupId(renderingGroupId: number);
  60124. /**
  60125. * An event triggered when the effect layer has been disposed.
  60126. */
  60127. onDisposeObservable: Observable<EffectLayer>;
  60128. /**
  60129. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60130. */
  60131. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60132. /**
  60133. * An event triggered when the generated texture is being merged in the scene.
  60134. */
  60135. onBeforeComposeObservable: Observable<EffectLayer>;
  60136. /**
  60137. * An event triggered when the mesh is rendered into the effect render target.
  60138. */
  60139. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60140. /**
  60141. * An event triggered after the mesh has been rendered into the effect render target.
  60142. */
  60143. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60144. /**
  60145. * An event triggered when the generated texture has been merged in the scene.
  60146. */
  60147. onAfterComposeObservable: Observable<EffectLayer>;
  60148. /**
  60149. * An event triggered when the efffect layer changes its size.
  60150. */
  60151. onSizeChangedObservable: Observable<EffectLayer>;
  60152. /** @hidden */
  60153. static _SceneComponentInitialization: (scene: Scene) => void;
  60154. /**
  60155. * Instantiates a new effect Layer and references it in the scene.
  60156. * @param name The name of the layer
  60157. * @param scene The scene to use the layer in
  60158. */
  60159. constructor(
  60160. /** The Friendly of the effect in the scene */
  60161. name: string, scene: Scene);
  60162. /**
  60163. * Get the effect name of the layer.
  60164. * @return The effect name
  60165. */
  60166. abstract getEffectName(): string;
  60167. /**
  60168. * Checks for the readiness of the element composing the layer.
  60169. * @param subMesh the mesh to check for
  60170. * @param useInstances specify whether or not to use instances to render the mesh
  60171. * @return true if ready otherwise, false
  60172. */
  60173. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60174. /**
  60175. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60176. * @returns true if the effect requires stencil during the main canvas render pass.
  60177. */
  60178. abstract needStencil(): boolean;
  60179. /**
  60180. * Create the merge effect. This is the shader use to blit the information back
  60181. * to the main canvas at the end of the scene rendering.
  60182. * @returns The effect containing the shader used to merge the effect on the main canvas
  60183. */
  60184. protected abstract _createMergeEffect(): Effect;
  60185. /**
  60186. * Creates the render target textures and post processes used in the effect layer.
  60187. */
  60188. protected abstract _createTextureAndPostProcesses(): void;
  60189. /**
  60190. * Implementation specific of rendering the generating effect on the main canvas.
  60191. * @param effect The effect used to render through
  60192. */
  60193. protected abstract _internalRender(effect: Effect): void;
  60194. /**
  60195. * Sets the required values for both the emissive texture and and the main color.
  60196. */
  60197. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60198. /**
  60199. * Free any resources and references associated to a mesh.
  60200. * Internal use
  60201. * @param mesh The mesh to free.
  60202. */
  60203. abstract _disposeMesh(mesh: Mesh): void;
  60204. /**
  60205. * Serializes this layer (Glow or Highlight for example)
  60206. * @returns a serialized layer object
  60207. */
  60208. abstract serialize?(): any;
  60209. /**
  60210. * Initializes the effect layer with the required options.
  60211. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60212. */
  60213. protected _init(options: Partial<IEffectLayerOptions>): void;
  60214. /**
  60215. * Generates the index buffer of the full screen quad blending to the main canvas.
  60216. */
  60217. private _generateIndexBuffer;
  60218. /**
  60219. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60220. */
  60221. private _generateVertexBuffer;
  60222. /**
  60223. * Sets the main texture desired size which is the closest power of two
  60224. * of the engine canvas size.
  60225. */
  60226. private _setMainTextureSize;
  60227. /**
  60228. * Creates the main texture for the effect layer.
  60229. */
  60230. protected _createMainTexture(): void;
  60231. /**
  60232. * Adds specific effects defines.
  60233. * @param defines The defines to add specifics to.
  60234. */
  60235. protected _addCustomEffectDefines(defines: string[]): void;
  60236. /**
  60237. * Checks for the readiness of the element composing the layer.
  60238. * @param subMesh the mesh to check for
  60239. * @param useInstances specify whether or not to use instances to render the mesh
  60240. * @param emissiveTexture the associated emissive texture used to generate the glow
  60241. * @return true if ready otherwise, false
  60242. */
  60243. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60244. /**
  60245. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60246. */
  60247. render(): void;
  60248. /**
  60249. * Determine if a given mesh will be used in the current effect.
  60250. * @param mesh mesh to test
  60251. * @returns true if the mesh will be used
  60252. */
  60253. hasMesh(mesh: AbstractMesh): boolean;
  60254. /**
  60255. * Returns true if the layer contains information to display, otherwise false.
  60256. * @returns true if the glow layer should be rendered
  60257. */
  60258. shouldRender(): boolean;
  60259. /**
  60260. * Returns true if the mesh should render, otherwise false.
  60261. * @param mesh The mesh to render
  60262. * @returns true if it should render otherwise false
  60263. */
  60264. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60265. /**
  60266. * Returns true if the mesh can be rendered, otherwise false.
  60267. * @param mesh The mesh to render
  60268. * @param material The material used on the mesh
  60269. * @returns true if it can be rendered otherwise false
  60270. */
  60271. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60272. /**
  60273. * Returns true if the mesh should render, otherwise false.
  60274. * @param mesh The mesh to render
  60275. * @returns true if it should render otherwise false
  60276. */
  60277. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60278. /**
  60279. * Renders the submesh passed in parameter to the generation map.
  60280. */
  60281. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60282. /**
  60283. * Defines whether the current material of the mesh should be use to render the effect.
  60284. * @param mesh defines the current mesh to render
  60285. */
  60286. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60287. /**
  60288. * Rebuild the required buffers.
  60289. * @hidden Internal use only.
  60290. */
  60291. _rebuild(): void;
  60292. /**
  60293. * Dispose only the render target textures and post process.
  60294. */
  60295. private _disposeTextureAndPostProcesses;
  60296. /**
  60297. * Dispose the highlight layer and free resources.
  60298. */
  60299. dispose(): void;
  60300. /**
  60301. * Gets the class name of the effect layer
  60302. * @returns the string with the class name of the effect layer
  60303. */
  60304. getClassName(): string;
  60305. /**
  60306. * Creates an effect layer from parsed effect layer data
  60307. * @param parsedEffectLayer defines effect layer data
  60308. * @param scene defines the current scene
  60309. * @param rootUrl defines the root URL containing the effect layer information
  60310. * @returns a parsed effect Layer
  60311. */
  60312. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60313. }
  60314. }
  60315. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60316. import { Scene } from "babylonjs/scene";
  60317. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60318. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60319. import { AbstractScene } from "babylonjs/abstractScene";
  60320. module "babylonjs/abstractScene" {
  60321. interface AbstractScene {
  60322. /**
  60323. * The list of effect layers (highlights/glow) added to the scene
  60324. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60325. * @see https://doc.babylonjs.com/how_to/glow_layer
  60326. */
  60327. effectLayers: Array<EffectLayer>;
  60328. /**
  60329. * Removes the given effect layer from this scene.
  60330. * @param toRemove defines the effect layer to remove
  60331. * @returns the index of the removed effect layer
  60332. */
  60333. removeEffectLayer(toRemove: EffectLayer): number;
  60334. /**
  60335. * Adds the given effect layer to this scene
  60336. * @param newEffectLayer defines the effect layer to add
  60337. */
  60338. addEffectLayer(newEffectLayer: EffectLayer): void;
  60339. }
  60340. }
  60341. /**
  60342. * Defines the layer scene component responsible to manage any effect layers
  60343. * in a given scene.
  60344. */
  60345. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60346. /**
  60347. * The component name helpfull to identify the component in the list of scene components.
  60348. */
  60349. readonly name: string;
  60350. /**
  60351. * The scene the component belongs to.
  60352. */
  60353. scene: Scene;
  60354. private _engine;
  60355. private _renderEffects;
  60356. private _needStencil;
  60357. private _previousStencilState;
  60358. /**
  60359. * Creates a new instance of the component for the given scene
  60360. * @param scene Defines the scene to register the component in
  60361. */
  60362. constructor(scene: Scene);
  60363. /**
  60364. * Registers the component in a given scene
  60365. */
  60366. register(): void;
  60367. /**
  60368. * Rebuilds the elements related to this component in case of
  60369. * context lost for instance.
  60370. */
  60371. rebuild(): void;
  60372. /**
  60373. * Serializes the component data to the specified json object
  60374. * @param serializationObject The object to serialize to
  60375. */
  60376. serialize(serializationObject: any): void;
  60377. /**
  60378. * Adds all the elements from the container to the scene
  60379. * @param container the container holding the elements
  60380. */
  60381. addFromContainer(container: AbstractScene): void;
  60382. /**
  60383. * Removes all the elements in the container from the scene
  60384. * @param container contains the elements to remove
  60385. * @param dispose if the removed element should be disposed (default: false)
  60386. */
  60387. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60388. /**
  60389. * Disposes the component and the associated ressources.
  60390. */
  60391. dispose(): void;
  60392. private _isReadyForMesh;
  60393. private _renderMainTexture;
  60394. private _setStencil;
  60395. private _setStencilBack;
  60396. private _draw;
  60397. private _drawCamera;
  60398. private _drawRenderingGroup;
  60399. }
  60400. }
  60401. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60402. /** @hidden */
  60403. export var glowMapMergePixelShader: {
  60404. name: string;
  60405. shader: string;
  60406. };
  60407. }
  60408. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60409. /** @hidden */
  60410. export var glowMapMergeVertexShader: {
  60411. name: string;
  60412. shader: string;
  60413. };
  60414. }
  60415. declare module "babylonjs/Layers/glowLayer" {
  60416. import { Nullable } from "babylonjs/types";
  60417. import { Camera } from "babylonjs/Cameras/camera";
  60418. import { Scene } from "babylonjs/scene";
  60419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60421. import { Mesh } from "babylonjs/Meshes/mesh";
  60422. import { Texture } from "babylonjs/Materials/Textures/texture";
  60423. import { Effect } from "babylonjs/Materials/effect";
  60424. import { Material } from "babylonjs/Materials/material";
  60425. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60426. import { Color4 } from "babylonjs/Maths/math.color";
  60427. import "babylonjs/Shaders/glowMapMerge.fragment";
  60428. import "babylonjs/Shaders/glowMapMerge.vertex";
  60429. import "babylonjs/Layers/effectLayerSceneComponent";
  60430. module "babylonjs/abstractScene" {
  60431. interface AbstractScene {
  60432. /**
  60433. * Return a the first highlight layer of the scene with a given name.
  60434. * @param name The name of the highlight layer to look for.
  60435. * @return The highlight layer if found otherwise null.
  60436. */
  60437. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60438. }
  60439. }
  60440. /**
  60441. * Glow layer options. This helps customizing the behaviour
  60442. * of the glow layer.
  60443. */
  60444. export interface IGlowLayerOptions {
  60445. /**
  60446. * Multiplication factor apply to the canvas size to compute the render target size
  60447. * used to generated the glowing objects (the smaller the faster).
  60448. */
  60449. mainTextureRatio: number;
  60450. /**
  60451. * Enforces a fixed size texture to ensure resize independant blur.
  60452. */
  60453. mainTextureFixedSize?: number;
  60454. /**
  60455. * How big is the kernel of the blur texture.
  60456. */
  60457. blurKernelSize: number;
  60458. /**
  60459. * The camera attached to the layer.
  60460. */
  60461. camera: Nullable<Camera>;
  60462. /**
  60463. * Enable MSAA by chosing the number of samples.
  60464. */
  60465. mainTextureSamples?: number;
  60466. /**
  60467. * The rendering group to draw the layer in.
  60468. */
  60469. renderingGroupId: number;
  60470. }
  60471. /**
  60472. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60473. *
  60474. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60475. *
  60476. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60477. */
  60478. export class GlowLayer extends EffectLayer {
  60479. /**
  60480. * Effect Name of the layer.
  60481. */
  60482. static readonly EffectName: string;
  60483. /**
  60484. * The default blur kernel size used for the glow.
  60485. */
  60486. static DefaultBlurKernelSize: number;
  60487. /**
  60488. * The default texture size ratio used for the glow.
  60489. */
  60490. static DefaultTextureRatio: number;
  60491. /**
  60492. * Sets the kernel size of the blur.
  60493. */
  60494. set blurKernelSize(value: number);
  60495. /**
  60496. * Gets the kernel size of the blur.
  60497. */
  60498. get blurKernelSize(): number;
  60499. /**
  60500. * Sets the glow intensity.
  60501. */
  60502. set intensity(value: number);
  60503. /**
  60504. * Gets the glow intensity.
  60505. */
  60506. get intensity(): number;
  60507. private _options;
  60508. private _intensity;
  60509. private _horizontalBlurPostprocess1;
  60510. private _verticalBlurPostprocess1;
  60511. private _horizontalBlurPostprocess2;
  60512. private _verticalBlurPostprocess2;
  60513. private _blurTexture1;
  60514. private _blurTexture2;
  60515. private _postProcesses1;
  60516. private _postProcesses2;
  60517. private _includedOnlyMeshes;
  60518. private _excludedMeshes;
  60519. private _meshesUsingTheirOwnMaterials;
  60520. /**
  60521. * Callback used to let the user override the color selection on a per mesh basis
  60522. */
  60523. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60524. /**
  60525. * Callback used to let the user override the texture selection on a per mesh basis
  60526. */
  60527. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60528. /**
  60529. * Instantiates a new glow Layer and references it to the scene.
  60530. * @param name The name of the layer
  60531. * @param scene The scene to use the layer in
  60532. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60533. */
  60534. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60535. /**
  60536. * Get the effect name of the layer.
  60537. * @return The effect name
  60538. */
  60539. getEffectName(): string;
  60540. /**
  60541. * Create the merge effect. This is the shader use to blit the information back
  60542. * to the main canvas at the end of the scene rendering.
  60543. */
  60544. protected _createMergeEffect(): Effect;
  60545. /**
  60546. * Creates the render target textures and post processes used in the glow layer.
  60547. */
  60548. protected _createTextureAndPostProcesses(): void;
  60549. /**
  60550. * Checks for the readiness of the element composing the layer.
  60551. * @param subMesh the mesh to check for
  60552. * @param useInstances specify wether or not to use instances to render the mesh
  60553. * @param emissiveTexture the associated emissive texture used to generate the glow
  60554. * @return true if ready otherwise, false
  60555. */
  60556. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60557. /**
  60558. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60559. */
  60560. needStencil(): boolean;
  60561. /**
  60562. * Returns true if the mesh can be rendered, otherwise false.
  60563. * @param mesh The mesh to render
  60564. * @param material The material used on the mesh
  60565. * @returns true if it can be rendered otherwise false
  60566. */
  60567. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60568. /**
  60569. * Implementation specific of rendering the generating effect on the main canvas.
  60570. * @param effect The effect used to render through
  60571. */
  60572. protected _internalRender(effect: Effect): void;
  60573. /**
  60574. * Sets the required values for both the emissive texture and and the main color.
  60575. */
  60576. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60577. /**
  60578. * Returns true if the mesh should render, otherwise false.
  60579. * @param mesh The mesh to render
  60580. * @returns true if it should render otherwise false
  60581. */
  60582. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60583. /**
  60584. * Adds specific effects defines.
  60585. * @param defines The defines to add specifics to.
  60586. */
  60587. protected _addCustomEffectDefines(defines: string[]): void;
  60588. /**
  60589. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60590. * @param mesh The mesh to exclude from the glow layer
  60591. */
  60592. addExcludedMesh(mesh: Mesh): void;
  60593. /**
  60594. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60595. * @param mesh The mesh to remove
  60596. */
  60597. removeExcludedMesh(mesh: Mesh): void;
  60598. /**
  60599. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60600. * @param mesh The mesh to include in the glow layer
  60601. */
  60602. addIncludedOnlyMesh(mesh: Mesh): void;
  60603. /**
  60604. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60605. * @param mesh The mesh to remove
  60606. */
  60607. removeIncludedOnlyMesh(mesh: Mesh): void;
  60608. /**
  60609. * Determine if a given mesh will be used in the glow layer
  60610. * @param mesh The mesh to test
  60611. * @returns true if the mesh will be highlighted by the current glow layer
  60612. */
  60613. hasMesh(mesh: AbstractMesh): boolean;
  60614. /**
  60615. * Defines whether the current material of the mesh should be use to render the effect.
  60616. * @param mesh defines the current mesh to render
  60617. */
  60618. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60619. /**
  60620. * Add a mesh to be rendered through its own material and not with emissive only.
  60621. * @param mesh The mesh for which we need to use its material
  60622. */
  60623. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60624. /**
  60625. * Remove a mesh from being rendered through its own material and not with emissive only.
  60626. * @param mesh The mesh for which we need to not use its material
  60627. */
  60628. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60629. /**
  60630. * Free any resources and references associated to a mesh.
  60631. * Internal use
  60632. * @param mesh The mesh to free.
  60633. * @hidden
  60634. */
  60635. _disposeMesh(mesh: Mesh): void;
  60636. /**
  60637. * Gets the class name of the effect layer
  60638. * @returns the string with the class name of the effect layer
  60639. */
  60640. getClassName(): string;
  60641. /**
  60642. * Serializes this glow layer
  60643. * @returns a serialized glow layer object
  60644. */
  60645. serialize(): any;
  60646. /**
  60647. * Creates a Glow Layer from parsed glow layer data
  60648. * @param parsedGlowLayer defines glow layer data
  60649. * @param scene defines the current scene
  60650. * @param rootUrl defines the root URL containing the glow layer information
  60651. * @returns a parsed Glow Layer
  60652. */
  60653. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60654. }
  60655. }
  60656. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60657. /** @hidden */
  60658. export var glowBlurPostProcessPixelShader: {
  60659. name: string;
  60660. shader: string;
  60661. };
  60662. }
  60663. declare module "babylonjs/Layers/highlightLayer" {
  60664. import { Observable } from "babylonjs/Misc/observable";
  60665. import { Nullable } from "babylonjs/types";
  60666. import { Camera } from "babylonjs/Cameras/camera";
  60667. import { Scene } from "babylonjs/scene";
  60668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60670. import { Mesh } from "babylonjs/Meshes/mesh";
  60671. import { Effect } from "babylonjs/Materials/effect";
  60672. import { Material } from "babylonjs/Materials/material";
  60673. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60674. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60675. import "babylonjs/Shaders/glowMapMerge.fragment";
  60676. import "babylonjs/Shaders/glowMapMerge.vertex";
  60677. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60678. module "babylonjs/abstractScene" {
  60679. interface AbstractScene {
  60680. /**
  60681. * Return a the first highlight layer of the scene with a given name.
  60682. * @param name The name of the highlight layer to look for.
  60683. * @return The highlight layer if found otherwise null.
  60684. */
  60685. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60686. }
  60687. }
  60688. /**
  60689. * Highlight layer options. This helps customizing the behaviour
  60690. * of the highlight layer.
  60691. */
  60692. export interface IHighlightLayerOptions {
  60693. /**
  60694. * Multiplication factor apply to the canvas size to compute the render target size
  60695. * used to generated the glowing objects (the smaller the faster).
  60696. */
  60697. mainTextureRatio: number;
  60698. /**
  60699. * Enforces a fixed size texture to ensure resize independant blur.
  60700. */
  60701. mainTextureFixedSize?: number;
  60702. /**
  60703. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60704. * of the picture to blur (the smaller the faster).
  60705. */
  60706. blurTextureSizeRatio: number;
  60707. /**
  60708. * How big in texel of the blur texture is the vertical blur.
  60709. */
  60710. blurVerticalSize: number;
  60711. /**
  60712. * How big in texel of the blur texture is the horizontal blur.
  60713. */
  60714. blurHorizontalSize: number;
  60715. /**
  60716. * Alpha blending mode used to apply the blur. Default is combine.
  60717. */
  60718. alphaBlendingMode: number;
  60719. /**
  60720. * The camera attached to the layer.
  60721. */
  60722. camera: Nullable<Camera>;
  60723. /**
  60724. * Should we display highlight as a solid stroke?
  60725. */
  60726. isStroke?: boolean;
  60727. /**
  60728. * The rendering group to draw the layer in.
  60729. */
  60730. renderingGroupId: number;
  60731. }
  60732. /**
  60733. * The highlight layer Helps adding a glow effect around a mesh.
  60734. *
  60735. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60736. * glowy meshes to your scene.
  60737. *
  60738. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60739. */
  60740. export class HighlightLayer extends EffectLayer {
  60741. name: string;
  60742. /**
  60743. * Effect Name of the highlight layer.
  60744. */
  60745. static readonly EffectName: string;
  60746. /**
  60747. * The neutral color used during the preparation of the glow effect.
  60748. * This is black by default as the blend operation is a blend operation.
  60749. */
  60750. static NeutralColor: Color4;
  60751. /**
  60752. * Stencil value used for glowing meshes.
  60753. */
  60754. static GlowingMeshStencilReference: number;
  60755. /**
  60756. * Stencil value used for the other meshes in the scene.
  60757. */
  60758. static NormalMeshStencilReference: number;
  60759. /**
  60760. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60761. */
  60762. innerGlow: boolean;
  60763. /**
  60764. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60765. */
  60766. outerGlow: boolean;
  60767. /**
  60768. * Specifies the horizontal size of the blur.
  60769. */
  60770. set blurHorizontalSize(value: number);
  60771. /**
  60772. * Specifies the vertical size of the blur.
  60773. */
  60774. set blurVerticalSize(value: number);
  60775. /**
  60776. * Gets the horizontal size of the blur.
  60777. */
  60778. get blurHorizontalSize(): number;
  60779. /**
  60780. * Gets the vertical size of the blur.
  60781. */
  60782. get blurVerticalSize(): number;
  60783. /**
  60784. * An event triggered when the highlight layer is being blurred.
  60785. */
  60786. onBeforeBlurObservable: Observable<HighlightLayer>;
  60787. /**
  60788. * An event triggered when the highlight layer has been blurred.
  60789. */
  60790. onAfterBlurObservable: Observable<HighlightLayer>;
  60791. private _instanceGlowingMeshStencilReference;
  60792. private _options;
  60793. private _downSamplePostprocess;
  60794. private _horizontalBlurPostprocess;
  60795. private _verticalBlurPostprocess;
  60796. private _blurTexture;
  60797. private _meshes;
  60798. private _excludedMeshes;
  60799. /**
  60800. * Instantiates a new highlight Layer and references it to the scene..
  60801. * @param name The name of the layer
  60802. * @param scene The scene to use the layer in
  60803. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60804. */
  60805. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60806. /**
  60807. * Get the effect name of the layer.
  60808. * @return The effect name
  60809. */
  60810. getEffectName(): string;
  60811. /**
  60812. * Create the merge effect. This is the shader use to blit the information back
  60813. * to the main canvas at the end of the scene rendering.
  60814. */
  60815. protected _createMergeEffect(): Effect;
  60816. /**
  60817. * Creates the render target textures and post processes used in the highlight layer.
  60818. */
  60819. protected _createTextureAndPostProcesses(): void;
  60820. /**
  60821. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60822. */
  60823. needStencil(): boolean;
  60824. /**
  60825. * Checks for the readiness of the element composing the layer.
  60826. * @param subMesh the mesh to check for
  60827. * @param useInstances specify wether or not to use instances to render the mesh
  60828. * @param emissiveTexture the associated emissive texture used to generate the glow
  60829. * @return true if ready otherwise, false
  60830. */
  60831. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60832. /**
  60833. * Implementation specific of rendering the generating effect on the main canvas.
  60834. * @param effect The effect used to render through
  60835. */
  60836. protected _internalRender(effect: Effect): void;
  60837. /**
  60838. * Returns true if the layer contains information to display, otherwise false.
  60839. */
  60840. shouldRender(): boolean;
  60841. /**
  60842. * Returns true if the mesh should render, otherwise false.
  60843. * @param mesh The mesh to render
  60844. * @returns true if it should render otherwise false
  60845. */
  60846. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60847. /**
  60848. * Returns true if the mesh can be rendered, otherwise false.
  60849. * @param mesh The mesh to render
  60850. * @param material The material used on the mesh
  60851. * @returns true if it can be rendered otherwise false
  60852. */
  60853. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60854. /**
  60855. * Adds specific effects defines.
  60856. * @param defines The defines to add specifics to.
  60857. */
  60858. protected _addCustomEffectDefines(defines: string[]): void;
  60859. /**
  60860. * Sets the required values for both the emissive texture and and the main color.
  60861. */
  60862. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60863. /**
  60864. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60865. * @param mesh The mesh to exclude from the highlight layer
  60866. */
  60867. addExcludedMesh(mesh: Mesh): void;
  60868. /**
  60869. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60870. * @param mesh The mesh to highlight
  60871. */
  60872. removeExcludedMesh(mesh: Mesh): void;
  60873. /**
  60874. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60875. * @param mesh mesh to test
  60876. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60877. */
  60878. hasMesh(mesh: AbstractMesh): boolean;
  60879. /**
  60880. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60881. * @param mesh The mesh to highlight
  60882. * @param color The color of the highlight
  60883. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60884. */
  60885. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60886. /**
  60887. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60888. * @param mesh The mesh to highlight
  60889. */
  60890. removeMesh(mesh: Mesh): void;
  60891. /**
  60892. * Remove all the meshes currently referenced in the highlight layer
  60893. */
  60894. removeAllMeshes(): void;
  60895. /**
  60896. * Force the stencil to the normal expected value for none glowing parts
  60897. */
  60898. private _defaultStencilReference;
  60899. /**
  60900. * Free any resources and references associated to a mesh.
  60901. * Internal use
  60902. * @param mesh The mesh to free.
  60903. * @hidden
  60904. */
  60905. _disposeMesh(mesh: Mesh): void;
  60906. /**
  60907. * Dispose the highlight layer and free resources.
  60908. */
  60909. dispose(): void;
  60910. /**
  60911. * Gets the class name of the effect layer
  60912. * @returns the string with the class name of the effect layer
  60913. */
  60914. getClassName(): string;
  60915. /**
  60916. * Serializes this Highlight layer
  60917. * @returns a serialized Highlight layer object
  60918. */
  60919. serialize(): any;
  60920. /**
  60921. * Creates a Highlight layer from parsed Highlight layer data
  60922. * @param parsedHightlightLayer defines the Highlight layer data
  60923. * @param scene defines the current scene
  60924. * @param rootUrl defines the root URL containing the Highlight layer information
  60925. * @returns a parsed Highlight layer
  60926. */
  60927. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60928. }
  60929. }
  60930. declare module "babylonjs/Layers/layerSceneComponent" {
  60931. import { Scene } from "babylonjs/scene";
  60932. import { ISceneComponent } from "babylonjs/sceneComponent";
  60933. import { Layer } from "babylonjs/Layers/layer";
  60934. import { AbstractScene } from "babylonjs/abstractScene";
  60935. module "babylonjs/abstractScene" {
  60936. interface AbstractScene {
  60937. /**
  60938. * The list of layers (background and foreground) of the scene
  60939. */
  60940. layers: Array<Layer>;
  60941. }
  60942. }
  60943. /**
  60944. * Defines the layer scene component responsible to manage any layers
  60945. * in a given scene.
  60946. */
  60947. export class LayerSceneComponent implements ISceneComponent {
  60948. /**
  60949. * The component name helpfull to identify the component in the list of scene components.
  60950. */
  60951. readonly name: string;
  60952. /**
  60953. * The scene the component belongs to.
  60954. */
  60955. scene: Scene;
  60956. private _engine;
  60957. /**
  60958. * Creates a new instance of the component for the given scene
  60959. * @param scene Defines the scene to register the component in
  60960. */
  60961. constructor(scene: Scene);
  60962. /**
  60963. * Registers the component in a given scene
  60964. */
  60965. register(): void;
  60966. /**
  60967. * Rebuilds the elements related to this component in case of
  60968. * context lost for instance.
  60969. */
  60970. rebuild(): void;
  60971. /**
  60972. * Disposes the component and the associated ressources.
  60973. */
  60974. dispose(): void;
  60975. private _draw;
  60976. private _drawCameraPredicate;
  60977. private _drawCameraBackground;
  60978. private _drawCameraForeground;
  60979. private _drawRenderTargetPredicate;
  60980. private _drawRenderTargetBackground;
  60981. private _drawRenderTargetForeground;
  60982. /**
  60983. * Adds all the elements from the container to the scene
  60984. * @param container the container holding the elements
  60985. */
  60986. addFromContainer(container: AbstractScene): void;
  60987. /**
  60988. * Removes all the elements in the container from the scene
  60989. * @param container contains the elements to remove
  60990. * @param dispose if the removed element should be disposed (default: false)
  60991. */
  60992. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60993. }
  60994. }
  60995. declare module "babylonjs/Shaders/layer.fragment" {
  60996. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60997. /** @hidden */
  60998. export var layerPixelShader: {
  60999. name: string;
  61000. shader: string;
  61001. };
  61002. }
  61003. declare module "babylonjs/Shaders/layer.vertex" {
  61004. /** @hidden */
  61005. export var layerVertexShader: {
  61006. name: string;
  61007. shader: string;
  61008. };
  61009. }
  61010. declare module "babylonjs/Layers/layer" {
  61011. import { Observable } from "babylonjs/Misc/observable";
  61012. import { Nullable } from "babylonjs/types";
  61013. import { Scene } from "babylonjs/scene";
  61014. import { Vector2 } from "babylonjs/Maths/math.vector";
  61015. import { Color4 } from "babylonjs/Maths/math.color";
  61016. import { Texture } from "babylonjs/Materials/Textures/texture";
  61017. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61018. import "babylonjs/Shaders/layer.fragment";
  61019. import "babylonjs/Shaders/layer.vertex";
  61020. /**
  61021. * This represents a full screen 2d layer.
  61022. * This can be useful to display a picture in the background of your scene for instance.
  61023. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61024. */
  61025. export class Layer {
  61026. /**
  61027. * Define the name of the layer.
  61028. */
  61029. name: string;
  61030. /**
  61031. * Define the texture the layer should display.
  61032. */
  61033. texture: Nullable<Texture>;
  61034. /**
  61035. * Is the layer in background or foreground.
  61036. */
  61037. isBackground: boolean;
  61038. /**
  61039. * Define the color of the layer (instead of texture).
  61040. */
  61041. color: Color4;
  61042. /**
  61043. * Define the scale of the layer in order to zoom in out of the texture.
  61044. */
  61045. scale: Vector2;
  61046. /**
  61047. * Define an offset for the layer in order to shift the texture.
  61048. */
  61049. offset: Vector2;
  61050. /**
  61051. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61052. */
  61053. alphaBlendingMode: number;
  61054. /**
  61055. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61056. * Alpha test will not mix with the background color in case of transparency.
  61057. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61058. */
  61059. alphaTest: boolean;
  61060. /**
  61061. * Define a mask to restrict the layer to only some of the scene cameras.
  61062. */
  61063. layerMask: number;
  61064. /**
  61065. * Define the list of render target the layer is visible into.
  61066. */
  61067. renderTargetTextures: RenderTargetTexture[];
  61068. /**
  61069. * Define if the layer is only used in renderTarget or if it also
  61070. * renders in the main frame buffer of the canvas.
  61071. */
  61072. renderOnlyInRenderTargetTextures: boolean;
  61073. private _scene;
  61074. private _vertexBuffers;
  61075. private _indexBuffer;
  61076. private _effect;
  61077. private _previousDefines;
  61078. /**
  61079. * An event triggered when the layer is disposed.
  61080. */
  61081. onDisposeObservable: Observable<Layer>;
  61082. private _onDisposeObserver;
  61083. /**
  61084. * Back compatibility with callback before the onDisposeObservable existed.
  61085. * The set callback will be triggered when the layer has been disposed.
  61086. */
  61087. set onDispose(callback: () => void);
  61088. /**
  61089. * An event triggered before rendering the scene
  61090. */
  61091. onBeforeRenderObservable: Observable<Layer>;
  61092. private _onBeforeRenderObserver;
  61093. /**
  61094. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61095. * The set callback will be triggered just before rendering the layer.
  61096. */
  61097. set onBeforeRender(callback: () => void);
  61098. /**
  61099. * An event triggered after rendering the scene
  61100. */
  61101. onAfterRenderObservable: Observable<Layer>;
  61102. private _onAfterRenderObserver;
  61103. /**
  61104. * Back compatibility with callback before the onAfterRenderObservable existed.
  61105. * The set callback will be triggered just after rendering the layer.
  61106. */
  61107. set onAfterRender(callback: () => void);
  61108. /**
  61109. * Instantiates a new layer.
  61110. * This represents a full screen 2d layer.
  61111. * This can be useful to display a picture in the background of your scene for instance.
  61112. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61113. * @param name Define the name of the layer in the scene
  61114. * @param imgUrl Define the url of the texture to display in the layer
  61115. * @param scene Define the scene the layer belongs to
  61116. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61117. * @param color Defines a color for the layer
  61118. */
  61119. constructor(
  61120. /**
  61121. * Define the name of the layer.
  61122. */
  61123. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61124. private _createIndexBuffer;
  61125. /** @hidden */
  61126. _rebuild(): void;
  61127. /**
  61128. * Renders the layer in the scene.
  61129. */
  61130. render(): void;
  61131. /**
  61132. * Disposes and releases the associated ressources.
  61133. */
  61134. dispose(): void;
  61135. }
  61136. }
  61137. declare module "babylonjs/Layers/index" {
  61138. export * from "babylonjs/Layers/effectLayer";
  61139. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61140. export * from "babylonjs/Layers/glowLayer";
  61141. export * from "babylonjs/Layers/highlightLayer";
  61142. export * from "babylonjs/Layers/layer";
  61143. export * from "babylonjs/Layers/layerSceneComponent";
  61144. }
  61145. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61146. /** @hidden */
  61147. export var lensFlarePixelShader: {
  61148. name: string;
  61149. shader: string;
  61150. };
  61151. }
  61152. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61153. /** @hidden */
  61154. export var lensFlareVertexShader: {
  61155. name: string;
  61156. shader: string;
  61157. };
  61158. }
  61159. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61160. import { Scene } from "babylonjs/scene";
  61161. import { Vector3 } from "babylonjs/Maths/math.vector";
  61162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61163. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61164. import "babylonjs/Shaders/lensFlare.fragment";
  61165. import "babylonjs/Shaders/lensFlare.vertex";
  61166. import { Viewport } from "babylonjs/Maths/math.viewport";
  61167. /**
  61168. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61169. * It is usually composed of several `lensFlare`.
  61170. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61171. */
  61172. export class LensFlareSystem {
  61173. /**
  61174. * Define the name of the lens flare system
  61175. */
  61176. name: string;
  61177. /**
  61178. * List of lens flares used in this system.
  61179. */
  61180. lensFlares: LensFlare[];
  61181. /**
  61182. * Define a limit from the border the lens flare can be visible.
  61183. */
  61184. borderLimit: number;
  61185. /**
  61186. * Define a viewport border we do not want to see the lens flare in.
  61187. */
  61188. viewportBorder: number;
  61189. /**
  61190. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61191. */
  61192. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61193. /**
  61194. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61195. */
  61196. layerMask: number;
  61197. /**
  61198. * Define the id of the lens flare system in the scene.
  61199. * (equal to name by default)
  61200. */
  61201. id: string;
  61202. private _scene;
  61203. private _emitter;
  61204. private _vertexBuffers;
  61205. private _indexBuffer;
  61206. private _effect;
  61207. private _positionX;
  61208. private _positionY;
  61209. private _isEnabled;
  61210. /** @hidden */
  61211. static _SceneComponentInitialization: (scene: Scene) => void;
  61212. /**
  61213. * Instantiates a lens flare system.
  61214. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61215. * It is usually composed of several `lensFlare`.
  61216. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61217. * @param name Define the name of the lens flare system in the scene
  61218. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61219. * @param scene Define the scene the lens flare system belongs to
  61220. */
  61221. constructor(
  61222. /**
  61223. * Define the name of the lens flare system
  61224. */
  61225. name: string, emitter: any, scene: Scene);
  61226. /**
  61227. * Define if the lens flare system is enabled.
  61228. */
  61229. get isEnabled(): boolean;
  61230. set isEnabled(value: boolean);
  61231. /**
  61232. * Get the scene the effects belongs to.
  61233. * @returns the scene holding the lens flare system
  61234. */
  61235. getScene(): Scene;
  61236. /**
  61237. * Get the emitter of the lens flare system.
  61238. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61239. * @returns the emitter of the lens flare system
  61240. */
  61241. getEmitter(): any;
  61242. /**
  61243. * Set the emitter of the lens flare system.
  61244. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61245. * @param newEmitter Define the new emitter of the system
  61246. */
  61247. setEmitter(newEmitter: any): void;
  61248. /**
  61249. * Get the lens flare system emitter position.
  61250. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61251. * @returns the position
  61252. */
  61253. getEmitterPosition(): Vector3;
  61254. /**
  61255. * @hidden
  61256. */
  61257. computeEffectivePosition(globalViewport: Viewport): boolean;
  61258. /** @hidden */
  61259. _isVisible(): boolean;
  61260. /**
  61261. * @hidden
  61262. */
  61263. render(): boolean;
  61264. /**
  61265. * Dispose and release the lens flare with its associated resources.
  61266. */
  61267. dispose(): void;
  61268. /**
  61269. * Parse a lens flare system from a JSON repressentation
  61270. * @param parsedLensFlareSystem Define the JSON to parse
  61271. * @param scene Define the scene the parsed system should be instantiated in
  61272. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61273. * @returns the parsed system
  61274. */
  61275. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61276. /**
  61277. * Serialize the current Lens Flare System into a JSON representation.
  61278. * @returns the serialized JSON
  61279. */
  61280. serialize(): any;
  61281. }
  61282. }
  61283. declare module "babylonjs/LensFlares/lensFlare" {
  61284. import { Nullable } from "babylonjs/types";
  61285. import { Color3 } from "babylonjs/Maths/math.color";
  61286. import { Texture } from "babylonjs/Materials/Textures/texture";
  61287. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61288. /**
  61289. * This represents one of the lens effect in a `lensFlareSystem`.
  61290. * It controls one of the indiviual texture used in the effect.
  61291. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61292. */
  61293. export class LensFlare {
  61294. /**
  61295. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61296. */
  61297. size: number;
  61298. /**
  61299. * 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.
  61300. */
  61301. position: number;
  61302. /**
  61303. * Define the lens color.
  61304. */
  61305. color: Color3;
  61306. /**
  61307. * Define the lens texture.
  61308. */
  61309. texture: Nullable<Texture>;
  61310. /**
  61311. * Define the alpha mode to render this particular lens.
  61312. */
  61313. alphaMode: number;
  61314. private _system;
  61315. /**
  61316. * Creates a new Lens Flare.
  61317. * This represents one of the lens effect in a `lensFlareSystem`.
  61318. * It controls one of the indiviual texture used in the effect.
  61319. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61320. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61321. * @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.
  61322. * @param color Define the lens color
  61323. * @param imgUrl Define the lens texture url
  61324. * @param system Define the `lensFlareSystem` this flare is part of
  61325. * @returns The newly created Lens Flare
  61326. */
  61327. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61328. /**
  61329. * Instantiates a new Lens Flare.
  61330. * This represents one of the lens effect in a `lensFlareSystem`.
  61331. * It controls one of the indiviual texture used in the effect.
  61332. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61333. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61334. * @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.
  61335. * @param color Define the lens color
  61336. * @param imgUrl Define the lens texture url
  61337. * @param system Define the `lensFlareSystem` this flare is part of
  61338. */
  61339. constructor(
  61340. /**
  61341. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61342. */
  61343. size: number,
  61344. /**
  61345. * 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.
  61346. */
  61347. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61348. /**
  61349. * Dispose and release the lens flare with its associated resources.
  61350. */
  61351. dispose(): void;
  61352. }
  61353. }
  61354. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61355. import { Nullable } from "babylonjs/types";
  61356. import { Scene } from "babylonjs/scene";
  61357. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61358. import { AbstractScene } from "babylonjs/abstractScene";
  61359. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61360. module "babylonjs/abstractScene" {
  61361. interface AbstractScene {
  61362. /**
  61363. * The list of lens flare system added to the scene
  61364. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61365. */
  61366. lensFlareSystems: Array<LensFlareSystem>;
  61367. /**
  61368. * Removes the given lens flare system from this scene.
  61369. * @param toRemove The lens flare system to remove
  61370. * @returns The index of the removed lens flare system
  61371. */
  61372. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61373. /**
  61374. * Adds the given lens flare system to this scene
  61375. * @param newLensFlareSystem The lens flare system to add
  61376. */
  61377. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61378. /**
  61379. * Gets a lens flare system using its name
  61380. * @param name defines the name to look for
  61381. * @returns the lens flare system or null if not found
  61382. */
  61383. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61384. /**
  61385. * Gets a lens flare system using its id
  61386. * @param id defines the id to look for
  61387. * @returns the lens flare system or null if not found
  61388. */
  61389. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61390. }
  61391. }
  61392. /**
  61393. * Defines the lens flare scene component responsible to manage any lens flares
  61394. * in a given scene.
  61395. */
  61396. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61397. /**
  61398. * The component name helpfull to identify the component in the list of scene components.
  61399. */
  61400. readonly name: string;
  61401. /**
  61402. * The scene the component belongs to.
  61403. */
  61404. scene: Scene;
  61405. /**
  61406. * Creates a new instance of the component for the given scene
  61407. * @param scene Defines the scene to register the component in
  61408. */
  61409. constructor(scene: Scene);
  61410. /**
  61411. * Registers the component in a given scene
  61412. */
  61413. register(): void;
  61414. /**
  61415. * Rebuilds the elements related to this component in case of
  61416. * context lost for instance.
  61417. */
  61418. rebuild(): void;
  61419. /**
  61420. * Adds all the elements from the container to the scene
  61421. * @param container the container holding the elements
  61422. */
  61423. addFromContainer(container: AbstractScene): void;
  61424. /**
  61425. * Removes all the elements in the container from the scene
  61426. * @param container contains the elements to remove
  61427. * @param dispose if the removed element should be disposed (default: false)
  61428. */
  61429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61430. /**
  61431. * Serializes the component data to the specified json object
  61432. * @param serializationObject The object to serialize to
  61433. */
  61434. serialize(serializationObject: any): void;
  61435. /**
  61436. * Disposes the component and the associated ressources.
  61437. */
  61438. dispose(): void;
  61439. private _draw;
  61440. }
  61441. }
  61442. declare module "babylonjs/LensFlares/index" {
  61443. export * from "babylonjs/LensFlares/lensFlare";
  61444. export * from "babylonjs/LensFlares/lensFlareSystem";
  61445. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61446. }
  61447. declare module "babylonjs/Shaders/depth.fragment" {
  61448. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61449. /** @hidden */
  61450. export var depthPixelShader: {
  61451. name: string;
  61452. shader: string;
  61453. };
  61454. }
  61455. declare module "babylonjs/Shaders/depth.vertex" {
  61456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61458. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61459. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61461. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61462. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61463. /** @hidden */
  61464. export var depthVertexShader: {
  61465. name: string;
  61466. shader: string;
  61467. };
  61468. }
  61469. declare module "babylonjs/Rendering/depthRenderer" {
  61470. import { Nullable } from "babylonjs/types";
  61471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61472. import { Scene } from "babylonjs/scene";
  61473. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61474. import { Camera } from "babylonjs/Cameras/camera";
  61475. import "babylonjs/Shaders/depth.fragment";
  61476. import "babylonjs/Shaders/depth.vertex";
  61477. /**
  61478. * This represents a depth renderer in Babylon.
  61479. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61480. */
  61481. export class DepthRenderer {
  61482. private _scene;
  61483. private _depthMap;
  61484. private _effect;
  61485. private readonly _storeNonLinearDepth;
  61486. private readonly _clearColor;
  61487. /** Get if the depth renderer is using packed depth or not */
  61488. readonly isPacked: boolean;
  61489. private _cachedDefines;
  61490. private _camera;
  61491. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61492. enabled: boolean;
  61493. /**
  61494. * Specifiess that the depth renderer will only be used within
  61495. * the camera it is created for.
  61496. * This can help forcing its rendering during the camera processing.
  61497. */
  61498. useOnlyInActiveCamera: boolean;
  61499. /** @hidden */
  61500. static _SceneComponentInitialization: (scene: Scene) => void;
  61501. /**
  61502. * Instantiates a depth renderer
  61503. * @param scene The scene the renderer belongs to
  61504. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61505. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61506. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61507. */
  61508. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61509. /**
  61510. * Creates the depth rendering effect and checks if the effect is ready.
  61511. * @param subMesh The submesh to be used to render the depth map of
  61512. * @param useInstances If multiple world instances should be used
  61513. * @returns if the depth renderer is ready to render the depth map
  61514. */
  61515. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61516. /**
  61517. * Gets the texture which the depth map will be written to.
  61518. * @returns The depth map texture
  61519. */
  61520. getDepthMap(): RenderTargetTexture;
  61521. /**
  61522. * Disposes of the depth renderer.
  61523. */
  61524. dispose(): void;
  61525. }
  61526. }
  61527. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61528. /** @hidden */
  61529. export var minmaxReduxPixelShader: {
  61530. name: string;
  61531. shader: string;
  61532. };
  61533. }
  61534. declare module "babylonjs/Misc/minMaxReducer" {
  61535. import { Nullable } from "babylonjs/types";
  61536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61537. import { Camera } from "babylonjs/Cameras/camera";
  61538. import { Observer } from "babylonjs/Misc/observable";
  61539. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61540. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61541. import { Observable } from "babylonjs/Misc/observable";
  61542. import "babylonjs/Shaders/minmaxRedux.fragment";
  61543. /**
  61544. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61545. * and maximum values from all values of the texture.
  61546. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61547. * The source values are read from the red channel of the texture.
  61548. */
  61549. export class MinMaxReducer {
  61550. /**
  61551. * Observable triggered when the computation has been performed
  61552. */
  61553. onAfterReductionPerformed: Observable<{
  61554. min: number;
  61555. max: number;
  61556. }>;
  61557. protected _camera: Camera;
  61558. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61559. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61560. protected _postProcessManager: PostProcessManager;
  61561. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61562. protected _forceFullscreenViewport: boolean;
  61563. /**
  61564. * Creates a min/max reducer
  61565. * @param camera The camera to use for the post processes
  61566. */
  61567. constructor(camera: Camera);
  61568. /**
  61569. * Gets the texture used to read the values from.
  61570. */
  61571. get sourceTexture(): Nullable<RenderTargetTexture>;
  61572. /**
  61573. * Sets the source texture to read the values from.
  61574. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61575. * because in such textures '1' value must not be taken into account to compute the maximum
  61576. * as this value is used to clear the texture.
  61577. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61578. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61579. * @param depthRedux Indicates if the texture is a depth texture or not
  61580. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61581. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61582. */
  61583. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61584. /**
  61585. * Defines the refresh rate of the computation.
  61586. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61587. */
  61588. get refreshRate(): number;
  61589. set refreshRate(value: number);
  61590. protected _activated: boolean;
  61591. /**
  61592. * Gets the activation status of the reducer
  61593. */
  61594. get activated(): boolean;
  61595. /**
  61596. * Activates the reduction computation.
  61597. * When activated, the observers registered in onAfterReductionPerformed are
  61598. * called after the compuation is performed
  61599. */
  61600. activate(): void;
  61601. /**
  61602. * Deactivates the reduction computation.
  61603. */
  61604. deactivate(): void;
  61605. /**
  61606. * Disposes the min/max reducer
  61607. * @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.
  61608. */
  61609. dispose(disposeAll?: boolean): void;
  61610. }
  61611. }
  61612. declare module "babylonjs/Misc/depthReducer" {
  61613. import { Nullable } from "babylonjs/types";
  61614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61615. import { Camera } from "babylonjs/Cameras/camera";
  61616. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61617. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61618. /**
  61619. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61620. */
  61621. export class DepthReducer extends MinMaxReducer {
  61622. private _depthRenderer;
  61623. private _depthRendererId;
  61624. /**
  61625. * Gets the depth renderer used for the computation.
  61626. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61627. */
  61628. get depthRenderer(): Nullable<DepthRenderer>;
  61629. /**
  61630. * Creates a depth reducer
  61631. * @param camera The camera used to render the depth texture
  61632. */
  61633. constructor(camera: Camera);
  61634. /**
  61635. * Sets the depth renderer to use to generate the depth map
  61636. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61637. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61638. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61639. */
  61640. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61641. /** @hidden */
  61642. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61643. /**
  61644. * Activates the reduction computation.
  61645. * When activated, the observers registered in onAfterReductionPerformed are
  61646. * called after the compuation is performed
  61647. */
  61648. activate(): void;
  61649. /**
  61650. * Deactivates the reduction computation.
  61651. */
  61652. deactivate(): void;
  61653. /**
  61654. * Disposes the depth reducer
  61655. * @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.
  61656. */
  61657. dispose(disposeAll?: boolean): void;
  61658. }
  61659. }
  61660. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61661. import { Nullable } from "babylonjs/types";
  61662. import { Scene } from "babylonjs/scene";
  61663. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61664. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61666. import { Effect } from "babylonjs/Materials/effect";
  61667. import "babylonjs/Shaders/shadowMap.fragment";
  61668. import "babylonjs/Shaders/shadowMap.vertex";
  61669. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61670. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61671. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61672. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61673. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61674. /**
  61675. * A CSM implementation allowing casting shadows on large scenes.
  61676. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61677. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61678. */
  61679. export class CascadedShadowGenerator extends ShadowGenerator {
  61680. private static readonly frustumCornersNDCSpace;
  61681. /**
  61682. * Name of the CSM class
  61683. */
  61684. static CLASSNAME: string;
  61685. /**
  61686. * Defines the default number of cascades used by the CSM.
  61687. */
  61688. static readonly DEFAULT_CASCADES_COUNT: number;
  61689. /**
  61690. * Defines the minimum number of cascades used by the CSM.
  61691. */
  61692. static readonly MIN_CASCADES_COUNT: number;
  61693. /**
  61694. * Defines the maximum number of cascades used by the CSM.
  61695. */
  61696. static readonly MAX_CASCADES_COUNT: number;
  61697. protected _validateFilter(filter: number): number;
  61698. /**
  61699. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61700. */
  61701. penumbraDarkness: number;
  61702. private _numCascades;
  61703. /**
  61704. * Gets or set the number of cascades used by the CSM.
  61705. */
  61706. get numCascades(): number;
  61707. set numCascades(value: number);
  61708. /**
  61709. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61710. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61711. */
  61712. stabilizeCascades: boolean;
  61713. private _freezeShadowCastersBoundingInfo;
  61714. private _freezeShadowCastersBoundingInfoObservable;
  61715. /**
  61716. * Enables or disables the shadow casters bounding info computation.
  61717. * If your shadow casters don't move, you can disable this feature.
  61718. * If it is enabled, the bounding box computation is done every frame.
  61719. */
  61720. get freezeShadowCastersBoundingInfo(): boolean;
  61721. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61722. private _scbiMin;
  61723. private _scbiMax;
  61724. protected _computeShadowCastersBoundingInfo(): void;
  61725. protected _shadowCastersBoundingInfo: BoundingInfo;
  61726. /**
  61727. * Gets or sets the shadow casters bounding info.
  61728. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61729. * so that the system won't overwrite the bounds you provide
  61730. */
  61731. get shadowCastersBoundingInfo(): BoundingInfo;
  61732. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61733. protected _breaksAreDirty: boolean;
  61734. protected _minDistance: number;
  61735. protected _maxDistance: number;
  61736. /**
  61737. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61738. *
  61739. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61740. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61741. * @param min minimal distance for the breaks (default to 0.)
  61742. * @param max maximal distance for the breaks (default to 1.)
  61743. */
  61744. setMinMaxDistance(min: number, max: number): void;
  61745. /** Gets the minimal distance used in the cascade break computation */
  61746. get minDistance(): number;
  61747. /** Gets the maximal distance used in the cascade break computation */
  61748. get maxDistance(): number;
  61749. /**
  61750. * Gets the class name of that object
  61751. * @returns "CascadedShadowGenerator"
  61752. */
  61753. getClassName(): string;
  61754. private _cascadeMinExtents;
  61755. private _cascadeMaxExtents;
  61756. /**
  61757. * Gets a cascade minimum extents
  61758. * @param cascadeIndex index of the cascade
  61759. * @returns the minimum cascade extents
  61760. */
  61761. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61762. /**
  61763. * Gets a cascade maximum extents
  61764. * @param cascadeIndex index of the cascade
  61765. * @returns the maximum cascade extents
  61766. */
  61767. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61768. private _cascades;
  61769. private _currentLayer;
  61770. private _viewSpaceFrustumsZ;
  61771. private _viewMatrices;
  61772. private _projectionMatrices;
  61773. private _transformMatrices;
  61774. private _transformMatricesAsArray;
  61775. private _frustumLengths;
  61776. private _lightSizeUVCorrection;
  61777. private _depthCorrection;
  61778. private _frustumCornersWorldSpace;
  61779. private _frustumCenter;
  61780. private _shadowCameraPos;
  61781. private _shadowMaxZ;
  61782. /**
  61783. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61784. * It defaults to camera.maxZ
  61785. */
  61786. get shadowMaxZ(): number;
  61787. /**
  61788. * Sets the shadow max z distance.
  61789. */
  61790. set shadowMaxZ(value: number);
  61791. protected _debug: boolean;
  61792. /**
  61793. * Gets or sets the debug flag.
  61794. * When enabled, the cascades are materialized by different colors on the screen.
  61795. */
  61796. get debug(): boolean;
  61797. set debug(dbg: boolean);
  61798. private _depthClamp;
  61799. /**
  61800. * Gets or sets the depth clamping value.
  61801. *
  61802. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61803. * to account for the shadow casters far away.
  61804. *
  61805. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61806. */
  61807. get depthClamp(): boolean;
  61808. set depthClamp(value: boolean);
  61809. private _cascadeBlendPercentage;
  61810. /**
  61811. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61812. * It defaults to 0.1 (10% blending).
  61813. */
  61814. get cascadeBlendPercentage(): number;
  61815. set cascadeBlendPercentage(value: number);
  61816. private _lambda;
  61817. /**
  61818. * Gets or set the lambda parameter.
  61819. * This parameter is used to split the camera frustum and create the cascades.
  61820. * 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.
  61821. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61822. */
  61823. get lambda(): number;
  61824. set lambda(value: number);
  61825. /**
  61826. * Gets the view matrix corresponding to a given cascade
  61827. * @param cascadeNum cascade to retrieve the view matrix from
  61828. * @returns the cascade view matrix
  61829. */
  61830. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61831. /**
  61832. * Gets the projection matrix corresponding to a given cascade
  61833. * @param cascadeNum cascade to retrieve the projection matrix from
  61834. * @returns the cascade projection matrix
  61835. */
  61836. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61837. /**
  61838. * Gets the transformation matrix corresponding to a given cascade
  61839. * @param cascadeNum cascade to retrieve the transformation matrix from
  61840. * @returns the cascade transformation matrix
  61841. */
  61842. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61843. private _depthRenderer;
  61844. /**
  61845. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61846. *
  61847. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61848. *
  61849. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61850. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61851. * @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
  61852. */
  61853. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61854. private _depthReducer;
  61855. private _autoCalcDepthBounds;
  61856. /**
  61857. * Gets or sets the autoCalcDepthBounds property.
  61858. *
  61859. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61860. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61861. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61862. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61863. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61864. */
  61865. get autoCalcDepthBounds(): boolean;
  61866. set autoCalcDepthBounds(value: boolean);
  61867. /**
  61868. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61869. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61870. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61871. * for setting the refresh rate on the renderer yourself!
  61872. */
  61873. get autoCalcDepthBoundsRefreshRate(): number;
  61874. set autoCalcDepthBoundsRefreshRate(value: number);
  61875. /**
  61876. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61877. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61878. * you change the camera near/far planes!
  61879. */
  61880. splitFrustum(): void;
  61881. private _splitFrustum;
  61882. private _computeMatrices;
  61883. private _computeFrustumInWorldSpace;
  61884. private _computeCascadeFrustum;
  61885. /**
  61886. * Support test.
  61887. */
  61888. static get IsSupported(): boolean;
  61889. /** @hidden */
  61890. static _SceneComponentInitialization: (scene: Scene) => void;
  61891. /**
  61892. * Creates a Cascaded Shadow Generator object.
  61893. * A ShadowGenerator is the required tool to use the shadows.
  61894. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61895. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61896. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61897. * @param light The directional light object generating the shadows.
  61898. * @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.
  61899. */
  61900. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61901. protected _initializeGenerator(): void;
  61902. protected _createTargetRenderTexture(): void;
  61903. protected _initializeShadowMap(): void;
  61904. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61905. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61906. /**
  61907. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61908. * @param defines Defines of the material we want to update
  61909. * @param lightIndex Index of the light in the enabled light list of the material
  61910. */
  61911. prepareDefines(defines: any, lightIndex: number): void;
  61912. /**
  61913. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61914. * defined in the generator but impacting the effect).
  61915. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61916. * @param effect The effect we are binfing the information for
  61917. */
  61918. bindShadowLight(lightIndex: string, effect: Effect): void;
  61919. /**
  61920. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61921. * (eq to view projection * shadow projection matrices)
  61922. * @returns The transform matrix used to create the shadow map
  61923. */
  61924. getTransformMatrix(): Matrix;
  61925. /**
  61926. * Disposes the ShadowGenerator.
  61927. * Returns nothing.
  61928. */
  61929. dispose(): void;
  61930. /**
  61931. * Serializes the shadow generator setup to a json object.
  61932. * @returns The serialized JSON object
  61933. */
  61934. serialize(): any;
  61935. /**
  61936. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61937. * @param parsedShadowGenerator The JSON object to parse
  61938. * @param scene The scene to create the shadow map for
  61939. * @returns The parsed shadow generator
  61940. */
  61941. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61942. }
  61943. }
  61944. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61945. import { Scene } from "babylonjs/scene";
  61946. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61947. import { AbstractScene } from "babylonjs/abstractScene";
  61948. /**
  61949. * Defines the shadow generator component responsible to manage any shadow generators
  61950. * in a given scene.
  61951. */
  61952. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61953. /**
  61954. * The component name helpfull to identify the component in the list of scene components.
  61955. */
  61956. readonly name: string;
  61957. /**
  61958. * The scene the component belongs to.
  61959. */
  61960. scene: Scene;
  61961. /**
  61962. * Creates a new instance of the component for the given scene
  61963. * @param scene Defines the scene to register the component in
  61964. */
  61965. constructor(scene: Scene);
  61966. /**
  61967. * Registers the component in a given scene
  61968. */
  61969. register(): void;
  61970. /**
  61971. * Rebuilds the elements related to this component in case of
  61972. * context lost for instance.
  61973. */
  61974. rebuild(): void;
  61975. /**
  61976. * Serializes the component data to the specified json object
  61977. * @param serializationObject The object to serialize to
  61978. */
  61979. serialize(serializationObject: any): void;
  61980. /**
  61981. * Adds all the elements from the container to the scene
  61982. * @param container the container holding the elements
  61983. */
  61984. addFromContainer(container: AbstractScene): void;
  61985. /**
  61986. * Removes all the elements in the container from the scene
  61987. * @param container contains the elements to remove
  61988. * @param dispose if the removed element should be disposed (default: false)
  61989. */
  61990. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61991. /**
  61992. * Rebuilds the elements related to this component in case of
  61993. * context lost for instance.
  61994. */
  61995. dispose(): void;
  61996. private _gatherRenderTargets;
  61997. }
  61998. }
  61999. declare module "babylonjs/Lights/Shadows/index" {
  62000. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62001. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62002. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62003. }
  62004. declare module "babylonjs/Lights/pointLight" {
  62005. import { Scene } from "babylonjs/scene";
  62006. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62008. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62009. import { Effect } from "babylonjs/Materials/effect";
  62010. /**
  62011. * A point light is a light defined by an unique point in world space.
  62012. * The light is emitted in every direction from this point.
  62013. * A good example of a point light is a standard light bulb.
  62014. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62015. */
  62016. export class PointLight extends ShadowLight {
  62017. private _shadowAngle;
  62018. /**
  62019. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62020. * This specifies what angle the shadow will use to be created.
  62021. *
  62022. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62023. */
  62024. get shadowAngle(): number;
  62025. /**
  62026. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62027. * This specifies what angle the shadow will use to be created.
  62028. *
  62029. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62030. */
  62031. set shadowAngle(value: number);
  62032. /**
  62033. * Gets the direction if it has been set.
  62034. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62035. */
  62036. get direction(): Vector3;
  62037. /**
  62038. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62039. */
  62040. set direction(value: Vector3);
  62041. /**
  62042. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62043. * A PointLight emits the light in every direction.
  62044. * It can cast shadows.
  62045. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62046. * ```javascript
  62047. * var pointLight = new PointLight("pl", camera.position, scene);
  62048. * ```
  62049. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62050. * @param name The light friendly name
  62051. * @param position The position of the point light in the scene
  62052. * @param scene The scene the lights belongs to
  62053. */
  62054. constructor(name: string, position: Vector3, scene: Scene);
  62055. /**
  62056. * Returns the string "PointLight"
  62057. * @returns the class name
  62058. */
  62059. getClassName(): string;
  62060. /**
  62061. * Returns the integer 0.
  62062. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62063. */
  62064. getTypeID(): number;
  62065. /**
  62066. * Specifies wether or not the shadowmap should be a cube texture.
  62067. * @returns true if the shadowmap needs to be a cube texture.
  62068. */
  62069. needCube(): boolean;
  62070. /**
  62071. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62072. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62073. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62074. */
  62075. getShadowDirection(faceIndex?: number): Vector3;
  62076. /**
  62077. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62078. * - fov = PI / 2
  62079. * - aspect ratio : 1.0
  62080. * - z-near and far equal to the active camera minZ and maxZ.
  62081. * Returns the PointLight.
  62082. */
  62083. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62084. protected _buildUniformLayout(): void;
  62085. /**
  62086. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62087. * @param effect The effect to update
  62088. * @param lightIndex The index of the light in the effect to update
  62089. * @returns The point light
  62090. */
  62091. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62092. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62093. /**
  62094. * Prepares the list of defines specific to the light type.
  62095. * @param defines the list of defines
  62096. * @param lightIndex defines the index of the light for the effect
  62097. */
  62098. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62099. }
  62100. }
  62101. declare module "babylonjs/Lights/index" {
  62102. export * from "babylonjs/Lights/light";
  62103. export * from "babylonjs/Lights/shadowLight";
  62104. export * from "babylonjs/Lights/Shadows/index";
  62105. export * from "babylonjs/Lights/directionalLight";
  62106. export * from "babylonjs/Lights/hemisphericLight";
  62107. export * from "babylonjs/Lights/pointLight";
  62108. export * from "babylonjs/Lights/spotLight";
  62109. }
  62110. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62111. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62112. /**
  62113. * Header information of HDR texture files.
  62114. */
  62115. export interface HDRInfo {
  62116. /**
  62117. * The height of the texture in pixels.
  62118. */
  62119. height: number;
  62120. /**
  62121. * The width of the texture in pixels.
  62122. */
  62123. width: number;
  62124. /**
  62125. * The index of the beginning of the data in the binary file.
  62126. */
  62127. dataPosition: number;
  62128. }
  62129. /**
  62130. * This groups tools to convert HDR texture to native colors array.
  62131. */
  62132. export class HDRTools {
  62133. private static Ldexp;
  62134. private static Rgbe2float;
  62135. private static readStringLine;
  62136. /**
  62137. * Reads header information from an RGBE texture stored in a native array.
  62138. * More information on this format are available here:
  62139. * https://en.wikipedia.org/wiki/RGBE_image_format
  62140. *
  62141. * @param uint8array The binary file stored in native array.
  62142. * @return The header information.
  62143. */
  62144. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62145. /**
  62146. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62147. * This RGBE texture needs to store the information as a panorama.
  62148. *
  62149. * More information on this format are available here:
  62150. * https://en.wikipedia.org/wiki/RGBE_image_format
  62151. *
  62152. * @param buffer The binary file stored in an array buffer.
  62153. * @param size The expected size of the extracted cubemap.
  62154. * @return The Cube Map information.
  62155. */
  62156. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62157. /**
  62158. * Returns the pixels data extracted from an RGBE texture.
  62159. * This pixels will be stored left to right up to down in the R G B order in one array.
  62160. *
  62161. * More information on this format are available here:
  62162. * https://en.wikipedia.org/wiki/RGBE_image_format
  62163. *
  62164. * @param uint8array The binary file stored in an array buffer.
  62165. * @param hdrInfo The header information of the file.
  62166. * @return The pixels data in RGB right to left up to down order.
  62167. */
  62168. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62169. private static RGBE_ReadPixels_RLE;
  62170. private static RGBE_ReadPixels_NOT_RLE;
  62171. }
  62172. }
  62173. declare module "babylonjs/Materials/effectRenderer" {
  62174. import { Nullable } from "babylonjs/types";
  62175. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62176. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62177. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62178. import { Viewport } from "babylonjs/Maths/math.viewport";
  62179. import { Observable } from "babylonjs/Misc/observable";
  62180. import { Effect } from "babylonjs/Materials/effect";
  62181. import "babylonjs/Shaders/postprocess.vertex";
  62182. /**
  62183. * Effect Render Options
  62184. */
  62185. export interface IEffectRendererOptions {
  62186. /**
  62187. * Defines the vertices positions.
  62188. */
  62189. positions?: number[];
  62190. /**
  62191. * Defines the indices.
  62192. */
  62193. indices?: number[];
  62194. }
  62195. /**
  62196. * Helper class to render one or more effects.
  62197. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62198. */
  62199. export class EffectRenderer {
  62200. private engine;
  62201. private static _DefaultOptions;
  62202. private _vertexBuffers;
  62203. private _indexBuffer;
  62204. private _fullscreenViewport;
  62205. /**
  62206. * Creates an effect renderer
  62207. * @param engine the engine to use for rendering
  62208. * @param options defines the options of the effect renderer
  62209. */
  62210. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62211. /**
  62212. * Sets the current viewport in normalized coordinates 0-1
  62213. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62214. */
  62215. setViewport(viewport?: Viewport): void;
  62216. /**
  62217. * Binds the embedded attributes buffer to the effect.
  62218. * @param effect Defines the effect to bind the attributes for
  62219. */
  62220. bindBuffers(effect: Effect): void;
  62221. /**
  62222. * Sets the current effect wrapper to use during draw.
  62223. * The effect needs to be ready before calling this api.
  62224. * This also sets the default full screen position attribute.
  62225. * @param effectWrapper Defines the effect to draw with
  62226. */
  62227. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62228. /**
  62229. * Restores engine states
  62230. */
  62231. restoreStates(): void;
  62232. /**
  62233. * Draws a full screen quad.
  62234. */
  62235. draw(): void;
  62236. private isRenderTargetTexture;
  62237. /**
  62238. * renders one or more effects to a specified texture
  62239. * @param effectWrapper the effect to renderer
  62240. * @param outputTexture texture to draw to, if null it will render to the screen.
  62241. */
  62242. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62243. /**
  62244. * Disposes of the effect renderer
  62245. */
  62246. dispose(): void;
  62247. }
  62248. /**
  62249. * Options to create an EffectWrapper
  62250. */
  62251. interface EffectWrapperCreationOptions {
  62252. /**
  62253. * Engine to use to create the effect
  62254. */
  62255. engine: ThinEngine;
  62256. /**
  62257. * Fragment shader for the effect
  62258. */
  62259. fragmentShader: string;
  62260. /**
  62261. * Use the shader store instead of direct source code
  62262. */
  62263. useShaderStore?: boolean;
  62264. /**
  62265. * Vertex shader for the effect
  62266. */
  62267. vertexShader?: string;
  62268. /**
  62269. * Attributes to use in the shader
  62270. */
  62271. attributeNames?: Array<string>;
  62272. /**
  62273. * Uniforms to use in the shader
  62274. */
  62275. uniformNames?: Array<string>;
  62276. /**
  62277. * Texture sampler names to use in the shader
  62278. */
  62279. samplerNames?: Array<string>;
  62280. /**
  62281. * Defines to use in the shader
  62282. */
  62283. defines?: Array<string>;
  62284. /**
  62285. * Callback when effect is compiled
  62286. */
  62287. onCompiled?: Nullable<(effect: Effect) => void>;
  62288. /**
  62289. * The friendly name of the effect displayed in Spector.
  62290. */
  62291. name?: string;
  62292. }
  62293. /**
  62294. * Wraps an effect to be used for rendering
  62295. */
  62296. export class EffectWrapper {
  62297. /**
  62298. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62299. */
  62300. onApplyObservable: Observable<{}>;
  62301. /**
  62302. * The underlying effect
  62303. */
  62304. effect: Effect;
  62305. /**
  62306. * Creates an effect to be renderer
  62307. * @param creationOptions options to create the effect
  62308. */
  62309. constructor(creationOptions: EffectWrapperCreationOptions);
  62310. /**
  62311. * Disposes of the effect wrapper
  62312. */
  62313. dispose(): void;
  62314. }
  62315. }
  62316. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62317. /** @hidden */
  62318. export var hdrFilteringVertexShader: {
  62319. name: string;
  62320. shader: string;
  62321. };
  62322. }
  62323. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62325. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62326. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62327. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62328. /** @hidden */
  62329. export var hdrFilteringPixelShader: {
  62330. name: string;
  62331. shader: string;
  62332. };
  62333. }
  62334. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62336. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62337. import { Nullable } from "babylonjs/types";
  62338. import "babylonjs/Shaders/hdrFiltering.vertex";
  62339. import "babylonjs/Shaders/hdrFiltering.fragment";
  62340. /**
  62341. * Options for texture filtering
  62342. */
  62343. interface IHDRFilteringOptions {
  62344. /**
  62345. * Scales pixel intensity for the input HDR map.
  62346. */
  62347. hdrScale?: number;
  62348. /**
  62349. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62350. */
  62351. quality?: number;
  62352. }
  62353. /**
  62354. * Filters HDR maps to get correct renderings of PBR reflections
  62355. */
  62356. export class HDRFiltering {
  62357. private _engine;
  62358. private _effectRenderer;
  62359. private _effectWrapper;
  62360. private _lodGenerationOffset;
  62361. private _lodGenerationScale;
  62362. /**
  62363. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62364. * you care about baking speed.
  62365. */
  62366. quality: number;
  62367. /**
  62368. * Scales pixel intensity for the input HDR map.
  62369. */
  62370. hdrScale: number;
  62371. /**
  62372. * Instantiates HDR filter for reflection maps
  62373. *
  62374. * @param engine Thin engine
  62375. * @param options Options
  62376. */
  62377. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62378. private _createRenderTarget;
  62379. private _prefilterInternal;
  62380. private _createEffect;
  62381. /**
  62382. * Get a value indicating if the filter is ready to be used
  62383. * @param texture Texture to filter
  62384. * @returns true if the filter is ready
  62385. */
  62386. isReady(texture: BaseTexture): boolean;
  62387. /**
  62388. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62389. * Prefiltering will be invoked at the end of next rendering pass.
  62390. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62391. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62392. * @param texture Texture to filter
  62393. * @param onFinished Callback when filtering is done
  62394. * @return Promise called when prefiltering is done
  62395. */
  62396. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62397. }
  62398. }
  62399. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62400. import { Nullable } from "babylonjs/types";
  62401. import { Scene } from "babylonjs/scene";
  62402. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62404. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62405. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62406. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62407. /**
  62408. * This represents a texture coming from an HDR input.
  62409. *
  62410. * The only supported format is currently panorama picture stored in RGBE format.
  62411. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62412. */
  62413. export class HDRCubeTexture extends BaseTexture {
  62414. private static _facesMapping;
  62415. private _generateHarmonics;
  62416. private _noMipmap;
  62417. private _prefilterOnLoad;
  62418. private _textureMatrix;
  62419. private _size;
  62420. private _onLoad;
  62421. private _onError;
  62422. /**
  62423. * The texture URL.
  62424. */
  62425. url: string;
  62426. /**
  62427. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62428. */
  62429. coordinatesMode: number;
  62430. protected _isBlocking: boolean;
  62431. /**
  62432. * Sets wether or not the texture is blocking during loading.
  62433. */
  62434. set isBlocking(value: boolean);
  62435. /**
  62436. * Gets wether or not the texture is blocking during loading.
  62437. */
  62438. get isBlocking(): boolean;
  62439. protected _rotationY: number;
  62440. /**
  62441. * Sets texture matrix rotation angle around Y axis in radians.
  62442. */
  62443. set rotationY(value: number);
  62444. /**
  62445. * Gets texture matrix rotation angle around Y axis radians.
  62446. */
  62447. get rotationY(): number;
  62448. /**
  62449. * Gets or sets the center of the bounding box associated with the cube texture
  62450. * It must define where the camera used to render the texture was set
  62451. */
  62452. boundingBoxPosition: Vector3;
  62453. private _boundingBoxSize;
  62454. /**
  62455. * Gets or sets the size of the bounding box associated with the cube texture
  62456. * When defined, the cubemap will switch to local mode
  62457. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62458. * @example https://www.babylonjs-playground.com/#RNASML
  62459. */
  62460. set boundingBoxSize(value: Vector3);
  62461. get boundingBoxSize(): Vector3;
  62462. /**
  62463. * Instantiates an HDRTexture from the following parameters.
  62464. *
  62465. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62466. * @param sceneOrEngine The scene or engine the texture will be used in
  62467. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62468. * @param noMipmap Forces to not generate the mipmap if true
  62469. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62470. * @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)
  62471. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62472. */
  62473. 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>);
  62474. /**
  62475. * Get the current class name of the texture useful for serialization or dynamic coding.
  62476. * @returns "HDRCubeTexture"
  62477. */
  62478. getClassName(): string;
  62479. /**
  62480. * Occurs when the file is raw .hdr file.
  62481. */
  62482. private loadTexture;
  62483. clone(): HDRCubeTexture;
  62484. delayLoad(): void;
  62485. /**
  62486. * Get the texture reflection matrix used to rotate/transform the reflection.
  62487. * @returns the reflection matrix
  62488. */
  62489. getReflectionTextureMatrix(): Matrix;
  62490. /**
  62491. * Set the texture reflection matrix used to rotate/transform the reflection.
  62492. * @param value Define the reflection matrix to set
  62493. */
  62494. setReflectionTextureMatrix(value: Matrix): void;
  62495. /**
  62496. * Parses a JSON representation of an HDR Texture in order to create the texture
  62497. * @param parsedTexture Define the JSON representation
  62498. * @param scene Define the scene the texture should be created in
  62499. * @param rootUrl Define the root url in case we need to load relative dependencies
  62500. * @returns the newly created texture after parsing
  62501. */
  62502. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62503. serialize(): any;
  62504. }
  62505. }
  62506. declare module "babylonjs/Physics/physicsEngine" {
  62507. import { Nullable } from "babylonjs/types";
  62508. import { Vector3 } from "babylonjs/Maths/math.vector";
  62509. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62510. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62511. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62512. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62513. /**
  62514. * Class used to control physics engine
  62515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62516. */
  62517. export class PhysicsEngine implements IPhysicsEngine {
  62518. private _physicsPlugin;
  62519. /**
  62520. * Global value used to control the smallest number supported by the simulation
  62521. */
  62522. static Epsilon: number;
  62523. private _impostors;
  62524. private _joints;
  62525. private _subTimeStep;
  62526. /**
  62527. * Gets the gravity vector used by the simulation
  62528. */
  62529. gravity: Vector3;
  62530. /**
  62531. * Factory used to create the default physics plugin.
  62532. * @returns The default physics plugin
  62533. */
  62534. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62535. /**
  62536. * Creates a new Physics Engine
  62537. * @param gravity defines the gravity vector used by the simulation
  62538. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62539. */
  62540. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62541. /**
  62542. * Sets the gravity vector used by the simulation
  62543. * @param gravity defines the gravity vector to use
  62544. */
  62545. setGravity(gravity: Vector3): void;
  62546. /**
  62547. * Set the time step of the physics engine.
  62548. * Default is 1/60.
  62549. * To slow it down, enter 1/600 for example.
  62550. * To speed it up, 1/30
  62551. * @param newTimeStep defines the new timestep to apply to this world.
  62552. */
  62553. setTimeStep(newTimeStep?: number): void;
  62554. /**
  62555. * Get the time step of the physics engine.
  62556. * @returns the current time step
  62557. */
  62558. getTimeStep(): number;
  62559. /**
  62560. * Set the sub time step of the physics engine.
  62561. * Default is 0 meaning there is no sub steps
  62562. * To increase physics resolution precision, set a small value (like 1 ms)
  62563. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62564. */
  62565. setSubTimeStep(subTimeStep?: number): void;
  62566. /**
  62567. * Get the sub time step of the physics engine.
  62568. * @returns the current sub time step
  62569. */
  62570. getSubTimeStep(): number;
  62571. /**
  62572. * Release all resources
  62573. */
  62574. dispose(): void;
  62575. /**
  62576. * Gets the name of the current physics plugin
  62577. * @returns the name of the plugin
  62578. */
  62579. getPhysicsPluginName(): string;
  62580. /**
  62581. * Adding a new impostor for the impostor tracking.
  62582. * This will be done by the impostor itself.
  62583. * @param impostor the impostor to add
  62584. */
  62585. addImpostor(impostor: PhysicsImpostor): void;
  62586. /**
  62587. * Remove an impostor from the engine.
  62588. * This impostor and its mesh will not longer be updated by the physics engine.
  62589. * @param impostor the impostor to remove
  62590. */
  62591. removeImpostor(impostor: PhysicsImpostor): void;
  62592. /**
  62593. * Add a joint to the physics engine
  62594. * @param mainImpostor defines the main impostor to which the joint is added.
  62595. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62596. * @param joint defines the joint that will connect both impostors.
  62597. */
  62598. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62599. /**
  62600. * Removes a joint from the simulation
  62601. * @param mainImpostor defines the impostor used with the joint
  62602. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62603. * @param joint defines the joint to remove
  62604. */
  62605. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62606. /**
  62607. * Called by the scene. No need to call it.
  62608. * @param delta defines the timespam between frames
  62609. */
  62610. _step(delta: number): void;
  62611. /**
  62612. * Gets the current plugin used to run the simulation
  62613. * @returns current plugin
  62614. */
  62615. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62616. /**
  62617. * Gets the list of physic impostors
  62618. * @returns an array of PhysicsImpostor
  62619. */
  62620. getImpostors(): Array<PhysicsImpostor>;
  62621. /**
  62622. * Gets the impostor for a physics enabled object
  62623. * @param object defines the object impersonated by the impostor
  62624. * @returns the PhysicsImpostor or null if not found
  62625. */
  62626. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62627. /**
  62628. * Gets the impostor for a physics body object
  62629. * @param body defines physics body used by the impostor
  62630. * @returns the PhysicsImpostor or null if not found
  62631. */
  62632. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62633. /**
  62634. * Does a raycast in the physics world
  62635. * @param from when should the ray start?
  62636. * @param to when should the ray end?
  62637. * @returns PhysicsRaycastResult
  62638. */
  62639. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62640. }
  62641. }
  62642. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62643. import { Nullable } from "babylonjs/types";
  62644. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62646. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62647. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62648. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62649. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62650. /** @hidden */
  62651. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62652. private _useDeltaForWorldStep;
  62653. world: any;
  62654. name: string;
  62655. private _physicsMaterials;
  62656. private _fixedTimeStep;
  62657. private _cannonRaycastResult;
  62658. private _raycastResult;
  62659. private _physicsBodysToRemoveAfterStep;
  62660. private _firstFrame;
  62661. BJSCANNON: any;
  62662. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62663. setGravity(gravity: Vector3): void;
  62664. setTimeStep(timeStep: number): void;
  62665. getTimeStep(): number;
  62666. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62667. private _removeMarkedPhysicsBodiesFromWorld;
  62668. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62670. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62671. private _processChildMeshes;
  62672. removePhysicsBody(impostor: PhysicsImpostor): void;
  62673. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62674. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62675. private _addMaterial;
  62676. private _checkWithEpsilon;
  62677. private _createShape;
  62678. private _createHeightmap;
  62679. private _minus90X;
  62680. private _plus90X;
  62681. private _tmpPosition;
  62682. private _tmpDeltaPosition;
  62683. private _tmpUnityRotation;
  62684. private _updatePhysicsBodyTransformation;
  62685. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62686. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62687. isSupported(): boolean;
  62688. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62689. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62690. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62691. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62692. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62693. getBodyMass(impostor: PhysicsImpostor): number;
  62694. getBodyFriction(impostor: PhysicsImpostor): number;
  62695. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62696. getBodyRestitution(impostor: PhysicsImpostor): number;
  62697. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62698. sleepBody(impostor: PhysicsImpostor): void;
  62699. wakeUpBody(impostor: PhysicsImpostor): void;
  62700. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62701. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62702. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62703. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62704. getRadius(impostor: PhysicsImpostor): number;
  62705. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62706. dispose(): void;
  62707. private _extendNamespace;
  62708. /**
  62709. * Does a raycast in the physics world
  62710. * @param from when should the ray start?
  62711. * @param to when should the ray end?
  62712. * @returns PhysicsRaycastResult
  62713. */
  62714. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62715. }
  62716. }
  62717. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62718. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62719. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62720. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62722. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62723. import { Nullable } from "babylonjs/types";
  62724. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62725. /** @hidden */
  62726. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62727. private _useDeltaForWorldStep;
  62728. world: any;
  62729. name: string;
  62730. BJSOIMO: any;
  62731. private _raycastResult;
  62732. private _fixedTimeStep;
  62733. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62734. setGravity(gravity: Vector3): void;
  62735. setTimeStep(timeStep: number): void;
  62736. getTimeStep(): number;
  62737. private _tmpImpostorsArray;
  62738. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62739. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62740. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62741. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62742. private _tmpPositionVector;
  62743. removePhysicsBody(impostor: PhysicsImpostor): void;
  62744. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62745. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62746. isSupported(): boolean;
  62747. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62748. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62749. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62750. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62751. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62752. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62753. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62754. getBodyMass(impostor: PhysicsImpostor): number;
  62755. getBodyFriction(impostor: PhysicsImpostor): number;
  62756. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62757. getBodyRestitution(impostor: PhysicsImpostor): number;
  62758. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62759. sleepBody(impostor: PhysicsImpostor): void;
  62760. wakeUpBody(impostor: PhysicsImpostor): void;
  62761. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62762. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62763. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62764. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62765. getRadius(impostor: PhysicsImpostor): number;
  62766. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62767. dispose(): void;
  62768. /**
  62769. * Does a raycast in the physics world
  62770. * @param from when should the ray start?
  62771. * @param to when should the ray end?
  62772. * @returns PhysicsRaycastResult
  62773. */
  62774. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62775. }
  62776. }
  62777. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62778. import { Nullable } from "babylonjs/types";
  62779. import { Scene } from "babylonjs/scene";
  62780. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62781. import { Color4 } from "babylonjs/Maths/math.color";
  62782. import { Mesh } from "babylonjs/Meshes/mesh";
  62783. /**
  62784. * Class containing static functions to help procedurally build meshes
  62785. */
  62786. export class RibbonBuilder {
  62787. /**
  62788. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62789. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62790. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62791. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62792. * * 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
  62793. * * 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
  62794. * * 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
  62795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62797. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62798. * * 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
  62799. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62800. * * 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
  62801. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62803. * @param name defines the name of the mesh
  62804. * @param options defines the options used to create the mesh
  62805. * @param scene defines the hosting scene
  62806. * @returns the ribbon mesh
  62807. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62808. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62809. */
  62810. static CreateRibbon(name: string, options: {
  62811. pathArray: Vector3[][];
  62812. closeArray?: boolean;
  62813. closePath?: boolean;
  62814. offset?: number;
  62815. updatable?: boolean;
  62816. sideOrientation?: number;
  62817. frontUVs?: Vector4;
  62818. backUVs?: Vector4;
  62819. instance?: Mesh;
  62820. invertUV?: boolean;
  62821. uvs?: Vector2[];
  62822. colors?: Color4[];
  62823. }, scene?: Nullable<Scene>): Mesh;
  62824. }
  62825. }
  62826. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62827. import { Nullable } from "babylonjs/types";
  62828. import { Scene } from "babylonjs/scene";
  62829. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62830. import { Mesh } from "babylonjs/Meshes/mesh";
  62831. /**
  62832. * Class containing static functions to help procedurally build meshes
  62833. */
  62834. export class ShapeBuilder {
  62835. /**
  62836. * 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.
  62837. * * 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.
  62838. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62839. * * 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.
  62840. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62841. * * 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
  62842. * * 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
  62843. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62846. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62848. * @param name defines the name of the mesh
  62849. * @param options defines the options used to create the mesh
  62850. * @param scene defines the hosting scene
  62851. * @returns the extruded shape mesh
  62852. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62854. */
  62855. static ExtrudeShape(name: string, options: {
  62856. shape: Vector3[];
  62857. path: Vector3[];
  62858. scale?: number;
  62859. rotation?: number;
  62860. cap?: number;
  62861. updatable?: boolean;
  62862. sideOrientation?: number;
  62863. frontUVs?: Vector4;
  62864. backUVs?: Vector4;
  62865. instance?: Mesh;
  62866. invertUV?: boolean;
  62867. }, scene?: Nullable<Scene>): Mesh;
  62868. /**
  62869. * Creates an custom extruded shape mesh.
  62870. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62871. * * 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.
  62872. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62873. * * 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
  62874. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62875. * * 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
  62876. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62877. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62878. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62879. * * 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
  62880. * * 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
  62881. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62886. * @param name defines the name of the mesh
  62887. * @param options defines the options used to create the mesh
  62888. * @param scene defines the hosting scene
  62889. * @returns the custom extruded shape mesh
  62890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62891. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62893. */
  62894. static ExtrudeShapeCustom(name: string, options: {
  62895. shape: Vector3[];
  62896. path: Vector3[];
  62897. scaleFunction?: any;
  62898. rotationFunction?: any;
  62899. ribbonCloseArray?: boolean;
  62900. ribbonClosePath?: boolean;
  62901. cap?: number;
  62902. updatable?: boolean;
  62903. sideOrientation?: number;
  62904. frontUVs?: Vector4;
  62905. backUVs?: Vector4;
  62906. instance?: Mesh;
  62907. invertUV?: boolean;
  62908. }, scene?: Nullable<Scene>): Mesh;
  62909. private static _ExtrudeShapeGeneric;
  62910. }
  62911. }
  62912. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62913. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62914. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62915. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62916. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62917. import { Nullable } from "babylonjs/types";
  62918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62919. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62920. /**
  62921. * AmmoJS Physics plugin
  62922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62923. * @see https://github.com/kripken/ammo.js/
  62924. */
  62925. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62926. private _useDeltaForWorldStep;
  62927. /**
  62928. * Reference to the Ammo library
  62929. */
  62930. bjsAMMO: any;
  62931. /**
  62932. * Created ammoJS world which physics bodies are added to
  62933. */
  62934. world: any;
  62935. /**
  62936. * Name of the plugin
  62937. */
  62938. name: string;
  62939. private _timeStep;
  62940. private _fixedTimeStep;
  62941. private _maxSteps;
  62942. private _tmpQuaternion;
  62943. private _tmpAmmoTransform;
  62944. private _tmpAmmoQuaternion;
  62945. private _tmpAmmoConcreteContactResultCallback;
  62946. private _collisionConfiguration;
  62947. private _dispatcher;
  62948. private _overlappingPairCache;
  62949. private _solver;
  62950. private _softBodySolver;
  62951. private _tmpAmmoVectorA;
  62952. private _tmpAmmoVectorB;
  62953. private _tmpAmmoVectorC;
  62954. private _tmpAmmoVectorD;
  62955. private _tmpContactCallbackResult;
  62956. private _tmpAmmoVectorRCA;
  62957. private _tmpAmmoVectorRCB;
  62958. private _raycastResult;
  62959. private static readonly DISABLE_COLLISION_FLAG;
  62960. private static readonly KINEMATIC_FLAG;
  62961. private static readonly DISABLE_DEACTIVATION_FLAG;
  62962. /**
  62963. * Initializes the ammoJS plugin
  62964. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62965. * @param ammoInjection can be used to inject your own ammo reference
  62966. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62967. */
  62968. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62969. /**
  62970. * Sets the gravity of the physics world (m/(s^2))
  62971. * @param gravity Gravity to set
  62972. */
  62973. setGravity(gravity: Vector3): void;
  62974. /**
  62975. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62976. * @param timeStep timestep to use in seconds
  62977. */
  62978. setTimeStep(timeStep: number): void;
  62979. /**
  62980. * 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)
  62981. * @param fixedTimeStep fixedTimeStep to use in seconds
  62982. */
  62983. setFixedTimeStep(fixedTimeStep: number): void;
  62984. /**
  62985. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62986. * @param maxSteps the maximum number of steps by the physics engine per frame
  62987. */
  62988. setMaxSteps(maxSteps: number): void;
  62989. /**
  62990. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62991. * @returns the current timestep in seconds
  62992. */
  62993. getTimeStep(): number;
  62994. /**
  62995. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62996. */
  62997. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62998. private _isImpostorInContact;
  62999. private _isImpostorPairInContact;
  63000. private _stepSimulation;
  63001. /**
  63002. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63003. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63004. * After the step the babylon meshes are set to the position of the physics imposters
  63005. * @param delta amount of time to step forward
  63006. * @param impostors array of imposters to update before/after the step
  63007. */
  63008. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63009. /**
  63010. * Update babylon mesh to match physics world object
  63011. * @param impostor imposter to match
  63012. */
  63013. private _afterSoftStep;
  63014. /**
  63015. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63016. * @param impostor imposter to match
  63017. */
  63018. private _ropeStep;
  63019. /**
  63020. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63021. * @param impostor imposter to match
  63022. */
  63023. private _softbodyOrClothStep;
  63024. private _tmpMatrix;
  63025. /**
  63026. * Applies an impulse on the imposter
  63027. * @param impostor imposter to apply impulse to
  63028. * @param force amount of force to be applied to the imposter
  63029. * @param contactPoint the location to apply the impulse on the imposter
  63030. */
  63031. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63032. /**
  63033. * Applies a force on the imposter
  63034. * @param impostor imposter to apply force
  63035. * @param force amount of force to be applied to the imposter
  63036. * @param contactPoint the location to apply the force on the imposter
  63037. */
  63038. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63039. /**
  63040. * Creates a physics body using the plugin
  63041. * @param impostor the imposter to create the physics body on
  63042. */
  63043. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63044. /**
  63045. * Removes the physics body from the imposter and disposes of the body's memory
  63046. * @param impostor imposter to remove the physics body from
  63047. */
  63048. removePhysicsBody(impostor: PhysicsImpostor): void;
  63049. /**
  63050. * Generates a joint
  63051. * @param impostorJoint the imposter joint to create the joint with
  63052. */
  63053. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63054. /**
  63055. * Removes a joint
  63056. * @param impostorJoint the imposter joint to remove the joint from
  63057. */
  63058. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63059. private _addMeshVerts;
  63060. /**
  63061. * Initialise the soft body vertices to match its object's (mesh) vertices
  63062. * Softbody vertices (nodes) are in world space and to match this
  63063. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63064. * @param impostor to create the softbody for
  63065. */
  63066. private _softVertexData;
  63067. /**
  63068. * Create an impostor's soft body
  63069. * @param impostor to create the softbody for
  63070. */
  63071. private _createSoftbody;
  63072. /**
  63073. * Create cloth for an impostor
  63074. * @param impostor to create the softbody for
  63075. */
  63076. private _createCloth;
  63077. /**
  63078. * Create rope for an impostor
  63079. * @param impostor to create the softbody for
  63080. */
  63081. private _createRope;
  63082. /**
  63083. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63084. * @param impostor to create the custom physics shape for
  63085. */
  63086. private _createCustom;
  63087. private _addHullVerts;
  63088. private _createShape;
  63089. /**
  63090. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63091. * @param impostor imposter containing the physics body and babylon object
  63092. */
  63093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63094. /**
  63095. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63096. * @param impostor imposter containing the physics body and babylon object
  63097. * @param newPosition new position
  63098. * @param newRotation new rotation
  63099. */
  63100. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63101. /**
  63102. * If this plugin is supported
  63103. * @returns true if its supported
  63104. */
  63105. isSupported(): boolean;
  63106. /**
  63107. * Sets the linear velocity of the physics body
  63108. * @param impostor imposter to set the velocity on
  63109. * @param velocity velocity to set
  63110. */
  63111. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63112. /**
  63113. * Sets the angular velocity of the physics body
  63114. * @param impostor imposter to set the velocity on
  63115. * @param velocity velocity to set
  63116. */
  63117. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63118. /**
  63119. * gets the linear velocity
  63120. * @param impostor imposter to get linear velocity from
  63121. * @returns linear velocity
  63122. */
  63123. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63124. /**
  63125. * gets the angular velocity
  63126. * @param impostor imposter to get angular velocity from
  63127. * @returns angular velocity
  63128. */
  63129. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63130. /**
  63131. * Sets the mass of physics body
  63132. * @param impostor imposter to set the mass on
  63133. * @param mass mass to set
  63134. */
  63135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63136. /**
  63137. * Gets the mass of the physics body
  63138. * @param impostor imposter to get the mass from
  63139. * @returns mass
  63140. */
  63141. getBodyMass(impostor: PhysicsImpostor): number;
  63142. /**
  63143. * Gets friction of the impostor
  63144. * @param impostor impostor to get friction from
  63145. * @returns friction value
  63146. */
  63147. getBodyFriction(impostor: PhysicsImpostor): number;
  63148. /**
  63149. * Sets friction of the impostor
  63150. * @param impostor impostor to set friction on
  63151. * @param friction friction value
  63152. */
  63153. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63154. /**
  63155. * Gets restitution of the impostor
  63156. * @param impostor impostor to get restitution from
  63157. * @returns restitution value
  63158. */
  63159. getBodyRestitution(impostor: PhysicsImpostor): number;
  63160. /**
  63161. * Sets resitution of the impostor
  63162. * @param impostor impostor to set resitution on
  63163. * @param restitution resitution value
  63164. */
  63165. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63166. /**
  63167. * Gets pressure inside the impostor
  63168. * @param impostor impostor to get pressure from
  63169. * @returns pressure value
  63170. */
  63171. getBodyPressure(impostor: PhysicsImpostor): number;
  63172. /**
  63173. * Sets pressure inside a soft body impostor
  63174. * Cloth and rope must remain 0 pressure
  63175. * @param impostor impostor to set pressure on
  63176. * @param pressure pressure value
  63177. */
  63178. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63179. /**
  63180. * Gets stiffness of the impostor
  63181. * @param impostor impostor to get stiffness from
  63182. * @returns pressure value
  63183. */
  63184. getBodyStiffness(impostor: PhysicsImpostor): number;
  63185. /**
  63186. * Sets stiffness of the impostor
  63187. * @param impostor impostor to set stiffness on
  63188. * @param stiffness stiffness value from 0 to 1
  63189. */
  63190. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63191. /**
  63192. * Gets velocityIterations of the impostor
  63193. * @param impostor impostor to get velocity iterations from
  63194. * @returns velocityIterations value
  63195. */
  63196. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63197. /**
  63198. * Sets velocityIterations of the impostor
  63199. * @param impostor impostor to set velocity iterations on
  63200. * @param velocityIterations velocityIterations value
  63201. */
  63202. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63203. /**
  63204. * Gets positionIterations of the impostor
  63205. * @param impostor impostor to get position iterations from
  63206. * @returns positionIterations value
  63207. */
  63208. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63209. /**
  63210. * Sets positionIterations of the impostor
  63211. * @param impostor impostor to set position on
  63212. * @param positionIterations positionIterations value
  63213. */
  63214. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63215. /**
  63216. * Append an anchor to a cloth object
  63217. * @param impostor is the cloth impostor to add anchor to
  63218. * @param otherImpostor is the rigid impostor to anchor to
  63219. * @param width ratio across width from 0 to 1
  63220. * @param height ratio up height from 0 to 1
  63221. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63222. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63223. */
  63224. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63225. /**
  63226. * Append an hook to a rope object
  63227. * @param impostor is the rope impostor to add hook to
  63228. * @param otherImpostor is the rigid impostor to hook to
  63229. * @param length ratio along the rope from 0 to 1
  63230. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63231. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63232. */
  63233. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63234. /**
  63235. * Sleeps the physics body and stops it from being active
  63236. * @param impostor impostor to sleep
  63237. */
  63238. sleepBody(impostor: PhysicsImpostor): void;
  63239. /**
  63240. * Activates the physics body
  63241. * @param impostor impostor to activate
  63242. */
  63243. wakeUpBody(impostor: PhysicsImpostor): void;
  63244. /**
  63245. * Updates the distance parameters of the joint
  63246. * @param joint joint to update
  63247. * @param maxDistance maximum distance of the joint
  63248. * @param minDistance minimum distance of the joint
  63249. */
  63250. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63251. /**
  63252. * Sets a motor on the joint
  63253. * @param joint joint to set motor on
  63254. * @param speed speed of the motor
  63255. * @param maxForce maximum force of the motor
  63256. * @param motorIndex index of the motor
  63257. */
  63258. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63259. /**
  63260. * Sets the motors limit
  63261. * @param joint joint to set limit on
  63262. * @param upperLimit upper limit
  63263. * @param lowerLimit lower limit
  63264. */
  63265. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63266. /**
  63267. * Syncs the position and rotation of a mesh with the impostor
  63268. * @param mesh mesh to sync
  63269. * @param impostor impostor to update the mesh with
  63270. */
  63271. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63272. /**
  63273. * Gets the radius of the impostor
  63274. * @param impostor impostor to get radius from
  63275. * @returns the radius
  63276. */
  63277. getRadius(impostor: PhysicsImpostor): number;
  63278. /**
  63279. * Gets the box size of the impostor
  63280. * @param impostor impostor to get box size from
  63281. * @param result the resulting box size
  63282. */
  63283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63284. /**
  63285. * Disposes of the impostor
  63286. */
  63287. dispose(): void;
  63288. /**
  63289. * Does a raycast in the physics world
  63290. * @param from when should the ray start?
  63291. * @param to when should the ray end?
  63292. * @returns PhysicsRaycastResult
  63293. */
  63294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63295. }
  63296. }
  63297. declare module "babylonjs/Probes/reflectionProbe" {
  63298. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63299. import { Vector3 } from "babylonjs/Maths/math.vector";
  63300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63301. import { Nullable } from "babylonjs/types";
  63302. import { Scene } from "babylonjs/scene";
  63303. module "babylonjs/abstractScene" {
  63304. interface AbstractScene {
  63305. /**
  63306. * The list of reflection probes added to the scene
  63307. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63308. */
  63309. reflectionProbes: Array<ReflectionProbe>;
  63310. /**
  63311. * Removes the given reflection probe from this scene.
  63312. * @param toRemove The reflection probe to remove
  63313. * @returns The index of the removed reflection probe
  63314. */
  63315. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63316. /**
  63317. * Adds the given reflection probe to this scene.
  63318. * @param newReflectionProbe The reflection probe to add
  63319. */
  63320. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63321. }
  63322. }
  63323. /**
  63324. * Class used to generate realtime reflection / refraction cube textures
  63325. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63326. */
  63327. export class ReflectionProbe {
  63328. /** defines the name of the probe */
  63329. name: string;
  63330. private _scene;
  63331. private _renderTargetTexture;
  63332. private _projectionMatrix;
  63333. private _viewMatrix;
  63334. private _target;
  63335. private _add;
  63336. private _attachedMesh;
  63337. private _invertYAxis;
  63338. /** Gets or sets probe position (center of the cube map) */
  63339. position: Vector3;
  63340. /**
  63341. * Creates a new reflection probe
  63342. * @param name defines the name of the probe
  63343. * @param size defines the texture resolution (for each face)
  63344. * @param scene defines the hosting scene
  63345. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63346. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63347. */
  63348. constructor(
  63349. /** defines the name of the probe */
  63350. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63351. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63352. get samples(): number;
  63353. set samples(value: number);
  63354. /** Gets or sets the refresh rate to use (on every frame by default) */
  63355. get refreshRate(): number;
  63356. set refreshRate(value: number);
  63357. /**
  63358. * Gets the hosting scene
  63359. * @returns a Scene
  63360. */
  63361. getScene(): Scene;
  63362. /** Gets the internal CubeTexture used to render to */
  63363. get cubeTexture(): RenderTargetTexture;
  63364. /** Gets the list of meshes to render */
  63365. get renderList(): Nullable<AbstractMesh[]>;
  63366. /**
  63367. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63368. * @param mesh defines the mesh to attach to
  63369. */
  63370. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63371. /**
  63372. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63373. * @param renderingGroupId The rendering group id corresponding to its index
  63374. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63375. */
  63376. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63377. /**
  63378. * Clean all associated resources
  63379. */
  63380. dispose(): void;
  63381. /**
  63382. * Converts the reflection probe information to a readable string for debug purpose.
  63383. * @param fullDetails Supports for multiple levels of logging within scene loading
  63384. * @returns the human readable reflection probe info
  63385. */
  63386. toString(fullDetails?: boolean): string;
  63387. /**
  63388. * Get the class name of the relfection probe.
  63389. * @returns "ReflectionProbe"
  63390. */
  63391. getClassName(): string;
  63392. /**
  63393. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63394. * @returns The JSON representation of the texture
  63395. */
  63396. serialize(): any;
  63397. /**
  63398. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63399. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63400. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63401. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63402. * @returns The parsed reflection probe if successful
  63403. */
  63404. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63405. }
  63406. }
  63407. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63408. /** @hidden */
  63409. export var _BabylonLoaderRegistered: boolean;
  63410. /**
  63411. * Helps setting up some configuration for the babylon file loader.
  63412. */
  63413. export class BabylonFileLoaderConfiguration {
  63414. /**
  63415. * The loader does not allow injecting custom physix engine into the plugins.
  63416. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63417. * So you could set this variable to your engine import to make it work.
  63418. */
  63419. static LoaderInjectedPhysicsEngine: any;
  63420. }
  63421. }
  63422. declare module "babylonjs/Loading/Plugins/index" {
  63423. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63424. }
  63425. declare module "babylonjs/Loading/index" {
  63426. export * from "babylonjs/Loading/loadingScreen";
  63427. export * from "babylonjs/Loading/Plugins/index";
  63428. export * from "babylonjs/Loading/sceneLoader";
  63429. export * from "babylonjs/Loading/sceneLoaderFlags";
  63430. }
  63431. declare module "babylonjs/Materials/Background/index" {
  63432. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63433. }
  63434. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63435. import { Scene } from "babylonjs/scene";
  63436. import { Color3 } from "babylonjs/Maths/math.color";
  63437. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63439. /**
  63440. * The Physically based simple base material of BJS.
  63441. *
  63442. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63443. * It is used as the base class for both the specGloss and metalRough conventions.
  63444. */
  63445. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63446. /**
  63447. * Number of Simultaneous lights allowed on the material.
  63448. */
  63449. maxSimultaneousLights: number;
  63450. /**
  63451. * If sets to true, disables all the lights affecting the material.
  63452. */
  63453. disableLighting: boolean;
  63454. /**
  63455. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63456. */
  63457. environmentTexture: BaseTexture;
  63458. /**
  63459. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63460. */
  63461. invertNormalMapX: boolean;
  63462. /**
  63463. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63464. */
  63465. invertNormalMapY: boolean;
  63466. /**
  63467. * Normal map used in the model.
  63468. */
  63469. normalTexture: BaseTexture;
  63470. /**
  63471. * Emissivie color used to self-illuminate the model.
  63472. */
  63473. emissiveColor: Color3;
  63474. /**
  63475. * Emissivie texture used to self-illuminate the model.
  63476. */
  63477. emissiveTexture: BaseTexture;
  63478. /**
  63479. * Occlusion Channel Strenght.
  63480. */
  63481. occlusionStrength: number;
  63482. /**
  63483. * Occlusion Texture of the material (adding extra occlusion effects).
  63484. */
  63485. occlusionTexture: BaseTexture;
  63486. /**
  63487. * Defines the alpha limits in alpha test mode.
  63488. */
  63489. alphaCutOff: number;
  63490. /**
  63491. * Gets the current double sided mode.
  63492. */
  63493. get doubleSided(): boolean;
  63494. /**
  63495. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63496. */
  63497. set doubleSided(value: boolean);
  63498. /**
  63499. * Stores the pre-calculated light information of a mesh in a texture.
  63500. */
  63501. lightmapTexture: BaseTexture;
  63502. /**
  63503. * If true, the light map contains occlusion information instead of lighting info.
  63504. */
  63505. useLightmapAsShadowmap: boolean;
  63506. /**
  63507. * Instantiates a new PBRMaterial instance.
  63508. *
  63509. * @param name The material name
  63510. * @param scene The scene the material will be use in.
  63511. */
  63512. constructor(name: string, scene: Scene);
  63513. getClassName(): string;
  63514. }
  63515. }
  63516. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63517. import { Scene } from "babylonjs/scene";
  63518. import { Color3 } from "babylonjs/Maths/math.color";
  63519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63520. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63521. /**
  63522. * The PBR material of BJS following the metal roughness convention.
  63523. *
  63524. * This fits to the PBR convention in the GLTF definition:
  63525. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63526. */
  63527. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63528. /**
  63529. * The base color has two different interpretations depending on the value of metalness.
  63530. * When the material is a metal, the base color is the specific measured reflectance value
  63531. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63532. * of the material.
  63533. */
  63534. baseColor: Color3;
  63535. /**
  63536. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63537. * well as opacity information in the alpha channel.
  63538. */
  63539. baseTexture: BaseTexture;
  63540. /**
  63541. * Specifies the metallic scalar value of the material.
  63542. * Can also be used to scale the metalness values of the metallic texture.
  63543. */
  63544. metallic: number;
  63545. /**
  63546. * Specifies the roughness scalar value of the material.
  63547. * Can also be used to scale the roughness values of the metallic texture.
  63548. */
  63549. roughness: number;
  63550. /**
  63551. * Texture containing both the metallic value in the B channel and the
  63552. * roughness value in the G channel to keep better precision.
  63553. */
  63554. metallicRoughnessTexture: BaseTexture;
  63555. /**
  63556. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63557. *
  63558. * @param name The material name
  63559. * @param scene The scene the material will be use in.
  63560. */
  63561. constructor(name: string, scene: Scene);
  63562. /**
  63563. * Return the currrent class name of the material.
  63564. */
  63565. getClassName(): string;
  63566. /**
  63567. * Makes a duplicate of the current material.
  63568. * @param name - name to use for the new material.
  63569. */
  63570. clone(name: string): PBRMetallicRoughnessMaterial;
  63571. /**
  63572. * Serialize the material to a parsable JSON object.
  63573. */
  63574. serialize(): any;
  63575. /**
  63576. * Parses a JSON object correponding to the serialize function.
  63577. */
  63578. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63579. }
  63580. }
  63581. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63582. import { Scene } from "babylonjs/scene";
  63583. import { Color3 } from "babylonjs/Maths/math.color";
  63584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63585. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63586. /**
  63587. * The PBR material of BJS following the specular glossiness convention.
  63588. *
  63589. * This fits to the PBR convention in the GLTF definition:
  63590. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63591. */
  63592. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63593. /**
  63594. * Specifies the diffuse color of the material.
  63595. */
  63596. diffuseColor: Color3;
  63597. /**
  63598. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63599. * channel.
  63600. */
  63601. diffuseTexture: BaseTexture;
  63602. /**
  63603. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63604. */
  63605. specularColor: Color3;
  63606. /**
  63607. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63608. */
  63609. glossiness: number;
  63610. /**
  63611. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63612. */
  63613. specularGlossinessTexture: BaseTexture;
  63614. /**
  63615. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63616. *
  63617. * @param name The material name
  63618. * @param scene The scene the material will be use in.
  63619. */
  63620. constructor(name: string, scene: Scene);
  63621. /**
  63622. * Return the currrent class name of the material.
  63623. */
  63624. getClassName(): string;
  63625. /**
  63626. * Makes a duplicate of the current material.
  63627. * @param name - name to use for the new material.
  63628. */
  63629. clone(name: string): PBRSpecularGlossinessMaterial;
  63630. /**
  63631. * Serialize the material to a parsable JSON object.
  63632. */
  63633. serialize(): any;
  63634. /**
  63635. * Parses a JSON object correponding to the serialize function.
  63636. */
  63637. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63638. }
  63639. }
  63640. declare module "babylonjs/Materials/PBR/index" {
  63641. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63642. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63643. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63644. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63645. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63646. }
  63647. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63648. import { Nullable } from "babylonjs/types";
  63649. import { Scene } from "babylonjs/scene";
  63650. import { Matrix } from "babylonjs/Maths/math.vector";
  63651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63652. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63653. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63654. /**
  63655. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63656. * It can help converting any input color in a desired output one. This can then be used to create effects
  63657. * from sepia, black and white to sixties or futuristic rendering...
  63658. *
  63659. * The only supported format is currently 3dl.
  63660. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63661. */
  63662. export class ColorGradingTexture extends BaseTexture {
  63663. /**
  63664. * The texture URL.
  63665. */
  63666. url: string;
  63667. /**
  63668. * Empty line regex stored for GC.
  63669. */
  63670. private static _noneEmptyLineRegex;
  63671. private _textureMatrix;
  63672. private _onLoad;
  63673. /**
  63674. * Instantiates a ColorGradingTexture from the following parameters.
  63675. *
  63676. * @param url The location of the color gradind data (currently only supporting 3dl)
  63677. * @param sceneOrEngine The scene or engine the texture will be used in
  63678. * @param onLoad defines a callback triggered when the texture has been loaded
  63679. */
  63680. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63681. /**
  63682. * Fires the onload event from the constructor if requested.
  63683. */
  63684. private _triggerOnLoad;
  63685. /**
  63686. * Returns the texture matrix used in most of the material.
  63687. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63688. */
  63689. getTextureMatrix(): Matrix;
  63690. /**
  63691. * Occurs when the file being loaded is a .3dl LUT file.
  63692. */
  63693. private load3dlTexture;
  63694. /**
  63695. * Starts the loading process of the texture.
  63696. */
  63697. private loadTexture;
  63698. /**
  63699. * Clones the color gradind texture.
  63700. */
  63701. clone(): ColorGradingTexture;
  63702. /**
  63703. * Called during delayed load for textures.
  63704. */
  63705. delayLoad(): void;
  63706. /**
  63707. * Parses a color grading texture serialized by Babylon.
  63708. * @param parsedTexture The texture information being parsedTexture
  63709. * @param scene The scene to load the texture in
  63710. * @param rootUrl The root url of the data assets to load
  63711. * @return A color gradind texture
  63712. */
  63713. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63714. /**
  63715. * Serializes the LUT texture to json format.
  63716. */
  63717. serialize(): any;
  63718. }
  63719. }
  63720. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63722. import { Scene } from "babylonjs/scene";
  63723. import { Nullable } from "babylonjs/types";
  63724. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63725. /**
  63726. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63727. */
  63728. export class EquiRectangularCubeTexture extends BaseTexture {
  63729. /** The six faces of the cube. */
  63730. private static _FacesMapping;
  63731. private _noMipmap;
  63732. private _onLoad;
  63733. private _onError;
  63734. /** The size of the cubemap. */
  63735. private _size;
  63736. /** The buffer of the image. */
  63737. private _buffer;
  63738. /** The width of the input image. */
  63739. private _width;
  63740. /** The height of the input image. */
  63741. private _height;
  63742. /** The URL to the image. */
  63743. url: string;
  63744. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63745. coordinatesMode: number;
  63746. /**
  63747. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63748. * @param url The location of the image
  63749. * @param scene The scene the texture will be used in
  63750. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63751. * @param noMipmap Forces to not generate the mipmap if true
  63752. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63753. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63754. * @param onLoad — defines a callback called when texture is loaded
  63755. * @param onError — defines a callback called if there is an error
  63756. */
  63757. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63758. /**
  63759. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63760. */
  63761. private loadImage;
  63762. /**
  63763. * Convert the image buffer into a cubemap and create a CubeTexture.
  63764. */
  63765. private loadTexture;
  63766. /**
  63767. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63768. * @param buffer The ArrayBuffer that should be converted.
  63769. * @returns The buffer as Float32Array.
  63770. */
  63771. private getFloat32ArrayFromArrayBuffer;
  63772. /**
  63773. * Get the current class name of the texture useful for serialization or dynamic coding.
  63774. * @returns "EquiRectangularCubeTexture"
  63775. */
  63776. getClassName(): string;
  63777. /**
  63778. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63779. * @returns A clone of the current EquiRectangularCubeTexture.
  63780. */
  63781. clone(): EquiRectangularCubeTexture;
  63782. }
  63783. }
  63784. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63785. import { Nullable } from "babylonjs/types";
  63786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63787. import { Matrix } from "babylonjs/Maths/math.vector";
  63788. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63789. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63790. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63791. import { Scene } from "babylonjs/scene";
  63792. /**
  63793. * Defines the options related to the creation of an HtmlElementTexture
  63794. */
  63795. export interface IHtmlElementTextureOptions {
  63796. /**
  63797. * Defines wether mip maps should be created or not.
  63798. */
  63799. generateMipMaps?: boolean;
  63800. /**
  63801. * Defines the sampling mode of the texture.
  63802. */
  63803. samplingMode?: number;
  63804. /**
  63805. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63806. */
  63807. engine: Nullable<ThinEngine>;
  63808. /**
  63809. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63810. */
  63811. scene: Nullable<Scene>;
  63812. }
  63813. /**
  63814. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63815. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63816. * is automatically managed.
  63817. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63818. * in your application.
  63819. *
  63820. * As the update is not automatic, you need to call them manually.
  63821. */
  63822. export class HtmlElementTexture extends BaseTexture {
  63823. /**
  63824. * The texture URL.
  63825. */
  63826. element: HTMLVideoElement | HTMLCanvasElement;
  63827. private static readonly DefaultOptions;
  63828. private _textureMatrix;
  63829. private _isVideo;
  63830. private _generateMipMaps;
  63831. private _samplingMode;
  63832. /**
  63833. * Instantiates a HtmlElementTexture from the following parameters.
  63834. *
  63835. * @param name Defines the name of the texture
  63836. * @param element Defines the video or canvas the texture is filled with
  63837. * @param options Defines the other none mandatory texture creation options
  63838. */
  63839. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63840. private _createInternalTexture;
  63841. /**
  63842. * Returns the texture matrix used in most of the material.
  63843. */
  63844. getTextureMatrix(): Matrix;
  63845. /**
  63846. * Updates the content of the texture.
  63847. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63848. */
  63849. update(invertY?: Nullable<boolean>): void;
  63850. }
  63851. }
  63852. declare module "babylonjs/Misc/tga" {
  63853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63854. /**
  63855. * Based on jsTGALoader - Javascript loader for TGA file
  63856. * By Vincent Thibault
  63857. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63858. */
  63859. export class TGATools {
  63860. private static _TYPE_INDEXED;
  63861. private static _TYPE_RGB;
  63862. private static _TYPE_GREY;
  63863. private static _TYPE_RLE_INDEXED;
  63864. private static _TYPE_RLE_RGB;
  63865. private static _TYPE_RLE_GREY;
  63866. private static _ORIGIN_MASK;
  63867. private static _ORIGIN_SHIFT;
  63868. private static _ORIGIN_BL;
  63869. private static _ORIGIN_BR;
  63870. private static _ORIGIN_UL;
  63871. private static _ORIGIN_UR;
  63872. /**
  63873. * Gets the header of a TGA file
  63874. * @param data defines the TGA data
  63875. * @returns the header
  63876. */
  63877. static GetTGAHeader(data: Uint8Array): any;
  63878. /**
  63879. * Uploads TGA content to a Babylon Texture
  63880. * @hidden
  63881. */
  63882. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63883. /** @hidden */
  63884. 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;
  63885. /** @hidden */
  63886. 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;
  63887. /** @hidden */
  63888. 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;
  63889. /** @hidden */
  63890. 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;
  63891. /** @hidden */
  63892. 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;
  63893. /** @hidden */
  63894. 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;
  63895. }
  63896. }
  63897. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63898. import { Nullable } from "babylonjs/types";
  63899. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63900. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63901. /**
  63902. * Implementation of the TGA Texture Loader.
  63903. * @hidden
  63904. */
  63905. export class _TGATextureLoader implements IInternalTextureLoader {
  63906. /**
  63907. * Defines wether the loader supports cascade loading the different faces.
  63908. */
  63909. readonly supportCascades: boolean;
  63910. /**
  63911. * This returns if the loader support the current file information.
  63912. * @param extension defines the file extension of the file being loaded
  63913. * @returns true if the loader can load the specified file
  63914. */
  63915. canLoad(extension: string): boolean;
  63916. /**
  63917. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63918. * @param data contains the texture data
  63919. * @param texture defines the BabylonJS internal texture
  63920. * @param createPolynomials will be true if polynomials have been requested
  63921. * @param onLoad defines the callback to trigger once the texture is ready
  63922. * @param onError defines the callback to trigger in case of error
  63923. */
  63924. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63925. /**
  63926. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63927. * @param data contains the texture data
  63928. * @param texture defines the BabylonJS internal texture
  63929. * @param callback defines the method to call once ready to upload
  63930. */
  63931. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63932. }
  63933. }
  63934. declare module "babylonjs/Misc/basis" {
  63935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63936. /**
  63937. * Info about the .basis files
  63938. */
  63939. class BasisFileInfo {
  63940. /**
  63941. * If the file has alpha
  63942. */
  63943. hasAlpha: boolean;
  63944. /**
  63945. * Info about each image of the basis file
  63946. */
  63947. images: Array<{
  63948. levels: Array<{
  63949. width: number;
  63950. height: number;
  63951. transcodedPixels: ArrayBufferView;
  63952. }>;
  63953. }>;
  63954. }
  63955. /**
  63956. * Result of transcoding a basis file
  63957. */
  63958. class TranscodeResult {
  63959. /**
  63960. * Info about the .basis file
  63961. */
  63962. fileInfo: BasisFileInfo;
  63963. /**
  63964. * Format to use when loading the file
  63965. */
  63966. format: number;
  63967. }
  63968. /**
  63969. * Configuration options for the Basis transcoder
  63970. */
  63971. export class BasisTranscodeConfiguration {
  63972. /**
  63973. * Supported compression formats used to determine the supported output format of the transcoder
  63974. */
  63975. supportedCompressionFormats?: {
  63976. /**
  63977. * etc1 compression format
  63978. */
  63979. etc1?: boolean;
  63980. /**
  63981. * s3tc compression format
  63982. */
  63983. s3tc?: boolean;
  63984. /**
  63985. * pvrtc compression format
  63986. */
  63987. pvrtc?: boolean;
  63988. /**
  63989. * etc2 compression format
  63990. */
  63991. etc2?: boolean;
  63992. };
  63993. /**
  63994. * If mipmap levels should be loaded for transcoded images (Default: true)
  63995. */
  63996. loadMipmapLevels?: boolean;
  63997. /**
  63998. * Index of a single image to load (Default: all images)
  63999. */
  64000. loadSingleImage?: number;
  64001. }
  64002. /**
  64003. * Used to load .Basis files
  64004. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64005. */
  64006. export class BasisTools {
  64007. private static _IgnoreSupportedFormats;
  64008. /**
  64009. * URL to use when loading the basis transcoder
  64010. */
  64011. static JSModuleURL: string;
  64012. /**
  64013. * URL to use when loading the wasm module for the transcoder
  64014. */
  64015. static WasmModuleURL: string;
  64016. /**
  64017. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64018. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64019. * @returns internal format corresponding to the Basis format
  64020. */
  64021. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64022. private static _WorkerPromise;
  64023. private static _Worker;
  64024. private static _actionId;
  64025. private static _CreateWorkerAsync;
  64026. /**
  64027. * Transcodes a loaded image file to compressed pixel data
  64028. * @param data image data to transcode
  64029. * @param config configuration options for the transcoding
  64030. * @returns a promise resulting in the transcoded image
  64031. */
  64032. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64033. /**
  64034. * Loads a texture from the transcode result
  64035. * @param texture texture load to
  64036. * @param transcodeResult the result of transcoding the basis file to load from
  64037. */
  64038. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64039. }
  64040. }
  64041. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64042. import { Nullable } from "babylonjs/types";
  64043. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64044. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64045. /**
  64046. * Loader for .basis file format
  64047. */
  64048. export class _BasisTextureLoader implements IInternalTextureLoader {
  64049. /**
  64050. * Defines whether the loader supports cascade loading the different faces.
  64051. */
  64052. readonly supportCascades: boolean;
  64053. /**
  64054. * This returns if the loader support the current file information.
  64055. * @param extension defines the file extension of the file being loaded
  64056. * @returns true if the loader can load the specified file
  64057. */
  64058. canLoad(extension: string): boolean;
  64059. /**
  64060. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64061. * @param data contains the texture data
  64062. * @param texture defines the BabylonJS internal texture
  64063. * @param createPolynomials will be true if polynomials have been requested
  64064. * @param onLoad defines the callback to trigger once the texture is ready
  64065. * @param onError defines the callback to trigger in case of error
  64066. */
  64067. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64068. /**
  64069. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64070. * @param data contains the texture data
  64071. * @param texture defines the BabylonJS internal texture
  64072. * @param callback defines the method to call once ready to upload
  64073. */
  64074. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64075. }
  64076. }
  64077. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64078. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64079. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64080. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64081. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64082. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64083. }
  64084. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64085. import { Vector2 } from "babylonjs/Maths/math.vector";
  64086. /**
  64087. * Defines the basic options interface of a TexturePacker Frame
  64088. */
  64089. export interface ITexturePackerFrame {
  64090. /**
  64091. * The frame ID
  64092. */
  64093. id: number;
  64094. /**
  64095. * The frames Scale
  64096. */
  64097. scale: Vector2;
  64098. /**
  64099. * The Frames offset
  64100. */
  64101. offset: Vector2;
  64102. }
  64103. /**
  64104. * This is a support class for frame Data on texture packer sets.
  64105. */
  64106. export class TexturePackerFrame implements ITexturePackerFrame {
  64107. /**
  64108. * The frame ID
  64109. */
  64110. id: number;
  64111. /**
  64112. * The frames Scale
  64113. */
  64114. scale: Vector2;
  64115. /**
  64116. * The Frames offset
  64117. */
  64118. offset: Vector2;
  64119. /**
  64120. * Initializes a texture package frame.
  64121. * @param id The numerical frame identifier
  64122. * @param scale Scalar Vector2 for UV frame
  64123. * @param offset Vector2 for the frame position in UV units.
  64124. * @returns TexturePackerFrame
  64125. */
  64126. constructor(id: number, scale: Vector2, offset: Vector2);
  64127. }
  64128. }
  64129. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64131. import { Scene } from "babylonjs/scene";
  64132. import { Nullable } from "babylonjs/types";
  64133. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64134. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64135. /**
  64136. * Defines the basic options interface of a TexturePacker
  64137. */
  64138. export interface ITexturePackerOptions {
  64139. /**
  64140. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64141. */
  64142. map?: string[];
  64143. /**
  64144. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64145. */
  64146. uvsIn?: string;
  64147. /**
  64148. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64149. */
  64150. uvsOut?: string;
  64151. /**
  64152. * number representing the layout style. Defaults to LAYOUT_STRIP
  64153. */
  64154. layout?: number;
  64155. /**
  64156. * number of columns if using custom column count layout(2). This defaults to 4.
  64157. */
  64158. colnum?: number;
  64159. /**
  64160. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64161. */
  64162. updateInputMeshes?: boolean;
  64163. /**
  64164. * boolean flag to dispose all the source textures. Defaults to true.
  64165. */
  64166. disposeSources?: boolean;
  64167. /**
  64168. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64169. */
  64170. fillBlanks?: boolean;
  64171. /**
  64172. * string value representing the context fill style color. Defaults to 'black'.
  64173. */
  64174. customFillColor?: string;
  64175. /**
  64176. * Width and Height Value of each Frame in the TexturePacker Sets
  64177. */
  64178. frameSize?: number;
  64179. /**
  64180. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64181. */
  64182. paddingRatio?: number;
  64183. /**
  64184. * Number that declares the fill method for the padding gutter.
  64185. */
  64186. paddingMode?: number;
  64187. /**
  64188. * If in SUBUV_COLOR padding mode what color to use.
  64189. */
  64190. paddingColor?: Color3 | Color4;
  64191. }
  64192. /**
  64193. * Defines the basic interface of a TexturePacker JSON File
  64194. */
  64195. export interface ITexturePackerJSON {
  64196. /**
  64197. * The frame ID
  64198. */
  64199. name: string;
  64200. /**
  64201. * The base64 channel data
  64202. */
  64203. sets: any;
  64204. /**
  64205. * The options of the Packer
  64206. */
  64207. options: ITexturePackerOptions;
  64208. /**
  64209. * The frame data of the Packer
  64210. */
  64211. frames: Array<number>;
  64212. }
  64213. /**
  64214. * This is a support class that generates a series of packed texture sets.
  64215. * @see https://doc.babylonjs.com/babylon101/materials
  64216. */
  64217. export class TexturePacker {
  64218. /** Packer Layout Constant 0 */
  64219. static readonly LAYOUT_STRIP: number;
  64220. /** Packer Layout Constant 1 */
  64221. static readonly LAYOUT_POWER2: number;
  64222. /** Packer Layout Constant 2 */
  64223. static readonly LAYOUT_COLNUM: number;
  64224. /** Packer Layout Constant 0 */
  64225. static readonly SUBUV_WRAP: number;
  64226. /** Packer Layout Constant 1 */
  64227. static readonly SUBUV_EXTEND: number;
  64228. /** Packer Layout Constant 2 */
  64229. static readonly SUBUV_COLOR: number;
  64230. /** The Name of the Texture Package */
  64231. name: string;
  64232. /** The scene scope of the TexturePacker */
  64233. scene: Scene;
  64234. /** The Meshes to target */
  64235. meshes: AbstractMesh[];
  64236. /** Arguments passed with the Constructor */
  64237. options: ITexturePackerOptions;
  64238. /** The promise that is started upon initialization */
  64239. promise: Nullable<Promise<TexturePacker | string>>;
  64240. /** The Container object for the channel sets that are generated */
  64241. sets: object;
  64242. /** The Container array for the frames that are generated */
  64243. frames: TexturePackerFrame[];
  64244. /** The expected number of textures the system is parsing. */
  64245. private _expecting;
  64246. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64247. private _paddingValue;
  64248. /**
  64249. * Initializes a texture package series from an array of meshes or a single mesh.
  64250. * @param name The name of the package
  64251. * @param meshes The target meshes to compose the package from
  64252. * @param options The arguments that texture packer should follow while building.
  64253. * @param scene The scene which the textures are scoped to.
  64254. * @returns TexturePacker
  64255. */
  64256. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64257. /**
  64258. * Starts the package process
  64259. * @param resolve The promises resolution function
  64260. * @returns TexturePacker
  64261. */
  64262. private _createFrames;
  64263. /**
  64264. * Calculates the Size of the Channel Sets
  64265. * @returns Vector2
  64266. */
  64267. private _calculateSize;
  64268. /**
  64269. * Calculates the UV data for the frames.
  64270. * @param baseSize the base frameSize
  64271. * @param padding the base frame padding
  64272. * @param dtSize size of the Dynamic Texture for that channel
  64273. * @param dtUnits is 1/dtSize
  64274. * @param update flag to update the input meshes
  64275. */
  64276. private _calculateMeshUVFrames;
  64277. /**
  64278. * Calculates the frames Offset.
  64279. * @param index of the frame
  64280. * @returns Vector2
  64281. */
  64282. private _getFrameOffset;
  64283. /**
  64284. * Updates a Mesh to the frame data
  64285. * @param mesh that is the target
  64286. * @param frameID or the frame index
  64287. */
  64288. private _updateMeshUV;
  64289. /**
  64290. * Updates a Meshes materials to use the texture packer channels
  64291. * @param m is the mesh to target
  64292. * @param force all channels on the packer to be set.
  64293. */
  64294. private _updateTextureReferences;
  64295. /**
  64296. * Public method to set a Mesh to a frame
  64297. * @param m that is the target
  64298. * @param frameID or the frame index
  64299. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64300. */
  64301. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64302. /**
  64303. * Starts the async promise to compile the texture packer.
  64304. * @returns Promise<void>
  64305. */
  64306. processAsync(): Promise<void>;
  64307. /**
  64308. * Disposes all textures associated with this packer
  64309. */
  64310. dispose(): void;
  64311. /**
  64312. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64313. * @param imageType is the image type to use.
  64314. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64315. */
  64316. download(imageType?: string, quality?: number): void;
  64317. /**
  64318. * Public method to load a texturePacker JSON file.
  64319. * @param data of the JSON file in string format.
  64320. */
  64321. updateFromJSON(data: string): void;
  64322. }
  64323. }
  64324. declare module "babylonjs/Materials/Textures/Packer/index" {
  64325. export * from "babylonjs/Materials/Textures/Packer/packer";
  64326. export * from "babylonjs/Materials/Textures/Packer/frame";
  64327. }
  64328. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64329. import { Scene } from "babylonjs/scene";
  64330. import { Texture } from "babylonjs/Materials/Textures/texture";
  64331. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64332. /**
  64333. * 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.
  64334. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64335. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64336. */
  64337. export class CustomProceduralTexture extends ProceduralTexture {
  64338. private _animate;
  64339. private _time;
  64340. private _config;
  64341. private _texturePath;
  64342. /**
  64343. * Instantiates a new Custom Procedural Texture.
  64344. * 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.
  64345. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64346. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64347. * @param name Define the name of the texture
  64348. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64349. * @param size Define the size of the texture to create
  64350. * @param scene Define the scene the texture belongs to
  64351. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64352. * @param generateMipMaps Define if the texture should creates mip maps or not
  64353. */
  64354. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64355. private _loadJson;
  64356. /**
  64357. * Is the texture ready to be used ? (rendered at least once)
  64358. * @returns true if ready, otherwise, false.
  64359. */
  64360. isReady(): boolean;
  64361. /**
  64362. * Render the texture to its associated render target.
  64363. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64364. */
  64365. render(useCameraPostProcess?: boolean): void;
  64366. /**
  64367. * Update the list of dependant textures samplers in the shader.
  64368. */
  64369. updateTextures(): void;
  64370. /**
  64371. * Update the uniform values of the procedural texture in the shader.
  64372. */
  64373. updateShaderUniforms(): void;
  64374. /**
  64375. * Define if the texture animates or not.
  64376. */
  64377. get animate(): boolean;
  64378. set animate(value: boolean);
  64379. }
  64380. }
  64381. declare module "babylonjs/Shaders/noise.fragment" {
  64382. /** @hidden */
  64383. export var noisePixelShader: {
  64384. name: string;
  64385. shader: string;
  64386. };
  64387. }
  64388. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64389. import { Nullable } from "babylonjs/types";
  64390. import { Scene } from "babylonjs/scene";
  64391. import { Texture } from "babylonjs/Materials/Textures/texture";
  64392. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64393. import "babylonjs/Shaders/noise.fragment";
  64394. /**
  64395. * Class used to generate noise procedural textures
  64396. */
  64397. export class NoiseProceduralTexture extends ProceduralTexture {
  64398. private _time;
  64399. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64400. brightness: number;
  64401. /** Defines the number of octaves to process */
  64402. octaves: number;
  64403. /** Defines the level of persistence (0.8 by default) */
  64404. persistence: number;
  64405. /** Gets or sets animation speed factor (default is 1) */
  64406. animationSpeedFactor: number;
  64407. /**
  64408. * Creates a new NoiseProceduralTexture
  64409. * @param name defines the name fo the texture
  64410. * @param size defines the size of the texture (default is 256)
  64411. * @param scene defines the hosting scene
  64412. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64413. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64414. */
  64415. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64416. private _updateShaderUniforms;
  64417. protected _getDefines(): string;
  64418. /** Generate the current state of the procedural texture */
  64419. render(useCameraPostProcess?: boolean): void;
  64420. /**
  64421. * Serializes this noise procedural texture
  64422. * @returns a serialized noise procedural texture object
  64423. */
  64424. serialize(): any;
  64425. /**
  64426. * Clone the texture.
  64427. * @returns the cloned texture
  64428. */
  64429. clone(): NoiseProceduralTexture;
  64430. /**
  64431. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64432. * @param parsedTexture defines parsed texture data
  64433. * @param scene defines the current scene
  64434. * @param rootUrl defines the root URL containing noise procedural texture information
  64435. * @returns a parsed NoiseProceduralTexture
  64436. */
  64437. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64438. }
  64439. }
  64440. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64441. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64442. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64443. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64444. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64445. }
  64446. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64447. import { Nullable } from "babylonjs/types";
  64448. import { Scene } from "babylonjs/scene";
  64449. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64451. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64452. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64453. /**
  64454. * Raw cube texture where the raw buffers are passed in
  64455. */
  64456. export class RawCubeTexture extends CubeTexture {
  64457. /**
  64458. * Creates a cube texture where the raw buffers are passed in.
  64459. * @param scene defines the scene the texture is attached to
  64460. * @param data defines the array of data to use to create each face
  64461. * @param size defines the size of the textures
  64462. * @param format defines the format of the data
  64463. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64464. * @param generateMipMaps defines if the engine should generate the mip levels
  64465. * @param invertY defines if data must be stored with Y axis inverted
  64466. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64467. * @param compression defines the compression used (null by default)
  64468. */
  64469. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64470. /**
  64471. * Updates the raw cube texture.
  64472. * @param data defines the data to store
  64473. * @param format defines the data format
  64474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64475. * @param invertY defines if data must be stored with Y axis inverted
  64476. * @param compression defines the compression used (null by default)
  64477. * @param level defines which level of the texture to update
  64478. */
  64479. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64480. /**
  64481. * Updates a raw cube texture with RGBD encoded data.
  64482. * @param data defines the array of data [mipmap][face] to use to create each face
  64483. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64484. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64485. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64486. * @returns a promsie that resolves when the operation is complete
  64487. */
  64488. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64489. /**
  64490. * Clones the raw cube texture.
  64491. * @return a new cube texture
  64492. */
  64493. clone(): CubeTexture;
  64494. /** @hidden */
  64495. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64496. }
  64497. }
  64498. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64499. import { Scene } from "babylonjs/scene";
  64500. import { Texture } from "babylonjs/Materials/Textures/texture";
  64501. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64502. /**
  64503. * Class used to store 2D array textures containing user data
  64504. */
  64505. export class RawTexture2DArray extends Texture {
  64506. /** Gets or sets the texture format to use */
  64507. format: number;
  64508. /**
  64509. * Create a new RawTexture2DArray
  64510. * @param data defines the data of the texture
  64511. * @param width defines the width of the texture
  64512. * @param height defines the height of the texture
  64513. * @param depth defines the number of layers of the texture
  64514. * @param format defines the texture format to use
  64515. * @param scene defines the hosting scene
  64516. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64517. * @param invertY defines if texture must be stored with Y axis inverted
  64518. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64519. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64520. */
  64521. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64522. /** Gets or sets the texture format to use */
  64523. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64524. /**
  64525. * Update the texture with new data
  64526. * @param data defines the data to store in the texture
  64527. */
  64528. update(data: ArrayBufferView): void;
  64529. }
  64530. }
  64531. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64532. import { Scene } from "babylonjs/scene";
  64533. import { Texture } from "babylonjs/Materials/Textures/texture";
  64534. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64535. /**
  64536. * Class used to store 3D textures containing user data
  64537. */
  64538. export class RawTexture3D extends Texture {
  64539. /** Gets or sets the texture format to use */
  64540. format: number;
  64541. /**
  64542. * Create a new RawTexture3D
  64543. * @param data defines the data of the texture
  64544. * @param width defines the width of the texture
  64545. * @param height defines the height of the texture
  64546. * @param depth defines the depth of the texture
  64547. * @param format defines the texture format to use
  64548. * @param scene defines the hosting scene
  64549. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64550. * @param invertY defines if texture must be stored with Y axis inverted
  64551. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64553. */
  64554. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64555. /** Gets or sets the texture format to use */
  64556. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64557. /**
  64558. * Update the texture with new data
  64559. * @param data defines the data to store in the texture
  64560. */
  64561. update(data: ArrayBufferView): void;
  64562. }
  64563. }
  64564. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64565. import { Scene } from "babylonjs/scene";
  64566. import { Plane } from "babylonjs/Maths/math.plane";
  64567. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64568. /**
  64569. * Creates a refraction texture used by refraction channel of the standard material.
  64570. * It is like a mirror but to see through a material.
  64571. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64572. */
  64573. export class RefractionTexture extends RenderTargetTexture {
  64574. /**
  64575. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64576. * 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.
  64577. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64578. */
  64579. refractionPlane: Plane;
  64580. /**
  64581. * Define how deep under the surface we should see.
  64582. */
  64583. depth: number;
  64584. /**
  64585. * Creates a refraction texture used by refraction channel of the standard material.
  64586. * It is like a mirror but to see through a material.
  64587. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64588. * @param name Define the texture name
  64589. * @param size Define the size of the underlying texture
  64590. * @param scene Define the scene the refraction belongs to
  64591. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64592. */
  64593. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64594. /**
  64595. * Clone the refraction texture.
  64596. * @returns the cloned texture
  64597. */
  64598. clone(): RefractionTexture;
  64599. /**
  64600. * Serialize the texture to a JSON representation you could use in Parse later on
  64601. * @returns the serialized JSON representation
  64602. */
  64603. serialize(): any;
  64604. }
  64605. }
  64606. declare module "babylonjs/Materials/Textures/index" {
  64607. export * from "babylonjs/Materials/Textures/baseTexture";
  64608. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64609. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64610. export * from "babylonjs/Materials/Textures/cubeTexture";
  64611. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64612. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64613. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64614. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64615. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64616. export * from "babylonjs/Materials/Textures/internalTexture";
  64617. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64618. export * from "babylonjs/Materials/Textures/Loaders/index";
  64619. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64620. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64621. export * from "babylonjs/Materials/Textures/Packer/index";
  64622. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64623. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64624. export * from "babylonjs/Materials/Textures/rawTexture";
  64625. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64626. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64627. export * from "babylonjs/Materials/Textures/refractionTexture";
  64628. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64629. export * from "babylonjs/Materials/Textures/texture";
  64630. export * from "babylonjs/Materials/Textures/videoTexture";
  64631. }
  64632. declare module "babylonjs/Materials/Node/Enums/index" {
  64633. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64634. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64635. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64636. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64637. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64638. }
  64639. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64643. import { Mesh } from "babylonjs/Meshes/mesh";
  64644. import { Effect } from "babylonjs/Materials/effect";
  64645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64646. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64647. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64648. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64649. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64650. /**
  64651. * Block used to add support for vertex skinning (bones)
  64652. */
  64653. export class BonesBlock extends NodeMaterialBlock {
  64654. /**
  64655. * Creates a new BonesBlock
  64656. * @param name defines the block name
  64657. */
  64658. constructor(name: string);
  64659. /**
  64660. * Initialize the block and prepare the context for build
  64661. * @param state defines the state that will be used for the build
  64662. */
  64663. initialize(state: NodeMaterialBuildState): void;
  64664. /**
  64665. * Gets the current class name
  64666. * @returns the class name
  64667. */
  64668. getClassName(): string;
  64669. /**
  64670. * Gets the matrix indices input component
  64671. */
  64672. get matricesIndices(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the matrix weights input component
  64675. */
  64676. get matricesWeights(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Gets the extra matrix indices input component
  64679. */
  64680. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the extra matrix weights input component
  64683. */
  64684. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64685. /**
  64686. * Gets the world input component
  64687. */
  64688. get world(): NodeMaterialConnectionPoint;
  64689. /**
  64690. * Gets the output component
  64691. */
  64692. get output(): NodeMaterialConnectionPoint;
  64693. autoConfigure(material: NodeMaterial): void;
  64694. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64697. protected _buildBlock(state: NodeMaterialBuildState): this;
  64698. }
  64699. }
  64700. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64705. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64706. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64707. /**
  64708. * Block used to add support for instances
  64709. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64710. */
  64711. export class InstancesBlock extends NodeMaterialBlock {
  64712. /**
  64713. * Creates a new InstancesBlock
  64714. * @param name defines the block name
  64715. */
  64716. constructor(name: string);
  64717. /**
  64718. * Gets the current class name
  64719. * @returns the class name
  64720. */
  64721. getClassName(): string;
  64722. /**
  64723. * Gets the first world row input component
  64724. */
  64725. get world0(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the second world row input component
  64728. */
  64729. get world1(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the third world row input component
  64732. */
  64733. get world2(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the forth world row input component
  64736. */
  64737. get world3(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the world input component
  64740. */
  64741. get world(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the output component
  64744. */
  64745. get output(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the isntanceID component
  64748. */
  64749. get instanceID(): NodeMaterialConnectionPoint;
  64750. autoConfigure(material: NodeMaterial): void;
  64751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64752. protected _buildBlock(state: NodeMaterialBuildState): this;
  64753. }
  64754. }
  64755. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64760. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64761. import { Effect } from "babylonjs/Materials/effect";
  64762. import { Mesh } from "babylonjs/Meshes/mesh";
  64763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64765. /**
  64766. * Block used to add morph targets support to vertex shader
  64767. */
  64768. export class MorphTargetsBlock extends NodeMaterialBlock {
  64769. private _repeatableContentAnchor;
  64770. /**
  64771. * Create a new MorphTargetsBlock
  64772. * @param name defines the block name
  64773. */
  64774. constructor(name: string);
  64775. /**
  64776. * Gets the current class name
  64777. * @returns the class name
  64778. */
  64779. getClassName(): string;
  64780. /**
  64781. * Gets the position input component
  64782. */
  64783. get position(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the normal input component
  64786. */
  64787. get normal(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the tangent input component
  64790. */
  64791. get tangent(): NodeMaterialConnectionPoint;
  64792. /**
  64793. * Gets the tangent input component
  64794. */
  64795. get uv(): NodeMaterialConnectionPoint;
  64796. /**
  64797. * Gets the position output component
  64798. */
  64799. get positionOutput(): NodeMaterialConnectionPoint;
  64800. /**
  64801. * Gets the normal output component
  64802. */
  64803. get normalOutput(): NodeMaterialConnectionPoint;
  64804. /**
  64805. * Gets the tangent output component
  64806. */
  64807. get tangentOutput(): NodeMaterialConnectionPoint;
  64808. /**
  64809. * Gets the tangent output component
  64810. */
  64811. get uvOutput(): NodeMaterialConnectionPoint;
  64812. initialize(state: NodeMaterialBuildState): void;
  64813. autoConfigure(material: NodeMaterial): void;
  64814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64815. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64816. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64817. protected _buildBlock(state: NodeMaterialBuildState): this;
  64818. }
  64819. }
  64820. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64824. import { Nullable } from "babylonjs/types";
  64825. import { Scene } from "babylonjs/scene";
  64826. import { Effect } from "babylonjs/Materials/effect";
  64827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64828. import { Mesh } from "babylonjs/Meshes/mesh";
  64829. import { Light } from "babylonjs/Lights/light";
  64830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64831. /**
  64832. * Block used to get data information from a light
  64833. */
  64834. export class LightInformationBlock extends NodeMaterialBlock {
  64835. private _lightDataUniformName;
  64836. private _lightColorUniformName;
  64837. private _lightTypeDefineName;
  64838. /**
  64839. * Gets or sets the light associated with this block
  64840. */
  64841. light: Nullable<Light>;
  64842. /**
  64843. * Creates a new LightInformationBlock
  64844. * @param name defines the block name
  64845. */
  64846. constructor(name: string);
  64847. /**
  64848. * Gets the current class name
  64849. * @returns the class name
  64850. */
  64851. getClassName(): string;
  64852. /**
  64853. * Gets the world position input component
  64854. */
  64855. get worldPosition(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the direction output component
  64858. */
  64859. get direction(): NodeMaterialConnectionPoint;
  64860. /**
  64861. * Gets the direction output component
  64862. */
  64863. get color(): NodeMaterialConnectionPoint;
  64864. /**
  64865. * Gets the direction output component
  64866. */
  64867. get intensity(): NodeMaterialConnectionPoint;
  64868. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64870. protected _buildBlock(state: NodeMaterialBuildState): this;
  64871. serialize(): any;
  64872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64873. }
  64874. }
  64875. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64876. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64877. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64878. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64879. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64880. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64881. }
  64882. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64887. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64888. import { Effect } from "babylonjs/Materials/effect";
  64889. import { Mesh } from "babylonjs/Meshes/mesh";
  64890. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64892. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64893. /**
  64894. * Block used to add image processing support to fragment shader
  64895. */
  64896. export class ImageProcessingBlock extends NodeMaterialBlock {
  64897. /**
  64898. * Create a new ImageProcessingBlock
  64899. * @param name defines the block name
  64900. */
  64901. constructor(name: string);
  64902. /**
  64903. * Gets the current class name
  64904. * @returns the class name
  64905. */
  64906. getClassName(): string;
  64907. /**
  64908. * Gets the color input component
  64909. */
  64910. get color(): NodeMaterialConnectionPoint;
  64911. /**
  64912. * Gets the output component
  64913. */
  64914. get output(): NodeMaterialConnectionPoint;
  64915. /**
  64916. * Initialize the block and prepare the context for build
  64917. * @param state defines the state that will be used for the build
  64918. */
  64919. initialize(state: NodeMaterialBuildState): void;
  64920. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64923. protected _buildBlock(state: NodeMaterialBuildState): this;
  64924. }
  64925. }
  64926. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64930. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64932. import { Effect } from "babylonjs/Materials/effect";
  64933. import { Mesh } from "babylonjs/Meshes/mesh";
  64934. import { Scene } from "babylonjs/scene";
  64935. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64936. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64937. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64938. /**
  64939. * Block used to pertub normals based on a normal map
  64940. */
  64941. export class PerturbNormalBlock extends NodeMaterialBlock {
  64942. private _tangentSpaceParameterName;
  64943. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64944. invertX: boolean;
  64945. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64946. invertY: boolean;
  64947. /**
  64948. * Create a new PerturbNormalBlock
  64949. * @param name defines the block name
  64950. */
  64951. constructor(name: string);
  64952. /**
  64953. * Gets the current class name
  64954. * @returns the class name
  64955. */
  64956. getClassName(): string;
  64957. /**
  64958. * Gets the world position input component
  64959. */
  64960. get worldPosition(): NodeMaterialConnectionPoint;
  64961. /**
  64962. * Gets the world normal input component
  64963. */
  64964. get worldNormal(): NodeMaterialConnectionPoint;
  64965. /**
  64966. * Gets the world tangent input component
  64967. */
  64968. get worldTangent(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the uv input component
  64971. */
  64972. get uv(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the normal map color input component
  64975. */
  64976. get normalMapColor(): NodeMaterialConnectionPoint;
  64977. /**
  64978. * Gets the strength input component
  64979. */
  64980. get strength(): NodeMaterialConnectionPoint;
  64981. /**
  64982. * Gets the output component
  64983. */
  64984. get output(): NodeMaterialConnectionPoint;
  64985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64986. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64987. autoConfigure(material: NodeMaterial): void;
  64988. protected _buildBlock(state: NodeMaterialBuildState): this;
  64989. protected _dumpPropertiesCode(): string;
  64990. serialize(): any;
  64991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64992. }
  64993. }
  64994. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64998. /**
  64999. * Block used to discard a pixel if a value is smaller than a cutoff
  65000. */
  65001. export class DiscardBlock extends NodeMaterialBlock {
  65002. /**
  65003. * Create a new DiscardBlock
  65004. * @param name defines the block name
  65005. */
  65006. constructor(name: string);
  65007. /**
  65008. * Gets the current class name
  65009. * @returns the class name
  65010. */
  65011. getClassName(): string;
  65012. /**
  65013. * Gets the color input component
  65014. */
  65015. get value(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the cutoff input component
  65018. */
  65019. get cutoff(): NodeMaterialConnectionPoint;
  65020. protected _buildBlock(state: NodeMaterialBuildState): this;
  65021. }
  65022. }
  65023. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65027. /**
  65028. * Block used to test if the fragment shader is front facing
  65029. */
  65030. export class FrontFacingBlock extends NodeMaterialBlock {
  65031. /**
  65032. * Creates a new FrontFacingBlock
  65033. * @param name defines the block name
  65034. */
  65035. constructor(name: string);
  65036. /**
  65037. * Gets the current class name
  65038. * @returns the class name
  65039. */
  65040. getClassName(): string;
  65041. /**
  65042. * Gets the output component
  65043. */
  65044. get output(): NodeMaterialConnectionPoint;
  65045. protected _buildBlock(state: NodeMaterialBuildState): this;
  65046. }
  65047. }
  65048. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65052. /**
  65053. * Block used to get the derivative value on x and y of a given input
  65054. */
  65055. export class DerivativeBlock extends NodeMaterialBlock {
  65056. /**
  65057. * Create a new DerivativeBlock
  65058. * @param name defines the block name
  65059. */
  65060. constructor(name: string);
  65061. /**
  65062. * Gets the current class name
  65063. * @returns the class name
  65064. */
  65065. getClassName(): string;
  65066. /**
  65067. * Gets the input component
  65068. */
  65069. get input(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the derivative output on x
  65072. */
  65073. get dx(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the derivative output on y
  65076. */
  65077. get dy(): NodeMaterialConnectionPoint;
  65078. protected _buildBlock(state: NodeMaterialBuildState): this;
  65079. }
  65080. }
  65081. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65085. /**
  65086. * Block used to make gl_FragCoord available
  65087. */
  65088. export class FragCoordBlock extends NodeMaterialBlock {
  65089. /**
  65090. * Creates a new FragCoordBlock
  65091. * @param name defines the block name
  65092. */
  65093. constructor(name: string);
  65094. /**
  65095. * Gets the current class name
  65096. * @returns the class name
  65097. */
  65098. getClassName(): string;
  65099. /**
  65100. * Gets the xy component
  65101. */
  65102. get xy(): NodeMaterialConnectionPoint;
  65103. /**
  65104. * Gets the xyz component
  65105. */
  65106. get xyz(): NodeMaterialConnectionPoint;
  65107. /**
  65108. * Gets the xyzw component
  65109. */
  65110. get xyzw(): NodeMaterialConnectionPoint;
  65111. /**
  65112. * Gets the x component
  65113. */
  65114. get x(): NodeMaterialConnectionPoint;
  65115. /**
  65116. * Gets the y component
  65117. */
  65118. get y(): NodeMaterialConnectionPoint;
  65119. /**
  65120. * Gets the z component
  65121. */
  65122. get z(): NodeMaterialConnectionPoint;
  65123. /**
  65124. * Gets the w component
  65125. */
  65126. get output(): NodeMaterialConnectionPoint;
  65127. protected writeOutputs(state: NodeMaterialBuildState): string;
  65128. protected _buildBlock(state: NodeMaterialBuildState): this;
  65129. }
  65130. }
  65131. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65135. import { Effect } from "babylonjs/Materials/effect";
  65136. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65137. import { Mesh } from "babylonjs/Meshes/mesh";
  65138. /**
  65139. * Block used to get the screen sizes
  65140. */
  65141. export class ScreenSizeBlock extends NodeMaterialBlock {
  65142. private _varName;
  65143. private _scene;
  65144. /**
  65145. * Creates a new ScreenSizeBlock
  65146. * @param name defines the block name
  65147. */
  65148. constructor(name: string);
  65149. /**
  65150. * Gets the current class name
  65151. * @returns the class name
  65152. */
  65153. getClassName(): string;
  65154. /**
  65155. * Gets the xy component
  65156. */
  65157. get xy(): NodeMaterialConnectionPoint;
  65158. /**
  65159. * Gets the x component
  65160. */
  65161. get x(): NodeMaterialConnectionPoint;
  65162. /**
  65163. * Gets the y component
  65164. */
  65165. get y(): NodeMaterialConnectionPoint;
  65166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65167. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65168. protected _buildBlock(state: NodeMaterialBuildState): this;
  65169. }
  65170. }
  65171. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65172. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65173. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65174. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65175. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65176. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65177. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65178. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65179. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65180. }
  65181. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65184. import { Mesh } from "babylonjs/Meshes/mesh";
  65185. import { Effect } from "babylonjs/Materials/effect";
  65186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65188. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65189. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65190. /**
  65191. * Block used to add support for scene fog
  65192. */
  65193. export class FogBlock extends NodeMaterialBlock {
  65194. private _fogDistanceName;
  65195. private _fogParameters;
  65196. /**
  65197. * Create a new FogBlock
  65198. * @param name defines the block name
  65199. */
  65200. constructor(name: string);
  65201. /**
  65202. * Gets the current class name
  65203. * @returns the class name
  65204. */
  65205. getClassName(): string;
  65206. /**
  65207. * Gets the world position input component
  65208. */
  65209. get worldPosition(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the view input component
  65212. */
  65213. get view(): NodeMaterialConnectionPoint;
  65214. /**
  65215. * Gets the color input component
  65216. */
  65217. get input(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the fog color input component
  65220. */
  65221. get fogColor(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the output component
  65224. */
  65225. get output(): NodeMaterialConnectionPoint;
  65226. autoConfigure(material: NodeMaterial): void;
  65227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65228. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65229. protected _buildBlock(state: NodeMaterialBuildState): this;
  65230. }
  65231. }
  65232. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65238. import { Effect } from "babylonjs/Materials/effect";
  65239. import { Mesh } from "babylonjs/Meshes/mesh";
  65240. import { Light } from "babylonjs/Lights/light";
  65241. import { Nullable } from "babylonjs/types";
  65242. import { Scene } from "babylonjs/scene";
  65243. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65244. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65245. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65246. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65247. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65248. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65249. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65250. /**
  65251. * Block used to add light in the fragment shader
  65252. */
  65253. export class LightBlock extends NodeMaterialBlock {
  65254. private _lightId;
  65255. /**
  65256. * Gets or sets the light associated with this block
  65257. */
  65258. light: Nullable<Light>;
  65259. /**
  65260. * Create a new LightBlock
  65261. * @param name defines the block name
  65262. */
  65263. constructor(name: string);
  65264. /**
  65265. * Gets the current class name
  65266. * @returns the class name
  65267. */
  65268. getClassName(): string;
  65269. /**
  65270. * Gets the world position input component
  65271. */
  65272. get worldPosition(): NodeMaterialConnectionPoint;
  65273. /**
  65274. * Gets the world normal input component
  65275. */
  65276. get worldNormal(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the camera (or eye) position component
  65279. */
  65280. get cameraPosition(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the glossiness component
  65283. */
  65284. get glossiness(): NodeMaterialConnectionPoint;
  65285. /**
  65286. * Gets the glossinness power component
  65287. */
  65288. get glossPower(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the diffuse color component
  65291. */
  65292. get diffuseColor(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the specular color component
  65295. */
  65296. get specularColor(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the diffuse output component
  65299. */
  65300. get diffuseOutput(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the specular output component
  65303. */
  65304. get specularOutput(): NodeMaterialConnectionPoint;
  65305. /**
  65306. * Gets the shadow output component
  65307. */
  65308. get shadow(): NodeMaterialConnectionPoint;
  65309. autoConfigure(material: NodeMaterial): void;
  65310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65311. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65313. private _injectVertexCode;
  65314. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65315. serialize(): any;
  65316. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65317. }
  65318. }
  65319. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65322. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65323. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65324. /**
  65325. * Block used to read a reflection texture from a sampler
  65326. */
  65327. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65328. /**
  65329. * Create a new ReflectionTextureBlock
  65330. * @param name defines the block name
  65331. */
  65332. constructor(name: string);
  65333. /**
  65334. * Gets the current class name
  65335. * @returns the class name
  65336. */
  65337. getClassName(): string;
  65338. /**
  65339. * Gets the world position input component
  65340. */
  65341. get position(): NodeMaterialConnectionPoint;
  65342. /**
  65343. * Gets the world position input component
  65344. */
  65345. get worldPosition(): NodeMaterialConnectionPoint;
  65346. /**
  65347. * Gets the world normal input component
  65348. */
  65349. get worldNormal(): NodeMaterialConnectionPoint;
  65350. /**
  65351. * Gets the world input component
  65352. */
  65353. get world(): NodeMaterialConnectionPoint;
  65354. /**
  65355. * Gets the camera (or eye) position component
  65356. */
  65357. get cameraPosition(): NodeMaterialConnectionPoint;
  65358. /**
  65359. * Gets the view input component
  65360. */
  65361. get view(): NodeMaterialConnectionPoint;
  65362. /**
  65363. * Gets the rgb output component
  65364. */
  65365. get rgb(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the rgba output component
  65368. */
  65369. get rgba(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the r output component
  65372. */
  65373. get r(): NodeMaterialConnectionPoint;
  65374. /**
  65375. * Gets the g output component
  65376. */
  65377. get g(): NodeMaterialConnectionPoint;
  65378. /**
  65379. * Gets the b output component
  65380. */
  65381. get b(): NodeMaterialConnectionPoint;
  65382. /**
  65383. * Gets the a output component
  65384. */
  65385. get a(): NodeMaterialConnectionPoint;
  65386. autoConfigure(material: NodeMaterial): void;
  65387. protected _buildBlock(state: NodeMaterialBuildState): this;
  65388. }
  65389. }
  65390. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65391. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65392. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65393. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65394. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65395. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65396. }
  65397. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65398. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65399. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65400. }
  65401. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65405. /**
  65406. * Block used to add 2 vectors
  65407. */
  65408. export class AddBlock extends NodeMaterialBlock {
  65409. /**
  65410. * Creates a new AddBlock
  65411. * @param name defines the block name
  65412. */
  65413. constructor(name: string);
  65414. /**
  65415. * Gets the current class name
  65416. * @returns the class name
  65417. */
  65418. getClassName(): string;
  65419. /**
  65420. * Gets the left operand input component
  65421. */
  65422. get left(): NodeMaterialConnectionPoint;
  65423. /**
  65424. * Gets the right operand input component
  65425. */
  65426. get right(): NodeMaterialConnectionPoint;
  65427. /**
  65428. * Gets the output component
  65429. */
  65430. get output(): NodeMaterialConnectionPoint;
  65431. protected _buildBlock(state: NodeMaterialBuildState): this;
  65432. }
  65433. }
  65434. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65438. /**
  65439. * Block used to scale a vector by a float
  65440. */
  65441. export class ScaleBlock extends NodeMaterialBlock {
  65442. /**
  65443. * Creates a new ScaleBlock
  65444. * @param name defines the block name
  65445. */
  65446. constructor(name: string);
  65447. /**
  65448. * Gets the current class name
  65449. * @returns the class name
  65450. */
  65451. getClassName(): string;
  65452. /**
  65453. * Gets the input component
  65454. */
  65455. get input(): NodeMaterialConnectionPoint;
  65456. /**
  65457. * Gets the factor input component
  65458. */
  65459. get factor(): NodeMaterialConnectionPoint;
  65460. /**
  65461. * Gets the output component
  65462. */
  65463. get output(): NodeMaterialConnectionPoint;
  65464. protected _buildBlock(state: NodeMaterialBuildState): this;
  65465. }
  65466. }
  65467. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65471. import { Scene } from "babylonjs/scene";
  65472. /**
  65473. * Block used to clamp a float
  65474. */
  65475. export class ClampBlock extends NodeMaterialBlock {
  65476. /** Gets or sets the minimum range */
  65477. minimum: number;
  65478. /** Gets or sets the maximum range */
  65479. maximum: number;
  65480. /**
  65481. * Creates a new ClampBlock
  65482. * @param name defines the block name
  65483. */
  65484. constructor(name: string);
  65485. /**
  65486. * Gets the current class name
  65487. * @returns the class name
  65488. */
  65489. getClassName(): string;
  65490. /**
  65491. * Gets the value input component
  65492. */
  65493. get value(): NodeMaterialConnectionPoint;
  65494. /**
  65495. * Gets the output component
  65496. */
  65497. get output(): NodeMaterialConnectionPoint;
  65498. protected _buildBlock(state: NodeMaterialBuildState): this;
  65499. protected _dumpPropertiesCode(): string;
  65500. serialize(): any;
  65501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65502. }
  65503. }
  65504. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65508. /**
  65509. * Block used to apply a cross product between 2 vectors
  65510. */
  65511. export class CrossBlock extends NodeMaterialBlock {
  65512. /**
  65513. * Creates a new CrossBlock
  65514. * @param name defines the block name
  65515. */
  65516. constructor(name: string);
  65517. /**
  65518. * Gets the current class name
  65519. * @returns the class name
  65520. */
  65521. getClassName(): string;
  65522. /**
  65523. * Gets the left operand input component
  65524. */
  65525. get left(): NodeMaterialConnectionPoint;
  65526. /**
  65527. * Gets the right operand input component
  65528. */
  65529. get right(): NodeMaterialConnectionPoint;
  65530. /**
  65531. * Gets the output component
  65532. */
  65533. get output(): NodeMaterialConnectionPoint;
  65534. protected _buildBlock(state: NodeMaterialBuildState): this;
  65535. }
  65536. }
  65537. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65541. /**
  65542. * Block used to apply a dot product between 2 vectors
  65543. */
  65544. export class DotBlock extends NodeMaterialBlock {
  65545. /**
  65546. * Creates a new DotBlock
  65547. * @param name defines the block name
  65548. */
  65549. constructor(name: string);
  65550. /**
  65551. * Gets the current class name
  65552. * @returns the class name
  65553. */
  65554. getClassName(): string;
  65555. /**
  65556. * Gets the left operand input component
  65557. */
  65558. get left(): NodeMaterialConnectionPoint;
  65559. /**
  65560. * Gets the right operand input component
  65561. */
  65562. get right(): NodeMaterialConnectionPoint;
  65563. /**
  65564. * Gets the output component
  65565. */
  65566. get output(): NodeMaterialConnectionPoint;
  65567. protected _buildBlock(state: NodeMaterialBuildState): this;
  65568. }
  65569. }
  65570. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65574. /**
  65575. * Block used to normalize a vector
  65576. */
  65577. export class NormalizeBlock extends NodeMaterialBlock {
  65578. /**
  65579. * Creates a new NormalizeBlock
  65580. * @param name defines the block name
  65581. */
  65582. constructor(name: string);
  65583. /**
  65584. * Gets the current class name
  65585. * @returns the class name
  65586. */
  65587. getClassName(): string;
  65588. /**
  65589. * Gets the input component
  65590. */
  65591. get input(): NodeMaterialConnectionPoint;
  65592. /**
  65593. * Gets the output component
  65594. */
  65595. get output(): NodeMaterialConnectionPoint;
  65596. protected _buildBlock(state: NodeMaterialBuildState): this;
  65597. }
  65598. }
  65599. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65603. import { Scene } from "babylonjs/scene";
  65604. /**
  65605. * Operations supported by the Trigonometry block
  65606. */
  65607. export enum TrigonometryBlockOperations {
  65608. /** Cos */
  65609. Cos = 0,
  65610. /** Sin */
  65611. Sin = 1,
  65612. /** Abs */
  65613. Abs = 2,
  65614. /** Exp */
  65615. Exp = 3,
  65616. /** Exp2 */
  65617. Exp2 = 4,
  65618. /** Round */
  65619. Round = 5,
  65620. /** Floor */
  65621. Floor = 6,
  65622. /** Ceiling */
  65623. Ceiling = 7,
  65624. /** Square root */
  65625. Sqrt = 8,
  65626. /** Log */
  65627. Log = 9,
  65628. /** Tangent */
  65629. Tan = 10,
  65630. /** Arc tangent */
  65631. ArcTan = 11,
  65632. /** Arc cosinus */
  65633. ArcCos = 12,
  65634. /** Arc sinus */
  65635. ArcSin = 13,
  65636. /** Fraction */
  65637. Fract = 14,
  65638. /** Sign */
  65639. Sign = 15,
  65640. /** To radians (from degrees) */
  65641. Radians = 16,
  65642. /** To degrees (from radians) */
  65643. Degrees = 17
  65644. }
  65645. /**
  65646. * Block used to apply trigonometry operation to floats
  65647. */
  65648. export class TrigonometryBlock extends NodeMaterialBlock {
  65649. /**
  65650. * Gets or sets the operation applied by the block
  65651. */
  65652. operation: TrigonometryBlockOperations;
  65653. /**
  65654. * Creates a new TrigonometryBlock
  65655. * @param name defines the block name
  65656. */
  65657. constructor(name: string);
  65658. /**
  65659. * Gets the current class name
  65660. * @returns the class name
  65661. */
  65662. getClassName(): string;
  65663. /**
  65664. * Gets the input component
  65665. */
  65666. get input(): NodeMaterialConnectionPoint;
  65667. /**
  65668. * Gets the output component
  65669. */
  65670. get output(): NodeMaterialConnectionPoint;
  65671. protected _buildBlock(state: NodeMaterialBuildState): this;
  65672. serialize(): any;
  65673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65674. protected _dumpPropertiesCode(): string;
  65675. }
  65676. }
  65677. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65681. /**
  65682. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65683. */
  65684. export class ColorMergerBlock extends NodeMaterialBlock {
  65685. /**
  65686. * Create a new ColorMergerBlock
  65687. * @param name defines the block name
  65688. */
  65689. constructor(name: string);
  65690. /**
  65691. * Gets the current class name
  65692. * @returns the class name
  65693. */
  65694. getClassName(): string;
  65695. /**
  65696. * Gets the rgb component (input)
  65697. */
  65698. get rgbIn(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the r component (input)
  65701. */
  65702. get r(): NodeMaterialConnectionPoint;
  65703. /**
  65704. * Gets the g component (input)
  65705. */
  65706. get g(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the b component (input)
  65709. */
  65710. get b(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the a component (input)
  65713. */
  65714. get a(): NodeMaterialConnectionPoint;
  65715. /**
  65716. * Gets the rgba component (output)
  65717. */
  65718. get rgba(): NodeMaterialConnectionPoint;
  65719. /**
  65720. * Gets the rgb component (output)
  65721. */
  65722. get rgbOut(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the rgb component (output)
  65725. * @deprecated Please use rgbOut instead.
  65726. */
  65727. get rgb(): NodeMaterialConnectionPoint;
  65728. protected _buildBlock(state: NodeMaterialBuildState): this;
  65729. }
  65730. }
  65731. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65735. /**
  65736. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65737. */
  65738. export class VectorSplitterBlock extends NodeMaterialBlock {
  65739. /**
  65740. * Create a new VectorSplitterBlock
  65741. * @param name defines the block name
  65742. */
  65743. constructor(name: string);
  65744. /**
  65745. * Gets the current class name
  65746. * @returns the class name
  65747. */
  65748. getClassName(): string;
  65749. /**
  65750. * Gets the xyzw component (input)
  65751. */
  65752. get xyzw(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the xyz component (input)
  65755. */
  65756. get xyzIn(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the xy component (input)
  65759. */
  65760. get xyIn(): NodeMaterialConnectionPoint;
  65761. /**
  65762. * Gets the xyz component (output)
  65763. */
  65764. get xyzOut(): NodeMaterialConnectionPoint;
  65765. /**
  65766. * Gets the xy component (output)
  65767. */
  65768. get xyOut(): NodeMaterialConnectionPoint;
  65769. /**
  65770. * Gets the x component (output)
  65771. */
  65772. get x(): NodeMaterialConnectionPoint;
  65773. /**
  65774. * Gets the y component (output)
  65775. */
  65776. get y(): NodeMaterialConnectionPoint;
  65777. /**
  65778. * Gets the z component (output)
  65779. */
  65780. get z(): NodeMaterialConnectionPoint;
  65781. /**
  65782. * Gets the w component (output)
  65783. */
  65784. get w(): NodeMaterialConnectionPoint;
  65785. protected _inputRename(name: string): string;
  65786. protected _outputRename(name: string): string;
  65787. protected _buildBlock(state: NodeMaterialBuildState): this;
  65788. }
  65789. }
  65790. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65794. /**
  65795. * Block used to lerp between 2 values
  65796. */
  65797. export class LerpBlock extends NodeMaterialBlock {
  65798. /**
  65799. * Creates a new LerpBlock
  65800. * @param name defines the block name
  65801. */
  65802. constructor(name: string);
  65803. /**
  65804. * Gets the current class name
  65805. * @returns the class name
  65806. */
  65807. getClassName(): string;
  65808. /**
  65809. * Gets the left operand input component
  65810. */
  65811. get left(): NodeMaterialConnectionPoint;
  65812. /**
  65813. * Gets the right operand input component
  65814. */
  65815. get right(): NodeMaterialConnectionPoint;
  65816. /**
  65817. * Gets the gradient operand input component
  65818. */
  65819. get gradient(): NodeMaterialConnectionPoint;
  65820. /**
  65821. * Gets the output component
  65822. */
  65823. get output(): NodeMaterialConnectionPoint;
  65824. protected _buildBlock(state: NodeMaterialBuildState): this;
  65825. }
  65826. }
  65827. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65831. /**
  65832. * Block used to divide 2 vectors
  65833. */
  65834. export class DivideBlock extends NodeMaterialBlock {
  65835. /**
  65836. * Creates a new DivideBlock
  65837. * @param name defines the block name
  65838. */
  65839. constructor(name: string);
  65840. /**
  65841. * Gets the current class name
  65842. * @returns the class name
  65843. */
  65844. getClassName(): string;
  65845. /**
  65846. * Gets the left operand input component
  65847. */
  65848. get left(): NodeMaterialConnectionPoint;
  65849. /**
  65850. * Gets the right operand input component
  65851. */
  65852. get right(): NodeMaterialConnectionPoint;
  65853. /**
  65854. * Gets the output component
  65855. */
  65856. get output(): NodeMaterialConnectionPoint;
  65857. protected _buildBlock(state: NodeMaterialBuildState): this;
  65858. }
  65859. }
  65860. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65864. /**
  65865. * Block used to subtract 2 vectors
  65866. */
  65867. export class SubtractBlock extends NodeMaterialBlock {
  65868. /**
  65869. * Creates a new SubtractBlock
  65870. * @param name defines the block name
  65871. */
  65872. constructor(name: string);
  65873. /**
  65874. * Gets the current class name
  65875. * @returns the class name
  65876. */
  65877. getClassName(): string;
  65878. /**
  65879. * Gets the left operand input component
  65880. */
  65881. get left(): NodeMaterialConnectionPoint;
  65882. /**
  65883. * Gets the right operand input component
  65884. */
  65885. get right(): NodeMaterialConnectionPoint;
  65886. /**
  65887. * Gets the output component
  65888. */
  65889. get output(): NodeMaterialConnectionPoint;
  65890. protected _buildBlock(state: NodeMaterialBuildState): this;
  65891. }
  65892. }
  65893. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65897. /**
  65898. * Block used to step a value
  65899. */
  65900. export class StepBlock extends NodeMaterialBlock {
  65901. /**
  65902. * Creates a new StepBlock
  65903. * @param name defines the block name
  65904. */
  65905. constructor(name: string);
  65906. /**
  65907. * Gets the current class name
  65908. * @returns the class name
  65909. */
  65910. getClassName(): string;
  65911. /**
  65912. * Gets the value operand input component
  65913. */
  65914. get value(): NodeMaterialConnectionPoint;
  65915. /**
  65916. * Gets the edge operand input component
  65917. */
  65918. get edge(): NodeMaterialConnectionPoint;
  65919. /**
  65920. * Gets the output component
  65921. */
  65922. get output(): NodeMaterialConnectionPoint;
  65923. protected _buildBlock(state: NodeMaterialBuildState): this;
  65924. }
  65925. }
  65926. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65930. /**
  65931. * Block used to get the opposite (1 - x) of a value
  65932. */
  65933. export class OneMinusBlock extends NodeMaterialBlock {
  65934. /**
  65935. * Creates a new OneMinusBlock
  65936. * @param name defines the block name
  65937. */
  65938. constructor(name: string);
  65939. /**
  65940. * Gets the current class name
  65941. * @returns the class name
  65942. */
  65943. getClassName(): string;
  65944. /**
  65945. * Gets the input component
  65946. */
  65947. get input(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the output component
  65950. */
  65951. get output(): NodeMaterialConnectionPoint;
  65952. protected _buildBlock(state: NodeMaterialBuildState): this;
  65953. }
  65954. }
  65955. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65959. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65960. /**
  65961. * Block used to get the view direction
  65962. */
  65963. export class ViewDirectionBlock extends NodeMaterialBlock {
  65964. /**
  65965. * Creates a new ViewDirectionBlock
  65966. * @param name defines the block name
  65967. */
  65968. constructor(name: string);
  65969. /**
  65970. * Gets the current class name
  65971. * @returns the class name
  65972. */
  65973. getClassName(): string;
  65974. /**
  65975. * Gets the world position component
  65976. */
  65977. get worldPosition(): NodeMaterialConnectionPoint;
  65978. /**
  65979. * Gets the camera position component
  65980. */
  65981. get cameraPosition(): NodeMaterialConnectionPoint;
  65982. /**
  65983. * Gets the output component
  65984. */
  65985. get output(): NodeMaterialConnectionPoint;
  65986. autoConfigure(material: NodeMaterial): void;
  65987. protected _buildBlock(state: NodeMaterialBuildState): this;
  65988. }
  65989. }
  65990. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65994. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65995. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65996. /**
  65997. * Block used to compute fresnel value
  65998. */
  65999. export class FresnelBlock extends NodeMaterialBlock {
  66000. /**
  66001. * Create a new FresnelBlock
  66002. * @param name defines the block name
  66003. */
  66004. constructor(name: string);
  66005. /**
  66006. * Gets the current class name
  66007. * @returns the class name
  66008. */
  66009. getClassName(): string;
  66010. /**
  66011. * Gets the world normal input component
  66012. */
  66013. get worldNormal(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the view direction input component
  66016. */
  66017. get viewDirection(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the bias input component
  66020. */
  66021. get bias(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the camera (or eye) position component
  66024. */
  66025. get power(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the fresnel output component
  66028. */
  66029. get fresnel(): NodeMaterialConnectionPoint;
  66030. autoConfigure(material: NodeMaterial): void;
  66031. protected _buildBlock(state: NodeMaterialBuildState): this;
  66032. }
  66033. }
  66034. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66038. /**
  66039. * Block used to get the max of 2 values
  66040. */
  66041. export class MaxBlock extends NodeMaterialBlock {
  66042. /**
  66043. * Creates a new MaxBlock
  66044. * @param name defines the block name
  66045. */
  66046. constructor(name: string);
  66047. /**
  66048. * Gets the current class name
  66049. * @returns the class name
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Gets the left operand input component
  66054. */
  66055. get left(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the right operand input component
  66058. */
  66059. get right(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the output component
  66062. */
  66063. get output(): NodeMaterialConnectionPoint;
  66064. protected _buildBlock(state: NodeMaterialBuildState): this;
  66065. }
  66066. }
  66067. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66071. /**
  66072. * Block used to get the min of 2 values
  66073. */
  66074. export class MinBlock extends NodeMaterialBlock {
  66075. /**
  66076. * Creates a new MinBlock
  66077. * @param name defines the block name
  66078. */
  66079. constructor(name: string);
  66080. /**
  66081. * Gets the current class name
  66082. * @returns the class name
  66083. */
  66084. getClassName(): string;
  66085. /**
  66086. * Gets the left operand input component
  66087. */
  66088. get left(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the right operand input component
  66091. */
  66092. get right(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the output component
  66095. */
  66096. get output(): NodeMaterialConnectionPoint;
  66097. protected _buildBlock(state: NodeMaterialBuildState): this;
  66098. }
  66099. }
  66100. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66104. /**
  66105. * Block used to get the distance between 2 values
  66106. */
  66107. export class DistanceBlock extends NodeMaterialBlock {
  66108. /**
  66109. * Creates a new DistanceBlock
  66110. * @param name defines the block name
  66111. */
  66112. constructor(name: string);
  66113. /**
  66114. * Gets the current class name
  66115. * @returns the class name
  66116. */
  66117. getClassName(): string;
  66118. /**
  66119. * Gets the left operand input component
  66120. */
  66121. get left(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the right operand input component
  66124. */
  66125. get right(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the output component
  66128. */
  66129. get output(): NodeMaterialConnectionPoint;
  66130. protected _buildBlock(state: NodeMaterialBuildState): this;
  66131. }
  66132. }
  66133. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66137. /**
  66138. * Block used to get the length of a vector
  66139. */
  66140. export class LengthBlock extends NodeMaterialBlock {
  66141. /**
  66142. * Creates a new LengthBlock
  66143. * @param name defines the block name
  66144. */
  66145. constructor(name: string);
  66146. /**
  66147. * Gets the current class name
  66148. * @returns the class name
  66149. */
  66150. getClassName(): string;
  66151. /**
  66152. * Gets the value input component
  66153. */
  66154. get value(): NodeMaterialConnectionPoint;
  66155. /**
  66156. * Gets the output component
  66157. */
  66158. get output(): NodeMaterialConnectionPoint;
  66159. protected _buildBlock(state: NodeMaterialBuildState): this;
  66160. }
  66161. }
  66162. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66166. /**
  66167. * Block used to get negative version of a value (i.e. x * -1)
  66168. */
  66169. export class NegateBlock extends NodeMaterialBlock {
  66170. /**
  66171. * Creates a new NegateBlock
  66172. * @param name defines the block name
  66173. */
  66174. constructor(name: string);
  66175. /**
  66176. * Gets the current class name
  66177. * @returns the class name
  66178. */
  66179. getClassName(): string;
  66180. /**
  66181. * Gets the value input component
  66182. */
  66183. get value(): NodeMaterialConnectionPoint;
  66184. /**
  66185. * Gets the output component
  66186. */
  66187. get output(): NodeMaterialConnectionPoint;
  66188. protected _buildBlock(state: NodeMaterialBuildState): this;
  66189. }
  66190. }
  66191. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66192. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66193. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66195. /**
  66196. * Block used to get the value of the first parameter raised to the power of the second
  66197. */
  66198. export class PowBlock extends NodeMaterialBlock {
  66199. /**
  66200. * Creates a new PowBlock
  66201. * @param name defines the block name
  66202. */
  66203. constructor(name: string);
  66204. /**
  66205. * Gets the current class name
  66206. * @returns the class name
  66207. */
  66208. getClassName(): string;
  66209. /**
  66210. * Gets the value operand input component
  66211. */
  66212. get value(): NodeMaterialConnectionPoint;
  66213. /**
  66214. * Gets the power operand input component
  66215. */
  66216. get power(): NodeMaterialConnectionPoint;
  66217. /**
  66218. * Gets the output component
  66219. */
  66220. get output(): NodeMaterialConnectionPoint;
  66221. protected _buildBlock(state: NodeMaterialBuildState): this;
  66222. }
  66223. }
  66224. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66228. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66229. /**
  66230. * Block used to get a random number
  66231. */
  66232. export class RandomNumberBlock extends NodeMaterialBlock {
  66233. /**
  66234. * Creates a new RandomNumberBlock
  66235. * @param name defines the block name
  66236. */
  66237. constructor(name: string);
  66238. /**
  66239. * Gets the current class name
  66240. * @returns the class name
  66241. */
  66242. getClassName(): string;
  66243. /**
  66244. * Gets the seed input component
  66245. */
  66246. get seed(): NodeMaterialConnectionPoint;
  66247. /**
  66248. * Gets the output component
  66249. */
  66250. get output(): NodeMaterialConnectionPoint;
  66251. protected _buildBlock(state: NodeMaterialBuildState): this;
  66252. }
  66253. }
  66254. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66258. /**
  66259. * Block used to compute arc tangent of 2 values
  66260. */
  66261. export class ArcTan2Block extends NodeMaterialBlock {
  66262. /**
  66263. * Creates a new ArcTan2Block
  66264. * @param name defines the block name
  66265. */
  66266. constructor(name: string);
  66267. /**
  66268. * Gets the current class name
  66269. * @returns the class name
  66270. */
  66271. getClassName(): string;
  66272. /**
  66273. * Gets the x operand input component
  66274. */
  66275. get x(): NodeMaterialConnectionPoint;
  66276. /**
  66277. * Gets the y operand input component
  66278. */
  66279. get y(): NodeMaterialConnectionPoint;
  66280. /**
  66281. * Gets the output component
  66282. */
  66283. get output(): NodeMaterialConnectionPoint;
  66284. protected _buildBlock(state: NodeMaterialBuildState): this;
  66285. }
  66286. }
  66287. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66291. /**
  66292. * Block used to smooth step a value
  66293. */
  66294. export class SmoothStepBlock extends NodeMaterialBlock {
  66295. /**
  66296. * Creates a new SmoothStepBlock
  66297. * @param name defines the block name
  66298. */
  66299. constructor(name: string);
  66300. /**
  66301. * Gets the current class name
  66302. * @returns the class name
  66303. */
  66304. getClassName(): string;
  66305. /**
  66306. * Gets the value operand input component
  66307. */
  66308. get value(): NodeMaterialConnectionPoint;
  66309. /**
  66310. * Gets the first edge operand input component
  66311. */
  66312. get edge0(): NodeMaterialConnectionPoint;
  66313. /**
  66314. * Gets the second edge operand input component
  66315. */
  66316. get edge1(): NodeMaterialConnectionPoint;
  66317. /**
  66318. * Gets the output component
  66319. */
  66320. get output(): NodeMaterialConnectionPoint;
  66321. protected _buildBlock(state: NodeMaterialBuildState): this;
  66322. }
  66323. }
  66324. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66328. /**
  66329. * Block used to get the reciprocal (1 / x) of a value
  66330. */
  66331. export class ReciprocalBlock extends NodeMaterialBlock {
  66332. /**
  66333. * Creates a new ReciprocalBlock
  66334. * @param name defines the block name
  66335. */
  66336. constructor(name: string);
  66337. /**
  66338. * Gets the current class name
  66339. * @returns the class name
  66340. */
  66341. getClassName(): string;
  66342. /**
  66343. * Gets the input component
  66344. */
  66345. get input(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the output component
  66348. */
  66349. get output(): NodeMaterialConnectionPoint;
  66350. protected _buildBlock(state: NodeMaterialBuildState): this;
  66351. }
  66352. }
  66353. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66357. /**
  66358. * Block used to replace a color by another one
  66359. */
  66360. export class ReplaceColorBlock extends NodeMaterialBlock {
  66361. /**
  66362. * Creates a new ReplaceColorBlock
  66363. * @param name defines the block name
  66364. */
  66365. constructor(name: string);
  66366. /**
  66367. * Gets the current class name
  66368. * @returns the class name
  66369. */
  66370. getClassName(): string;
  66371. /**
  66372. * Gets the value input component
  66373. */
  66374. get value(): NodeMaterialConnectionPoint;
  66375. /**
  66376. * Gets the reference input component
  66377. */
  66378. get reference(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the distance input component
  66381. */
  66382. get distance(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the replacement input component
  66385. */
  66386. get replacement(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the output component
  66389. */
  66390. get output(): NodeMaterialConnectionPoint;
  66391. protected _buildBlock(state: NodeMaterialBuildState): this;
  66392. }
  66393. }
  66394. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66398. /**
  66399. * Block used to posterize a value
  66400. * @see https://en.wikipedia.org/wiki/Posterization
  66401. */
  66402. export class PosterizeBlock extends NodeMaterialBlock {
  66403. /**
  66404. * Creates a new PosterizeBlock
  66405. * @param name defines the block name
  66406. */
  66407. constructor(name: string);
  66408. /**
  66409. * Gets the current class name
  66410. * @returns the class name
  66411. */
  66412. getClassName(): string;
  66413. /**
  66414. * Gets the value input component
  66415. */
  66416. get value(): NodeMaterialConnectionPoint;
  66417. /**
  66418. * Gets the steps input component
  66419. */
  66420. get steps(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the output component
  66423. */
  66424. get output(): NodeMaterialConnectionPoint;
  66425. protected _buildBlock(state: NodeMaterialBuildState): this;
  66426. }
  66427. }
  66428. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66432. import { Scene } from "babylonjs/scene";
  66433. /**
  66434. * Operations supported by the Wave block
  66435. */
  66436. export enum WaveBlockKind {
  66437. /** SawTooth */
  66438. SawTooth = 0,
  66439. /** Square */
  66440. Square = 1,
  66441. /** Triangle */
  66442. Triangle = 2
  66443. }
  66444. /**
  66445. * Block used to apply wave operation to floats
  66446. */
  66447. export class WaveBlock extends NodeMaterialBlock {
  66448. /**
  66449. * Gets or sets the kibnd of wave to be applied by the block
  66450. */
  66451. kind: WaveBlockKind;
  66452. /**
  66453. * Creates a new WaveBlock
  66454. * @param name defines the block name
  66455. */
  66456. constructor(name: string);
  66457. /**
  66458. * Gets the current class name
  66459. * @returns the class name
  66460. */
  66461. getClassName(): string;
  66462. /**
  66463. * Gets the input component
  66464. */
  66465. get input(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the output component
  66468. */
  66469. get output(): NodeMaterialConnectionPoint;
  66470. protected _buildBlock(state: NodeMaterialBuildState): this;
  66471. serialize(): any;
  66472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66473. }
  66474. }
  66475. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66479. import { Color3 } from "babylonjs/Maths/math.color";
  66480. import { Scene } from "babylonjs/scene";
  66481. /**
  66482. * Class used to store a color step for the GradientBlock
  66483. */
  66484. export class GradientBlockColorStep {
  66485. /**
  66486. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66487. */
  66488. step: number;
  66489. /**
  66490. * Gets or sets the color associated with this step
  66491. */
  66492. color: Color3;
  66493. /**
  66494. * Creates a new GradientBlockColorStep
  66495. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66496. * @param color defines the color associated with this step
  66497. */
  66498. constructor(
  66499. /**
  66500. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66501. */
  66502. step: number,
  66503. /**
  66504. * Gets or sets the color associated with this step
  66505. */
  66506. color: Color3);
  66507. }
  66508. /**
  66509. * Block used to return a color from a gradient based on an input value between 0 and 1
  66510. */
  66511. export class GradientBlock extends NodeMaterialBlock {
  66512. /**
  66513. * Gets or sets the list of color steps
  66514. */
  66515. colorSteps: GradientBlockColorStep[];
  66516. /**
  66517. * Creates a new GradientBlock
  66518. * @param name defines the block name
  66519. */
  66520. constructor(name: string);
  66521. /**
  66522. * Gets the current class name
  66523. * @returns the class name
  66524. */
  66525. getClassName(): string;
  66526. /**
  66527. * Gets the gradient input component
  66528. */
  66529. get gradient(): NodeMaterialConnectionPoint;
  66530. /**
  66531. * Gets the output component
  66532. */
  66533. get output(): NodeMaterialConnectionPoint;
  66534. private _writeColorConstant;
  66535. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66536. serialize(): any;
  66537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66538. protected _dumpPropertiesCode(): string;
  66539. }
  66540. }
  66541. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66545. /**
  66546. * Block used to normalize lerp between 2 values
  66547. */
  66548. export class NLerpBlock extends NodeMaterialBlock {
  66549. /**
  66550. * Creates a new NLerpBlock
  66551. * @param name defines the block name
  66552. */
  66553. constructor(name: string);
  66554. /**
  66555. * Gets the current class name
  66556. * @returns the class name
  66557. */
  66558. getClassName(): string;
  66559. /**
  66560. * Gets the left operand input component
  66561. */
  66562. get left(): NodeMaterialConnectionPoint;
  66563. /**
  66564. * Gets the right operand input component
  66565. */
  66566. get right(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the gradient operand input component
  66569. */
  66570. get gradient(): NodeMaterialConnectionPoint;
  66571. /**
  66572. * Gets the output component
  66573. */
  66574. get output(): NodeMaterialConnectionPoint;
  66575. protected _buildBlock(state: NodeMaterialBuildState): this;
  66576. }
  66577. }
  66578. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66582. import { Scene } from "babylonjs/scene";
  66583. /**
  66584. * block used to Generate a Worley Noise 3D Noise Pattern
  66585. */
  66586. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66587. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66588. manhattanDistance: boolean;
  66589. /**
  66590. * Creates a new WorleyNoise3DBlock
  66591. * @param name defines the block name
  66592. */
  66593. constructor(name: string);
  66594. /**
  66595. * Gets the current class name
  66596. * @returns the class name
  66597. */
  66598. getClassName(): string;
  66599. /**
  66600. * Gets the seed input component
  66601. */
  66602. get seed(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the jitter input component
  66605. */
  66606. get jitter(): NodeMaterialConnectionPoint;
  66607. /**
  66608. * Gets the output component
  66609. */
  66610. get output(): NodeMaterialConnectionPoint;
  66611. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66612. /**
  66613. * Exposes the properties to the UI?
  66614. */
  66615. protected _dumpPropertiesCode(): string;
  66616. /**
  66617. * Exposes the properties to the Seralize?
  66618. */
  66619. serialize(): any;
  66620. /**
  66621. * Exposes the properties to the deseralize?
  66622. */
  66623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66624. }
  66625. }
  66626. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66630. /**
  66631. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66632. */
  66633. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66634. /**
  66635. * Creates a new SimplexPerlin3DBlock
  66636. * @param name defines the block name
  66637. */
  66638. constructor(name: string);
  66639. /**
  66640. * Gets the current class name
  66641. * @returns the class name
  66642. */
  66643. getClassName(): string;
  66644. /**
  66645. * Gets the seed operand input component
  66646. */
  66647. get seed(): NodeMaterialConnectionPoint;
  66648. /**
  66649. * Gets the output component
  66650. */
  66651. get output(): NodeMaterialConnectionPoint;
  66652. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66653. }
  66654. }
  66655. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66659. /**
  66660. * Block used to blend normals
  66661. */
  66662. export class NormalBlendBlock extends NodeMaterialBlock {
  66663. /**
  66664. * Creates a new NormalBlendBlock
  66665. * @param name defines the block name
  66666. */
  66667. constructor(name: string);
  66668. /**
  66669. * Gets the current class name
  66670. * @returns the class name
  66671. */
  66672. getClassName(): string;
  66673. /**
  66674. * Gets the first input component
  66675. */
  66676. get normalMap0(): NodeMaterialConnectionPoint;
  66677. /**
  66678. * Gets the second input component
  66679. */
  66680. get normalMap1(): NodeMaterialConnectionPoint;
  66681. /**
  66682. * Gets the output component
  66683. */
  66684. get output(): NodeMaterialConnectionPoint;
  66685. protected _buildBlock(state: NodeMaterialBuildState): this;
  66686. }
  66687. }
  66688. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66692. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66693. /**
  66694. * Block used to rotate a 2d vector by a given angle
  66695. */
  66696. export class Rotate2dBlock extends NodeMaterialBlock {
  66697. /**
  66698. * Creates a new Rotate2dBlock
  66699. * @param name defines the block name
  66700. */
  66701. constructor(name: string);
  66702. /**
  66703. * Gets the current class name
  66704. * @returns the class name
  66705. */
  66706. getClassName(): string;
  66707. /**
  66708. * Gets the input vector
  66709. */
  66710. get input(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the input angle
  66713. */
  66714. get angle(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the output component
  66717. */
  66718. get output(): NodeMaterialConnectionPoint;
  66719. autoConfigure(material: NodeMaterial): void;
  66720. protected _buildBlock(state: NodeMaterialBuildState): this;
  66721. }
  66722. }
  66723. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66727. /**
  66728. * Block used to get the reflected vector from a direction and a normal
  66729. */
  66730. export class ReflectBlock extends NodeMaterialBlock {
  66731. /**
  66732. * Creates a new ReflectBlock
  66733. * @param name defines the block name
  66734. */
  66735. constructor(name: string);
  66736. /**
  66737. * Gets the current class name
  66738. * @returns the class name
  66739. */
  66740. getClassName(): string;
  66741. /**
  66742. * Gets the incident component
  66743. */
  66744. get incident(): NodeMaterialConnectionPoint;
  66745. /**
  66746. * Gets the normal component
  66747. */
  66748. get normal(): NodeMaterialConnectionPoint;
  66749. /**
  66750. * Gets the output component
  66751. */
  66752. get output(): NodeMaterialConnectionPoint;
  66753. protected _buildBlock(state: NodeMaterialBuildState): this;
  66754. }
  66755. }
  66756. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66760. /**
  66761. * Block used to get the refracted vector from a direction and a normal
  66762. */
  66763. export class RefractBlock extends NodeMaterialBlock {
  66764. /**
  66765. * Creates a new RefractBlock
  66766. * @param name defines the block name
  66767. */
  66768. constructor(name: string);
  66769. /**
  66770. * Gets the current class name
  66771. * @returns the class name
  66772. */
  66773. getClassName(): string;
  66774. /**
  66775. * Gets the incident component
  66776. */
  66777. get incident(): NodeMaterialConnectionPoint;
  66778. /**
  66779. * Gets the normal component
  66780. */
  66781. get normal(): NodeMaterialConnectionPoint;
  66782. /**
  66783. * Gets the index of refraction component
  66784. */
  66785. get ior(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the output component
  66788. */
  66789. get output(): NodeMaterialConnectionPoint;
  66790. protected _buildBlock(state: NodeMaterialBuildState): this;
  66791. }
  66792. }
  66793. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66797. /**
  66798. * Block used to desaturate a color
  66799. */
  66800. export class DesaturateBlock extends NodeMaterialBlock {
  66801. /**
  66802. * Creates a new DesaturateBlock
  66803. * @param name defines the block name
  66804. */
  66805. constructor(name: string);
  66806. /**
  66807. * Gets the current class name
  66808. * @returns the class name
  66809. */
  66810. getClassName(): string;
  66811. /**
  66812. * Gets the color operand input component
  66813. */
  66814. get color(): NodeMaterialConnectionPoint;
  66815. /**
  66816. * Gets the level operand input component
  66817. */
  66818. get level(): NodeMaterialConnectionPoint;
  66819. /**
  66820. * Gets the output component
  66821. */
  66822. get output(): NodeMaterialConnectionPoint;
  66823. protected _buildBlock(state: NodeMaterialBuildState): this;
  66824. }
  66825. }
  66826. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66830. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66831. import { Nullable } from "babylonjs/types";
  66832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66833. import { Scene } from "babylonjs/scene";
  66834. /**
  66835. * Block used to implement the ambient occlusion module of the PBR material
  66836. */
  66837. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66838. /**
  66839. * Create a new AmbientOcclusionBlock
  66840. * @param name defines the block name
  66841. */
  66842. constructor(name: string);
  66843. /**
  66844. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66845. */
  66846. useAmbientInGrayScale: boolean;
  66847. /**
  66848. * Initialize the block and prepare the context for build
  66849. * @param state defines the state that will be used for the build
  66850. */
  66851. initialize(state: NodeMaterialBuildState): void;
  66852. /**
  66853. * Gets the current class name
  66854. * @returns the class name
  66855. */
  66856. getClassName(): string;
  66857. /**
  66858. * Gets the texture input component
  66859. */
  66860. get texture(): NodeMaterialConnectionPoint;
  66861. /**
  66862. * Gets the texture intensity component
  66863. */
  66864. get intensity(): NodeMaterialConnectionPoint;
  66865. /**
  66866. * Gets the direct light intensity input component
  66867. */
  66868. get directLightIntensity(): NodeMaterialConnectionPoint;
  66869. /**
  66870. * Gets the ambient occlusion object output component
  66871. */
  66872. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66873. /**
  66874. * Gets the main code of the block (fragment side)
  66875. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66876. * @returns the shader code
  66877. */
  66878. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66880. protected _buildBlock(state: NodeMaterialBuildState): this;
  66881. protected _dumpPropertiesCode(): string;
  66882. serialize(): any;
  66883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66884. }
  66885. }
  66886. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66889. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66890. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66892. import { Nullable } from "babylonjs/types";
  66893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66894. import { Mesh } from "babylonjs/Meshes/mesh";
  66895. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66896. import { Effect } from "babylonjs/Materials/effect";
  66897. import { Scene } from "babylonjs/scene";
  66898. /**
  66899. * Block used to implement the reflection module of the PBR material
  66900. */
  66901. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66902. /** @hidden */
  66903. _defineLODReflectionAlpha: string;
  66904. /** @hidden */
  66905. _defineLinearSpecularReflection: string;
  66906. private _vEnvironmentIrradianceName;
  66907. /** @hidden */
  66908. _vReflectionMicrosurfaceInfosName: string;
  66909. /** @hidden */
  66910. _vReflectionInfosName: string;
  66911. /** @hidden */
  66912. _vReflectionFilteringInfoName: string;
  66913. private _scene;
  66914. /**
  66915. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66916. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66917. * It's less burden on the user side in the editor part.
  66918. */
  66919. /** @hidden */
  66920. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66921. /** @hidden */
  66922. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66923. /** @hidden */
  66924. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66925. /**
  66926. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66927. * diffuse part of the IBL.
  66928. */
  66929. useSphericalHarmonics: boolean;
  66930. /**
  66931. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66932. */
  66933. forceIrradianceInFragment: boolean;
  66934. /**
  66935. * Create a new ReflectionBlock
  66936. * @param name defines the block name
  66937. */
  66938. constructor(name: string);
  66939. /**
  66940. * Gets the current class name
  66941. * @returns the class name
  66942. */
  66943. getClassName(): string;
  66944. /**
  66945. * Gets the position input component
  66946. */
  66947. get position(): NodeMaterialConnectionPoint;
  66948. /**
  66949. * Gets the world position input component
  66950. */
  66951. get worldPosition(): NodeMaterialConnectionPoint;
  66952. /**
  66953. * Gets the world normal input component
  66954. */
  66955. get worldNormal(): NodeMaterialConnectionPoint;
  66956. /**
  66957. * Gets the world input component
  66958. */
  66959. get world(): NodeMaterialConnectionPoint;
  66960. /**
  66961. * Gets the camera (or eye) position component
  66962. */
  66963. get cameraPosition(): NodeMaterialConnectionPoint;
  66964. /**
  66965. * Gets the view input component
  66966. */
  66967. get view(): NodeMaterialConnectionPoint;
  66968. /**
  66969. * Gets the color input component
  66970. */
  66971. get color(): NodeMaterialConnectionPoint;
  66972. /**
  66973. * Gets the reflection object output component
  66974. */
  66975. get reflection(): NodeMaterialConnectionPoint;
  66976. /**
  66977. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66978. */
  66979. get hasTexture(): boolean;
  66980. /**
  66981. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66982. */
  66983. get reflectionColor(): string;
  66984. protected _getTexture(): Nullable<BaseTexture>;
  66985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66986. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66987. /**
  66988. * Gets the code to inject in the vertex shader
  66989. * @param state current state of the node material building
  66990. * @returns the shader code
  66991. */
  66992. handleVertexSide(state: NodeMaterialBuildState): string;
  66993. /**
  66994. * Gets the main code of the block (fragment side)
  66995. * @param state current state of the node material building
  66996. * @param normalVarName name of the existing variable corresponding to the normal
  66997. * @returns the shader code
  66998. */
  66999. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67000. protected _buildBlock(state: NodeMaterialBuildState): this;
  67001. protected _dumpPropertiesCode(): string;
  67002. serialize(): any;
  67003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67004. }
  67005. }
  67006. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67010. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67012. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67013. import { Scene } from "babylonjs/scene";
  67014. import { Nullable } from "babylonjs/types";
  67015. /**
  67016. * Block used to implement the sheen module of the PBR material
  67017. */
  67018. export class SheenBlock extends NodeMaterialBlock {
  67019. /**
  67020. * Create a new SheenBlock
  67021. * @param name defines the block name
  67022. */
  67023. constructor(name: string);
  67024. /**
  67025. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67026. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67027. * making it easier to setup and tweak the effect
  67028. */
  67029. albedoScaling: boolean;
  67030. /**
  67031. * Defines if the sheen is linked to the sheen color.
  67032. */
  67033. linkSheenWithAlbedo: boolean;
  67034. /**
  67035. * Initialize the block and prepare the context for build
  67036. * @param state defines the state that will be used for the build
  67037. */
  67038. initialize(state: NodeMaterialBuildState): void;
  67039. /**
  67040. * Gets the current class name
  67041. * @returns the class name
  67042. */
  67043. getClassName(): string;
  67044. /**
  67045. * Gets the intensity input component
  67046. */
  67047. get intensity(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the color input component
  67050. */
  67051. get color(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the roughness input component
  67054. */
  67055. get roughness(): NodeMaterialConnectionPoint;
  67056. /**
  67057. * Gets the sheen object output component
  67058. */
  67059. get sheen(): NodeMaterialConnectionPoint;
  67060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67061. /**
  67062. * Gets the main code of the block (fragment side)
  67063. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67064. * @returns the shader code
  67065. */
  67066. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67067. protected _buildBlock(state: NodeMaterialBuildState): this;
  67068. protected _dumpPropertiesCode(): string;
  67069. serialize(): any;
  67070. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67071. }
  67072. }
  67073. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67074. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67079. import { Scene } from "babylonjs/scene";
  67080. import { Nullable } from "babylonjs/types";
  67081. import { Mesh } from "babylonjs/Meshes/mesh";
  67082. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67083. import { Effect } from "babylonjs/Materials/effect";
  67084. /**
  67085. * Block used to implement the reflectivity module of the PBR material
  67086. */
  67087. export class ReflectivityBlock extends NodeMaterialBlock {
  67088. private _metallicReflectanceColor;
  67089. private _metallicF0Factor;
  67090. /** @hidden */
  67091. _vMetallicReflectanceFactorsName: string;
  67092. /**
  67093. * The property below is set by the main PBR block prior to calling methods of this class.
  67094. */
  67095. /** @hidden */
  67096. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67097. /**
  67098. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67099. */
  67100. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67101. /**
  67102. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67103. */
  67104. useMetallnessFromMetallicTextureBlue: boolean;
  67105. /**
  67106. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67107. */
  67108. useRoughnessFromMetallicTextureAlpha: boolean;
  67109. /**
  67110. * Specifies if the metallic texture contains the roughness information in its green channel.
  67111. */
  67112. useRoughnessFromMetallicTextureGreen: boolean;
  67113. /**
  67114. * Create a new ReflectivityBlock
  67115. * @param name defines the block name
  67116. */
  67117. constructor(name: string);
  67118. /**
  67119. * Initialize the block and prepare the context for build
  67120. * @param state defines the state that will be used for the build
  67121. */
  67122. initialize(state: NodeMaterialBuildState): void;
  67123. /**
  67124. * Gets the current class name
  67125. * @returns the class name
  67126. */
  67127. getClassName(): string;
  67128. /**
  67129. * Gets the metallic input component
  67130. */
  67131. get metallic(): NodeMaterialConnectionPoint;
  67132. /**
  67133. * Gets the roughness input component
  67134. */
  67135. get roughness(): NodeMaterialConnectionPoint;
  67136. /**
  67137. * Gets the texture input component
  67138. */
  67139. get texture(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the reflectivity object output component
  67142. */
  67143. get reflectivity(): NodeMaterialConnectionPoint;
  67144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67145. /**
  67146. * Gets the main code of the block (fragment side)
  67147. * @param state current state of the node material building
  67148. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67149. * @returns the shader code
  67150. */
  67151. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67153. protected _buildBlock(state: NodeMaterialBuildState): this;
  67154. protected _dumpPropertiesCode(): string;
  67155. serialize(): any;
  67156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67157. }
  67158. }
  67159. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67160. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67165. /**
  67166. * Block used to implement the anisotropy module of the PBR material
  67167. */
  67168. export class AnisotropyBlock extends NodeMaterialBlock {
  67169. /**
  67170. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67171. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67172. * It's less burden on the user side in the editor part.
  67173. */
  67174. /** @hidden */
  67175. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67176. /** @hidden */
  67177. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67178. /**
  67179. * Create a new AnisotropyBlock
  67180. * @param name defines the block name
  67181. */
  67182. constructor(name: string);
  67183. /**
  67184. * Initialize the block and prepare the context for build
  67185. * @param state defines the state that will be used for the build
  67186. */
  67187. initialize(state: NodeMaterialBuildState): void;
  67188. /**
  67189. * Gets the current class name
  67190. * @returns the class name
  67191. */
  67192. getClassName(): string;
  67193. /**
  67194. * Gets the intensity input component
  67195. */
  67196. get intensity(): NodeMaterialConnectionPoint;
  67197. /**
  67198. * Gets the direction input component
  67199. */
  67200. get direction(): NodeMaterialConnectionPoint;
  67201. /**
  67202. * Gets the texture input component
  67203. */
  67204. get texture(): NodeMaterialConnectionPoint;
  67205. /**
  67206. * Gets the uv input component
  67207. */
  67208. get uv(): NodeMaterialConnectionPoint;
  67209. /**
  67210. * Gets the worldTangent input component
  67211. */
  67212. get worldTangent(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the anisotropy object output component
  67215. */
  67216. get anisotropy(): NodeMaterialConnectionPoint;
  67217. private _generateTBNSpace;
  67218. /**
  67219. * Gets the main code of the block (fragment side)
  67220. * @param state current state of the node material building
  67221. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67222. * @returns the shader code
  67223. */
  67224. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67226. protected _buildBlock(state: NodeMaterialBuildState): this;
  67227. }
  67228. }
  67229. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67233. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67235. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67236. import { Nullable } from "babylonjs/types";
  67237. import { Mesh } from "babylonjs/Meshes/mesh";
  67238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67239. import { Effect } from "babylonjs/Materials/effect";
  67240. /**
  67241. * Block used to implement the clear coat module of the PBR material
  67242. */
  67243. export class ClearCoatBlock extends NodeMaterialBlock {
  67244. private _scene;
  67245. /**
  67246. * Create a new ClearCoatBlock
  67247. * @param name defines the block name
  67248. */
  67249. constructor(name: string);
  67250. /**
  67251. * Initialize the block and prepare the context for build
  67252. * @param state defines the state that will be used for the build
  67253. */
  67254. initialize(state: NodeMaterialBuildState): void;
  67255. /**
  67256. * Gets the current class name
  67257. * @returns the class name
  67258. */
  67259. getClassName(): string;
  67260. /**
  67261. * Gets the intensity input component
  67262. */
  67263. get intensity(): NodeMaterialConnectionPoint;
  67264. /**
  67265. * Gets the roughness input component
  67266. */
  67267. get roughness(): NodeMaterialConnectionPoint;
  67268. /**
  67269. * Gets the ior input component
  67270. */
  67271. get ior(): NodeMaterialConnectionPoint;
  67272. /**
  67273. * Gets the texture input component
  67274. */
  67275. get texture(): NodeMaterialConnectionPoint;
  67276. /**
  67277. * Gets the bump texture input component
  67278. */
  67279. get bumpTexture(): NodeMaterialConnectionPoint;
  67280. /**
  67281. * Gets the uv input component
  67282. */
  67283. get uv(): NodeMaterialConnectionPoint;
  67284. /**
  67285. * Gets the tint color input component
  67286. */
  67287. get tintColor(): NodeMaterialConnectionPoint;
  67288. /**
  67289. * Gets the tint "at distance" input component
  67290. */
  67291. get tintAtDistance(): NodeMaterialConnectionPoint;
  67292. /**
  67293. * Gets the tint thickness input component
  67294. */
  67295. get tintThickness(): NodeMaterialConnectionPoint;
  67296. /**
  67297. * Gets the world tangent input component
  67298. */
  67299. get worldTangent(): NodeMaterialConnectionPoint;
  67300. /**
  67301. * Gets the clear coat object output component
  67302. */
  67303. get clearcoat(): NodeMaterialConnectionPoint;
  67304. autoConfigure(material: NodeMaterial): void;
  67305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67307. private _generateTBNSpace;
  67308. /**
  67309. * Gets the main code of the block (fragment side)
  67310. * @param state current state of the node material building
  67311. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67312. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67313. * @param worldPosVarName name of the variable holding the world position
  67314. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67315. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67316. * @param worldNormalVarName name of the variable holding the world normal
  67317. * @returns the shader code
  67318. */
  67319. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67320. protected _buildBlock(state: NodeMaterialBuildState): this;
  67321. }
  67322. }
  67323. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67327. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67329. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67330. import { Nullable } from "babylonjs/types";
  67331. /**
  67332. * Block used to implement the sub surface module of the PBR material
  67333. */
  67334. export class SubSurfaceBlock extends NodeMaterialBlock {
  67335. /**
  67336. * Create a new SubSurfaceBlock
  67337. * @param name defines the block name
  67338. */
  67339. constructor(name: string);
  67340. /**
  67341. * Stores the intensity of the different subsurface effects in the thickness texture.
  67342. * * the green channel is the translucency intensity.
  67343. * * the blue channel is the scattering intensity.
  67344. * * the alpha channel is the refraction intensity.
  67345. */
  67346. useMaskFromThicknessTexture: boolean;
  67347. /**
  67348. * Initialize the block and prepare the context for build
  67349. * @param state defines the state that will be used for the build
  67350. */
  67351. initialize(state: NodeMaterialBuildState): void;
  67352. /**
  67353. * Gets the current class name
  67354. * @returns the class name
  67355. */
  67356. getClassName(): string;
  67357. /**
  67358. * Gets the min thickness input component
  67359. */
  67360. get minThickness(): NodeMaterialConnectionPoint;
  67361. /**
  67362. * Gets the max thickness input component
  67363. */
  67364. get maxThickness(): NodeMaterialConnectionPoint;
  67365. /**
  67366. * Gets the thickness texture component
  67367. */
  67368. get thicknessTexture(): NodeMaterialConnectionPoint;
  67369. /**
  67370. * Gets the tint color input component
  67371. */
  67372. get tintColor(): NodeMaterialConnectionPoint;
  67373. /**
  67374. * Gets the translucency intensity input component
  67375. */
  67376. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67377. /**
  67378. * Gets the translucency diffusion distance input component
  67379. */
  67380. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67381. /**
  67382. * Gets the refraction object parameters
  67383. */
  67384. get refraction(): NodeMaterialConnectionPoint;
  67385. /**
  67386. * Gets the sub surface object output component
  67387. */
  67388. get subsurface(): NodeMaterialConnectionPoint;
  67389. autoConfigure(material: NodeMaterial): void;
  67390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67391. /**
  67392. * Gets the main code of the block (fragment side)
  67393. * @param state current state of the node material building
  67394. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67395. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67396. * @param worldPosVarName name of the variable holding the world position
  67397. * @returns the shader code
  67398. */
  67399. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67400. protected _buildBlock(state: NodeMaterialBuildState): this;
  67401. }
  67402. }
  67403. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67407. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67408. import { Light } from "babylonjs/Lights/light";
  67409. import { Nullable } from "babylonjs/types";
  67410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67411. import { Effect } from "babylonjs/Materials/effect";
  67412. import { Mesh } from "babylonjs/Meshes/mesh";
  67413. import { Scene } from "babylonjs/scene";
  67414. /**
  67415. * Block used to implement the PBR metallic/roughness model
  67416. */
  67417. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67418. /**
  67419. * Gets or sets the light associated with this block
  67420. */
  67421. light: Nullable<Light>;
  67422. private _lightId;
  67423. private _scene;
  67424. private _environmentBRDFTexture;
  67425. private _environmentBrdfSamplerName;
  67426. private _vNormalWName;
  67427. private _invertNormalName;
  67428. /**
  67429. * Create a new ReflectionBlock
  67430. * @param name defines the block name
  67431. */
  67432. constructor(name: string);
  67433. /**
  67434. * Intensity of the direct lights e.g. the four lights available in your scene.
  67435. * This impacts both the direct diffuse and specular highlights.
  67436. */
  67437. directIntensity: number;
  67438. /**
  67439. * Intensity of the environment e.g. how much the environment will light the object
  67440. * either through harmonics for rough material or through the refelction for shiny ones.
  67441. */
  67442. environmentIntensity: number;
  67443. /**
  67444. * This is a special control allowing the reduction of the specular highlights coming from the
  67445. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67446. */
  67447. specularIntensity: number;
  67448. /**
  67449. * Defines the falloff type used in this material.
  67450. * It by default is Physical.
  67451. */
  67452. lightFalloff: number;
  67453. /**
  67454. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67455. */
  67456. useAlphaFromAlbedoTexture: boolean;
  67457. /**
  67458. * Specifies that alpha test should be used
  67459. */
  67460. useAlphaTest: boolean;
  67461. /**
  67462. * Defines the alpha limits in alpha test mode.
  67463. */
  67464. alphaTestCutoff: number;
  67465. /**
  67466. * Specifies that alpha blending should be used
  67467. */
  67468. useAlphaBlending: boolean;
  67469. /**
  67470. * Defines if the alpha value should be determined via the rgb values.
  67471. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67472. */
  67473. opacityRGB: boolean;
  67474. /**
  67475. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67476. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67477. */
  67478. useRadianceOverAlpha: boolean;
  67479. /**
  67480. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67481. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67482. */
  67483. useSpecularOverAlpha: boolean;
  67484. /**
  67485. * Enables specular anti aliasing in the PBR shader.
  67486. * It will both interacts on the Geometry for analytical and IBL lighting.
  67487. * It also prefilter the roughness map based on the bump values.
  67488. */
  67489. enableSpecularAntiAliasing: boolean;
  67490. /**
  67491. * Enables realtime filtering on the texture.
  67492. */
  67493. realTimeFiltering: boolean;
  67494. /**
  67495. * Quality switch for realtime filtering
  67496. */
  67497. realTimeFilteringQuality: number;
  67498. /**
  67499. * Defines if the material uses energy conservation.
  67500. */
  67501. useEnergyConservation: boolean;
  67502. /**
  67503. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67504. * too much the area relying on ambient texture to define their ambient occlusion.
  67505. */
  67506. useRadianceOcclusion: boolean;
  67507. /**
  67508. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67509. * makes the reflect vector face the model (under horizon).
  67510. */
  67511. useHorizonOcclusion: boolean;
  67512. /**
  67513. * If set to true, no lighting calculations will be applied.
  67514. */
  67515. unlit: boolean;
  67516. /**
  67517. * Force normal to face away from face.
  67518. */
  67519. forceNormalForward: boolean;
  67520. /**
  67521. * Defines the material debug mode.
  67522. * It helps seeing only some components of the material while troubleshooting.
  67523. */
  67524. debugMode: number;
  67525. /**
  67526. * Specify from where on screen the debug mode should start.
  67527. * The value goes from -1 (full screen) to 1 (not visible)
  67528. * It helps with side by side comparison against the final render
  67529. * This defaults to 0
  67530. */
  67531. debugLimit: number;
  67532. /**
  67533. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67534. * You can use the factor to better multiply the final value.
  67535. */
  67536. debugFactor: number;
  67537. /**
  67538. * Initialize the block and prepare the context for build
  67539. * @param state defines the state that will be used for the build
  67540. */
  67541. initialize(state: NodeMaterialBuildState): void;
  67542. /**
  67543. * Gets the current class name
  67544. * @returns the class name
  67545. */
  67546. getClassName(): string;
  67547. /**
  67548. * Gets the world position input component
  67549. */
  67550. get worldPosition(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the world normal input component
  67553. */
  67554. get worldNormal(): NodeMaterialConnectionPoint;
  67555. /**
  67556. * Gets the perturbed normal input component
  67557. */
  67558. get perturbedNormal(): NodeMaterialConnectionPoint;
  67559. /**
  67560. * Gets the camera position input component
  67561. */
  67562. get cameraPosition(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the base color input component
  67565. */
  67566. get baseColor(): NodeMaterialConnectionPoint;
  67567. /**
  67568. * Gets the opacity texture input component
  67569. */
  67570. get opacityTexture(): NodeMaterialConnectionPoint;
  67571. /**
  67572. * Gets the ambient color input component
  67573. */
  67574. get ambientColor(): NodeMaterialConnectionPoint;
  67575. /**
  67576. * Gets the reflectivity object parameters
  67577. */
  67578. get reflectivity(): NodeMaterialConnectionPoint;
  67579. /**
  67580. * Gets the ambient occlusion object parameters
  67581. */
  67582. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67583. /**
  67584. * Gets the reflection object parameters
  67585. */
  67586. get reflection(): NodeMaterialConnectionPoint;
  67587. /**
  67588. * Gets the sheen object parameters
  67589. */
  67590. get sheen(): NodeMaterialConnectionPoint;
  67591. /**
  67592. * Gets the clear coat object parameters
  67593. */
  67594. get clearcoat(): NodeMaterialConnectionPoint;
  67595. /**
  67596. * Gets the sub surface object parameters
  67597. */
  67598. get subsurface(): NodeMaterialConnectionPoint;
  67599. /**
  67600. * Gets the anisotropy object parameters
  67601. */
  67602. get anisotropy(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the ambient output component
  67605. */
  67606. get ambient(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the diffuse output component
  67609. */
  67610. get diffuse(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the specular output component
  67613. */
  67614. get specular(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the sheen output component
  67617. */
  67618. get sheenDir(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the clear coat output component
  67621. */
  67622. get clearcoatDir(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the indirect diffuse output component
  67625. */
  67626. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67627. /**
  67628. * Gets the indirect specular output component
  67629. */
  67630. get specularIndirect(): NodeMaterialConnectionPoint;
  67631. /**
  67632. * Gets the indirect sheen output component
  67633. */
  67634. get sheenIndirect(): NodeMaterialConnectionPoint;
  67635. /**
  67636. * Gets the indirect clear coat output component
  67637. */
  67638. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67639. /**
  67640. * Gets the refraction output component
  67641. */
  67642. get refraction(): NodeMaterialConnectionPoint;
  67643. /**
  67644. * Gets the global lighting output component
  67645. */
  67646. get lighting(): NodeMaterialConnectionPoint;
  67647. /**
  67648. * Gets the shadow output component
  67649. */
  67650. get shadow(): NodeMaterialConnectionPoint;
  67651. /**
  67652. * Gets the alpha output component
  67653. */
  67654. get alpha(): NodeMaterialConnectionPoint;
  67655. autoConfigure(material: NodeMaterial): void;
  67656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67657. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67658. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67659. private _injectVertexCode;
  67660. /**
  67661. * Gets the code corresponding to the albedo/opacity module
  67662. * @returns the shader code
  67663. */
  67664. getAlbedoOpacityCode(): string;
  67665. protected _buildBlock(state: NodeMaterialBuildState): this;
  67666. protected _dumpPropertiesCode(): string;
  67667. serialize(): any;
  67668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67669. }
  67670. }
  67671. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67672. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67673. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67674. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67675. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67676. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67677. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67678. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67679. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67680. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67681. }
  67682. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67683. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67684. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67685. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67686. }
  67687. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67691. /**
  67692. * Block used to compute value of one parameter modulo another
  67693. */
  67694. export class ModBlock extends NodeMaterialBlock {
  67695. /**
  67696. * Creates a new ModBlock
  67697. * @param name defines the block name
  67698. */
  67699. constructor(name: string);
  67700. /**
  67701. * Gets the current class name
  67702. * @returns the class name
  67703. */
  67704. getClassName(): string;
  67705. /**
  67706. * Gets the left operand input component
  67707. */
  67708. get left(): NodeMaterialConnectionPoint;
  67709. /**
  67710. * Gets the right operand input component
  67711. */
  67712. get right(): NodeMaterialConnectionPoint;
  67713. /**
  67714. * Gets the output component
  67715. */
  67716. get output(): NodeMaterialConnectionPoint;
  67717. protected _buildBlock(state: NodeMaterialBuildState): this;
  67718. }
  67719. }
  67720. declare module "babylonjs/Materials/Node/Blocks/index" {
  67721. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67722. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67723. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67724. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67725. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67726. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67727. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67728. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67729. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67730. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67731. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67732. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67733. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67734. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67735. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67736. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67737. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67738. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67739. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67740. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67741. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67742. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67743. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67744. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67745. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67746. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67747. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67748. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67749. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67750. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67751. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67752. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67753. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67754. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67755. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67756. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67757. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67758. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67759. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67760. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67761. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67762. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67763. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67764. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67765. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67766. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67767. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67768. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67769. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67770. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67771. }
  67772. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67773. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67774. }
  67775. declare module "babylonjs/Materials/Node/index" {
  67776. export * from "babylonjs/Materials/Node/Enums/index";
  67777. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67778. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67779. export * from "babylonjs/Materials/Node/nodeMaterial";
  67780. export * from "babylonjs/Materials/Node/Blocks/index";
  67781. export * from "babylonjs/Materials/Node/Optimizers/index";
  67782. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67783. }
  67784. declare module "babylonjs/Materials/index" {
  67785. export * from "babylonjs/Materials/Background/index";
  67786. export * from "babylonjs/Materials/colorCurves";
  67787. export * from "babylonjs/Materials/iEffectFallbacks";
  67788. export * from "babylonjs/Materials/effectFallbacks";
  67789. export * from "babylonjs/Materials/effect";
  67790. export * from "babylonjs/Materials/fresnelParameters";
  67791. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67792. export * from "babylonjs/Materials/material";
  67793. export * from "babylonjs/Materials/materialDefines";
  67794. export * from "babylonjs/Materials/materialHelper";
  67795. export * from "babylonjs/Materials/multiMaterial";
  67796. export * from "babylonjs/Materials/PBR/index";
  67797. export * from "babylonjs/Materials/pushMaterial";
  67798. export * from "babylonjs/Materials/shaderMaterial";
  67799. export * from "babylonjs/Materials/standardMaterial";
  67800. export * from "babylonjs/Materials/Textures/index";
  67801. export * from "babylonjs/Materials/uniformBuffer";
  67802. export * from "babylonjs/Materials/materialFlags";
  67803. export * from "babylonjs/Materials/Node/index";
  67804. export * from "babylonjs/Materials/effectRenderer";
  67805. export * from "babylonjs/Materials/shadowDepthWrapper";
  67806. }
  67807. declare module "babylonjs/Maths/index" {
  67808. export * from "babylonjs/Maths/math.scalar";
  67809. export * from "babylonjs/Maths/math";
  67810. export * from "babylonjs/Maths/sphericalPolynomial";
  67811. }
  67812. declare module "babylonjs/Misc/workerPool" {
  67813. import { IDisposable } from "babylonjs/scene";
  67814. /**
  67815. * Helper class to push actions to a pool of workers.
  67816. */
  67817. export class WorkerPool implements IDisposable {
  67818. private _workerInfos;
  67819. private _pendingActions;
  67820. /**
  67821. * Constructor
  67822. * @param workers Array of workers to use for actions
  67823. */
  67824. constructor(workers: Array<Worker>);
  67825. /**
  67826. * Terminates all workers and clears any pending actions.
  67827. */
  67828. dispose(): void;
  67829. /**
  67830. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67831. * pended until a worker has completed its action.
  67832. * @param action The action to perform. Call onComplete when the action is complete.
  67833. */
  67834. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67835. private _execute;
  67836. }
  67837. }
  67838. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67839. import { IDisposable } from "babylonjs/scene";
  67840. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67841. /**
  67842. * Configuration for Draco compression
  67843. */
  67844. export interface IDracoCompressionConfiguration {
  67845. /**
  67846. * Configuration for the decoder.
  67847. */
  67848. decoder: {
  67849. /**
  67850. * The url to the WebAssembly module.
  67851. */
  67852. wasmUrl?: string;
  67853. /**
  67854. * The url to the WebAssembly binary.
  67855. */
  67856. wasmBinaryUrl?: string;
  67857. /**
  67858. * The url to the fallback JavaScript module.
  67859. */
  67860. fallbackUrl?: string;
  67861. };
  67862. }
  67863. /**
  67864. * Draco compression (https://google.github.io/draco/)
  67865. *
  67866. * This class wraps the Draco module.
  67867. *
  67868. * **Encoder**
  67869. *
  67870. * The encoder is not currently implemented.
  67871. *
  67872. * **Decoder**
  67873. *
  67874. * 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.
  67875. *
  67876. * To update the configuration, use the following code:
  67877. * ```javascript
  67878. * DracoCompression.Configuration = {
  67879. * decoder: {
  67880. * wasmUrl: "<url to the WebAssembly library>",
  67881. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67882. * fallbackUrl: "<url to the fallback JavaScript library>",
  67883. * }
  67884. * };
  67885. * ```
  67886. *
  67887. * 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.
  67888. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67889. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67890. *
  67891. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67892. * ```javascript
  67893. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67894. * ```
  67895. *
  67896. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67897. */
  67898. export class DracoCompression implements IDisposable {
  67899. private _workerPoolPromise?;
  67900. private _decoderModulePromise?;
  67901. /**
  67902. * The configuration. Defaults to the following urls:
  67903. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67904. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67905. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67906. */
  67907. static Configuration: IDracoCompressionConfiguration;
  67908. /**
  67909. * Returns true if the decoder configuration is available.
  67910. */
  67911. static get DecoderAvailable(): boolean;
  67912. /**
  67913. * Default number of workers to create when creating the draco compression object.
  67914. */
  67915. static DefaultNumWorkers: number;
  67916. private static GetDefaultNumWorkers;
  67917. private static _Default;
  67918. /**
  67919. * Default instance for the draco compression object.
  67920. */
  67921. static get Default(): DracoCompression;
  67922. /**
  67923. * Constructor
  67924. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67925. */
  67926. constructor(numWorkers?: number);
  67927. /**
  67928. * Stop all async operations and release resources.
  67929. */
  67930. dispose(): void;
  67931. /**
  67932. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67933. * @returns a promise that resolves when ready
  67934. */
  67935. whenReadyAsync(): Promise<void>;
  67936. /**
  67937. * Decode Draco compressed mesh data to vertex data.
  67938. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67939. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67940. * @returns A promise that resolves with the decoded vertex data
  67941. */
  67942. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67943. [kind: string]: number;
  67944. }): Promise<VertexData>;
  67945. }
  67946. }
  67947. declare module "babylonjs/Meshes/Compression/index" {
  67948. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67949. }
  67950. declare module "babylonjs/Meshes/csg" {
  67951. import { Nullable } from "babylonjs/types";
  67952. import { Scene } from "babylonjs/scene";
  67953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67954. import { Mesh } from "babylonjs/Meshes/mesh";
  67955. import { Material } from "babylonjs/Materials/material";
  67956. /**
  67957. * Class for building Constructive Solid Geometry
  67958. */
  67959. export class CSG {
  67960. private polygons;
  67961. /**
  67962. * The world matrix
  67963. */
  67964. matrix: Matrix;
  67965. /**
  67966. * Stores the position
  67967. */
  67968. position: Vector3;
  67969. /**
  67970. * Stores the rotation
  67971. */
  67972. rotation: Vector3;
  67973. /**
  67974. * Stores the rotation quaternion
  67975. */
  67976. rotationQuaternion: Nullable<Quaternion>;
  67977. /**
  67978. * Stores the scaling vector
  67979. */
  67980. scaling: Vector3;
  67981. /**
  67982. * Convert the Mesh to CSG
  67983. * @param mesh The Mesh to convert to CSG
  67984. * @returns A new CSG from the Mesh
  67985. */
  67986. static FromMesh(mesh: Mesh): CSG;
  67987. /**
  67988. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67989. * @param polygons Polygons used to construct a CSG solid
  67990. */
  67991. private static FromPolygons;
  67992. /**
  67993. * Clones, or makes a deep copy, of the CSG
  67994. * @returns A new CSG
  67995. */
  67996. clone(): CSG;
  67997. /**
  67998. * Unions this CSG with another CSG
  67999. * @param csg The CSG to union against this CSG
  68000. * @returns The unioned CSG
  68001. */
  68002. union(csg: CSG): CSG;
  68003. /**
  68004. * Unions this CSG with another CSG in place
  68005. * @param csg The CSG to union against this CSG
  68006. */
  68007. unionInPlace(csg: CSG): void;
  68008. /**
  68009. * Subtracts this CSG with another CSG
  68010. * @param csg The CSG to subtract against this CSG
  68011. * @returns A new CSG
  68012. */
  68013. subtract(csg: CSG): CSG;
  68014. /**
  68015. * Subtracts this CSG with another CSG in place
  68016. * @param csg The CSG to subtact against this CSG
  68017. */
  68018. subtractInPlace(csg: CSG): void;
  68019. /**
  68020. * Intersect this CSG with another CSG
  68021. * @param csg The CSG to intersect against this CSG
  68022. * @returns A new CSG
  68023. */
  68024. intersect(csg: CSG): CSG;
  68025. /**
  68026. * Intersects this CSG with another CSG in place
  68027. * @param csg The CSG to intersect against this CSG
  68028. */
  68029. intersectInPlace(csg: CSG): void;
  68030. /**
  68031. * Return a new CSG solid with solid and empty space switched. This solid is
  68032. * not modified.
  68033. * @returns A new CSG solid with solid and empty space switched
  68034. */
  68035. inverse(): CSG;
  68036. /**
  68037. * Inverses the CSG in place
  68038. */
  68039. inverseInPlace(): void;
  68040. /**
  68041. * This is used to keep meshes transformations so they can be restored
  68042. * when we build back a Babylon Mesh
  68043. * NB : All CSG operations are performed in world coordinates
  68044. * @param csg The CSG to copy the transform attributes from
  68045. * @returns This CSG
  68046. */
  68047. copyTransformAttributes(csg: CSG): CSG;
  68048. /**
  68049. * Build Raw mesh from CSG
  68050. * Coordinates here are in world space
  68051. * @param name The name of the mesh geometry
  68052. * @param scene The Scene
  68053. * @param keepSubMeshes Specifies if the submeshes should be kept
  68054. * @returns A new Mesh
  68055. */
  68056. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68057. /**
  68058. * Build Mesh from CSG taking material and transforms into account
  68059. * @param name The name of the Mesh
  68060. * @param material The material of the Mesh
  68061. * @param scene The Scene
  68062. * @param keepSubMeshes Specifies if submeshes should be kept
  68063. * @returns The new Mesh
  68064. */
  68065. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68066. }
  68067. }
  68068. declare module "babylonjs/Meshes/trailMesh" {
  68069. import { Mesh } from "babylonjs/Meshes/mesh";
  68070. import { Scene } from "babylonjs/scene";
  68071. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68072. /**
  68073. * Class used to create a trail following a mesh
  68074. */
  68075. export class TrailMesh extends Mesh {
  68076. private _generator;
  68077. private _autoStart;
  68078. private _running;
  68079. private _diameter;
  68080. private _length;
  68081. private _sectionPolygonPointsCount;
  68082. private _sectionVectors;
  68083. private _sectionNormalVectors;
  68084. private _beforeRenderObserver;
  68085. /**
  68086. * @constructor
  68087. * @param name The value used by scene.getMeshByName() to do a lookup.
  68088. * @param generator The mesh or transform node to generate a trail.
  68089. * @param scene The scene to add this mesh to.
  68090. * @param diameter Diameter of trailing mesh. Default is 1.
  68091. * @param length Length of trailing mesh. Default is 60.
  68092. * @param autoStart Automatically start trailing mesh. Default true.
  68093. */
  68094. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68095. /**
  68096. * "TrailMesh"
  68097. * @returns "TrailMesh"
  68098. */
  68099. getClassName(): string;
  68100. private _createMesh;
  68101. /**
  68102. * Start trailing mesh.
  68103. */
  68104. start(): void;
  68105. /**
  68106. * Stop trailing mesh.
  68107. */
  68108. stop(): void;
  68109. /**
  68110. * Update trailing mesh geometry.
  68111. */
  68112. update(): void;
  68113. /**
  68114. * Returns a new TrailMesh object.
  68115. * @param name is a string, the name given to the new mesh
  68116. * @param newGenerator use new generator object for cloned trail mesh
  68117. * @returns a new mesh
  68118. */
  68119. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68120. /**
  68121. * Serializes this trail mesh
  68122. * @param serializationObject object to write serialization to
  68123. */
  68124. serialize(serializationObject: any): void;
  68125. /**
  68126. * Parses a serialized trail mesh
  68127. * @param parsedMesh the serialized mesh
  68128. * @param scene the scene to create the trail mesh in
  68129. * @returns the created trail mesh
  68130. */
  68131. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68132. }
  68133. }
  68134. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68135. import { Nullable } from "babylonjs/types";
  68136. import { Scene } from "babylonjs/scene";
  68137. import { Vector4 } from "babylonjs/Maths/math.vector";
  68138. import { Color4 } from "babylonjs/Maths/math.color";
  68139. import { Mesh } from "babylonjs/Meshes/mesh";
  68140. /**
  68141. * Class containing static functions to help procedurally build meshes
  68142. */
  68143. export class TiledBoxBuilder {
  68144. /**
  68145. * Creates a box mesh
  68146. * 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)
  68147. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68151. * @param name defines the name of the mesh
  68152. * @param options defines the options used to create the mesh
  68153. * @param scene defines the hosting scene
  68154. * @returns the box mesh
  68155. */
  68156. static CreateTiledBox(name: string, options: {
  68157. pattern?: number;
  68158. width?: number;
  68159. height?: number;
  68160. depth?: number;
  68161. tileSize?: number;
  68162. tileWidth?: number;
  68163. tileHeight?: number;
  68164. alignHorizontal?: number;
  68165. alignVertical?: number;
  68166. faceUV?: Vector4[];
  68167. faceColors?: Color4[];
  68168. sideOrientation?: number;
  68169. updatable?: boolean;
  68170. }, scene?: Nullable<Scene>): Mesh;
  68171. }
  68172. }
  68173. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68174. import { Vector4 } from "babylonjs/Maths/math.vector";
  68175. import { Mesh } from "babylonjs/Meshes/mesh";
  68176. /**
  68177. * Class containing static functions to help procedurally build meshes
  68178. */
  68179. export class TorusKnotBuilder {
  68180. /**
  68181. * Creates a torus knot mesh
  68182. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68183. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68184. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68185. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68189. * @param name defines the name of the mesh
  68190. * @param options defines the options used to create the mesh
  68191. * @param scene defines the hosting scene
  68192. * @returns the torus knot mesh
  68193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68194. */
  68195. static CreateTorusKnot(name: string, options: {
  68196. radius?: number;
  68197. tube?: number;
  68198. radialSegments?: number;
  68199. tubularSegments?: number;
  68200. p?: number;
  68201. q?: number;
  68202. updatable?: boolean;
  68203. sideOrientation?: number;
  68204. frontUVs?: Vector4;
  68205. backUVs?: Vector4;
  68206. }, scene: any): Mesh;
  68207. }
  68208. }
  68209. declare module "babylonjs/Meshes/polygonMesh" {
  68210. import { Scene } from "babylonjs/scene";
  68211. import { Vector2 } from "babylonjs/Maths/math.vector";
  68212. import { Mesh } from "babylonjs/Meshes/mesh";
  68213. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68214. import { Path2 } from "babylonjs/Maths/math.path";
  68215. /**
  68216. * Polygon
  68217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68218. */
  68219. export class Polygon {
  68220. /**
  68221. * Creates a rectangle
  68222. * @param xmin bottom X coord
  68223. * @param ymin bottom Y coord
  68224. * @param xmax top X coord
  68225. * @param ymax top Y coord
  68226. * @returns points that make the resulting rectation
  68227. */
  68228. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68229. /**
  68230. * Creates a circle
  68231. * @param radius radius of circle
  68232. * @param cx scale in x
  68233. * @param cy scale in y
  68234. * @param numberOfSides number of sides that make up the circle
  68235. * @returns points that make the resulting circle
  68236. */
  68237. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68238. /**
  68239. * Creates a polygon from input string
  68240. * @param input Input polygon data
  68241. * @returns the parsed points
  68242. */
  68243. static Parse(input: string): Vector2[];
  68244. /**
  68245. * Starts building a polygon from x and y coordinates
  68246. * @param x x coordinate
  68247. * @param y y coordinate
  68248. * @returns the started path2
  68249. */
  68250. static StartingAt(x: number, y: number): Path2;
  68251. }
  68252. /**
  68253. * Builds a polygon
  68254. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68255. */
  68256. export class PolygonMeshBuilder {
  68257. private _points;
  68258. private _outlinepoints;
  68259. private _holes;
  68260. private _name;
  68261. private _scene;
  68262. private _epoints;
  68263. private _eholes;
  68264. private _addToepoint;
  68265. /**
  68266. * Babylon reference to the earcut plugin.
  68267. */
  68268. bjsEarcut: any;
  68269. /**
  68270. * Creates a PolygonMeshBuilder
  68271. * @param name name of the builder
  68272. * @param contours Path of the polygon
  68273. * @param scene scene to add to when creating the mesh
  68274. * @param earcutInjection can be used to inject your own earcut reference
  68275. */
  68276. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68277. /**
  68278. * Adds a whole within the polygon
  68279. * @param hole Array of points defining the hole
  68280. * @returns this
  68281. */
  68282. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68283. /**
  68284. * Creates the polygon
  68285. * @param updatable If the mesh should be updatable
  68286. * @param depth The depth of the mesh created
  68287. * @returns the created mesh
  68288. */
  68289. build(updatable?: boolean, depth?: number): Mesh;
  68290. /**
  68291. * Creates the polygon
  68292. * @param depth The depth of the mesh created
  68293. * @returns the created VertexData
  68294. */
  68295. buildVertexData(depth?: number): VertexData;
  68296. /**
  68297. * Adds a side to the polygon
  68298. * @param positions points that make the polygon
  68299. * @param normals normals of the polygon
  68300. * @param uvs uvs of the polygon
  68301. * @param indices indices of the polygon
  68302. * @param bounds bounds of the polygon
  68303. * @param points points of the polygon
  68304. * @param depth depth of the polygon
  68305. * @param flip flip of the polygon
  68306. */
  68307. private addSide;
  68308. }
  68309. }
  68310. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68311. import { Scene } from "babylonjs/scene";
  68312. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68313. import { Color4 } from "babylonjs/Maths/math.color";
  68314. import { Mesh } from "babylonjs/Meshes/mesh";
  68315. import { Nullable } from "babylonjs/types";
  68316. /**
  68317. * Class containing static functions to help procedurally build meshes
  68318. */
  68319. export class PolygonBuilder {
  68320. /**
  68321. * Creates a polygon mesh
  68322. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68323. * * 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
  68324. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68327. * * Remember you can only change the shape positions, not their number when updating a polygon
  68328. * @param name defines the name of the mesh
  68329. * @param options defines the options used to create the mesh
  68330. * @param scene defines the hosting scene
  68331. * @param earcutInjection can be used to inject your own earcut reference
  68332. * @returns the polygon mesh
  68333. */
  68334. static CreatePolygon(name: string, options: {
  68335. shape: Vector3[];
  68336. holes?: Vector3[][];
  68337. depth?: number;
  68338. faceUV?: Vector4[];
  68339. faceColors?: Color4[];
  68340. updatable?: boolean;
  68341. sideOrientation?: number;
  68342. frontUVs?: Vector4;
  68343. backUVs?: Vector4;
  68344. wrap?: boolean;
  68345. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68346. /**
  68347. * Creates an extruded polygon mesh, with depth in the Y direction.
  68348. * * 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)
  68349. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68350. * @param name defines the name of the mesh
  68351. * @param options defines the options used to create the mesh
  68352. * @param scene defines the hosting scene
  68353. * @param earcutInjection can be used to inject your own earcut reference
  68354. * @returns the polygon mesh
  68355. */
  68356. static ExtrudePolygon(name: string, options: {
  68357. shape: Vector3[];
  68358. holes?: Vector3[][];
  68359. depth?: number;
  68360. faceUV?: Vector4[];
  68361. faceColors?: Color4[];
  68362. updatable?: boolean;
  68363. sideOrientation?: number;
  68364. frontUVs?: Vector4;
  68365. backUVs?: Vector4;
  68366. wrap?: boolean;
  68367. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68368. }
  68369. }
  68370. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68371. import { Scene } from "babylonjs/scene";
  68372. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68373. import { Mesh } from "babylonjs/Meshes/mesh";
  68374. import { Nullable } from "babylonjs/types";
  68375. /**
  68376. * Class containing static functions to help procedurally build meshes
  68377. */
  68378. export class LatheBuilder {
  68379. /**
  68380. * Creates lathe mesh.
  68381. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68382. * * 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
  68383. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68384. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68385. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68386. * * 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
  68387. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68388. * * 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
  68389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68391. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68393. * @param name defines the name of the mesh
  68394. * @param options defines the options used to create the mesh
  68395. * @param scene defines the hosting scene
  68396. * @returns the lathe mesh
  68397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68398. */
  68399. static CreateLathe(name: string, options: {
  68400. shape: Vector3[];
  68401. radius?: number;
  68402. tessellation?: number;
  68403. clip?: number;
  68404. arc?: number;
  68405. closed?: boolean;
  68406. updatable?: boolean;
  68407. sideOrientation?: number;
  68408. frontUVs?: Vector4;
  68409. backUVs?: Vector4;
  68410. cap?: number;
  68411. invertUV?: boolean;
  68412. }, scene?: Nullable<Scene>): Mesh;
  68413. }
  68414. }
  68415. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68416. import { Nullable } from "babylonjs/types";
  68417. import { Scene } from "babylonjs/scene";
  68418. import { Vector4 } from "babylonjs/Maths/math.vector";
  68419. import { Mesh } from "babylonjs/Meshes/mesh";
  68420. /**
  68421. * Class containing static functions to help procedurally build meshes
  68422. */
  68423. export class TiledPlaneBuilder {
  68424. /**
  68425. * Creates a tiled plane mesh
  68426. * * The parameter `pattern` will, depending on value, do nothing or
  68427. * * * flip (reflect about central vertical) alternate tiles across and up
  68428. * * * flip every tile on alternate rows
  68429. * * * rotate (180 degs) alternate tiles across and up
  68430. * * * rotate every tile on alternate rows
  68431. * * * flip and rotate alternate tiles across and up
  68432. * * * flip and rotate every tile on alternate rows
  68433. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68434. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68437. * * 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)
  68438. * * 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)
  68439. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68440. * @param name defines the name of the mesh
  68441. * @param options defines the options used to create the mesh
  68442. * @param scene defines the hosting scene
  68443. * @returns the box mesh
  68444. */
  68445. static CreateTiledPlane(name: string, options: {
  68446. pattern?: number;
  68447. tileSize?: number;
  68448. tileWidth?: number;
  68449. tileHeight?: number;
  68450. size?: number;
  68451. width?: number;
  68452. height?: number;
  68453. alignHorizontal?: number;
  68454. alignVertical?: number;
  68455. sideOrientation?: number;
  68456. frontUVs?: Vector4;
  68457. backUVs?: Vector4;
  68458. updatable?: boolean;
  68459. }, scene?: Nullable<Scene>): Mesh;
  68460. }
  68461. }
  68462. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68463. import { Nullable } from "babylonjs/types";
  68464. import { Scene } from "babylonjs/scene";
  68465. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68466. import { Mesh } from "babylonjs/Meshes/mesh";
  68467. /**
  68468. * Class containing static functions to help procedurally build meshes
  68469. */
  68470. export class TubeBuilder {
  68471. /**
  68472. * Creates a tube mesh.
  68473. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68474. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68475. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68476. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68477. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68478. * * 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)
  68479. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68480. * * 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
  68481. * * 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
  68482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68486. * @param name defines the name of the mesh
  68487. * @param options defines the options used to create the mesh
  68488. * @param scene defines the hosting scene
  68489. * @returns the tube mesh
  68490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68491. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68492. */
  68493. static CreateTube(name: string, options: {
  68494. path: Vector3[];
  68495. radius?: number;
  68496. tessellation?: number;
  68497. radiusFunction?: {
  68498. (i: number, distance: number): number;
  68499. };
  68500. cap?: number;
  68501. arc?: number;
  68502. updatable?: boolean;
  68503. sideOrientation?: number;
  68504. frontUVs?: Vector4;
  68505. backUVs?: Vector4;
  68506. instance?: Mesh;
  68507. invertUV?: boolean;
  68508. }, scene?: Nullable<Scene>): Mesh;
  68509. }
  68510. }
  68511. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68512. import { Scene } from "babylonjs/scene";
  68513. import { Vector4 } from "babylonjs/Maths/math.vector";
  68514. import { Mesh } from "babylonjs/Meshes/mesh";
  68515. import { Nullable } from "babylonjs/types";
  68516. /**
  68517. * Class containing static functions to help procedurally build meshes
  68518. */
  68519. export class IcoSphereBuilder {
  68520. /**
  68521. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68522. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68523. * * 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`)
  68524. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68525. * * 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
  68526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68529. * @param name defines the name of the mesh
  68530. * @param options defines the options used to create the mesh
  68531. * @param scene defines the hosting scene
  68532. * @returns the icosahedron mesh
  68533. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68534. */
  68535. static CreateIcoSphere(name: string, options: {
  68536. radius?: number;
  68537. radiusX?: number;
  68538. radiusY?: number;
  68539. radiusZ?: number;
  68540. flat?: boolean;
  68541. subdivisions?: number;
  68542. sideOrientation?: number;
  68543. frontUVs?: Vector4;
  68544. backUVs?: Vector4;
  68545. updatable?: boolean;
  68546. }, scene?: Nullable<Scene>): Mesh;
  68547. }
  68548. }
  68549. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68550. import { Vector3 } from "babylonjs/Maths/math.vector";
  68551. import { Mesh } from "babylonjs/Meshes/mesh";
  68552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68553. /**
  68554. * Class containing static functions to help procedurally build meshes
  68555. */
  68556. export class DecalBuilder {
  68557. /**
  68558. * Creates a decal mesh.
  68559. * 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
  68560. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68561. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68562. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68563. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68564. * @param name defines the name of the mesh
  68565. * @param sourceMesh defines the mesh where the decal must be applied
  68566. * @param options defines the options used to create the mesh
  68567. * @param scene defines the hosting scene
  68568. * @returns the decal mesh
  68569. * @see https://doc.babylonjs.com/how_to/decals
  68570. */
  68571. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68572. position?: Vector3;
  68573. normal?: Vector3;
  68574. size?: Vector3;
  68575. angle?: number;
  68576. }): Mesh;
  68577. }
  68578. }
  68579. declare module "babylonjs/Meshes/meshBuilder" {
  68580. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68581. import { Nullable } from "babylonjs/types";
  68582. import { Scene } from "babylonjs/scene";
  68583. import { Mesh } from "babylonjs/Meshes/mesh";
  68584. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68585. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68587. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68588. import { Plane } from "babylonjs/Maths/math.plane";
  68589. /**
  68590. * Class containing static functions to help procedurally build meshes
  68591. */
  68592. export class MeshBuilder {
  68593. /**
  68594. * Creates a box mesh
  68595. * * The parameter `size` sets the size (float) of each box side (default 1)
  68596. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68597. * * 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)
  68598. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68602. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68603. * @param name defines the name of the mesh
  68604. * @param options defines the options used to create the mesh
  68605. * @param scene defines the hosting scene
  68606. * @returns the box mesh
  68607. */
  68608. static CreateBox(name: string, options: {
  68609. size?: number;
  68610. width?: number;
  68611. height?: number;
  68612. depth?: number;
  68613. faceUV?: Vector4[];
  68614. faceColors?: Color4[];
  68615. sideOrientation?: number;
  68616. frontUVs?: Vector4;
  68617. backUVs?: Vector4;
  68618. wrap?: boolean;
  68619. topBaseAt?: number;
  68620. bottomBaseAt?: number;
  68621. updatable?: boolean;
  68622. }, scene?: Nullable<Scene>): Mesh;
  68623. /**
  68624. * Creates a tiled box mesh
  68625. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68627. * @param name defines the name of the mesh
  68628. * @param options defines the options used to create the mesh
  68629. * @param scene defines the hosting scene
  68630. * @returns the tiled box mesh
  68631. */
  68632. static CreateTiledBox(name: string, options: {
  68633. pattern?: number;
  68634. size?: number;
  68635. width?: number;
  68636. height?: number;
  68637. depth: number;
  68638. tileSize?: number;
  68639. tileWidth?: number;
  68640. tileHeight?: number;
  68641. faceUV?: Vector4[];
  68642. faceColors?: Color4[];
  68643. alignHorizontal?: number;
  68644. alignVertical?: number;
  68645. sideOrientation?: number;
  68646. updatable?: boolean;
  68647. }, scene?: Nullable<Scene>): Mesh;
  68648. /**
  68649. * Creates a sphere mesh
  68650. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68651. * * 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`)
  68652. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68653. * * 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
  68654. * * 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)
  68655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68658. * @param name defines the name of the mesh
  68659. * @param options defines the options used to create the mesh
  68660. * @param scene defines the hosting scene
  68661. * @returns the sphere mesh
  68662. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68663. */
  68664. static CreateSphere(name: string, options: {
  68665. segments?: number;
  68666. diameter?: number;
  68667. diameterX?: number;
  68668. diameterY?: number;
  68669. diameterZ?: number;
  68670. arc?: number;
  68671. slice?: number;
  68672. sideOrientation?: number;
  68673. frontUVs?: Vector4;
  68674. backUVs?: Vector4;
  68675. updatable?: boolean;
  68676. }, scene?: Nullable<Scene>): Mesh;
  68677. /**
  68678. * Creates a plane polygonal mesh. By default, this is a disc
  68679. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68680. * * 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
  68681. * * 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
  68682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68685. * @param name defines the name of the mesh
  68686. * @param options defines the options used to create the mesh
  68687. * @param scene defines the hosting scene
  68688. * @returns the plane polygonal mesh
  68689. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68690. */
  68691. static CreateDisc(name: string, options: {
  68692. radius?: number;
  68693. tessellation?: number;
  68694. arc?: number;
  68695. updatable?: boolean;
  68696. sideOrientation?: number;
  68697. frontUVs?: Vector4;
  68698. backUVs?: Vector4;
  68699. }, scene?: Nullable<Scene>): Mesh;
  68700. /**
  68701. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68702. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68703. * * 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`)
  68704. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68705. * * 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
  68706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68709. * @param name defines the name of the mesh
  68710. * @param options defines the options used to create the mesh
  68711. * @param scene defines the hosting scene
  68712. * @returns the icosahedron mesh
  68713. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68714. */
  68715. static CreateIcoSphere(name: string, options: {
  68716. radius?: number;
  68717. radiusX?: number;
  68718. radiusY?: number;
  68719. radiusZ?: number;
  68720. flat?: boolean;
  68721. subdivisions?: number;
  68722. sideOrientation?: number;
  68723. frontUVs?: Vector4;
  68724. backUVs?: Vector4;
  68725. updatable?: boolean;
  68726. }, scene?: Nullable<Scene>): Mesh;
  68727. /**
  68728. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68729. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68730. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68731. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68732. * * 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
  68733. * * 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
  68734. * * 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
  68735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68738. * * 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
  68739. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68740. * * 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
  68741. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68743. * @param name defines the name of the mesh
  68744. * @param options defines the options used to create the mesh
  68745. * @param scene defines the hosting scene
  68746. * @returns the ribbon mesh
  68747. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68749. */
  68750. static CreateRibbon(name: string, options: {
  68751. pathArray: Vector3[][];
  68752. closeArray?: boolean;
  68753. closePath?: boolean;
  68754. offset?: number;
  68755. updatable?: boolean;
  68756. sideOrientation?: number;
  68757. frontUVs?: Vector4;
  68758. backUVs?: Vector4;
  68759. instance?: Mesh;
  68760. invertUV?: boolean;
  68761. uvs?: Vector2[];
  68762. colors?: Color4[];
  68763. }, scene?: Nullable<Scene>): Mesh;
  68764. /**
  68765. * Creates a cylinder or a cone mesh
  68766. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68767. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68768. * * 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.
  68769. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68770. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68771. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68772. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68773. * * 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).
  68774. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68775. * * 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).
  68776. * * 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
  68777. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68778. * * 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
  68779. * * 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.
  68780. * * If `enclose` is false, a ring surface is one element.
  68781. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68782. * * 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
  68783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68786. * @param name defines the name of the mesh
  68787. * @param options defines the options used to create the mesh
  68788. * @param scene defines the hosting scene
  68789. * @returns the cylinder mesh
  68790. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68791. */
  68792. static CreateCylinder(name: string, options: {
  68793. height?: number;
  68794. diameterTop?: number;
  68795. diameterBottom?: number;
  68796. diameter?: number;
  68797. tessellation?: number;
  68798. subdivisions?: number;
  68799. arc?: number;
  68800. faceColors?: Color4[];
  68801. faceUV?: Vector4[];
  68802. updatable?: boolean;
  68803. hasRings?: boolean;
  68804. enclose?: boolean;
  68805. cap?: number;
  68806. sideOrientation?: number;
  68807. frontUVs?: Vector4;
  68808. backUVs?: Vector4;
  68809. }, scene?: Nullable<Scene>): Mesh;
  68810. /**
  68811. * Creates a torus mesh
  68812. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68813. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68814. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68818. * @param name defines the name of the mesh
  68819. * @param options defines the options used to create the mesh
  68820. * @param scene defines the hosting scene
  68821. * @returns the torus mesh
  68822. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68823. */
  68824. static CreateTorus(name: string, options: {
  68825. diameter?: number;
  68826. thickness?: number;
  68827. tessellation?: number;
  68828. updatable?: boolean;
  68829. sideOrientation?: number;
  68830. frontUVs?: Vector4;
  68831. backUVs?: Vector4;
  68832. }, scene?: Nullable<Scene>): Mesh;
  68833. /**
  68834. * Creates a torus knot mesh
  68835. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68836. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68837. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68838. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68842. * @param name defines the name of the mesh
  68843. * @param options defines the options used to create the mesh
  68844. * @param scene defines the hosting scene
  68845. * @returns the torus knot mesh
  68846. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68847. */
  68848. static CreateTorusKnot(name: string, options: {
  68849. radius?: number;
  68850. tube?: number;
  68851. radialSegments?: number;
  68852. tubularSegments?: number;
  68853. p?: number;
  68854. q?: number;
  68855. updatable?: boolean;
  68856. sideOrientation?: number;
  68857. frontUVs?: Vector4;
  68858. backUVs?: Vector4;
  68859. }, scene?: Nullable<Scene>): Mesh;
  68860. /**
  68861. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68862. * * 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
  68863. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68864. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68865. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68866. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68867. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68868. * * 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
  68869. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68872. * @param name defines the name of the new line system
  68873. * @param options defines the options used to create the line system
  68874. * @param scene defines the hosting scene
  68875. * @returns a new line system mesh
  68876. */
  68877. static CreateLineSystem(name: string, options: {
  68878. lines: Vector3[][];
  68879. updatable?: boolean;
  68880. instance?: Nullable<LinesMesh>;
  68881. colors?: Nullable<Color4[][]>;
  68882. useVertexAlpha?: boolean;
  68883. }, scene: Nullable<Scene>): LinesMesh;
  68884. /**
  68885. * Creates a line mesh
  68886. * 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
  68887. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68888. * * The parameter `points` is an array successive Vector3
  68889. * * 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
  68890. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68891. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68892. * * When updating an instance, remember that only point positions can change, not the number of points
  68893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68895. * @param name defines the name of the new line system
  68896. * @param options defines the options used to create the line system
  68897. * @param scene defines the hosting scene
  68898. * @returns a new line mesh
  68899. */
  68900. static CreateLines(name: string, options: {
  68901. points: Vector3[];
  68902. updatable?: boolean;
  68903. instance?: Nullable<LinesMesh>;
  68904. colors?: Color4[];
  68905. useVertexAlpha?: boolean;
  68906. }, scene?: Nullable<Scene>): LinesMesh;
  68907. /**
  68908. * Creates a dashed line mesh
  68909. * * 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
  68910. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68911. * * The parameter `points` is an array successive Vector3
  68912. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68913. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68914. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68915. * * 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
  68916. * * When updating an instance, remember that only point positions can change, not the number of points
  68917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68918. * @param name defines the name of the mesh
  68919. * @param options defines the options used to create the mesh
  68920. * @param scene defines the hosting scene
  68921. * @returns the dashed line mesh
  68922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68923. */
  68924. static CreateDashedLines(name: string, options: {
  68925. points: Vector3[];
  68926. dashSize?: number;
  68927. gapSize?: number;
  68928. dashNb?: number;
  68929. updatable?: boolean;
  68930. instance?: LinesMesh;
  68931. }, scene?: Nullable<Scene>): LinesMesh;
  68932. /**
  68933. * 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.
  68934. * * 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.
  68935. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68936. * * 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.
  68937. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68938. * * 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
  68939. * * 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
  68940. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68945. * @param name defines the name of the mesh
  68946. * @param options defines the options used to create the mesh
  68947. * @param scene defines the hosting scene
  68948. * @returns the extruded shape mesh
  68949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68951. */
  68952. static ExtrudeShape(name: string, options: {
  68953. shape: Vector3[];
  68954. path: Vector3[];
  68955. scale?: number;
  68956. rotation?: number;
  68957. cap?: number;
  68958. updatable?: boolean;
  68959. sideOrientation?: number;
  68960. frontUVs?: Vector4;
  68961. backUVs?: Vector4;
  68962. instance?: Mesh;
  68963. invertUV?: boolean;
  68964. }, scene?: Nullable<Scene>): Mesh;
  68965. /**
  68966. * Creates an custom extruded shape mesh.
  68967. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68968. * * 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.
  68969. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68970. * * 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
  68971. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68972. * * 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
  68973. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68974. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68975. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68976. * * 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
  68977. * * 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
  68978. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68981. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68983. * @param name defines the name of the mesh
  68984. * @param options defines the options used to create the mesh
  68985. * @param scene defines the hosting scene
  68986. * @returns the custom extruded shape mesh
  68987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68990. */
  68991. static ExtrudeShapeCustom(name: string, options: {
  68992. shape: Vector3[];
  68993. path: Vector3[];
  68994. scaleFunction?: any;
  68995. rotationFunction?: any;
  68996. ribbonCloseArray?: boolean;
  68997. ribbonClosePath?: boolean;
  68998. cap?: number;
  68999. updatable?: boolean;
  69000. sideOrientation?: number;
  69001. frontUVs?: Vector4;
  69002. backUVs?: Vector4;
  69003. instance?: Mesh;
  69004. invertUV?: boolean;
  69005. }, scene?: Nullable<Scene>): Mesh;
  69006. /**
  69007. * Creates lathe mesh.
  69008. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69009. * * 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
  69010. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69011. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69012. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69013. * * 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
  69014. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69015. * * 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
  69016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69020. * @param name defines the name of the mesh
  69021. * @param options defines the options used to create the mesh
  69022. * @param scene defines the hosting scene
  69023. * @returns the lathe mesh
  69024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69025. */
  69026. static CreateLathe(name: string, options: {
  69027. shape: Vector3[];
  69028. radius?: number;
  69029. tessellation?: number;
  69030. clip?: number;
  69031. arc?: number;
  69032. closed?: boolean;
  69033. updatable?: boolean;
  69034. sideOrientation?: number;
  69035. frontUVs?: Vector4;
  69036. backUVs?: Vector4;
  69037. cap?: number;
  69038. invertUV?: boolean;
  69039. }, scene?: Nullable<Scene>): Mesh;
  69040. /**
  69041. * Creates a tiled plane mesh
  69042. * * You can set a limited pattern arrangement with the tiles
  69043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69046. * @param name defines the name of the mesh
  69047. * @param options defines the options used to create the mesh
  69048. * @param scene defines the hosting scene
  69049. * @returns the plane mesh
  69050. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69051. */
  69052. static CreateTiledPlane(name: string, options: {
  69053. pattern?: number;
  69054. tileSize?: number;
  69055. tileWidth?: number;
  69056. tileHeight?: number;
  69057. size?: number;
  69058. width?: number;
  69059. height?: number;
  69060. alignHorizontal?: number;
  69061. alignVertical?: number;
  69062. sideOrientation?: number;
  69063. frontUVs?: Vector4;
  69064. backUVs?: Vector4;
  69065. updatable?: boolean;
  69066. }, scene?: Nullable<Scene>): Mesh;
  69067. /**
  69068. * Creates a plane mesh
  69069. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69070. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69071. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69075. * @param name defines the name of the mesh
  69076. * @param options defines the options used to create the mesh
  69077. * @param scene defines the hosting scene
  69078. * @returns the plane mesh
  69079. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69080. */
  69081. static CreatePlane(name: string, options: {
  69082. size?: number;
  69083. width?: number;
  69084. height?: number;
  69085. sideOrientation?: number;
  69086. frontUVs?: Vector4;
  69087. backUVs?: Vector4;
  69088. updatable?: boolean;
  69089. sourcePlane?: Plane;
  69090. }, scene?: Nullable<Scene>): Mesh;
  69091. /**
  69092. * Creates a ground mesh
  69093. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69094. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69096. * @param name defines the name of the mesh
  69097. * @param options defines the options used to create the mesh
  69098. * @param scene defines the hosting scene
  69099. * @returns the ground mesh
  69100. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69101. */
  69102. static CreateGround(name: string, options: {
  69103. width?: number;
  69104. height?: number;
  69105. subdivisions?: number;
  69106. subdivisionsX?: number;
  69107. subdivisionsY?: number;
  69108. updatable?: boolean;
  69109. }, scene?: Nullable<Scene>): Mesh;
  69110. /**
  69111. * Creates a tiled ground mesh
  69112. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69113. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69114. * * 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
  69115. * * 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
  69116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69117. * @param name defines the name of the mesh
  69118. * @param options defines the options used to create the mesh
  69119. * @param scene defines the hosting scene
  69120. * @returns the tiled ground mesh
  69121. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69122. */
  69123. static CreateTiledGround(name: string, options: {
  69124. xmin: number;
  69125. zmin: number;
  69126. xmax: number;
  69127. zmax: number;
  69128. subdivisions?: {
  69129. w: number;
  69130. h: number;
  69131. };
  69132. precision?: {
  69133. w: number;
  69134. h: number;
  69135. };
  69136. updatable?: boolean;
  69137. }, scene?: Nullable<Scene>): Mesh;
  69138. /**
  69139. * Creates a ground mesh from a height map
  69140. * * The parameter `url` sets the URL of the height map image resource.
  69141. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69142. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69143. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69144. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69145. * * 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.
  69146. * * 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).
  69147. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69149. * @param name defines the name of the mesh
  69150. * @param url defines the url to the height map
  69151. * @param options defines the options used to create the mesh
  69152. * @param scene defines the hosting scene
  69153. * @returns the ground mesh
  69154. * @see https://doc.babylonjs.com/babylon101/height_map
  69155. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69156. */
  69157. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69158. width?: number;
  69159. height?: number;
  69160. subdivisions?: number;
  69161. minHeight?: number;
  69162. maxHeight?: number;
  69163. colorFilter?: Color3;
  69164. alphaFilter?: number;
  69165. updatable?: boolean;
  69166. onReady?: (mesh: GroundMesh) => void;
  69167. }, scene?: Nullable<Scene>): GroundMesh;
  69168. /**
  69169. * Creates a polygon mesh
  69170. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69171. * * 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
  69172. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69175. * * Remember you can only change the shape positions, not their number when updating a polygon
  69176. * @param name defines the name of the mesh
  69177. * @param options defines the options used to create the mesh
  69178. * @param scene defines the hosting scene
  69179. * @param earcutInjection can be used to inject your own earcut reference
  69180. * @returns the polygon mesh
  69181. */
  69182. static CreatePolygon(name: string, options: {
  69183. shape: Vector3[];
  69184. holes?: Vector3[][];
  69185. depth?: number;
  69186. faceUV?: Vector4[];
  69187. faceColors?: Color4[];
  69188. updatable?: boolean;
  69189. sideOrientation?: number;
  69190. frontUVs?: Vector4;
  69191. backUVs?: Vector4;
  69192. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69193. /**
  69194. * Creates an extruded polygon mesh, with depth in the Y direction.
  69195. * * 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)
  69196. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69197. * @param name defines the name of the mesh
  69198. * @param options defines the options used to create the mesh
  69199. * @param scene defines the hosting scene
  69200. * @param earcutInjection can be used to inject your own earcut reference
  69201. * @returns the polygon mesh
  69202. */
  69203. static ExtrudePolygon(name: string, options: {
  69204. shape: Vector3[];
  69205. holes?: Vector3[][];
  69206. depth?: number;
  69207. faceUV?: Vector4[];
  69208. faceColors?: Color4[];
  69209. updatable?: boolean;
  69210. sideOrientation?: number;
  69211. frontUVs?: Vector4;
  69212. backUVs?: Vector4;
  69213. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69214. /**
  69215. * Creates a tube mesh.
  69216. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69217. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69218. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69219. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69220. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69221. * * 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)
  69222. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69223. * * 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
  69224. * * 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
  69225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69229. * @param name defines the name of the mesh
  69230. * @param options defines the options used to create the mesh
  69231. * @param scene defines the hosting scene
  69232. * @returns the tube mesh
  69233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69234. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69235. */
  69236. static CreateTube(name: string, options: {
  69237. path: Vector3[];
  69238. radius?: number;
  69239. tessellation?: number;
  69240. radiusFunction?: {
  69241. (i: number, distance: number): number;
  69242. };
  69243. cap?: number;
  69244. arc?: number;
  69245. updatable?: boolean;
  69246. sideOrientation?: number;
  69247. frontUVs?: Vector4;
  69248. backUVs?: Vector4;
  69249. instance?: Mesh;
  69250. invertUV?: boolean;
  69251. }, scene?: Nullable<Scene>): Mesh;
  69252. /**
  69253. * Creates a polyhedron mesh
  69254. * * 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
  69255. * * The parameter `size` (positive float, default 1) sets the polygon size
  69256. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69257. * * 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`
  69258. * * 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
  69259. * * 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)`)
  69260. * * 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
  69261. * * 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
  69262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69265. * @param name defines the name of the mesh
  69266. * @param options defines the options used to create the mesh
  69267. * @param scene defines the hosting scene
  69268. * @returns the polyhedron mesh
  69269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69270. */
  69271. static CreatePolyhedron(name: string, options: {
  69272. type?: number;
  69273. size?: number;
  69274. sizeX?: number;
  69275. sizeY?: number;
  69276. sizeZ?: number;
  69277. custom?: any;
  69278. faceUV?: Vector4[];
  69279. faceColors?: Color4[];
  69280. flat?: boolean;
  69281. updatable?: boolean;
  69282. sideOrientation?: number;
  69283. frontUVs?: Vector4;
  69284. backUVs?: Vector4;
  69285. }, scene?: Nullable<Scene>): Mesh;
  69286. /**
  69287. * Creates a decal mesh.
  69288. * 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
  69289. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69290. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69291. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69292. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69293. * @param name defines the name of the mesh
  69294. * @param sourceMesh defines the mesh where the decal must be applied
  69295. * @param options defines the options used to create the mesh
  69296. * @param scene defines the hosting scene
  69297. * @returns the decal mesh
  69298. * @see https://doc.babylonjs.com/how_to/decals
  69299. */
  69300. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69301. position?: Vector3;
  69302. normal?: Vector3;
  69303. size?: Vector3;
  69304. angle?: number;
  69305. }): Mesh;
  69306. }
  69307. }
  69308. declare module "babylonjs/Meshes/meshSimplification" {
  69309. import { Mesh } from "babylonjs/Meshes/mesh";
  69310. /**
  69311. * A simplifier interface for future simplification implementations
  69312. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69313. */
  69314. export interface ISimplifier {
  69315. /**
  69316. * Simplification of a given mesh according to the given settings.
  69317. * Since this requires computation, it is assumed that the function runs async.
  69318. * @param settings The settings of the simplification, including quality and distance
  69319. * @param successCallback A callback that will be called after the mesh was simplified.
  69320. * @param errorCallback in case of an error, this callback will be called. optional.
  69321. */
  69322. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69323. }
  69324. /**
  69325. * Expected simplification settings.
  69326. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69327. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69328. */
  69329. export interface ISimplificationSettings {
  69330. /**
  69331. * Gets or sets the expected quality
  69332. */
  69333. quality: number;
  69334. /**
  69335. * Gets or sets the distance when this optimized version should be used
  69336. */
  69337. distance: number;
  69338. /**
  69339. * Gets an already optimized mesh
  69340. */
  69341. optimizeMesh?: boolean;
  69342. }
  69343. /**
  69344. * Class used to specify simplification options
  69345. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69346. */
  69347. export class SimplificationSettings implements ISimplificationSettings {
  69348. /** expected quality */
  69349. quality: number;
  69350. /** distance when this optimized version should be used */
  69351. distance: number;
  69352. /** already optimized mesh */
  69353. optimizeMesh?: boolean | undefined;
  69354. /**
  69355. * Creates a SimplificationSettings
  69356. * @param quality expected quality
  69357. * @param distance distance when this optimized version should be used
  69358. * @param optimizeMesh already optimized mesh
  69359. */
  69360. constructor(
  69361. /** expected quality */
  69362. quality: number,
  69363. /** distance when this optimized version should be used */
  69364. distance: number,
  69365. /** already optimized mesh */
  69366. optimizeMesh?: boolean | undefined);
  69367. }
  69368. /**
  69369. * Interface used to define a simplification task
  69370. */
  69371. export interface ISimplificationTask {
  69372. /**
  69373. * Array of settings
  69374. */
  69375. settings: Array<ISimplificationSettings>;
  69376. /**
  69377. * Simplification type
  69378. */
  69379. simplificationType: SimplificationType;
  69380. /**
  69381. * Mesh to simplify
  69382. */
  69383. mesh: Mesh;
  69384. /**
  69385. * Callback called on success
  69386. */
  69387. successCallback?: () => void;
  69388. /**
  69389. * Defines if parallel processing can be used
  69390. */
  69391. parallelProcessing: boolean;
  69392. }
  69393. /**
  69394. * Queue used to order the simplification tasks
  69395. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69396. */
  69397. export class SimplificationQueue {
  69398. private _simplificationArray;
  69399. /**
  69400. * Gets a boolean indicating that the process is still running
  69401. */
  69402. running: boolean;
  69403. /**
  69404. * Creates a new queue
  69405. */
  69406. constructor();
  69407. /**
  69408. * Adds a new simplification task
  69409. * @param task defines a task to add
  69410. */
  69411. addTask(task: ISimplificationTask): void;
  69412. /**
  69413. * Execute next task
  69414. */
  69415. executeNext(): void;
  69416. /**
  69417. * Execute a simplification task
  69418. * @param task defines the task to run
  69419. */
  69420. runSimplification(task: ISimplificationTask): void;
  69421. private getSimplifier;
  69422. }
  69423. /**
  69424. * The implemented types of simplification
  69425. * At the moment only Quadratic Error Decimation is implemented
  69426. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69427. */
  69428. export enum SimplificationType {
  69429. /** Quadratic error decimation */
  69430. QUADRATIC = 0
  69431. }
  69432. /**
  69433. * An implementation of the Quadratic Error simplification algorithm.
  69434. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69435. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69436. * @author RaananW
  69437. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69438. */
  69439. export class QuadraticErrorSimplification implements ISimplifier {
  69440. private _mesh;
  69441. private triangles;
  69442. private vertices;
  69443. private references;
  69444. private _reconstructedMesh;
  69445. /** Gets or sets the number pf sync interations */
  69446. syncIterations: number;
  69447. /** Gets or sets the aggressiveness of the simplifier */
  69448. aggressiveness: number;
  69449. /** Gets or sets the number of allowed iterations for decimation */
  69450. decimationIterations: number;
  69451. /** Gets or sets the espilon to use for bounding box computation */
  69452. boundingBoxEpsilon: number;
  69453. /**
  69454. * Creates a new QuadraticErrorSimplification
  69455. * @param _mesh defines the target mesh
  69456. */
  69457. constructor(_mesh: Mesh);
  69458. /**
  69459. * Simplification of a given mesh according to the given settings.
  69460. * Since this requires computation, it is assumed that the function runs async.
  69461. * @param settings The settings of the simplification, including quality and distance
  69462. * @param successCallback A callback that will be called after the mesh was simplified.
  69463. */
  69464. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69465. private runDecimation;
  69466. private initWithMesh;
  69467. private init;
  69468. private reconstructMesh;
  69469. private initDecimatedMesh;
  69470. private isFlipped;
  69471. private updateTriangles;
  69472. private identifyBorder;
  69473. private updateMesh;
  69474. private vertexError;
  69475. private calculateError;
  69476. }
  69477. }
  69478. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69479. import { Scene } from "babylonjs/scene";
  69480. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69481. import { ISceneComponent } from "babylonjs/sceneComponent";
  69482. module "babylonjs/scene" {
  69483. interface Scene {
  69484. /** @hidden (Backing field) */
  69485. _simplificationQueue: SimplificationQueue;
  69486. /**
  69487. * Gets or sets the simplification queue attached to the scene
  69488. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69489. */
  69490. simplificationQueue: SimplificationQueue;
  69491. }
  69492. }
  69493. module "babylonjs/Meshes/mesh" {
  69494. interface Mesh {
  69495. /**
  69496. * Simplify the mesh according to the given array of settings.
  69497. * Function will return immediately and will simplify async
  69498. * @param settings a collection of simplification settings
  69499. * @param parallelProcessing should all levels calculate parallel or one after the other
  69500. * @param simplificationType the type of simplification to run
  69501. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69502. * @returns the current mesh
  69503. */
  69504. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69505. }
  69506. }
  69507. /**
  69508. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69509. * created in a scene
  69510. */
  69511. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69512. /**
  69513. * The component name helpfull to identify the component in the list of scene components.
  69514. */
  69515. readonly name: string;
  69516. /**
  69517. * The scene the component belongs to.
  69518. */
  69519. scene: Scene;
  69520. /**
  69521. * Creates a new instance of the component for the given scene
  69522. * @param scene Defines the scene to register the component in
  69523. */
  69524. constructor(scene: Scene);
  69525. /**
  69526. * Registers the component in a given scene
  69527. */
  69528. register(): void;
  69529. /**
  69530. * Rebuilds the elements related to this component in case of
  69531. * context lost for instance.
  69532. */
  69533. rebuild(): void;
  69534. /**
  69535. * Disposes the component and the associated ressources
  69536. */
  69537. dispose(): void;
  69538. private _beforeCameraUpdate;
  69539. }
  69540. }
  69541. declare module "babylonjs/Meshes/Builders/index" {
  69542. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69543. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69544. export * from "babylonjs/Meshes/Builders/discBuilder";
  69545. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69546. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69547. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69548. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69549. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69550. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69551. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69552. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69553. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69554. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69555. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69556. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69557. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69558. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69559. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69560. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69561. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69562. }
  69563. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69564. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69565. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69566. import { Matrix } from "babylonjs/Maths/math.vector";
  69567. module "babylonjs/Meshes/mesh" {
  69568. interface Mesh {
  69569. /**
  69570. * Creates a new thin instance
  69571. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69572. * @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
  69573. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69574. */
  69575. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69576. /**
  69577. * Adds the transformation (matrix) of the current mesh as a thin instance
  69578. * @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
  69579. * @returns the thin instance index number
  69580. */
  69581. thinInstanceAddSelf(refresh: boolean): number;
  69582. /**
  69583. * Registers a custom attribute to be used with thin instances
  69584. * @param kind name of the attribute
  69585. * @param stride size in floats of the attribute
  69586. */
  69587. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69588. /**
  69589. * Sets the matrix of a thin instance
  69590. * @param index index of the thin instance
  69591. * @param matrix matrix to set
  69592. * @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
  69593. */
  69594. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69595. /**
  69596. * Sets the value of a custom attribute for a thin instance
  69597. * @param kind name of the attribute
  69598. * @param index index of the thin instance
  69599. * @param value value to set
  69600. * @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
  69601. */
  69602. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69603. /**
  69604. * 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.
  69605. */
  69606. thinInstanceCount: number;
  69607. /**
  69608. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69609. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69610. * @param buffer buffer to set
  69611. * @param stride size in floats of each value of the buffer
  69612. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69613. */
  69614. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69615. /**
  69616. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69617. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69618. */
  69619. thinInstanceBufferUpdated(kind: string): void;
  69620. /**
  69621. * Refreshes the bounding info, taking into account all the thin instances defined
  69622. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69623. */
  69624. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69625. /** @hidden */
  69626. _thinInstanceInitializeUserStorage(): void;
  69627. /** @hidden */
  69628. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69629. /** @hidden */
  69630. _userThinInstanceBuffersStorage: {
  69631. data: {
  69632. [key: string]: Float32Array;
  69633. };
  69634. sizes: {
  69635. [key: string]: number;
  69636. };
  69637. vertexBuffers: {
  69638. [key: string]: Nullable<VertexBuffer>;
  69639. };
  69640. strides: {
  69641. [key: string]: number;
  69642. };
  69643. };
  69644. }
  69645. }
  69646. }
  69647. declare module "babylonjs/Meshes/index" {
  69648. export * from "babylonjs/Meshes/abstractMesh";
  69649. export * from "babylonjs/Meshes/buffer";
  69650. export * from "babylonjs/Meshes/Compression/index";
  69651. export * from "babylonjs/Meshes/csg";
  69652. export * from "babylonjs/Meshes/geometry";
  69653. export * from "babylonjs/Meshes/groundMesh";
  69654. export * from "babylonjs/Meshes/trailMesh";
  69655. export * from "babylonjs/Meshes/instancedMesh";
  69656. export * from "babylonjs/Meshes/linesMesh";
  69657. export * from "babylonjs/Meshes/mesh";
  69658. export * from "babylonjs/Meshes/mesh.vertexData";
  69659. export * from "babylonjs/Meshes/meshBuilder";
  69660. export * from "babylonjs/Meshes/meshSimplification";
  69661. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69662. export * from "babylonjs/Meshes/polygonMesh";
  69663. export * from "babylonjs/Meshes/subMesh";
  69664. export * from "babylonjs/Meshes/meshLODLevel";
  69665. export * from "babylonjs/Meshes/transformNode";
  69666. export * from "babylonjs/Meshes/Builders/index";
  69667. export * from "babylonjs/Meshes/dataBuffer";
  69668. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69669. import "babylonjs/Meshes/thinInstanceMesh";
  69670. export * from "babylonjs/Meshes/thinInstanceMesh";
  69671. }
  69672. declare module "babylonjs/Morph/index" {
  69673. export * from "babylonjs/Morph/morphTarget";
  69674. export * from "babylonjs/Morph/morphTargetManager";
  69675. }
  69676. declare module "babylonjs/Navigation/INavigationEngine" {
  69677. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69678. import { Vector3 } from "babylonjs/Maths/math";
  69679. import { Mesh } from "babylonjs/Meshes/mesh";
  69680. import { Scene } from "babylonjs/scene";
  69681. /**
  69682. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69683. */
  69684. export interface INavigationEnginePlugin {
  69685. /**
  69686. * plugin name
  69687. */
  69688. name: string;
  69689. /**
  69690. * Creates a navigation mesh
  69691. * @param meshes array of all the geometry used to compute the navigatio mesh
  69692. * @param parameters bunch of parameters used to filter geometry
  69693. */
  69694. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69695. /**
  69696. * Create a navigation mesh debug mesh
  69697. * @param scene is where the mesh will be added
  69698. * @returns debug display mesh
  69699. */
  69700. createDebugNavMesh(scene: Scene): Mesh;
  69701. /**
  69702. * Get a navigation mesh constrained position, closest to the parameter position
  69703. * @param position world position
  69704. * @returns the closest point to position constrained by the navigation mesh
  69705. */
  69706. getClosestPoint(position: Vector3): Vector3;
  69707. /**
  69708. * Get a navigation mesh constrained position, closest to the parameter position
  69709. * @param position world position
  69710. * @param result output the closest point to position constrained by the navigation mesh
  69711. */
  69712. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69713. /**
  69714. * Get a navigation mesh constrained position, within a particular radius
  69715. * @param position world position
  69716. * @param maxRadius the maximum distance to the constrained world position
  69717. * @returns the closest point to position constrained by the navigation mesh
  69718. */
  69719. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69720. /**
  69721. * Get a navigation mesh constrained position, within a particular radius
  69722. * @param position world position
  69723. * @param maxRadius the maximum distance to the constrained world position
  69724. * @param result output the closest point to position constrained by the navigation mesh
  69725. */
  69726. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69727. /**
  69728. * Compute the final position from a segment made of destination-position
  69729. * @param position world position
  69730. * @param destination world position
  69731. * @returns the resulting point along the navmesh
  69732. */
  69733. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69734. /**
  69735. * Compute the final position from a segment made of destination-position
  69736. * @param position world position
  69737. * @param destination world position
  69738. * @param result output the resulting point along the navmesh
  69739. */
  69740. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69741. /**
  69742. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69743. * @param start world position
  69744. * @param end world position
  69745. * @returns array containing world position composing the path
  69746. */
  69747. computePath(start: Vector3, end: Vector3): Vector3[];
  69748. /**
  69749. * If this plugin is supported
  69750. * @returns true if plugin is supported
  69751. */
  69752. isSupported(): boolean;
  69753. /**
  69754. * Create a new Crowd so you can add agents
  69755. * @param maxAgents the maximum agent count in the crowd
  69756. * @param maxAgentRadius the maximum radius an agent can have
  69757. * @param scene to attach the crowd to
  69758. * @returns the crowd you can add agents to
  69759. */
  69760. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69761. /**
  69762. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69763. * The queries will try to find a solution within those bounds
  69764. * default is (1,1,1)
  69765. * @param extent x,y,z value that define the extent around the queries point of reference
  69766. */
  69767. setDefaultQueryExtent(extent: Vector3): void;
  69768. /**
  69769. * Get the Bounding box extent specified by setDefaultQueryExtent
  69770. * @returns the box extent values
  69771. */
  69772. getDefaultQueryExtent(): Vector3;
  69773. /**
  69774. * build the navmesh from a previously saved state using getNavmeshData
  69775. * @param data the Uint8Array returned by getNavmeshData
  69776. */
  69777. buildFromNavmeshData(data: Uint8Array): void;
  69778. /**
  69779. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69780. * @returns data the Uint8Array that can be saved and reused
  69781. */
  69782. getNavmeshData(): Uint8Array;
  69783. /**
  69784. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69785. * @param result output the box extent values
  69786. */
  69787. getDefaultQueryExtentToRef(result: Vector3): void;
  69788. /**
  69789. * Release all resources
  69790. */
  69791. dispose(): void;
  69792. }
  69793. /**
  69794. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69795. */
  69796. export interface ICrowd {
  69797. /**
  69798. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69799. * You can attach anything to that node. The node position is updated in the scene update tick.
  69800. * @param pos world position that will be constrained by the navigation mesh
  69801. * @param parameters agent parameters
  69802. * @param transform hooked to the agent that will be update by the scene
  69803. * @returns agent index
  69804. */
  69805. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69806. /**
  69807. * Returns the agent position in world space
  69808. * @param index agent index returned by addAgent
  69809. * @returns world space position
  69810. */
  69811. getAgentPosition(index: number): Vector3;
  69812. /**
  69813. * Gets the agent position result in world space
  69814. * @param index agent index returned by addAgent
  69815. * @param result output world space position
  69816. */
  69817. getAgentPositionToRef(index: number, result: Vector3): void;
  69818. /**
  69819. * Gets the agent velocity in world space
  69820. * @param index agent index returned by addAgent
  69821. * @returns world space velocity
  69822. */
  69823. getAgentVelocity(index: number): Vector3;
  69824. /**
  69825. * Gets the agent velocity result in world space
  69826. * @param index agent index returned by addAgent
  69827. * @param result output world space velocity
  69828. */
  69829. getAgentVelocityToRef(index: number, result: Vector3): void;
  69830. /**
  69831. * remove a particular agent previously created
  69832. * @param index agent index returned by addAgent
  69833. */
  69834. removeAgent(index: number): void;
  69835. /**
  69836. * get the list of all agents attached to this crowd
  69837. * @returns list of agent indices
  69838. */
  69839. getAgents(): number[];
  69840. /**
  69841. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69842. * @param deltaTime in seconds
  69843. */
  69844. update(deltaTime: number): void;
  69845. /**
  69846. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69847. * @param index agent index returned by addAgent
  69848. * @param destination targeted world position
  69849. */
  69850. agentGoto(index: number, destination: Vector3): void;
  69851. /**
  69852. * Teleport the agent to a new position
  69853. * @param index agent index returned by addAgent
  69854. * @param destination targeted world position
  69855. */
  69856. agentTeleport(index: number, destination: Vector3): void;
  69857. /**
  69858. * Update agent parameters
  69859. * @param index agent index returned by addAgent
  69860. * @param parameters agent parameters
  69861. */
  69862. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69863. /**
  69864. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69865. * The queries will try to find a solution within those bounds
  69866. * default is (1,1,1)
  69867. * @param extent x,y,z value that define the extent around the queries point of reference
  69868. */
  69869. setDefaultQueryExtent(extent: Vector3): void;
  69870. /**
  69871. * Get the Bounding box extent specified by setDefaultQueryExtent
  69872. * @returns the box extent values
  69873. */
  69874. getDefaultQueryExtent(): Vector3;
  69875. /**
  69876. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69877. * @param result output the box extent values
  69878. */
  69879. getDefaultQueryExtentToRef(result: Vector3): void;
  69880. /**
  69881. * Release all resources
  69882. */
  69883. dispose(): void;
  69884. }
  69885. /**
  69886. * Configures an agent
  69887. */
  69888. export interface IAgentParameters {
  69889. /**
  69890. * Agent radius. [Limit: >= 0]
  69891. */
  69892. radius: number;
  69893. /**
  69894. * Agent height. [Limit: > 0]
  69895. */
  69896. height: number;
  69897. /**
  69898. * Maximum allowed acceleration. [Limit: >= 0]
  69899. */
  69900. maxAcceleration: number;
  69901. /**
  69902. * Maximum allowed speed. [Limit: >= 0]
  69903. */
  69904. maxSpeed: number;
  69905. /**
  69906. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69907. */
  69908. collisionQueryRange: number;
  69909. /**
  69910. * The path visibility optimization range. [Limit: > 0]
  69911. */
  69912. pathOptimizationRange: number;
  69913. /**
  69914. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69915. */
  69916. separationWeight: number;
  69917. }
  69918. /**
  69919. * Configures the navigation mesh creation
  69920. */
  69921. export interface INavMeshParameters {
  69922. /**
  69923. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69924. */
  69925. cs: number;
  69926. /**
  69927. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69928. */
  69929. ch: number;
  69930. /**
  69931. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69932. */
  69933. walkableSlopeAngle: number;
  69934. /**
  69935. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69936. * be considered walkable. [Limit: >= 3] [Units: vx]
  69937. */
  69938. walkableHeight: number;
  69939. /**
  69940. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69941. */
  69942. walkableClimb: number;
  69943. /**
  69944. * The distance to erode/shrink the walkable area of the heightfield away from
  69945. * obstructions. [Limit: >=0] [Units: vx]
  69946. */
  69947. walkableRadius: number;
  69948. /**
  69949. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69950. */
  69951. maxEdgeLen: number;
  69952. /**
  69953. * The maximum distance a simplfied contour's border edges should deviate
  69954. * the original raw contour. [Limit: >=0] [Units: vx]
  69955. */
  69956. maxSimplificationError: number;
  69957. /**
  69958. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69959. */
  69960. minRegionArea: number;
  69961. /**
  69962. * Any regions with a span count smaller than this value will, if possible,
  69963. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69964. */
  69965. mergeRegionArea: number;
  69966. /**
  69967. * The maximum number of vertices allowed for polygons generated during the
  69968. * contour to polygon conversion process. [Limit: >= 3]
  69969. */
  69970. maxVertsPerPoly: number;
  69971. /**
  69972. * Sets the sampling distance to use when generating the detail mesh.
  69973. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69974. */
  69975. detailSampleDist: number;
  69976. /**
  69977. * The maximum distance the detail mesh surface should deviate from heightfield
  69978. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69979. */
  69980. detailSampleMaxError: number;
  69981. }
  69982. }
  69983. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69984. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69985. import { Mesh } from "babylonjs/Meshes/mesh";
  69986. import { Scene } from "babylonjs/scene";
  69987. import { Vector3 } from "babylonjs/Maths/math";
  69988. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69989. /**
  69990. * RecastJS navigation plugin
  69991. */
  69992. export class RecastJSPlugin implements INavigationEnginePlugin {
  69993. /**
  69994. * Reference to the Recast library
  69995. */
  69996. bjsRECAST: any;
  69997. /**
  69998. * plugin name
  69999. */
  70000. name: string;
  70001. /**
  70002. * the first navmesh created. We might extend this to support multiple navmeshes
  70003. */
  70004. navMesh: any;
  70005. /**
  70006. * Initializes the recastJS plugin
  70007. * @param recastInjection can be used to inject your own recast reference
  70008. */
  70009. constructor(recastInjection?: any);
  70010. /**
  70011. * Creates a navigation mesh
  70012. * @param meshes array of all the geometry used to compute the navigatio mesh
  70013. * @param parameters bunch of parameters used to filter geometry
  70014. */
  70015. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70016. /**
  70017. * Create a navigation mesh debug mesh
  70018. * @param scene is where the mesh will be added
  70019. * @returns debug display mesh
  70020. */
  70021. createDebugNavMesh(scene: Scene): Mesh;
  70022. /**
  70023. * Get a navigation mesh constrained position, closest to the parameter position
  70024. * @param position world position
  70025. * @returns the closest point to position constrained by the navigation mesh
  70026. */
  70027. getClosestPoint(position: Vector3): Vector3;
  70028. /**
  70029. * Get a navigation mesh constrained position, closest to the parameter position
  70030. * @param position world position
  70031. * @param result output the closest point to position constrained by the navigation mesh
  70032. */
  70033. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70034. /**
  70035. * Get a navigation mesh constrained position, within a particular radius
  70036. * @param position world position
  70037. * @param maxRadius the maximum distance to the constrained world position
  70038. * @returns the closest point to position constrained by the navigation mesh
  70039. */
  70040. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70041. /**
  70042. * Get a navigation mesh constrained position, within a particular radius
  70043. * @param position world position
  70044. * @param maxRadius the maximum distance to the constrained world position
  70045. * @param result output the closest point to position constrained by the navigation mesh
  70046. */
  70047. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70048. /**
  70049. * Compute the final position from a segment made of destination-position
  70050. * @param position world position
  70051. * @param destination world position
  70052. * @returns the resulting point along the navmesh
  70053. */
  70054. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70055. /**
  70056. * Compute the final position from a segment made of destination-position
  70057. * @param position world position
  70058. * @param destination world position
  70059. * @param result output the resulting point along the navmesh
  70060. */
  70061. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70062. /**
  70063. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70064. * @param start world position
  70065. * @param end world position
  70066. * @returns array containing world position composing the path
  70067. */
  70068. computePath(start: Vector3, end: Vector3): Vector3[];
  70069. /**
  70070. * Create a new Crowd so you can add agents
  70071. * @param maxAgents the maximum agent count in the crowd
  70072. * @param maxAgentRadius the maximum radius an agent can have
  70073. * @param scene to attach the crowd to
  70074. * @returns the crowd you can add agents to
  70075. */
  70076. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70077. /**
  70078. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70079. * The queries will try to find a solution within those bounds
  70080. * default is (1,1,1)
  70081. * @param extent x,y,z value that define the extent around the queries point of reference
  70082. */
  70083. setDefaultQueryExtent(extent: Vector3): void;
  70084. /**
  70085. * Get the Bounding box extent specified by setDefaultQueryExtent
  70086. * @returns the box extent values
  70087. */
  70088. getDefaultQueryExtent(): Vector3;
  70089. /**
  70090. * build the navmesh from a previously saved state using getNavmeshData
  70091. * @param data the Uint8Array returned by getNavmeshData
  70092. */
  70093. buildFromNavmeshData(data: Uint8Array): void;
  70094. /**
  70095. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70096. * @returns data the Uint8Array that can be saved and reused
  70097. */
  70098. getNavmeshData(): Uint8Array;
  70099. /**
  70100. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70101. * @param result output the box extent values
  70102. */
  70103. getDefaultQueryExtentToRef(result: Vector3): void;
  70104. /**
  70105. * Disposes
  70106. */
  70107. dispose(): void;
  70108. /**
  70109. * If this plugin is supported
  70110. * @returns true if plugin is supported
  70111. */
  70112. isSupported(): boolean;
  70113. }
  70114. /**
  70115. * Recast detour crowd implementation
  70116. */
  70117. export class RecastJSCrowd implements ICrowd {
  70118. /**
  70119. * Recast/detour plugin
  70120. */
  70121. bjsRECASTPlugin: RecastJSPlugin;
  70122. /**
  70123. * Link to the detour crowd
  70124. */
  70125. recastCrowd: any;
  70126. /**
  70127. * One transform per agent
  70128. */
  70129. transforms: TransformNode[];
  70130. /**
  70131. * All agents created
  70132. */
  70133. agents: number[];
  70134. /**
  70135. * Link to the scene is kept to unregister the crowd from the scene
  70136. */
  70137. private _scene;
  70138. /**
  70139. * Observer for crowd updates
  70140. */
  70141. private _onBeforeAnimationsObserver;
  70142. /**
  70143. * Constructor
  70144. * @param plugin recastJS plugin
  70145. * @param maxAgents the maximum agent count in the crowd
  70146. * @param maxAgentRadius the maximum radius an agent can have
  70147. * @param scene to attach the crowd to
  70148. * @returns the crowd you can add agents to
  70149. */
  70150. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70151. /**
  70152. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70153. * You can attach anything to that node. The node position is updated in the scene update tick.
  70154. * @param pos world position that will be constrained by the navigation mesh
  70155. * @param parameters agent parameters
  70156. * @param transform hooked to the agent that will be update by the scene
  70157. * @returns agent index
  70158. */
  70159. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70160. /**
  70161. * Returns the agent position in world space
  70162. * @param index agent index returned by addAgent
  70163. * @returns world space position
  70164. */
  70165. getAgentPosition(index: number): Vector3;
  70166. /**
  70167. * Returns the agent position result in world space
  70168. * @param index agent index returned by addAgent
  70169. * @param result output world space position
  70170. */
  70171. getAgentPositionToRef(index: number, result: Vector3): void;
  70172. /**
  70173. * Returns the agent velocity in world space
  70174. * @param index agent index returned by addAgent
  70175. * @returns world space velocity
  70176. */
  70177. getAgentVelocity(index: number): Vector3;
  70178. /**
  70179. * Returns the agent velocity result in world space
  70180. * @param index agent index returned by addAgent
  70181. * @param result output world space velocity
  70182. */
  70183. getAgentVelocityToRef(index: number, result: Vector3): void;
  70184. /**
  70185. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70186. * @param index agent index returned by addAgent
  70187. * @param destination targeted world position
  70188. */
  70189. agentGoto(index: number, destination: Vector3): void;
  70190. /**
  70191. * Teleport the agent to a new position
  70192. * @param index agent index returned by addAgent
  70193. * @param destination targeted world position
  70194. */
  70195. agentTeleport(index: number, destination: Vector3): void;
  70196. /**
  70197. * Update agent parameters
  70198. * @param index agent index returned by addAgent
  70199. * @param parameters agent parameters
  70200. */
  70201. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70202. /**
  70203. * remove a particular agent previously created
  70204. * @param index agent index returned by addAgent
  70205. */
  70206. removeAgent(index: number): void;
  70207. /**
  70208. * get the list of all agents attached to this crowd
  70209. * @returns list of agent indices
  70210. */
  70211. getAgents(): number[];
  70212. /**
  70213. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70214. * @param deltaTime in seconds
  70215. */
  70216. update(deltaTime: number): void;
  70217. /**
  70218. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70219. * The queries will try to find a solution within those bounds
  70220. * default is (1,1,1)
  70221. * @param extent x,y,z value that define the extent around the queries point of reference
  70222. */
  70223. setDefaultQueryExtent(extent: Vector3): void;
  70224. /**
  70225. * Get the Bounding box extent specified by setDefaultQueryExtent
  70226. * @returns the box extent values
  70227. */
  70228. getDefaultQueryExtent(): Vector3;
  70229. /**
  70230. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70231. * @param result output the box extent values
  70232. */
  70233. getDefaultQueryExtentToRef(result: Vector3): void;
  70234. /**
  70235. * Release all resources
  70236. */
  70237. dispose(): void;
  70238. }
  70239. }
  70240. declare module "babylonjs/Navigation/Plugins/index" {
  70241. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70242. }
  70243. declare module "babylonjs/Navigation/index" {
  70244. export * from "babylonjs/Navigation/INavigationEngine";
  70245. export * from "babylonjs/Navigation/Plugins/index";
  70246. }
  70247. declare module "babylonjs/Offline/database" {
  70248. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70249. /**
  70250. * Class used to enable access to IndexedDB
  70251. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70252. */
  70253. export class Database implements IOfflineProvider {
  70254. private _callbackManifestChecked;
  70255. private _currentSceneUrl;
  70256. private _db;
  70257. private _enableSceneOffline;
  70258. private _enableTexturesOffline;
  70259. private _manifestVersionFound;
  70260. private _mustUpdateRessources;
  70261. private _hasReachedQuota;
  70262. private _isSupported;
  70263. private _idbFactory;
  70264. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70265. private static IsUASupportingBlobStorage;
  70266. /**
  70267. * Gets a boolean indicating if Database storate is enabled (off by default)
  70268. */
  70269. static IDBStorageEnabled: boolean;
  70270. /**
  70271. * Gets a boolean indicating if scene must be saved in the database
  70272. */
  70273. get enableSceneOffline(): boolean;
  70274. /**
  70275. * Gets a boolean indicating if textures must be saved in the database
  70276. */
  70277. get enableTexturesOffline(): boolean;
  70278. /**
  70279. * Creates a new Database
  70280. * @param urlToScene defines the url to load the scene
  70281. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70282. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70283. */
  70284. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70285. private static _ParseURL;
  70286. private static _ReturnFullUrlLocation;
  70287. private _checkManifestFile;
  70288. /**
  70289. * Open the database and make it available
  70290. * @param successCallback defines the callback to call on success
  70291. * @param errorCallback defines the callback to call on error
  70292. */
  70293. open(successCallback: () => void, errorCallback: () => void): void;
  70294. /**
  70295. * Loads an image from the database
  70296. * @param url defines the url to load from
  70297. * @param image defines the target DOM image
  70298. */
  70299. loadImage(url: string, image: HTMLImageElement): void;
  70300. private _loadImageFromDBAsync;
  70301. private _saveImageIntoDBAsync;
  70302. private _checkVersionFromDB;
  70303. private _loadVersionFromDBAsync;
  70304. private _saveVersionIntoDBAsync;
  70305. /**
  70306. * Loads a file from database
  70307. * @param url defines the URL to load from
  70308. * @param sceneLoaded defines a callback to call on success
  70309. * @param progressCallBack defines a callback to call when progress changed
  70310. * @param errorCallback defines a callback to call on error
  70311. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70312. */
  70313. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70314. private _loadFileAsync;
  70315. private _saveFileAsync;
  70316. /**
  70317. * Validates if xhr data is correct
  70318. * @param xhr defines the request to validate
  70319. * @param dataType defines the expected data type
  70320. * @returns true if data is correct
  70321. */
  70322. private static _ValidateXHRData;
  70323. }
  70324. }
  70325. declare module "babylonjs/Offline/index" {
  70326. export * from "babylonjs/Offline/database";
  70327. export * from "babylonjs/Offline/IOfflineProvider";
  70328. }
  70329. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70330. /** @hidden */
  70331. export var gpuUpdateParticlesPixelShader: {
  70332. name: string;
  70333. shader: string;
  70334. };
  70335. }
  70336. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70337. /** @hidden */
  70338. export var gpuUpdateParticlesVertexShader: {
  70339. name: string;
  70340. shader: string;
  70341. };
  70342. }
  70343. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70344. /** @hidden */
  70345. export var clipPlaneFragmentDeclaration2: {
  70346. name: string;
  70347. shader: string;
  70348. };
  70349. }
  70350. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70351. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70352. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70353. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70354. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70355. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70356. /** @hidden */
  70357. export var gpuRenderParticlesPixelShader: {
  70358. name: string;
  70359. shader: string;
  70360. };
  70361. }
  70362. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70363. /** @hidden */
  70364. export var clipPlaneVertexDeclaration2: {
  70365. name: string;
  70366. shader: string;
  70367. };
  70368. }
  70369. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70371. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70372. /** @hidden */
  70373. export var gpuRenderParticlesVertexShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module "babylonjs/Particles/gpuParticleSystem" {
  70379. import { Nullable } from "babylonjs/types";
  70380. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70381. import { Observable } from "babylonjs/Misc/observable";
  70382. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70384. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70385. import { Scene, IDisposable } from "babylonjs/scene";
  70386. import { Effect } from "babylonjs/Materials/effect";
  70387. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70388. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70389. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70390. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70391. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70392. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70393. /**
  70394. * This represents a GPU particle system in Babylon
  70395. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70396. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70397. */
  70398. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70399. /**
  70400. * The layer mask we are rendering the particles through.
  70401. */
  70402. layerMask: number;
  70403. private _capacity;
  70404. private _activeCount;
  70405. private _currentActiveCount;
  70406. private _accumulatedCount;
  70407. private _renderEffect;
  70408. private _updateEffect;
  70409. private _buffer0;
  70410. private _buffer1;
  70411. private _spriteBuffer;
  70412. private _updateVAO;
  70413. private _renderVAO;
  70414. private _targetIndex;
  70415. private _sourceBuffer;
  70416. private _targetBuffer;
  70417. private _engine;
  70418. private _currentRenderId;
  70419. private _started;
  70420. private _stopped;
  70421. private _timeDelta;
  70422. private _randomTexture;
  70423. private _randomTexture2;
  70424. private _attributesStrideSize;
  70425. private _updateEffectOptions;
  70426. private _randomTextureSize;
  70427. private _actualFrame;
  70428. private _customEffect;
  70429. private readonly _rawTextureWidth;
  70430. /**
  70431. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70432. */
  70433. static get IsSupported(): boolean;
  70434. /**
  70435. * An event triggered when the system is disposed.
  70436. */
  70437. onDisposeObservable: Observable<IParticleSystem>;
  70438. /**
  70439. * Gets the maximum number of particles active at the same time.
  70440. * @returns The max number of active particles.
  70441. */
  70442. getCapacity(): number;
  70443. /**
  70444. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70445. * to override the particles.
  70446. */
  70447. forceDepthWrite: boolean;
  70448. /**
  70449. * Gets or set the number of active particles
  70450. */
  70451. get activeParticleCount(): number;
  70452. set activeParticleCount(value: number);
  70453. private _preWarmDone;
  70454. /**
  70455. * Specifies if the particles are updated in emitter local space or world space.
  70456. */
  70457. isLocal: boolean;
  70458. /**
  70459. * Is this system ready to be used/rendered
  70460. * @return true if the system is ready
  70461. */
  70462. isReady(): boolean;
  70463. /**
  70464. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70465. * @returns True if it has been started, otherwise false.
  70466. */
  70467. isStarted(): boolean;
  70468. /**
  70469. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70470. * @returns True if it has been stopped, otherwise false.
  70471. */
  70472. isStopped(): boolean;
  70473. /**
  70474. * Gets a boolean indicating that the system is stopping
  70475. * @returns true if the system is currently stopping
  70476. */
  70477. isStopping(): boolean;
  70478. /**
  70479. * Gets the number of particles active at the same time.
  70480. * @returns The number of active particles.
  70481. */
  70482. getActiveCount(): number;
  70483. /**
  70484. * Starts the particle system and begins to emit
  70485. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70486. */
  70487. start(delay?: number): void;
  70488. /**
  70489. * Stops the particle system.
  70490. */
  70491. stop(): void;
  70492. /**
  70493. * Remove all active particles
  70494. */
  70495. reset(): void;
  70496. /**
  70497. * Returns the string "GPUParticleSystem"
  70498. * @returns a string containing the class name
  70499. */
  70500. getClassName(): string;
  70501. /**
  70502. * Gets the custom effect used to render the particles
  70503. * @param blendMode Blend mode for which the effect should be retrieved
  70504. * @returns The effect
  70505. */
  70506. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70507. /**
  70508. * Sets the custom effect used to render the particles
  70509. * @param effect The effect to set
  70510. * @param blendMode Blend mode for which the effect should be set
  70511. */
  70512. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70513. /** @hidden */
  70514. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70515. /**
  70516. * Observable that will be called just before the particles are drawn
  70517. */
  70518. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70519. /**
  70520. * Gets the name of the particle vertex shader
  70521. */
  70522. get vertexShaderName(): string;
  70523. private _colorGradientsTexture;
  70524. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70525. /**
  70526. * Adds a new color gradient
  70527. * @param gradient defines the gradient to use (between 0 and 1)
  70528. * @param color1 defines the color to affect to the specified gradient
  70529. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70530. * @returns the current particle system
  70531. */
  70532. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70533. private _refreshColorGradient;
  70534. /** Force the system to rebuild all gradients that need to be resync */
  70535. forceRefreshGradients(): void;
  70536. /**
  70537. * Remove a specific color gradient
  70538. * @param gradient defines the gradient to remove
  70539. * @returns the current particle system
  70540. */
  70541. removeColorGradient(gradient: number): GPUParticleSystem;
  70542. private _angularSpeedGradientsTexture;
  70543. private _sizeGradientsTexture;
  70544. private _velocityGradientsTexture;
  70545. private _limitVelocityGradientsTexture;
  70546. private _dragGradientsTexture;
  70547. private _addFactorGradient;
  70548. /**
  70549. * Adds a new size gradient
  70550. * @param gradient defines the gradient to use (between 0 and 1)
  70551. * @param factor defines the size factor to affect to the specified gradient
  70552. * @returns the current particle system
  70553. */
  70554. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70555. /**
  70556. * Remove a specific size gradient
  70557. * @param gradient defines the gradient to remove
  70558. * @returns the current particle system
  70559. */
  70560. removeSizeGradient(gradient: number): GPUParticleSystem;
  70561. private _refreshFactorGradient;
  70562. /**
  70563. * Adds a new angular speed gradient
  70564. * @param gradient defines the gradient to use (between 0 and 1)
  70565. * @param factor defines the angular speed to affect to the specified gradient
  70566. * @returns the current particle system
  70567. */
  70568. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70569. /**
  70570. * Remove a specific angular speed gradient
  70571. * @param gradient defines the gradient to remove
  70572. * @returns the current particle system
  70573. */
  70574. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70575. /**
  70576. * Adds a new velocity gradient
  70577. * @param gradient defines the gradient to use (between 0 and 1)
  70578. * @param factor defines the velocity to affect to the specified gradient
  70579. * @returns the current particle system
  70580. */
  70581. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70582. /**
  70583. * Remove a specific velocity gradient
  70584. * @param gradient defines the gradient to remove
  70585. * @returns the current particle system
  70586. */
  70587. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70588. /**
  70589. * Adds a new limit velocity gradient
  70590. * @param gradient defines the gradient to use (between 0 and 1)
  70591. * @param factor defines the limit velocity value to affect to the specified gradient
  70592. * @returns the current particle system
  70593. */
  70594. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70595. /**
  70596. * Remove a specific limit velocity gradient
  70597. * @param gradient defines the gradient to remove
  70598. * @returns the current particle system
  70599. */
  70600. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70601. /**
  70602. * Adds a new drag gradient
  70603. * @param gradient defines the gradient to use (between 0 and 1)
  70604. * @param factor defines the drag value to affect to the specified gradient
  70605. * @returns the current particle system
  70606. */
  70607. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70608. /**
  70609. * Remove a specific drag gradient
  70610. * @param gradient defines the gradient to remove
  70611. * @returns the current particle system
  70612. */
  70613. removeDragGradient(gradient: number): GPUParticleSystem;
  70614. /**
  70615. * Not supported by GPUParticleSystem
  70616. * @param gradient defines the gradient to use (between 0 and 1)
  70617. * @param factor defines the emit rate value to affect to the specified gradient
  70618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70619. * @returns the current particle system
  70620. */
  70621. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70622. /**
  70623. * Not supported by GPUParticleSystem
  70624. * @param gradient defines the gradient to remove
  70625. * @returns the current particle system
  70626. */
  70627. removeEmitRateGradient(gradient: number): IParticleSystem;
  70628. /**
  70629. * Not supported by GPUParticleSystem
  70630. * @param gradient defines the gradient to use (between 0 and 1)
  70631. * @param factor defines the start size value to affect to the specified gradient
  70632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70633. * @returns the current particle system
  70634. */
  70635. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70636. /**
  70637. * Not supported by GPUParticleSystem
  70638. * @param gradient defines the gradient to remove
  70639. * @returns the current particle system
  70640. */
  70641. removeStartSizeGradient(gradient: number): IParticleSystem;
  70642. /**
  70643. * Not supported by GPUParticleSystem
  70644. * @param gradient defines the gradient to use (between 0 and 1)
  70645. * @param min defines the color remap minimal range
  70646. * @param max defines the color remap maximal range
  70647. * @returns the current particle system
  70648. */
  70649. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70650. /**
  70651. * Not supported by GPUParticleSystem
  70652. * @param gradient defines the gradient to remove
  70653. * @returns the current particle system
  70654. */
  70655. removeColorRemapGradient(): IParticleSystem;
  70656. /**
  70657. * Not supported by GPUParticleSystem
  70658. * @param gradient defines the gradient to use (between 0 and 1)
  70659. * @param min defines the alpha remap minimal range
  70660. * @param max defines the alpha remap maximal range
  70661. * @returns the current particle system
  70662. */
  70663. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70664. /**
  70665. * Not supported by GPUParticleSystem
  70666. * @param gradient defines the gradient to remove
  70667. * @returns the current particle system
  70668. */
  70669. removeAlphaRemapGradient(): IParticleSystem;
  70670. /**
  70671. * Not supported by GPUParticleSystem
  70672. * @param gradient defines the gradient to use (between 0 and 1)
  70673. * @param color defines the color to affect to the specified gradient
  70674. * @returns the current particle system
  70675. */
  70676. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70677. /**
  70678. * Not supported by GPUParticleSystem
  70679. * @param gradient defines the gradient to remove
  70680. * @returns the current particle system
  70681. */
  70682. removeRampGradient(): IParticleSystem;
  70683. /**
  70684. * Not supported by GPUParticleSystem
  70685. * @returns the list of ramp gradients
  70686. */
  70687. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70688. /**
  70689. * Not supported by GPUParticleSystem
  70690. * Gets or sets a boolean indicating that ramp gradients must be used
  70691. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70692. */
  70693. get useRampGradients(): boolean;
  70694. set useRampGradients(value: boolean);
  70695. /**
  70696. * Not supported by GPUParticleSystem
  70697. * @param gradient defines the gradient to use (between 0 and 1)
  70698. * @param factor defines the life time factor to affect to the specified gradient
  70699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70700. * @returns the current particle system
  70701. */
  70702. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70703. /**
  70704. * Not supported by GPUParticleSystem
  70705. * @param gradient defines the gradient to remove
  70706. * @returns the current particle system
  70707. */
  70708. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70709. /**
  70710. * Instantiates a GPU particle system.
  70711. * 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.
  70712. * @param name The name of the particle system
  70713. * @param options The options used to create the system
  70714. * @param scene The scene the particle system belongs to
  70715. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70716. * @param customEffect a custom effect used to change the way particles are rendered by default
  70717. */
  70718. constructor(name: string, options: Partial<{
  70719. capacity: number;
  70720. randomTextureSize: number;
  70721. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70722. protected _reset(): void;
  70723. private _createUpdateVAO;
  70724. private _createRenderVAO;
  70725. private _initialize;
  70726. /** @hidden */
  70727. _recreateUpdateEffect(): void;
  70728. private _getEffect;
  70729. /**
  70730. * Fill the defines array according to the current settings of the particle system
  70731. * @param defines Array to be updated
  70732. * @param blendMode blend mode to take into account when updating the array
  70733. */
  70734. fillDefines(defines: Array<string>, blendMode?: number): void;
  70735. /**
  70736. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70737. * @param uniforms Uniforms array to fill
  70738. * @param attributes Attributes array to fill
  70739. * @param samplers Samplers array to fill
  70740. */
  70741. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70742. /** @hidden */
  70743. _recreateRenderEffect(): Effect;
  70744. /**
  70745. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70746. * @param preWarm defines if we are in the pre-warmimg phase
  70747. */
  70748. animate(preWarm?: boolean): void;
  70749. private _createFactorGradientTexture;
  70750. private _createSizeGradientTexture;
  70751. private _createAngularSpeedGradientTexture;
  70752. private _createVelocityGradientTexture;
  70753. private _createLimitVelocityGradientTexture;
  70754. private _createDragGradientTexture;
  70755. private _createColorGradientTexture;
  70756. /**
  70757. * Renders the particle system in its current state
  70758. * @param preWarm defines if the system should only update the particles but not render them
  70759. * @returns the current number of particles
  70760. */
  70761. render(preWarm?: boolean): number;
  70762. /**
  70763. * Rebuilds the particle system
  70764. */
  70765. rebuild(): void;
  70766. private _releaseBuffers;
  70767. private _releaseVAOs;
  70768. /**
  70769. * Disposes the particle system and free the associated resources
  70770. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70771. */
  70772. dispose(disposeTexture?: boolean): void;
  70773. /**
  70774. * Clones the particle system.
  70775. * @param name The name of the cloned object
  70776. * @param newEmitter The new emitter to use
  70777. * @returns the cloned particle system
  70778. */
  70779. clone(name: string, newEmitter: any): GPUParticleSystem;
  70780. /**
  70781. * Serializes the particle system to a JSON object
  70782. * @param serializeTexture defines if the texture must be serialized as well
  70783. * @returns the JSON object
  70784. */
  70785. serialize(serializeTexture?: boolean): any;
  70786. /**
  70787. * Parses a JSON object to create a GPU particle system.
  70788. * @param parsedParticleSystem The JSON object to parse
  70789. * @param scene The scene to create the particle system in
  70790. * @param rootUrl The root url to use to load external dependencies like texture
  70791. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70792. * @returns the parsed GPU particle system
  70793. */
  70794. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70795. }
  70796. }
  70797. declare module "babylonjs/Particles/particleSystemSet" {
  70798. import { Nullable } from "babylonjs/types";
  70799. import { Color3 } from "babylonjs/Maths/math.color";
  70800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70802. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70803. import { Scene, IDisposable } from "babylonjs/scene";
  70804. /**
  70805. * Represents a set of particle systems working together to create a specific effect
  70806. */
  70807. export class ParticleSystemSet implements IDisposable {
  70808. /**
  70809. * Gets or sets base Assets URL
  70810. */
  70811. static BaseAssetsUrl: string;
  70812. private _emitterCreationOptions;
  70813. private _emitterNode;
  70814. /**
  70815. * Gets the particle system list
  70816. */
  70817. systems: IParticleSystem[];
  70818. /**
  70819. * Gets the emitter node used with this set
  70820. */
  70821. get emitterNode(): Nullable<TransformNode>;
  70822. /**
  70823. * Creates a new emitter mesh as a sphere
  70824. * @param options defines the options used to create the sphere
  70825. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70826. * @param scene defines the hosting scene
  70827. */
  70828. setEmitterAsSphere(options: {
  70829. diameter: number;
  70830. segments: number;
  70831. color: Color3;
  70832. }, renderingGroupId: number, scene: Scene): void;
  70833. /**
  70834. * Starts all particle systems of the set
  70835. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70836. */
  70837. start(emitter?: AbstractMesh): void;
  70838. /**
  70839. * Release all associated resources
  70840. */
  70841. dispose(): void;
  70842. /**
  70843. * Serialize the set into a JSON compatible object
  70844. * @param serializeTexture defines if the texture must be serialized as well
  70845. * @returns a JSON compatible representation of the set
  70846. */
  70847. serialize(serializeTexture?: boolean): any;
  70848. /**
  70849. * Parse a new ParticleSystemSet from a serialized source
  70850. * @param data defines a JSON compatible representation of the set
  70851. * @param scene defines the hosting scene
  70852. * @param gpu defines if we want GPU particles or CPU particles
  70853. * @returns a new ParticleSystemSet
  70854. */
  70855. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70856. }
  70857. }
  70858. declare module "babylonjs/Particles/particleHelper" {
  70859. import { Nullable } from "babylonjs/types";
  70860. import { Scene } from "babylonjs/scene";
  70861. import { Vector3 } from "babylonjs/Maths/math.vector";
  70862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70863. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70864. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70865. /**
  70866. * This class is made for on one-liner static method to help creating particle system set.
  70867. */
  70868. export class ParticleHelper {
  70869. /**
  70870. * Gets or sets base Assets URL
  70871. */
  70872. static BaseAssetsUrl: string;
  70873. /** Define the Url to load snippets */
  70874. static SnippetUrl: string;
  70875. /**
  70876. * Create a default particle system that you can tweak
  70877. * @param emitter defines the emitter to use
  70878. * @param capacity defines the system capacity (default is 500 particles)
  70879. * @param scene defines the hosting scene
  70880. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70881. * @returns the new Particle system
  70882. */
  70883. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70884. /**
  70885. * This is the main static method (one-liner) of this helper to create different particle systems
  70886. * @param type This string represents the type to the particle system to create
  70887. * @param scene The scene where the particle system should live
  70888. * @param gpu If the system will use gpu
  70889. * @returns the ParticleSystemSet created
  70890. */
  70891. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70892. /**
  70893. * Static function used to export a particle system to a ParticleSystemSet variable.
  70894. * Please note that the emitter shape is not exported
  70895. * @param systems defines the particle systems to export
  70896. * @returns the created particle system set
  70897. */
  70898. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70899. /**
  70900. * Creates a particle system from a snippet saved in a remote file
  70901. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70902. * @param url defines the url to load from
  70903. * @param scene defines the hosting scene
  70904. * @param gpu If the system will use gpu
  70905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70906. * @returns a promise that will resolve to the new particle system
  70907. */
  70908. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70909. /**
  70910. * Creates a particle system from a snippet saved by the particle system editor
  70911. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  70912. * @param scene defines the hosting scene
  70913. * @param gpu If the system will use gpu
  70914. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70915. * @returns a promise that will resolve to the new particle system
  70916. */
  70917. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70918. }
  70919. }
  70920. declare module "babylonjs/Particles/particleSystemComponent" {
  70921. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70922. import { Effect } from "babylonjs/Materials/effect";
  70923. import "babylonjs/Shaders/particles.vertex";
  70924. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70925. module "babylonjs/Engines/engine" {
  70926. interface Engine {
  70927. /**
  70928. * Create an effect to use with particle systems.
  70929. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70930. * the particle system for which you want to create a custom effect in the last parameter
  70931. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70932. * @param uniformsNames defines a list of attribute names
  70933. * @param samplers defines an array of string used to represent textures
  70934. * @param defines defines the string containing the defines to use to compile the shaders
  70935. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70936. * @param onCompiled defines a function to call when the effect creation is successful
  70937. * @param onError defines a function to call when the effect creation has failed
  70938. * @param particleSystem the particle system you want to create the effect for
  70939. * @returns the new Effect
  70940. */
  70941. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70942. }
  70943. }
  70944. module "babylonjs/Meshes/mesh" {
  70945. interface Mesh {
  70946. /**
  70947. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70948. * @returns an array of IParticleSystem
  70949. */
  70950. getEmittedParticleSystems(): IParticleSystem[];
  70951. /**
  70952. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70953. * @returns an array of IParticleSystem
  70954. */
  70955. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70956. }
  70957. }
  70958. }
  70959. declare module "babylonjs/Particles/pointsCloudSystem" {
  70960. import { Color4 } from "babylonjs/Maths/math";
  70961. import { Mesh } from "babylonjs/Meshes/mesh";
  70962. import { Scene, IDisposable } from "babylonjs/scene";
  70963. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70964. /** Defines the 4 color options */
  70965. export enum PointColor {
  70966. /** color value */
  70967. Color = 2,
  70968. /** uv value */
  70969. UV = 1,
  70970. /** random value */
  70971. Random = 0,
  70972. /** stated value */
  70973. Stated = 3
  70974. }
  70975. /**
  70976. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70977. * 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.
  70978. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70979. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70980. *
  70981. * Full documentation here : TO BE ENTERED
  70982. */
  70983. export class PointsCloudSystem implements IDisposable {
  70984. /**
  70985. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70986. * Example : var p = SPS.particles[i];
  70987. */
  70988. particles: CloudPoint[];
  70989. /**
  70990. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70991. */
  70992. nbParticles: number;
  70993. /**
  70994. * This a counter for your own usage. It's not set by any SPS functions.
  70995. */
  70996. counter: number;
  70997. /**
  70998. * The PCS name. This name is also given to the underlying mesh.
  70999. */
  71000. name: string;
  71001. /**
  71002. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71003. */
  71004. mesh: Mesh;
  71005. /**
  71006. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71007. * Please read :
  71008. */
  71009. vars: any;
  71010. /**
  71011. * @hidden
  71012. */
  71013. _size: number;
  71014. private _scene;
  71015. private _promises;
  71016. private _positions;
  71017. private _indices;
  71018. private _normals;
  71019. private _colors;
  71020. private _uvs;
  71021. private _indices32;
  71022. private _positions32;
  71023. private _colors32;
  71024. private _uvs32;
  71025. private _updatable;
  71026. private _isVisibilityBoxLocked;
  71027. private _alwaysVisible;
  71028. private _groups;
  71029. private _groupCounter;
  71030. private _computeParticleColor;
  71031. private _computeParticleTexture;
  71032. private _computeParticleRotation;
  71033. private _computeBoundingBox;
  71034. private _isReady;
  71035. /**
  71036. * Creates a PCS (Points Cloud System) object
  71037. * @param name (String) is the PCS name, this will be the underlying mesh name
  71038. * @param pointSize (number) is the size for each point
  71039. * @param scene (Scene) is the scene in which the PCS is added
  71040. * @param options defines the options of the PCS e.g.
  71041. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71042. */
  71043. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71044. updatable?: boolean;
  71045. });
  71046. /**
  71047. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71048. * If no points were added to the PCS, the returned mesh is just a single point.
  71049. * @returns a promise for the created mesh
  71050. */
  71051. buildMeshAsync(): Promise<Mesh>;
  71052. /**
  71053. * @hidden
  71054. */
  71055. private _buildMesh;
  71056. private _addParticle;
  71057. private _randomUnitVector;
  71058. private _getColorIndicesForCoord;
  71059. private _setPointsColorOrUV;
  71060. private _colorFromTexture;
  71061. private _calculateDensity;
  71062. /**
  71063. * Adds points to the PCS in random positions within a unit sphere
  71064. * @param nb (positive integer) the number of particles to be created from this model
  71065. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71066. * @returns the number of groups in the system
  71067. */
  71068. addPoints(nb: number, pointFunction?: any): number;
  71069. /**
  71070. * Adds points to the PCS from the surface of the model shape
  71071. * @param mesh is any Mesh object that will be used as a surface model for the points
  71072. * @param nb (positive integer) the number of particles to be created from this model
  71073. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71074. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71075. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71076. * @returns the number of groups in the system
  71077. */
  71078. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71079. /**
  71080. * Adds points to the PCS inside the model shape
  71081. * @param mesh is any Mesh object that will be used as a surface model for the points
  71082. * @param nb (positive integer) the number of particles to be created from this model
  71083. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71084. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71085. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71086. * @returns the number of groups in the system
  71087. */
  71088. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71089. /**
  71090. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71091. * This method calls `updateParticle()` for each particle of the SPS.
  71092. * For an animated SPS, it is usually called within the render loop.
  71093. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71094. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71095. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71096. * @returns the PCS.
  71097. */
  71098. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71099. /**
  71100. * Disposes the PCS.
  71101. */
  71102. dispose(): void;
  71103. /**
  71104. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71105. * doc :
  71106. * @returns the PCS.
  71107. */
  71108. refreshVisibleSize(): PointsCloudSystem;
  71109. /**
  71110. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71111. * @param size the size (float) of the visibility box
  71112. * note : this doesn't lock the PCS mesh bounding box.
  71113. * doc :
  71114. */
  71115. setVisibilityBox(size: number): void;
  71116. /**
  71117. * Gets whether the PCS is always visible or not
  71118. * doc :
  71119. */
  71120. get isAlwaysVisible(): boolean;
  71121. /**
  71122. * Sets the PCS as always visible or not
  71123. * doc :
  71124. */
  71125. set isAlwaysVisible(val: boolean);
  71126. /**
  71127. * Tells to `setParticles()` to compute the particle rotations or not
  71128. * Default value : false. The PCS is faster when it's set to false
  71129. * Note : particle rotations are only applied to parent particles
  71130. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71131. */
  71132. set computeParticleRotation(val: boolean);
  71133. /**
  71134. * Tells to `setParticles()` to compute the particle colors or not.
  71135. * Default value : true. The PCS is faster when it's set to false.
  71136. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71137. */
  71138. set computeParticleColor(val: boolean);
  71139. set computeParticleTexture(val: boolean);
  71140. /**
  71141. * Gets if `setParticles()` computes the particle colors or not.
  71142. * Default value : false. The PCS is faster when it's set to false.
  71143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71144. */
  71145. get computeParticleColor(): boolean;
  71146. /**
  71147. * Gets if `setParticles()` computes the particle textures or not.
  71148. * Default value : false. The PCS is faster when it's set to false.
  71149. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71150. */
  71151. get computeParticleTexture(): boolean;
  71152. /**
  71153. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71154. */
  71155. set computeBoundingBox(val: boolean);
  71156. /**
  71157. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71158. */
  71159. get computeBoundingBox(): boolean;
  71160. /**
  71161. * This function does nothing. It may be overwritten to set all the particle first values.
  71162. * The PCS doesn't call this function, you may have to call it by your own.
  71163. * doc :
  71164. */
  71165. initParticles(): void;
  71166. /**
  71167. * This function does nothing. It may be overwritten to recycle a particle
  71168. * The PCS doesn't call this function, you can to call it
  71169. * doc :
  71170. * @param particle The particle to recycle
  71171. * @returns the recycled particle
  71172. */
  71173. recycleParticle(particle: CloudPoint): CloudPoint;
  71174. /**
  71175. * Updates a particle : this function should be overwritten by the user.
  71176. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71177. * doc :
  71178. * @example : just set a particle position or velocity and recycle conditions
  71179. * @param particle The particle to update
  71180. * @returns the updated particle
  71181. */
  71182. updateParticle(particle: CloudPoint): CloudPoint;
  71183. /**
  71184. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71185. * This does nothing and may be overwritten by the user.
  71186. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71187. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71188. * @param update the boolean update value actually passed to setParticles()
  71189. */
  71190. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71191. /**
  71192. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71193. * This will be passed three parameters.
  71194. * This does nothing and may be overwritten by the user.
  71195. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71196. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71197. * @param update the boolean update value actually passed to setParticles()
  71198. */
  71199. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71200. }
  71201. }
  71202. declare module "babylonjs/Particles/cloudPoint" {
  71203. import { Nullable } from "babylonjs/types";
  71204. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71205. import { Mesh } from "babylonjs/Meshes/mesh";
  71206. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71207. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71208. /**
  71209. * Represents one particle of a points cloud system.
  71210. */
  71211. export class CloudPoint {
  71212. /**
  71213. * particle global index
  71214. */
  71215. idx: number;
  71216. /**
  71217. * The color of the particle
  71218. */
  71219. color: Nullable<Color4>;
  71220. /**
  71221. * The world space position of the particle.
  71222. */
  71223. position: Vector3;
  71224. /**
  71225. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71226. */
  71227. rotation: Vector3;
  71228. /**
  71229. * The world space rotation quaternion of the particle.
  71230. */
  71231. rotationQuaternion: Nullable<Quaternion>;
  71232. /**
  71233. * The uv of the particle.
  71234. */
  71235. uv: Nullable<Vector2>;
  71236. /**
  71237. * The current speed of the particle.
  71238. */
  71239. velocity: Vector3;
  71240. /**
  71241. * The pivot point in the particle local space.
  71242. */
  71243. pivot: Vector3;
  71244. /**
  71245. * Must the particle be translated from its pivot point in its local space ?
  71246. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71247. * Default : false
  71248. */
  71249. translateFromPivot: boolean;
  71250. /**
  71251. * Index of this particle in the global "positions" array (Internal use)
  71252. * @hidden
  71253. */
  71254. _pos: number;
  71255. /**
  71256. * @hidden Index of this particle in the global "indices" array (Internal use)
  71257. */
  71258. _ind: number;
  71259. /**
  71260. * Group this particle belongs to
  71261. */
  71262. _group: PointsGroup;
  71263. /**
  71264. * Group id of this particle
  71265. */
  71266. groupId: number;
  71267. /**
  71268. * Index of the particle in its group id (Internal use)
  71269. */
  71270. idxInGroup: number;
  71271. /**
  71272. * @hidden Particle BoundingInfo object (Internal use)
  71273. */
  71274. _boundingInfo: BoundingInfo;
  71275. /**
  71276. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71277. */
  71278. _pcs: PointsCloudSystem;
  71279. /**
  71280. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71281. */
  71282. _stillInvisible: boolean;
  71283. /**
  71284. * @hidden Last computed particle rotation matrix
  71285. */
  71286. _rotationMatrix: number[];
  71287. /**
  71288. * Parent particle Id, if any.
  71289. * Default null.
  71290. */
  71291. parentId: Nullable<number>;
  71292. /**
  71293. * @hidden Internal global position in the PCS.
  71294. */
  71295. _globalPosition: Vector3;
  71296. /**
  71297. * Creates a Point Cloud object.
  71298. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71299. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71300. * @param group (PointsGroup) is the group the particle belongs to
  71301. * @param groupId (integer) is the group identifier in the PCS.
  71302. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71303. * @param pcs defines the PCS it is associated to
  71304. */
  71305. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71306. /**
  71307. * get point size
  71308. */
  71309. get size(): Vector3;
  71310. /**
  71311. * Set point size
  71312. */
  71313. set size(scale: Vector3);
  71314. /**
  71315. * Legacy support, changed quaternion to rotationQuaternion
  71316. */
  71317. get quaternion(): Nullable<Quaternion>;
  71318. /**
  71319. * Legacy support, changed quaternion to rotationQuaternion
  71320. */
  71321. set quaternion(q: Nullable<Quaternion>);
  71322. /**
  71323. * Returns a boolean. True if the particle intersects a mesh, else false
  71324. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71325. * @param target is the object (point or mesh) what the intersection is computed against
  71326. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71327. * @returns true if it intersects
  71328. */
  71329. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71330. /**
  71331. * get the rotation matrix of the particle
  71332. * @hidden
  71333. */
  71334. getRotationMatrix(m: Matrix): void;
  71335. }
  71336. /**
  71337. * Represents a group of points in a points cloud system
  71338. * * PCS internal tool, don't use it manually.
  71339. */
  71340. export class PointsGroup {
  71341. /**
  71342. * The group id
  71343. * @hidden
  71344. */
  71345. groupID: number;
  71346. /**
  71347. * image data for group (internal use)
  71348. * @hidden
  71349. */
  71350. _groupImageData: Nullable<ArrayBufferView>;
  71351. /**
  71352. * Image Width (internal use)
  71353. * @hidden
  71354. */
  71355. _groupImgWidth: number;
  71356. /**
  71357. * Image Height (internal use)
  71358. * @hidden
  71359. */
  71360. _groupImgHeight: number;
  71361. /**
  71362. * Custom position function (internal use)
  71363. * @hidden
  71364. */
  71365. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71366. /**
  71367. * density per facet for surface points
  71368. * @hidden
  71369. */
  71370. _groupDensity: number[];
  71371. /**
  71372. * Only when points are colored by texture carries pointer to texture list array
  71373. * @hidden
  71374. */
  71375. _textureNb: number;
  71376. /**
  71377. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71378. * PCS internal tool, don't use it manually.
  71379. * @hidden
  71380. */
  71381. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71382. }
  71383. }
  71384. declare module "babylonjs/Particles/index" {
  71385. export * from "babylonjs/Particles/baseParticleSystem";
  71386. export * from "babylonjs/Particles/EmitterTypes/index";
  71387. export * from "babylonjs/Particles/gpuParticleSystem";
  71388. export * from "babylonjs/Particles/IParticleSystem";
  71389. export * from "babylonjs/Particles/particle";
  71390. export * from "babylonjs/Particles/particleHelper";
  71391. export * from "babylonjs/Particles/particleSystem";
  71392. import "babylonjs/Particles/particleSystemComponent";
  71393. export * from "babylonjs/Particles/particleSystemComponent";
  71394. export * from "babylonjs/Particles/particleSystemSet";
  71395. export * from "babylonjs/Particles/solidParticle";
  71396. export * from "babylonjs/Particles/solidParticleSystem";
  71397. export * from "babylonjs/Particles/cloudPoint";
  71398. export * from "babylonjs/Particles/pointsCloudSystem";
  71399. export * from "babylonjs/Particles/subEmitter";
  71400. }
  71401. declare module "babylonjs/Physics/physicsEngineComponent" {
  71402. import { Nullable } from "babylonjs/types";
  71403. import { Observable, Observer } from "babylonjs/Misc/observable";
  71404. import { Vector3 } from "babylonjs/Maths/math.vector";
  71405. import { Mesh } from "babylonjs/Meshes/mesh";
  71406. import { ISceneComponent } from "babylonjs/sceneComponent";
  71407. import { Scene } from "babylonjs/scene";
  71408. import { Node } from "babylonjs/node";
  71409. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71410. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71411. module "babylonjs/scene" {
  71412. interface Scene {
  71413. /** @hidden (Backing field) */
  71414. _physicsEngine: Nullable<IPhysicsEngine>;
  71415. /** @hidden */
  71416. _physicsTimeAccumulator: number;
  71417. /**
  71418. * Gets the current physics engine
  71419. * @returns a IPhysicsEngine or null if none attached
  71420. */
  71421. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71422. /**
  71423. * Enables physics to the current scene
  71424. * @param gravity defines the scene's gravity for the physics engine
  71425. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71426. * @return a boolean indicating if the physics engine was initialized
  71427. */
  71428. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71429. /**
  71430. * Disables and disposes the physics engine associated with the scene
  71431. */
  71432. disablePhysicsEngine(): void;
  71433. /**
  71434. * Gets a boolean indicating if there is an active physics engine
  71435. * @returns a boolean indicating if there is an active physics engine
  71436. */
  71437. isPhysicsEnabled(): boolean;
  71438. /**
  71439. * Deletes a physics compound impostor
  71440. * @param compound defines the compound to delete
  71441. */
  71442. deleteCompoundImpostor(compound: any): void;
  71443. /**
  71444. * An event triggered when physic simulation is about to be run
  71445. */
  71446. onBeforePhysicsObservable: Observable<Scene>;
  71447. /**
  71448. * An event triggered when physic simulation has been done
  71449. */
  71450. onAfterPhysicsObservable: Observable<Scene>;
  71451. }
  71452. }
  71453. module "babylonjs/Meshes/abstractMesh" {
  71454. interface AbstractMesh {
  71455. /** @hidden */
  71456. _physicsImpostor: Nullable<PhysicsImpostor>;
  71457. /**
  71458. * Gets or sets impostor used for physic simulation
  71459. * @see https://doc.babylonjs.com/features/physics_engine
  71460. */
  71461. physicsImpostor: Nullable<PhysicsImpostor>;
  71462. /**
  71463. * Gets the current physics impostor
  71464. * @see https://doc.babylonjs.com/features/physics_engine
  71465. * @returns a physics impostor or null
  71466. */
  71467. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71468. /** Apply a physic impulse to the mesh
  71469. * @param force defines the force to apply
  71470. * @param contactPoint defines where to apply the force
  71471. * @returns the current mesh
  71472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71473. */
  71474. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71475. /**
  71476. * Creates a physic joint between two meshes
  71477. * @param otherMesh defines the other mesh to use
  71478. * @param pivot1 defines the pivot to use on this mesh
  71479. * @param pivot2 defines the pivot to use on the other mesh
  71480. * @param options defines additional options (can be plugin dependent)
  71481. * @returns the current mesh
  71482. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71483. */
  71484. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71485. /** @hidden */
  71486. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71487. }
  71488. }
  71489. /**
  71490. * Defines the physics engine scene component responsible to manage a physics engine
  71491. */
  71492. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71493. /**
  71494. * The component name helpful to identify the component in the list of scene components.
  71495. */
  71496. readonly name: string;
  71497. /**
  71498. * The scene the component belongs to.
  71499. */
  71500. scene: Scene;
  71501. /**
  71502. * Creates a new instance of the component for the given scene
  71503. * @param scene Defines the scene to register the component in
  71504. */
  71505. constructor(scene: Scene);
  71506. /**
  71507. * Registers the component in a given scene
  71508. */
  71509. register(): void;
  71510. /**
  71511. * Rebuilds the elements related to this component in case of
  71512. * context lost for instance.
  71513. */
  71514. rebuild(): void;
  71515. /**
  71516. * Disposes the component and the associated ressources
  71517. */
  71518. dispose(): void;
  71519. }
  71520. }
  71521. declare module "babylonjs/Physics/physicsHelper" {
  71522. import { Nullable } from "babylonjs/types";
  71523. import { Vector3 } from "babylonjs/Maths/math.vector";
  71524. import { Mesh } from "babylonjs/Meshes/mesh";
  71525. import { Scene } from "babylonjs/scene";
  71526. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71527. /**
  71528. * A helper for physics simulations
  71529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71530. */
  71531. export class PhysicsHelper {
  71532. private _scene;
  71533. private _physicsEngine;
  71534. /**
  71535. * Initializes the Physics helper
  71536. * @param scene Babylon.js scene
  71537. */
  71538. constructor(scene: Scene);
  71539. /**
  71540. * Applies a radial explosion impulse
  71541. * @param origin the origin of the explosion
  71542. * @param radiusOrEventOptions the radius or the options of radial explosion
  71543. * @param strength the explosion strength
  71544. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71545. * @returns A physics radial explosion event, or null
  71546. */
  71547. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71548. /**
  71549. * Applies a radial explosion force
  71550. * @param origin the origin of the explosion
  71551. * @param radiusOrEventOptions the radius or the options of radial explosion
  71552. * @param strength the explosion strength
  71553. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71554. * @returns A physics radial explosion event, or null
  71555. */
  71556. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71557. /**
  71558. * Creates a gravitational field
  71559. * @param origin the origin of the explosion
  71560. * @param radiusOrEventOptions the radius or the options of radial explosion
  71561. * @param strength the explosion strength
  71562. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71563. * @returns A physics gravitational field event, or null
  71564. */
  71565. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71566. /**
  71567. * Creates a physics updraft event
  71568. * @param origin the origin of the updraft
  71569. * @param radiusOrEventOptions the radius or the options of the updraft
  71570. * @param strength the strength of the updraft
  71571. * @param height the height of the updraft
  71572. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71573. * @returns A physics updraft event, or null
  71574. */
  71575. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71576. /**
  71577. * Creates a physics vortex event
  71578. * @param origin the of the vortex
  71579. * @param radiusOrEventOptions the radius or the options of the vortex
  71580. * @param strength the strength of the vortex
  71581. * @param height the height of the vortex
  71582. * @returns a Physics vortex event, or null
  71583. * A physics vortex event or null
  71584. */
  71585. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71586. }
  71587. /**
  71588. * Represents a physics radial explosion event
  71589. */
  71590. class PhysicsRadialExplosionEvent {
  71591. private _scene;
  71592. private _options;
  71593. private _sphere;
  71594. private _dataFetched;
  71595. /**
  71596. * Initializes a radial explosioin event
  71597. * @param _scene BabylonJS scene
  71598. * @param _options The options for the vortex event
  71599. */
  71600. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71601. /**
  71602. * Returns the data related to the radial explosion event (sphere).
  71603. * @returns The radial explosion event data
  71604. */
  71605. getData(): PhysicsRadialExplosionEventData;
  71606. /**
  71607. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71608. * @param impostor A physics imposter
  71609. * @param origin the origin of the explosion
  71610. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71611. */
  71612. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71613. /**
  71614. * Triggers affecterd impostors callbacks
  71615. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71616. */
  71617. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71618. /**
  71619. * Disposes the sphere.
  71620. * @param force Specifies if the sphere should be disposed by force
  71621. */
  71622. dispose(force?: boolean): void;
  71623. /*** Helpers ***/
  71624. private _prepareSphere;
  71625. private _intersectsWithSphere;
  71626. }
  71627. /**
  71628. * Represents a gravitational field event
  71629. */
  71630. class PhysicsGravitationalFieldEvent {
  71631. private _physicsHelper;
  71632. private _scene;
  71633. private _origin;
  71634. private _options;
  71635. private _tickCallback;
  71636. private _sphere;
  71637. private _dataFetched;
  71638. /**
  71639. * Initializes the physics gravitational field event
  71640. * @param _physicsHelper A physics helper
  71641. * @param _scene BabylonJS scene
  71642. * @param _origin The origin position of the gravitational field event
  71643. * @param _options The options for the vortex event
  71644. */
  71645. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71646. /**
  71647. * Returns the data related to the gravitational field event (sphere).
  71648. * @returns A gravitational field event
  71649. */
  71650. getData(): PhysicsGravitationalFieldEventData;
  71651. /**
  71652. * Enables the gravitational field.
  71653. */
  71654. enable(): void;
  71655. /**
  71656. * Disables the gravitational field.
  71657. */
  71658. disable(): void;
  71659. /**
  71660. * Disposes the sphere.
  71661. * @param force The force to dispose from the gravitational field event
  71662. */
  71663. dispose(force?: boolean): void;
  71664. private _tick;
  71665. }
  71666. /**
  71667. * Represents a physics updraft event
  71668. */
  71669. class PhysicsUpdraftEvent {
  71670. private _scene;
  71671. private _origin;
  71672. private _options;
  71673. private _physicsEngine;
  71674. private _originTop;
  71675. private _originDirection;
  71676. private _tickCallback;
  71677. private _cylinder;
  71678. private _cylinderPosition;
  71679. private _dataFetched;
  71680. /**
  71681. * Initializes the physics updraft event
  71682. * @param _scene BabylonJS scene
  71683. * @param _origin The origin position of the updraft
  71684. * @param _options The options for the updraft event
  71685. */
  71686. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71687. /**
  71688. * Returns the data related to the updraft event (cylinder).
  71689. * @returns A physics updraft event
  71690. */
  71691. getData(): PhysicsUpdraftEventData;
  71692. /**
  71693. * Enables the updraft.
  71694. */
  71695. enable(): void;
  71696. /**
  71697. * Disables the updraft.
  71698. */
  71699. disable(): void;
  71700. /**
  71701. * Disposes the cylinder.
  71702. * @param force Specifies if the updraft should be disposed by force
  71703. */
  71704. dispose(force?: boolean): void;
  71705. private getImpostorHitData;
  71706. private _tick;
  71707. /*** Helpers ***/
  71708. private _prepareCylinder;
  71709. private _intersectsWithCylinder;
  71710. }
  71711. /**
  71712. * Represents a physics vortex event
  71713. */
  71714. class PhysicsVortexEvent {
  71715. private _scene;
  71716. private _origin;
  71717. private _options;
  71718. private _physicsEngine;
  71719. private _originTop;
  71720. private _tickCallback;
  71721. private _cylinder;
  71722. private _cylinderPosition;
  71723. private _dataFetched;
  71724. /**
  71725. * Initializes the physics vortex event
  71726. * @param _scene The BabylonJS scene
  71727. * @param _origin The origin position of the vortex
  71728. * @param _options The options for the vortex event
  71729. */
  71730. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71731. /**
  71732. * Returns the data related to the vortex event (cylinder).
  71733. * @returns The physics vortex event data
  71734. */
  71735. getData(): PhysicsVortexEventData;
  71736. /**
  71737. * Enables the vortex.
  71738. */
  71739. enable(): void;
  71740. /**
  71741. * Disables the cortex.
  71742. */
  71743. disable(): void;
  71744. /**
  71745. * Disposes the sphere.
  71746. * @param force
  71747. */
  71748. dispose(force?: boolean): void;
  71749. private getImpostorHitData;
  71750. private _tick;
  71751. /*** Helpers ***/
  71752. private _prepareCylinder;
  71753. private _intersectsWithCylinder;
  71754. }
  71755. /**
  71756. * Options fot the radial explosion event
  71757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71758. */
  71759. export class PhysicsRadialExplosionEventOptions {
  71760. /**
  71761. * The radius of the sphere for the radial explosion.
  71762. */
  71763. radius: number;
  71764. /**
  71765. * The strenth of the explosion.
  71766. */
  71767. strength: number;
  71768. /**
  71769. * The strenght of the force in correspondence to the distance of the affected object
  71770. */
  71771. falloff: PhysicsRadialImpulseFalloff;
  71772. /**
  71773. * Sphere options for the radial explosion.
  71774. */
  71775. sphere: {
  71776. segments: number;
  71777. diameter: number;
  71778. };
  71779. /**
  71780. * Sphere options for the radial explosion.
  71781. */
  71782. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71783. }
  71784. /**
  71785. * Options fot the updraft event
  71786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71787. */
  71788. export class PhysicsUpdraftEventOptions {
  71789. /**
  71790. * The radius of the cylinder for the vortex
  71791. */
  71792. radius: number;
  71793. /**
  71794. * The strenth of the updraft.
  71795. */
  71796. strength: number;
  71797. /**
  71798. * The height of the cylinder for the updraft.
  71799. */
  71800. height: number;
  71801. /**
  71802. * The mode for the the updraft.
  71803. */
  71804. updraftMode: PhysicsUpdraftMode;
  71805. }
  71806. /**
  71807. * Options fot the vortex event
  71808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71809. */
  71810. export class PhysicsVortexEventOptions {
  71811. /**
  71812. * The radius of the cylinder for the vortex
  71813. */
  71814. radius: number;
  71815. /**
  71816. * The strenth of the vortex.
  71817. */
  71818. strength: number;
  71819. /**
  71820. * The height of the cylinder for the vortex.
  71821. */
  71822. height: number;
  71823. /**
  71824. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71825. */
  71826. centripetalForceThreshold: number;
  71827. /**
  71828. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71829. */
  71830. centripetalForceMultiplier: number;
  71831. /**
  71832. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71833. */
  71834. centrifugalForceMultiplier: number;
  71835. /**
  71836. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71837. */
  71838. updraftForceMultiplier: number;
  71839. }
  71840. /**
  71841. * The strenght of the force in correspondence to the distance of the affected object
  71842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71843. */
  71844. export enum PhysicsRadialImpulseFalloff {
  71845. /** Defines that impulse is constant in strength across it's whole radius */
  71846. Constant = 0,
  71847. /** Defines that impulse gets weaker if it's further from the origin */
  71848. Linear = 1
  71849. }
  71850. /**
  71851. * The strength of the force in correspondence to the distance of the affected object
  71852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71853. */
  71854. export enum PhysicsUpdraftMode {
  71855. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71856. Center = 0,
  71857. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71858. Perpendicular = 1
  71859. }
  71860. /**
  71861. * Interface for a physics hit data
  71862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71863. */
  71864. export interface PhysicsHitData {
  71865. /**
  71866. * The force applied at the contact point
  71867. */
  71868. force: Vector3;
  71869. /**
  71870. * The contact point
  71871. */
  71872. contactPoint: Vector3;
  71873. /**
  71874. * The distance from the origin to the contact point
  71875. */
  71876. distanceFromOrigin: number;
  71877. }
  71878. /**
  71879. * Interface for radial explosion event data
  71880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71881. */
  71882. export interface PhysicsRadialExplosionEventData {
  71883. /**
  71884. * A sphere used for the radial explosion event
  71885. */
  71886. sphere: Mesh;
  71887. }
  71888. /**
  71889. * Interface for gravitational field event data
  71890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71891. */
  71892. export interface PhysicsGravitationalFieldEventData {
  71893. /**
  71894. * A sphere mesh used for the gravitational field event
  71895. */
  71896. sphere: Mesh;
  71897. }
  71898. /**
  71899. * Interface for updraft event data
  71900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71901. */
  71902. export interface PhysicsUpdraftEventData {
  71903. /**
  71904. * A cylinder used for the updraft event
  71905. */
  71906. cylinder: Mesh;
  71907. }
  71908. /**
  71909. * Interface for vortex event data
  71910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71911. */
  71912. export interface PhysicsVortexEventData {
  71913. /**
  71914. * A cylinder used for the vortex event
  71915. */
  71916. cylinder: Mesh;
  71917. }
  71918. /**
  71919. * Interface for an affected physics impostor
  71920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71921. */
  71922. export interface PhysicsAffectedImpostorWithData {
  71923. /**
  71924. * The impostor affected by the effect
  71925. */
  71926. impostor: PhysicsImpostor;
  71927. /**
  71928. * The data about the hit/horce from the explosion
  71929. */
  71930. hitData: PhysicsHitData;
  71931. }
  71932. }
  71933. declare module "babylonjs/Physics/Plugins/index" {
  71934. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71935. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71936. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71937. }
  71938. declare module "babylonjs/Physics/index" {
  71939. export * from "babylonjs/Physics/IPhysicsEngine";
  71940. export * from "babylonjs/Physics/physicsEngine";
  71941. export * from "babylonjs/Physics/physicsEngineComponent";
  71942. export * from "babylonjs/Physics/physicsHelper";
  71943. export * from "babylonjs/Physics/physicsImpostor";
  71944. export * from "babylonjs/Physics/physicsJoint";
  71945. export * from "babylonjs/Physics/Plugins/index";
  71946. }
  71947. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71948. /** @hidden */
  71949. export var blackAndWhitePixelShader: {
  71950. name: string;
  71951. shader: string;
  71952. };
  71953. }
  71954. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71955. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71956. import { Camera } from "babylonjs/Cameras/camera";
  71957. import { Engine } from "babylonjs/Engines/engine";
  71958. import "babylonjs/Shaders/blackAndWhite.fragment";
  71959. /**
  71960. * Post process used to render in black and white
  71961. */
  71962. export class BlackAndWhitePostProcess extends PostProcess {
  71963. /**
  71964. * Linear about to convert he result to black and white (default: 1)
  71965. */
  71966. degree: number;
  71967. /**
  71968. * Creates a black and white post process
  71969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71970. * @param name The name of the effect.
  71971. * @param options The required width/height ratio to downsize to before computing the render pass.
  71972. * @param camera The camera to apply the render pass to.
  71973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71974. * @param engine The engine which the post process will be applied. (default: current engine)
  71975. * @param reusable If the post process can be reused on the same frame. (default: false)
  71976. */
  71977. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71978. }
  71979. }
  71980. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71981. import { Nullable } from "babylonjs/types";
  71982. import { Camera } from "babylonjs/Cameras/camera";
  71983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71984. import { Engine } from "babylonjs/Engines/engine";
  71985. /**
  71986. * This represents a set of one or more post processes in Babylon.
  71987. * A post process can be used to apply a shader to a texture after it is rendered.
  71988. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71989. */
  71990. export class PostProcessRenderEffect {
  71991. private _postProcesses;
  71992. private _getPostProcesses;
  71993. private _singleInstance;
  71994. private _cameras;
  71995. private _indicesForCamera;
  71996. /**
  71997. * Name of the effect
  71998. * @hidden
  71999. */
  72000. _name: string;
  72001. /**
  72002. * Instantiates a post process render effect.
  72003. * A post process can be used to apply a shader to a texture after it is rendered.
  72004. * @param engine The engine the effect is tied to
  72005. * @param name The name of the effect
  72006. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72007. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72008. */
  72009. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72010. /**
  72011. * Checks if all the post processes in the effect are supported.
  72012. */
  72013. get isSupported(): boolean;
  72014. /**
  72015. * Updates the current state of the effect
  72016. * @hidden
  72017. */
  72018. _update(): void;
  72019. /**
  72020. * Attaches the effect on cameras
  72021. * @param cameras The camera to attach to.
  72022. * @hidden
  72023. */
  72024. _attachCameras(cameras: Camera): void;
  72025. /**
  72026. * Attaches the effect on cameras
  72027. * @param cameras The camera to attach to.
  72028. * @hidden
  72029. */
  72030. _attachCameras(cameras: Camera[]): void;
  72031. /**
  72032. * Detaches the effect on cameras
  72033. * @param cameras The camera to detatch from.
  72034. * @hidden
  72035. */
  72036. _detachCameras(cameras: Camera): void;
  72037. /**
  72038. * Detatches the effect on cameras
  72039. * @param cameras The camera to detatch from.
  72040. * @hidden
  72041. */
  72042. _detachCameras(cameras: Camera[]): void;
  72043. /**
  72044. * Enables the effect on given cameras
  72045. * @param cameras The camera to enable.
  72046. * @hidden
  72047. */
  72048. _enable(cameras: Camera): void;
  72049. /**
  72050. * Enables the effect on given cameras
  72051. * @param cameras The camera to enable.
  72052. * @hidden
  72053. */
  72054. _enable(cameras: Nullable<Camera[]>): void;
  72055. /**
  72056. * Disables the effect on the given cameras
  72057. * @param cameras The camera to disable.
  72058. * @hidden
  72059. */
  72060. _disable(cameras: Camera): void;
  72061. /**
  72062. * Disables the effect on the given cameras
  72063. * @param cameras The camera to disable.
  72064. * @hidden
  72065. */
  72066. _disable(cameras: Nullable<Camera[]>): void;
  72067. /**
  72068. * Gets a list of the post processes contained in the effect.
  72069. * @param camera The camera to get the post processes on.
  72070. * @returns The list of the post processes in the effect.
  72071. */
  72072. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72073. }
  72074. }
  72075. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72077. /** @hidden */
  72078. export var extractHighlightsPixelShader: {
  72079. name: string;
  72080. shader: string;
  72081. };
  72082. }
  72083. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72084. import { Nullable } from "babylonjs/types";
  72085. import { Camera } from "babylonjs/Cameras/camera";
  72086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72087. import { Engine } from "babylonjs/Engines/engine";
  72088. import "babylonjs/Shaders/extractHighlights.fragment";
  72089. /**
  72090. * 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.
  72091. */
  72092. export class ExtractHighlightsPostProcess extends PostProcess {
  72093. /**
  72094. * The luminance threshold, pixels below this value will be set to black.
  72095. */
  72096. threshold: number;
  72097. /** @hidden */
  72098. _exposure: number;
  72099. /**
  72100. * Post process which has the input texture to be used when performing highlight extraction
  72101. * @hidden
  72102. */
  72103. _inputPostProcess: Nullable<PostProcess>;
  72104. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72105. }
  72106. }
  72107. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72108. /** @hidden */
  72109. export var bloomMergePixelShader: {
  72110. name: string;
  72111. shader: string;
  72112. };
  72113. }
  72114. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72116. import { Nullable } from "babylonjs/types";
  72117. import { Engine } from "babylonjs/Engines/engine";
  72118. import { Camera } from "babylonjs/Cameras/camera";
  72119. import "babylonjs/Shaders/bloomMerge.fragment";
  72120. /**
  72121. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72122. */
  72123. export class BloomMergePostProcess extends PostProcess {
  72124. /** Weight of the bloom to be added to the original input. */
  72125. weight: number;
  72126. /**
  72127. * Creates a new instance of @see BloomMergePostProcess
  72128. * @param name The name of the effect.
  72129. * @param originalFromInput Post process which's input will be used for the merge.
  72130. * @param blurred Blurred highlights post process which's output will be used.
  72131. * @param weight Weight of the bloom to be added to the original input.
  72132. * @param options The required width/height ratio to downsize to before computing the render pass.
  72133. * @param camera The camera to apply the render pass to.
  72134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72135. * @param engine The engine which the post process will be applied. (default: current engine)
  72136. * @param reusable If the post process can be reused on the same frame. (default: false)
  72137. * @param textureType Type of textures used when performing the post process. (default: 0)
  72138. * @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)
  72139. */
  72140. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72141. /** Weight of the bloom to be added to the original input. */
  72142. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72143. }
  72144. }
  72145. declare module "babylonjs/PostProcesses/bloomEffect" {
  72146. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72147. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72148. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72149. import { Camera } from "babylonjs/Cameras/camera";
  72150. import { Scene } from "babylonjs/scene";
  72151. /**
  72152. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72153. */
  72154. export class BloomEffect extends PostProcessRenderEffect {
  72155. private bloomScale;
  72156. /**
  72157. * @hidden Internal
  72158. */
  72159. _effects: Array<PostProcess>;
  72160. /**
  72161. * @hidden Internal
  72162. */
  72163. _downscale: ExtractHighlightsPostProcess;
  72164. private _blurX;
  72165. private _blurY;
  72166. private _merge;
  72167. /**
  72168. * The luminance threshold to find bright areas of the image to bloom.
  72169. */
  72170. get threshold(): number;
  72171. set threshold(value: number);
  72172. /**
  72173. * The strength of the bloom.
  72174. */
  72175. get weight(): number;
  72176. set weight(value: number);
  72177. /**
  72178. * Specifies the size of the bloom blur kernel, relative to the final output size
  72179. */
  72180. get kernel(): number;
  72181. set kernel(value: number);
  72182. /**
  72183. * Creates a new instance of @see BloomEffect
  72184. * @param scene The scene the effect belongs to.
  72185. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72186. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72187. * @param bloomWeight The the strength of bloom.
  72188. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72189. * @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)
  72190. */
  72191. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72192. /**
  72193. * Disposes each of the internal effects for a given camera.
  72194. * @param camera The camera to dispose the effect on.
  72195. */
  72196. disposeEffects(camera: Camera): void;
  72197. /**
  72198. * @hidden Internal
  72199. */
  72200. _updateEffects(): void;
  72201. /**
  72202. * Internal
  72203. * @returns if all the contained post processes are ready.
  72204. * @hidden
  72205. */
  72206. _isReady(): boolean;
  72207. }
  72208. }
  72209. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72210. /** @hidden */
  72211. export var chromaticAberrationPixelShader: {
  72212. name: string;
  72213. shader: string;
  72214. };
  72215. }
  72216. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72217. import { Vector2 } from "babylonjs/Maths/math.vector";
  72218. import { Nullable } from "babylonjs/types";
  72219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72220. import { Camera } from "babylonjs/Cameras/camera";
  72221. import { Engine } from "babylonjs/Engines/engine";
  72222. import "babylonjs/Shaders/chromaticAberration.fragment";
  72223. /**
  72224. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72225. */
  72226. export class ChromaticAberrationPostProcess extends PostProcess {
  72227. /**
  72228. * The amount of seperation of rgb channels (default: 30)
  72229. */
  72230. aberrationAmount: number;
  72231. /**
  72232. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72233. */
  72234. radialIntensity: number;
  72235. /**
  72236. * 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))
  72237. */
  72238. direction: Vector2;
  72239. /**
  72240. * 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))
  72241. */
  72242. centerPosition: Vector2;
  72243. /**
  72244. * Creates a new instance ChromaticAberrationPostProcess
  72245. * @param name The name of the effect.
  72246. * @param screenWidth The width of the screen to apply the effect on.
  72247. * @param screenHeight The height of the screen to apply the effect on.
  72248. * @param options The required width/height ratio to downsize to before computing the render pass.
  72249. * @param camera The camera to apply the render pass to.
  72250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72251. * @param engine The engine which the post process will be applied. (default: current engine)
  72252. * @param reusable If the post process can be reused on the same frame. (default: false)
  72253. * @param textureType Type of textures used when performing the post process. (default: 0)
  72254. * @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)
  72255. */
  72256. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72257. }
  72258. }
  72259. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72260. /** @hidden */
  72261. export var circleOfConfusionPixelShader: {
  72262. name: string;
  72263. shader: string;
  72264. };
  72265. }
  72266. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72267. import { Nullable } from "babylonjs/types";
  72268. import { Engine } from "babylonjs/Engines/engine";
  72269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72271. import { Camera } from "babylonjs/Cameras/camera";
  72272. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72273. /**
  72274. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72275. */
  72276. export class CircleOfConfusionPostProcess extends PostProcess {
  72277. /**
  72278. * 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.
  72279. */
  72280. lensSize: number;
  72281. /**
  72282. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72283. */
  72284. fStop: number;
  72285. /**
  72286. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72287. */
  72288. focusDistance: number;
  72289. /**
  72290. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72291. */
  72292. focalLength: number;
  72293. private _depthTexture;
  72294. /**
  72295. * Creates a new instance CircleOfConfusionPostProcess
  72296. * @param name The name of the effect.
  72297. * @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.
  72298. * @param options The required width/height ratio to downsize to before computing the render pass.
  72299. * @param camera The camera to apply the render pass to.
  72300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72301. * @param engine The engine which the post process will be applied. (default: current engine)
  72302. * @param reusable If the post process can be reused on the same frame. (default: false)
  72303. * @param textureType Type of textures used when performing the post process. (default: 0)
  72304. * @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)
  72305. */
  72306. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72307. /**
  72308. * 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.
  72309. */
  72310. set depthTexture(value: RenderTargetTexture);
  72311. }
  72312. }
  72313. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72314. /** @hidden */
  72315. export var colorCorrectionPixelShader: {
  72316. name: string;
  72317. shader: string;
  72318. };
  72319. }
  72320. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72321. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72322. import { Engine } from "babylonjs/Engines/engine";
  72323. import { Camera } from "babylonjs/Cameras/camera";
  72324. import "babylonjs/Shaders/colorCorrection.fragment";
  72325. /**
  72326. *
  72327. * This post-process allows the modification of rendered colors by using
  72328. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72329. *
  72330. * The object needs to be provided an url to a texture containing the color
  72331. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72332. * Use an image editing software to tweak the LUT to match your needs.
  72333. *
  72334. * For an example of a color LUT, see here:
  72335. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72336. * For explanations on color grading, see here:
  72337. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72338. *
  72339. */
  72340. export class ColorCorrectionPostProcess extends PostProcess {
  72341. private _colorTableTexture;
  72342. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72343. }
  72344. }
  72345. declare module "babylonjs/Shaders/convolution.fragment" {
  72346. /** @hidden */
  72347. export var convolutionPixelShader: {
  72348. name: string;
  72349. shader: string;
  72350. };
  72351. }
  72352. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72353. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72354. import { Nullable } from "babylonjs/types";
  72355. import { Camera } from "babylonjs/Cameras/camera";
  72356. import { Engine } from "babylonjs/Engines/engine";
  72357. import "babylonjs/Shaders/convolution.fragment";
  72358. /**
  72359. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72360. * input texture to perform effects such as edge detection or sharpening
  72361. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72362. */
  72363. export class ConvolutionPostProcess extends PostProcess {
  72364. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72365. kernel: number[];
  72366. /**
  72367. * Creates a new instance ConvolutionPostProcess
  72368. * @param name The name of the effect.
  72369. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72370. * @param options The required width/height ratio to downsize to before computing the render pass.
  72371. * @param camera The camera to apply the render pass to.
  72372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72373. * @param engine The engine which the post process will be applied. (default: current engine)
  72374. * @param reusable If the post process can be reused on the same frame. (default: false)
  72375. * @param textureType Type of textures used when performing the post process. (default: 0)
  72376. */
  72377. constructor(name: string,
  72378. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72379. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72380. /**
  72381. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72382. */
  72383. static EdgeDetect0Kernel: number[];
  72384. /**
  72385. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72386. */
  72387. static EdgeDetect1Kernel: number[];
  72388. /**
  72389. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72390. */
  72391. static EdgeDetect2Kernel: number[];
  72392. /**
  72393. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72394. */
  72395. static SharpenKernel: number[];
  72396. /**
  72397. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72398. */
  72399. static EmbossKernel: number[];
  72400. /**
  72401. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72402. */
  72403. static GaussianKernel: number[];
  72404. }
  72405. }
  72406. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72407. import { Nullable } from "babylonjs/types";
  72408. import { Vector2 } from "babylonjs/Maths/math.vector";
  72409. import { Camera } from "babylonjs/Cameras/camera";
  72410. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72411. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72412. import { Engine } from "babylonjs/Engines/engine";
  72413. import { Scene } from "babylonjs/scene";
  72414. /**
  72415. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72416. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72417. * based on samples that have a large difference in distance than the center pixel.
  72418. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72419. */
  72420. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72421. direction: Vector2;
  72422. /**
  72423. * Creates a new instance CircleOfConfusionPostProcess
  72424. * @param name The name of the effect.
  72425. * @param scene The scene the effect belongs to.
  72426. * @param direction The direction the blur should be applied.
  72427. * @param kernel The size of the kernel used to blur.
  72428. * @param options The required width/height ratio to downsize to before computing the render pass.
  72429. * @param camera The camera to apply the render pass to.
  72430. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72431. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72433. * @param engine The engine which the post process will be applied. (default: current engine)
  72434. * @param reusable If the post process can be reused on the same frame. (default: false)
  72435. * @param textureType Type of textures used when performing the post process. (default: 0)
  72436. * @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)
  72437. */
  72438. 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);
  72439. }
  72440. }
  72441. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72442. /** @hidden */
  72443. export var depthOfFieldMergePixelShader: {
  72444. name: string;
  72445. shader: string;
  72446. };
  72447. }
  72448. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72449. import { Nullable } from "babylonjs/types";
  72450. import { Camera } from "babylonjs/Cameras/camera";
  72451. import { Effect } from "babylonjs/Materials/effect";
  72452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72453. import { Engine } from "babylonjs/Engines/engine";
  72454. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72455. /**
  72456. * Options to be set when merging outputs from the default pipeline.
  72457. */
  72458. export class DepthOfFieldMergePostProcessOptions {
  72459. /**
  72460. * The original image to merge on top of
  72461. */
  72462. originalFromInput: PostProcess;
  72463. /**
  72464. * Parameters to perform the merge of the depth of field effect
  72465. */
  72466. depthOfField?: {
  72467. circleOfConfusion: PostProcess;
  72468. blurSteps: Array<PostProcess>;
  72469. };
  72470. /**
  72471. * Parameters to perform the merge of bloom effect
  72472. */
  72473. bloom?: {
  72474. blurred: PostProcess;
  72475. weight: number;
  72476. };
  72477. }
  72478. /**
  72479. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72480. */
  72481. export class DepthOfFieldMergePostProcess extends PostProcess {
  72482. private blurSteps;
  72483. /**
  72484. * Creates a new instance of DepthOfFieldMergePostProcess
  72485. * @param name The name of the effect.
  72486. * @param originalFromInput Post process which's input will be used for the merge.
  72487. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72488. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72489. * @param options The required width/height ratio to downsize to before computing the render pass.
  72490. * @param camera The camera to apply the render pass to.
  72491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72492. * @param engine The engine which the post process will be applied. (default: current engine)
  72493. * @param reusable If the post process can be reused on the same frame. (default: false)
  72494. * @param textureType Type of textures used when performing the post process. (default: 0)
  72495. * @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)
  72496. */
  72497. 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);
  72498. /**
  72499. * Updates the effect with the current post process compile time values and recompiles the shader.
  72500. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72501. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72502. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72503. * @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
  72504. * @param onCompiled Called when the shader has been compiled.
  72505. * @param onError Called if there is an error when compiling a shader.
  72506. */
  72507. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72508. }
  72509. }
  72510. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72511. import { Nullable } from "babylonjs/types";
  72512. import { Camera } from "babylonjs/Cameras/camera";
  72513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72515. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72516. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72517. import { Scene } from "babylonjs/scene";
  72518. /**
  72519. * Specifies the level of max blur that should be applied when using the depth of field effect
  72520. */
  72521. export enum DepthOfFieldEffectBlurLevel {
  72522. /**
  72523. * Subtle blur
  72524. */
  72525. Low = 0,
  72526. /**
  72527. * Medium blur
  72528. */
  72529. Medium = 1,
  72530. /**
  72531. * Large blur
  72532. */
  72533. High = 2
  72534. }
  72535. /**
  72536. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72537. */
  72538. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72539. private _circleOfConfusion;
  72540. /**
  72541. * @hidden Internal, blurs from high to low
  72542. */
  72543. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72544. private _depthOfFieldBlurY;
  72545. private _dofMerge;
  72546. /**
  72547. * @hidden Internal post processes in depth of field effect
  72548. */
  72549. _effects: Array<PostProcess>;
  72550. /**
  72551. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72552. */
  72553. set focalLength(value: number);
  72554. get focalLength(): number;
  72555. /**
  72556. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72557. */
  72558. set fStop(value: number);
  72559. get fStop(): number;
  72560. /**
  72561. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72562. */
  72563. set focusDistance(value: number);
  72564. get focusDistance(): number;
  72565. /**
  72566. * 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.
  72567. */
  72568. set lensSize(value: number);
  72569. get lensSize(): number;
  72570. /**
  72571. * Creates a new instance DepthOfFieldEffect
  72572. * @param scene The scene the effect belongs to.
  72573. * @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.
  72574. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72575. * @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)
  72576. */
  72577. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72578. /**
  72579. * Get the current class name of the current effet
  72580. * @returns "DepthOfFieldEffect"
  72581. */
  72582. getClassName(): string;
  72583. /**
  72584. * 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.
  72585. */
  72586. set depthTexture(value: RenderTargetTexture);
  72587. /**
  72588. * Disposes each of the internal effects for a given camera.
  72589. * @param camera The camera to dispose the effect on.
  72590. */
  72591. disposeEffects(camera: Camera): void;
  72592. /**
  72593. * @hidden Internal
  72594. */
  72595. _updateEffects(): void;
  72596. /**
  72597. * Internal
  72598. * @returns if all the contained post processes are ready.
  72599. * @hidden
  72600. */
  72601. _isReady(): boolean;
  72602. }
  72603. }
  72604. declare module "babylonjs/Shaders/displayPass.fragment" {
  72605. /** @hidden */
  72606. export var displayPassPixelShader: {
  72607. name: string;
  72608. shader: string;
  72609. };
  72610. }
  72611. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72612. import { Nullable } from "babylonjs/types";
  72613. import { Camera } from "babylonjs/Cameras/camera";
  72614. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72615. import { Engine } from "babylonjs/Engines/engine";
  72616. import "babylonjs/Shaders/displayPass.fragment";
  72617. /**
  72618. * DisplayPassPostProcess which produces an output the same as it's input
  72619. */
  72620. export class DisplayPassPostProcess extends PostProcess {
  72621. /**
  72622. * Creates the DisplayPassPostProcess
  72623. * @param name The name of the effect.
  72624. * @param options The required width/height ratio to downsize to before computing the render pass.
  72625. * @param camera The camera to apply the render pass to.
  72626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72627. * @param engine The engine which the post process will be applied. (default: current engine)
  72628. * @param reusable If the post process can be reused on the same frame. (default: false)
  72629. */
  72630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72631. }
  72632. }
  72633. declare module "babylonjs/Shaders/filter.fragment" {
  72634. /** @hidden */
  72635. export var filterPixelShader: {
  72636. name: string;
  72637. shader: string;
  72638. };
  72639. }
  72640. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72641. import { Nullable } from "babylonjs/types";
  72642. import { Matrix } from "babylonjs/Maths/math.vector";
  72643. import { Camera } from "babylonjs/Cameras/camera";
  72644. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72645. import { Engine } from "babylonjs/Engines/engine";
  72646. import "babylonjs/Shaders/filter.fragment";
  72647. /**
  72648. * Applies a kernel filter to the image
  72649. */
  72650. export class FilterPostProcess extends PostProcess {
  72651. /** The matrix to be applied to the image */
  72652. kernelMatrix: Matrix;
  72653. /**
  72654. *
  72655. * @param name The name of the effect.
  72656. * @param kernelMatrix The matrix to be applied to the image
  72657. * @param options The required width/height ratio to downsize to before computing the render pass.
  72658. * @param camera The camera to apply the render pass to.
  72659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72660. * @param engine The engine which the post process will be applied. (default: current engine)
  72661. * @param reusable If the post process can be reused on the same frame. (default: false)
  72662. */
  72663. constructor(name: string,
  72664. /** The matrix to be applied to the image */
  72665. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72666. }
  72667. }
  72668. declare module "babylonjs/Shaders/fxaa.fragment" {
  72669. /** @hidden */
  72670. export var fxaaPixelShader: {
  72671. name: string;
  72672. shader: string;
  72673. };
  72674. }
  72675. declare module "babylonjs/Shaders/fxaa.vertex" {
  72676. /** @hidden */
  72677. export var fxaaVertexShader: {
  72678. name: string;
  72679. shader: string;
  72680. };
  72681. }
  72682. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72683. import { Nullable } from "babylonjs/types";
  72684. import { Camera } from "babylonjs/Cameras/camera";
  72685. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72686. import { Engine } from "babylonjs/Engines/engine";
  72687. import "babylonjs/Shaders/fxaa.fragment";
  72688. import "babylonjs/Shaders/fxaa.vertex";
  72689. /**
  72690. * Fxaa post process
  72691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72692. */
  72693. export class FxaaPostProcess extends PostProcess {
  72694. /** @hidden */
  72695. texelWidth: number;
  72696. /** @hidden */
  72697. texelHeight: number;
  72698. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72699. private _getDefines;
  72700. }
  72701. }
  72702. declare module "babylonjs/Shaders/grain.fragment" {
  72703. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72704. /** @hidden */
  72705. export var grainPixelShader: {
  72706. name: string;
  72707. shader: string;
  72708. };
  72709. }
  72710. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72711. import { Nullable } from "babylonjs/types";
  72712. import { Camera } from "babylonjs/Cameras/camera";
  72713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72714. import { Engine } from "babylonjs/Engines/engine";
  72715. import "babylonjs/Shaders/grain.fragment";
  72716. /**
  72717. * The GrainPostProcess adds noise to the image at mid luminance levels
  72718. */
  72719. export class GrainPostProcess extends PostProcess {
  72720. /**
  72721. * The intensity of the grain added (default: 30)
  72722. */
  72723. intensity: number;
  72724. /**
  72725. * If the grain should be randomized on every frame
  72726. */
  72727. animated: boolean;
  72728. /**
  72729. * Creates a new instance of @see GrainPostProcess
  72730. * @param name The name of the effect.
  72731. * @param options The required width/height ratio to downsize to before computing the render pass.
  72732. * @param camera The camera to apply the render pass to.
  72733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72734. * @param engine The engine which the post process will be applied. (default: current engine)
  72735. * @param reusable If the post process can be reused on the same frame. (default: false)
  72736. * @param textureType Type of textures used when performing the post process. (default: 0)
  72737. * @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)
  72738. */
  72739. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72740. }
  72741. }
  72742. declare module "babylonjs/Shaders/highlights.fragment" {
  72743. /** @hidden */
  72744. export var highlightsPixelShader: {
  72745. name: string;
  72746. shader: string;
  72747. };
  72748. }
  72749. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72750. import { Nullable } from "babylonjs/types";
  72751. import { Camera } from "babylonjs/Cameras/camera";
  72752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72753. import { Engine } from "babylonjs/Engines/engine";
  72754. import "babylonjs/Shaders/highlights.fragment";
  72755. /**
  72756. * Extracts highlights from the image
  72757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72758. */
  72759. export class HighlightsPostProcess extends PostProcess {
  72760. /**
  72761. * Extracts highlights from the image
  72762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72763. * @param name The name of the effect.
  72764. * @param options The required width/height ratio to downsize to before computing the render pass.
  72765. * @param camera The camera to apply the render pass to.
  72766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72767. * @param engine The engine which the post process will be applied. (default: current engine)
  72768. * @param reusable If the post process can be reused on the same frame. (default: false)
  72769. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72770. */
  72771. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72772. }
  72773. }
  72774. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72775. /** @hidden */
  72776. export var mrtFragmentDeclaration: {
  72777. name: string;
  72778. shader: string;
  72779. };
  72780. }
  72781. declare module "babylonjs/Shaders/geometry.fragment" {
  72782. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72783. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72784. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72785. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72786. /** @hidden */
  72787. export var geometryPixelShader: {
  72788. name: string;
  72789. shader: string;
  72790. };
  72791. }
  72792. declare module "babylonjs/Shaders/geometry.vertex" {
  72793. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72795. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72796. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72797. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72798. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72799. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72800. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72801. /** @hidden */
  72802. export var geometryVertexShader: {
  72803. name: string;
  72804. shader: string;
  72805. };
  72806. }
  72807. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72808. import { Matrix } from "babylonjs/Maths/math.vector";
  72809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72810. import { Mesh } from "babylonjs/Meshes/mesh";
  72811. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72812. import { Effect } from "babylonjs/Materials/effect";
  72813. import { Scene } from "babylonjs/scene";
  72814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72815. import "babylonjs/Shaders/geometry.fragment";
  72816. import "babylonjs/Shaders/geometry.vertex";
  72817. /** @hidden */
  72818. interface ISavedTransformationMatrix {
  72819. world: Matrix;
  72820. viewProjection: Matrix;
  72821. }
  72822. /**
  72823. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72824. */
  72825. export class GeometryBufferRenderer {
  72826. /**
  72827. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72828. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72829. */
  72830. static readonly POSITION_TEXTURE_TYPE: number;
  72831. /**
  72832. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72833. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72834. */
  72835. static readonly VELOCITY_TEXTURE_TYPE: number;
  72836. /**
  72837. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72838. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72839. */
  72840. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72841. /**
  72842. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72843. * in order to compute objects velocities when enableVelocity is set to "true"
  72844. * @hidden
  72845. */
  72846. _previousTransformationMatrices: {
  72847. [index: number]: ISavedTransformationMatrix;
  72848. };
  72849. /**
  72850. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72851. * in order to compute objects velocities when enableVelocity is set to "true"
  72852. * @hidden
  72853. */
  72854. _previousBonesTransformationMatrices: {
  72855. [index: number]: Float32Array;
  72856. };
  72857. /**
  72858. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72859. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72860. */
  72861. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72862. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72863. renderTransparentMeshes: boolean;
  72864. private _scene;
  72865. private _resizeObserver;
  72866. private _multiRenderTarget;
  72867. private _ratio;
  72868. private _enablePosition;
  72869. private _enableVelocity;
  72870. private _enableReflectivity;
  72871. private _positionIndex;
  72872. private _velocityIndex;
  72873. private _reflectivityIndex;
  72874. protected _effect: Effect;
  72875. protected _cachedDefines: string;
  72876. /**
  72877. * Set the render list (meshes to be rendered) used in the G buffer.
  72878. */
  72879. set renderList(meshes: Mesh[]);
  72880. /**
  72881. * Gets wether or not G buffer are supported by the running hardware.
  72882. * This requires draw buffer supports
  72883. */
  72884. get isSupported(): boolean;
  72885. /**
  72886. * Returns the index of the given texture type in the G-Buffer textures array
  72887. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72888. * @returns the index of the given texture type in the G-Buffer textures array
  72889. */
  72890. getTextureIndex(textureType: number): number;
  72891. /**
  72892. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72893. */
  72894. get enablePosition(): boolean;
  72895. /**
  72896. * Sets whether or not objects positions are enabled for the G buffer.
  72897. */
  72898. set enablePosition(enable: boolean);
  72899. /**
  72900. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72901. */
  72902. get enableVelocity(): boolean;
  72903. /**
  72904. * Sets wether or not objects velocities are enabled for the G buffer.
  72905. */
  72906. set enableVelocity(enable: boolean);
  72907. /**
  72908. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72909. */
  72910. get enableReflectivity(): boolean;
  72911. /**
  72912. * Sets wether or not objects roughness are enabled for the G buffer.
  72913. */
  72914. set enableReflectivity(enable: boolean);
  72915. /**
  72916. * Gets the scene associated with the buffer.
  72917. */
  72918. get scene(): Scene;
  72919. /**
  72920. * Gets the ratio used by the buffer during its creation.
  72921. * How big is the buffer related to the main canvas.
  72922. */
  72923. get ratio(): number;
  72924. /** @hidden */
  72925. static _SceneComponentInitialization: (scene: Scene) => void;
  72926. /**
  72927. * Creates a new G Buffer for the scene
  72928. * @param scene The scene the buffer belongs to
  72929. * @param ratio How big is the buffer related to the main canvas.
  72930. */
  72931. constructor(scene: Scene, ratio?: number);
  72932. /**
  72933. * Checks wether everything is ready to render a submesh to the G buffer.
  72934. * @param subMesh the submesh to check readiness for
  72935. * @param useInstances is the mesh drawn using instance or not
  72936. * @returns true if ready otherwise false
  72937. */
  72938. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72939. /**
  72940. * Gets the current underlying G Buffer.
  72941. * @returns the buffer
  72942. */
  72943. getGBuffer(): MultiRenderTarget;
  72944. /**
  72945. * Gets the number of samples used to render the buffer (anti aliasing).
  72946. */
  72947. get samples(): number;
  72948. /**
  72949. * Sets the number of samples used to render the buffer (anti aliasing).
  72950. */
  72951. set samples(value: number);
  72952. /**
  72953. * Disposes the renderer and frees up associated resources.
  72954. */
  72955. dispose(): void;
  72956. protected _createRenderTargets(): void;
  72957. private _copyBonesTransformationMatrices;
  72958. }
  72959. }
  72960. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72961. import { Nullable } from "babylonjs/types";
  72962. import { Scene } from "babylonjs/scene";
  72963. import { ISceneComponent } from "babylonjs/sceneComponent";
  72964. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72965. module "babylonjs/scene" {
  72966. interface Scene {
  72967. /** @hidden (Backing field) */
  72968. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72969. /**
  72970. * Gets or Sets the current geometry buffer associated to the scene.
  72971. */
  72972. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72973. /**
  72974. * Enables a GeometryBufferRender and associates it with the scene
  72975. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72976. * @returns the GeometryBufferRenderer
  72977. */
  72978. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72979. /**
  72980. * Disables the GeometryBufferRender associated with the scene
  72981. */
  72982. disableGeometryBufferRenderer(): void;
  72983. }
  72984. }
  72985. /**
  72986. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72987. * in several rendering techniques.
  72988. */
  72989. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72990. /**
  72991. * The component name helpful to identify the component in the list of scene components.
  72992. */
  72993. readonly name: string;
  72994. /**
  72995. * The scene the component belongs to.
  72996. */
  72997. scene: Scene;
  72998. /**
  72999. * Creates a new instance of the component for the given scene
  73000. * @param scene Defines the scene to register the component in
  73001. */
  73002. constructor(scene: Scene);
  73003. /**
  73004. * Registers the component in a given scene
  73005. */
  73006. register(): void;
  73007. /**
  73008. * Rebuilds the elements related to this component in case of
  73009. * context lost for instance.
  73010. */
  73011. rebuild(): void;
  73012. /**
  73013. * Disposes the component and the associated ressources
  73014. */
  73015. dispose(): void;
  73016. private _gatherRenderTargets;
  73017. }
  73018. }
  73019. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73020. /** @hidden */
  73021. export var motionBlurPixelShader: {
  73022. name: string;
  73023. shader: string;
  73024. };
  73025. }
  73026. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73027. import { Nullable } from "babylonjs/types";
  73028. import { Camera } from "babylonjs/Cameras/camera";
  73029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73030. import { Scene } from "babylonjs/scene";
  73031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73032. import "babylonjs/Animations/animatable";
  73033. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73034. import "babylonjs/Shaders/motionBlur.fragment";
  73035. import { Engine } from "babylonjs/Engines/engine";
  73036. /**
  73037. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73038. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73039. * As an example, all you have to do is to create the post-process:
  73040. * var mb = new BABYLON.MotionBlurPostProcess(
  73041. * 'mb', // The name of the effect.
  73042. * scene, // The scene containing the objects to blur according to their velocity.
  73043. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73044. * camera // The camera to apply the render pass to.
  73045. * );
  73046. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73047. */
  73048. export class MotionBlurPostProcess extends PostProcess {
  73049. /**
  73050. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73051. */
  73052. motionStrength: number;
  73053. /**
  73054. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73055. */
  73056. get motionBlurSamples(): number;
  73057. /**
  73058. * Sets the number of iterations to be used for motion blur quality
  73059. */
  73060. set motionBlurSamples(samples: number);
  73061. private _motionBlurSamples;
  73062. private _geometryBufferRenderer;
  73063. /**
  73064. * Creates a new instance MotionBlurPostProcess
  73065. * @param name The name of the effect.
  73066. * @param scene The scene containing the objects to blur according to their velocity.
  73067. * @param options The required width/height ratio to downsize to before computing the render pass.
  73068. * @param camera The camera to apply the render pass to.
  73069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73070. * @param engine The engine which the post process will be applied. (default: current engine)
  73071. * @param reusable If the post process can be reused on the same frame. (default: false)
  73072. * @param textureType Type of textures used when performing the post process. (default: 0)
  73073. * @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)
  73074. */
  73075. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73076. /**
  73077. * Excludes the given skinned mesh from computing bones velocities.
  73078. * 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.
  73079. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73080. */
  73081. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73082. /**
  73083. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73084. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73085. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73086. */
  73087. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73088. /**
  73089. * Disposes the post process.
  73090. * @param camera The camera to dispose the post process on.
  73091. */
  73092. dispose(camera?: Camera): void;
  73093. }
  73094. }
  73095. declare module "babylonjs/Shaders/refraction.fragment" {
  73096. /** @hidden */
  73097. export var refractionPixelShader: {
  73098. name: string;
  73099. shader: string;
  73100. };
  73101. }
  73102. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73103. import { Color3 } from "babylonjs/Maths/math.color";
  73104. import { Camera } from "babylonjs/Cameras/camera";
  73105. import { Texture } from "babylonjs/Materials/Textures/texture";
  73106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73107. import { Engine } from "babylonjs/Engines/engine";
  73108. import "babylonjs/Shaders/refraction.fragment";
  73109. /**
  73110. * Post process which applies a refractin texture
  73111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73112. */
  73113. export class RefractionPostProcess extends PostProcess {
  73114. /** the base color of the refraction (used to taint the rendering) */
  73115. color: Color3;
  73116. /** simulated refraction depth */
  73117. depth: number;
  73118. /** the coefficient of the base color (0 to remove base color tainting) */
  73119. colorLevel: number;
  73120. private _refTexture;
  73121. private _ownRefractionTexture;
  73122. /**
  73123. * Gets or sets the refraction texture
  73124. * Please note that you are responsible for disposing the texture if you set it manually
  73125. */
  73126. get refractionTexture(): Texture;
  73127. set refractionTexture(value: Texture);
  73128. /**
  73129. * Initializes the RefractionPostProcess
  73130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73131. * @param name The name of the effect.
  73132. * @param refractionTextureUrl Url of the refraction texture to use
  73133. * @param color the base color of the refraction (used to taint the rendering)
  73134. * @param depth simulated refraction depth
  73135. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73136. * @param camera The camera to apply the render pass to.
  73137. * @param options The required width/height ratio to downsize to before computing the render pass.
  73138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73139. * @param engine The engine which the post process will be applied. (default: current engine)
  73140. * @param reusable If the post process can be reused on the same frame. (default: false)
  73141. */
  73142. constructor(name: string, refractionTextureUrl: string,
  73143. /** the base color of the refraction (used to taint the rendering) */
  73144. color: Color3,
  73145. /** simulated refraction depth */
  73146. depth: number,
  73147. /** the coefficient of the base color (0 to remove base color tainting) */
  73148. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73149. /**
  73150. * Disposes of the post process
  73151. * @param camera Camera to dispose post process on
  73152. */
  73153. dispose(camera: Camera): void;
  73154. }
  73155. }
  73156. declare module "babylonjs/Shaders/sharpen.fragment" {
  73157. /** @hidden */
  73158. export var sharpenPixelShader: {
  73159. name: string;
  73160. shader: string;
  73161. };
  73162. }
  73163. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73164. import { Nullable } from "babylonjs/types";
  73165. import { Camera } from "babylonjs/Cameras/camera";
  73166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73167. import "babylonjs/Shaders/sharpen.fragment";
  73168. import { Engine } from "babylonjs/Engines/engine";
  73169. /**
  73170. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73171. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73172. */
  73173. export class SharpenPostProcess extends PostProcess {
  73174. /**
  73175. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73176. */
  73177. colorAmount: number;
  73178. /**
  73179. * How much sharpness should be applied (default: 0.3)
  73180. */
  73181. edgeAmount: number;
  73182. /**
  73183. * Creates a new instance ConvolutionPostProcess
  73184. * @param name The name of the effect.
  73185. * @param options The required width/height ratio to downsize to before computing the render pass.
  73186. * @param camera The camera to apply the render pass to.
  73187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73188. * @param engine The engine which the post process will be applied. (default: current engine)
  73189. * @param reusable If the post process can be reused on the same frame. (default: false)
  73190. * @param textureType Type of textures used when performing the post process. (default: 0)
  73191. * @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)
  73192. */
  73193. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73194. }
  73195. }
  73196. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73197. import { Nullable } from "babylonjs/types";
  73198. import { Camera } from "babylonjs/Cameras/camera";
  73199. import { Engine } from "babylonjs/Engines/engine";
  73200. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73201. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73202. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73203. /**
  73204. * PostProcessRenderPipeline
  73205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73206. */
  73207. export class PostProcessRenderPipeline {
  73208. private engine;
  73209. private _renderEffects;
  73210. private _renderEffectsForIsolatedPass;
  73211. /**
  73212. * List of inspectable custom properties (used by the Inspector)
  73213. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73214. */
  73215. inspectableCustomProperties: IInspectable[];
  73216. /**
  73217. * @hidden
  73218. */
  73219. protected _cameras: Camera[];
  73220. /** @hidden */
  73221. _name: string;
  73222. /**
  73223. * Gets pipeline name
  73224. */
  73225. get name(): string;
  73226. /** Gets the list of attached cameras */
  73227. get cameras(): Camera[];
  73228. /**
  73229. * Initializes a PostProcessRenderPipeline
  73230. * @param engine engine to add the pipeline to
  73231. * @param name name of the pipeline
  73232. */
  73233. constructor(engine: Engine, name: string);
  73234. /**
  73235. * Gets the class name
  73236. * @returns "PostProcessRenderPipeline"
  73237. */
  73238. getClassName(): string;
  73239. /**
  73240. * If all the render effects in the pipeline are supported
  73241. */
  73242. get isSupported(): boolean;
  73243. /**
  73244. * Adds an effect to the pipeline
  73245. * @param renderEffect the effect to add
  73246. */
  73247. addEffect(renderEffect: PostProcessRenderEffect): void;
  73248. /** @hidden */
  73249. _rebuild(): void;
  73250. /** @hidden */
  73251. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73252. /** @hidden */
  73253. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73254. /** @hidden */
  73255. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73256. /** @hidden */
  73257. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73258. /** @hidden */
  73259. _attachCameras(cameras: Camera, unique: boolean): void;
  73260. /** @hidden */
  73261. _attachCameras(cameras: Camera[], unique: boolean): void;
  73262. /** @hidden */
  73263. _detachCameras(cameras: Camera): void;
  73264. /** @hidden */
  73265. _detachCameras(cameras: Nullable<Camera[]>): void;
  73266. /** @hidden */
  73267. _update(): void;
  73268. /** @hidden */
  73269. _reset(): void;
  73270. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73271. /**
  73272. * Sets the required values to the prepass renderer.
  73273. * @param prePassRenderer defines the prepass renderer to setup.
  73274. * @returns true if the pre pass is needed.
  73275. */
  73276. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73277. /**
  73278. * Disposes of the pipeline
  73279. */
  73280. dispose(): void;
  73281. }
  73282. }
  73283. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73284. import { Camera } from "babylonjs/Cameras/camera";
  73285. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73286. /**
  73287. * PostProcessRenderPipelineManager class
  73288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73289. */
  73290. export class PostProcessRenderPipelineManager {
  73291. private _renderPipelines;
  73292. /**
  73293. * Initializes a PostProcessRenderPipelineManager
  73294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73295. */
  73296. constructor();
  73297. /**
  73298. * Gets the list of supported render pipelines
  73299. */
  73300. get supportedPipelines(): PostProcessRenderPipeline[];
  73301. /**
  73302. * Adds a pipeline to the manager
  73303. * @param renderPipeline The pipeline to add
  73304. */
  73305. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73306. /**
  73307. * Attaches a camera to the pipeline
  73308. * @param renderPipelineName The name of the pipeline to attach to
  73309. * @param cameras the camera to attach
  73310. * @param unique if the camera can be attached multiple times to the pipeline
  73311. */
  73312. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73313. /**
  73314. * Detaches a camera from the pipeline
  73315. * @param renderPipelineName The name of the pipeline to detach from
  73316. * @param cameras the camera to detach
  73317. */
  73318. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73319. /**
  73320. * Enables an effect by name on a pipeline
  73321. * @param renderPipelineName the name of the pipeline to enable the effect in
  73322. * @param renderEffectName the name of the effect to enable
  73323. * @param cameras the cameras that the effect should be enabled on
  73324. */
  73325. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73326. /**
  73327. * Disables an effect by name on a pipeline
  73328. * @param renderPipelineName the name of the pipeline to disable the effect in
  73329. * @param renderEffectName the name of the effect to disable
  73330. * @param cameras the cameras that the effect should be disabled on
  73331. */
  73332. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73333. /**
  73334. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73335. */
  73336. update(): void;
  73337. /** @hidden */
  73338. _rebuild(): void;
  73339. /**
  73340. * Disposes of the manager and pipelines
  73341. */
  73342. dispose(): void;
  73343. }
  73344. }
  73345. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73346. import { ISceneComponent } from "babylonjs/sceneComponent";
  73347. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73348. import { Scene } from "babylonjs/scene";
  73349. module "babylonjs/scene" {
  73350. interface Scene {
  73351. /** @hidden (Backing field) */
  73352. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73353. /**
  73354. * Gets the postprocess render pipeline manager
  73355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73356. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73357. */
  73358. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73359. }
  73360. }
  73361. /**
  73362. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73363. */
  73364. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73365. /**
  73366. * The component name helpfull to identify the component in the list of scene components.
  73367. */
  73368. readonly name: string;
  73369. /**
  73370. * The scene the component belongs to.
  73371. */
  73372. scene: Scene;
  73373. /**
  73374. * Creates a new instance of the component for the given scene
  73375. * @param scene Defines the scene to register the component in
  73376. */
  73377. constructor(scene: Scene);
  73378. /**
  73379. * Registers the component in a given scene
  73380. */
  73381. register(): void;
  73382. /**
  73383. * Rebuilds the elements related to this component in case of
  73384. * context lost for instance.
  73385. */
  73386. rebuild(): void;
  73387. /**
  73388. * Disposes the component and the associated ressources
  73389. */
  73390. dispose(): void;
  73391. private _gatherRenderTargets;
  73392. }
  73393. }
  73394. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73395. import { Nullable } from "babylonjs/types";
  73396. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73397. import { Camera } from "babylonjs/Cameras/camera";
  73398. import { IDisposable } from "babylonjs/scene";
  73399. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73400. import { Scene } from "babylonjs/scene";
  73401. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73402. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73403. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73404. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73405. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73406. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73407. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73408. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73409. import { Animation } from "babylonjs/Animations/animation";
  73410. /**
  73411. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73412. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73413. */
  73414. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73415. private _scene;
  73416. private _camerasToBeAttached;
  73417. /**
  73418. * ID of the sharpen post process,
  73419. */
  73420. private readonly SharpenPostProcessId;
  73421. /**
  73422. * @ignore
  73423. * ID of the image processing post process;
  73424. */
  73425. readonly ImageProcessingPostProcessId: string;
  73426. /**
  73427. * @ignore
  73428. * ID of the Fast Approximate Anti-Aliasing post process;
  73429. */
  73430. readonly FxaaPostProcessId: string;
  73431. /**
  73432. * ID of the chromatic aberration post process,
  73433. */
  73434. private readonly ChromaticAberrationPostProcessId;
  73435. /**
  73436. * ID of the grain post process
  73437. */
  73438. private readonly GrainPostProcessId;
  73439. /**
  73440. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73441. */
  73442. sharpen: SharpenPostProcess;
  73443. private _sharpenEffect;
  73444. private bloom;
  73445. /**
  73446. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73447. */
  73448. depthOfField: DepthOfFieldEffect;
  73449. /**
  73450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73451. */
  73452. fxaa: FxaaPostProcess;
  73453. /**
  73454. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73455. */
  73456. imageProcessing: ImageProcessingPostProcess;
  73457. /**
  73458. * Chromatic aberration post process which will shift rgb colors in the image
  73459. */
  73460. chromaticAberration: ChromaticAberrationPostProcess;
  73461. private _chromaticAberrationEffect;
  73462. /**
  73463. * Grain post process which add noise to the image
  73464. */
  73465. grain: GrainPostProcess;
  73466. private _grainEffect;
  73467. /**
  73468. * Glow post process which adds a glow to emissive areas of the image
  73469. */
  73470. private _glowLayer;
  73471. /**
  73472. * Animations which can be used to tweak settings over a period of time
  73473. */
  73474. animations: Animation[];
  73475. private _imageProcessingConfigurationObserver;
  73476. private _sharpenEnabled;
  73477. private _bloomEnabled;
  73478. private _depthOfFieldEnabled;
  73479. private _depthOfFieldBlurLevel;
  73480. private _fxaaEnabled;
  73481. private _imageProcessingEnabled;
  73482. private _defaultPipelineTextureType;
  73483. private _bloomScale;
  73484. private _chromaticAberrationEnabled;
  73485. private _grainEnabled;
  73486. private _buildAllowed;
  73487. /**
  73488. * Gets active scene
  73489. */
  73490. get scene(): Scene;
  73491. /**
  73492. * Enable or disable the sharpen process from the pipeline
  73493. */
  73494. set sharpenEnabled(enabled: boolean);
  73495. get sharpenEnabled(): boolean;
  73496. private _resizeObserver;
  73497. private _hardwareScaleLevel;
  73498. private _bloomKernel;
  73499. /**
  73500. * Specifies the size of the bloom blur kernel, relative to the final output size
  73501. */
  73502. get bloomKernel(): number;
  73503. set bloomKernel(value: number);
  73504. /**
  73505. * Specifies the weight of the bloom in the final rendering
  73506. */
  73507. private _bloomWeight;
  73508. /**
  73509. * Specifies the luma threshold for the area that will be blurred by the bloom
  73510. */
  73511. private _bloomThreshold;
  73512. private _hdr;
  73513. /**
  73514. * The strength of the bloom.
  73515. */
  73516. set bloomWeight(value: number);
  73517. get bloomWeight(): number;
  73518. /**
  73519. * The strength of the bloom.
  73520. */
  73521. set bloomThreshold(value: number);
  73522. get bloomThreshold(): number;
  73523. /**
  73524. * The scale of the bloom, lower value will provide better performance.
  73525. */
  73526. set bloomScale(value: number);
  73527. get bloomScale(): number;
  73528. /**
  73529. * Enable or disable the bloom from the pipeline
  73530. */
  73531. set bloomEnabled(enabled: boolean);
  73532. get bloomEnabled(): boolean;
  73533. private _rebuildBloom;
  73534. /**
  73535. * If the depth of field is enabled.
  73536. */
  73537. get depthOfFieldEnabled(): boolean;
  73538. set depthOfFieldEnabled(enabled: boolean);
  73539. /**
  73540. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73541. */
  73542. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73543. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73544. /**
  73545. * If the anti aliasing is enabled.
  73546. */
  73547. set fxaaEnabled(enabled: boolean);
  73548. get fxaaEnabled(): boolean;
  73549. private _samples;
  73550. /**
  73551. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73552. */
  73553. set samples(sampleCount: number);
  73554. get samples(): number;
  73555. /**
  73556. * If image processing is enabled.
  73557. */
  73558. set imageProcessingEnabled(enabled: boolean);
  73559. get imageProcessingEnabled(): boolean;
  73560. /**
  73561. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73562. */
  73563. set glowLayerEnabled(enabled: boolean);
  73564. get glowLayerEnabled(): boolean;
  73565. /**
  73566. * Gets the glow layer (or null if not defined)
  73567. */
  73568. get glowLayer(): Nullable<GlowLayer>;
  73569. /**
  73570. * Enable or disable the chromaticAberration process from the pipeline
  73571. */
  73572. set chromaticAberrationEnabled(enabled: boolean);
  73573. get chromaticAberrationEnabled(): boolean;
  73574. /**
  73575. * Enable or disable the grain process from the pipeline
  73576. */
  73577. set grainEnabled(enabled: boolean);
  73578. get grainEnabled(): boolean;
  73579. /**
  73580. * @constructor
  73581. * @param name - The rendering pipeline name (default: "")
  73582. * @param hdr - If high dynamic range textures should be used (default: true)
  73583. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73584. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73585. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73586. */
  73587. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73588. /**
  73589. * Get the class name
  73590. * @returns "DefaultRenderingPipeline"
  73591. */
  73592. getClassName(): string;
  73593. /**
  73594. * Force the compilation of the entire pipeline.
  73595. */
  73596. prepare(): void;
  73597. private _hasCleared;
  73598. private _prevPostProcess;
  73599. private _prevPrevPostProcess;
  73600. private _setAutoClearAndTextureSharing;
  73601. private _depthOfFieldSceneObserver;
  73602. private _buildPipeline;
  73603. private _disposePostProcesses;
  73604. /**
  73605. * Adds a camera to the pipeline
  73606. * @param camera the camera to be added
  73607. */
  73608. addCamera(camera: Camera): void;
  73609. /**
  73610. * Removes a camera from the pipeline
  73611. * @param camera the camera to remove
  73612. */
  73613. removeCamera(camera: Camera): void;
  73614. /**
  73615. * Dispose of the pipeline and stop all post processes
  73616. */
  73617. dispose(): void;
  73618. /**
  73619. * Serialize the rendering pipeline (Used when exporting)
  73620. * @returns the serialized object
  73621. */
  73622. serialize(): any;
  73623. /**
  73624. * Parse the serialized pipeline
  73625. * @param source Source pipeline.
  73626. * @param scene The scene to load the pipeline to.
  73627. * @param rootUrl The URL of the serialized pipeline.
  73628. * @returns An instantiated pipeline from the serialized object.
  73629. */
  73630. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73631. }
  73632. }
  73633. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73634. /** @hidden */
  73635. export var lensHighlightsPixelShader: {
  73636. name: string;
  73637. shader: string;
  73638. };
  73639. }
  73640. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73641. /** @hidden */
  73642. export var depthOfFieldPixelShader: {
  73643. name: string;
  73644. shader: string;
  73645. };
  73646. }
  73647. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73648. import { Camera } from "babylonjs/Cameras/camera";
  73649. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73650. import { Scene } from "babylonjs/scene";
  73651. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73652. import "babylonjs/Shaders/chromaticAberration.fragment";
  73653. import "babylonjs/Shaders/lensHighlights.fragment";
  73654. import "babylonjs/Shaders/depthOfField.fragment";
  73655. /**
  73656. * BABYLON.JS Chromatic Aberration GLSL Shader
  73657. * Author: Olivier Guyot
  73658. * Separates very slightly R, G and B colors on the edges of the screen
  73659. * Inspired by Francois Tarlier & Martins Upitis
  73660. */
  73661. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73662. /**
  73663. * @ignore
  73664. * The chromatic aberration PostProcess id in the pipeline
  73665. */
  73666. LensChromaticAberrationEffect: string;
  73667. /**
  73668. * @ignore
  73669. * The highlights enhancing PostProcess id in the pipeline
  73670. */
  73671. HighlightsEnhancingEffect: string;
  73672. /**
  73673. * @ignore
  73674. * The depth-of-field PostProcess id in the pipeline
  73675. */
  73676. LensDepthOfFieldEffect: string;
  73677. private _scene;
  73678. private _depthTexture;
  73679. private _grainTexture;
  73680. private _chromaticAberrationPostProcess;
  73681. private _highlightsPostProcess;
  73682. private _depthOfFieldPostProcess;
  73683. private _edgeBlur;
  73684. private _grainAmount;
  73685. private _chromaticAberration;
  73686. private _distortion;
  73687. private _highlightsGain;
  73688. private _highlightsThreshold;
  73689. private _dofDistance;
  73690. private _dofAperture;
  73691. private _dofDarken;
  73692. private _dofPentagon;
  73693. private _blurNoise;
  73694. /**
  73695. * @constructor
  73696. *
  73697. * Effect parameters are as follow:
  73698. * {
  73699. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73700. * edge_blur: number; // from 0 to x (1 for realism)
  73701. * distortion: number; // from 0 to x (1 for realism)
  73702. * grain_amount: number; // from 0 to 1
  73703. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73704. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73705. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73706. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73707. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73708. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73709. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73710. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73711. * }
  73712. * Note: if an effect parameter is unset, effect is disabled
  73713. *
  73714. * @param name The rendering pipeline name
  73715. * @param parameters - An object containing all parameters (see above)
  73716. * @param scene The scene linked to this pipeline
  73717. * @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)
  73718. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73719. */
  73720. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73721. /**
  73722. * Get the class name
  73723. * @returns "LensRenderingPipeline"
  73724. */
  73725. getClassName(): string;
  73726. /**
  73727. * Gets associated scene
  73728. */
  73729. get scene(): Scene;
  73730. /**
  73731. * Gets or sets the edge blur
  73732. */
  73733. get edgeBlur(): number;
  73734. set edgeBlur(value: number);
  73735. /**
  73736. * Gets or sets the grain amount
  73737. */
  73738. get grainAmount(): number;
  73739. set grainAmount(value: number);
  73740. /**
  73741. * Gets or sets the chromatic aberration amount
  73742. */
  73743. get chromaticAberration(): number;
  73744. set chromaticAberration(value: number);
  73745. /**
  73746. * Gets or sets the depth of field aperture
  73747. */
  73748. get dofAperture(): number;
  73749. set dofAperture(value: number);
  73750. /**
  73751. * Gets or sets the edge distortion
  73752. */
  73753. get edgeDistortion(): number;
  73754. set edgeDistortion(value: number);
  73755. /**
  73756. * Gets or sets the depth of field distortion
  73757. */
  73758. get dofDistortion(): number;
  73759. set dofDistortion(value: number);
  73760. /**
  73761. * Gets or sets the darken out of focus amount
  73762. */
  73763. get darkenOutOfFocus(): number;
  73764. set darkenOutOfFocus(value: number);
  73765. /**
  73766. * Gets or sets a boolean indicating if blur noise is enabled
  73767. */
  73768. get blurNoise(): boolean;
  73769. set blurNoise(value: boolean);
  73770. /**
  73771. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73772. */
  73773. get pentagonBokeh(): boolean;
  73774. set pentagonBokeh(value: boolean);
  73775. /**
  73776. * Gets or sets the highlight grain amount
  73777. */
  73778. get highlightsGain(): number;
  73779. set highlightsGain(value: number);
  73780. /**
  73781. * Gets or sets the highlight threshold
  73782. */
  73783. get highlightsThreshold(): number;
  73784. set highlightsThreshold(value: number);
  73785. /**
  73786. * Sets the amount of blur at the edges
  73787. * @param amount blur amount
  73788. */
  73789. setEdgeBlur(amount: number): void;
  73790. /**
  73791. * Sets edge blur to 0
  73792. */
  73793. disableEdgeBlur(): void;
  73794. /**
  73795. * Sets the amout of grain
  73796. * @param amount Amount of grain
  73797. */
  73798. setGrainAmount(amount: number): void;
  73799. /**
  73800. * Set grain amount to 0
  73801. */
  73802. disableGrain(): void;
  73803. /**
  73804. * Sets the chromatic aberration amount
  73805. * @param amount amount of chromatic aberration
  73806. */
  73807. setChromaticAberration(amount: number): void;
  73808. /**
  73809. * Sets chromatic aberration amount to 0
  73810. */
  73811. disableChromaticAberration(): void;
  73812. /**
  73813. * Sets the EdgeDistortion amount
  73814. * @param amount amount of EdgeDistortion
  73815. */
  73816. setEdgeDistortion(amount: number): void;
  73817. /**
  73818. * Sets edge distortion to 0
  73819. */
  73820. disableEdgeDistortion(): void;
  73821. /**
  73822. * Sets the FocusDistance amount
  73823. * @param amount amount of FocusDistance
  73824. */
  73825. setFocusDistance(amount: number): void;
  73826. /**
  73827. * Disables depth of field
  73828. */
  73829. disableDepthOfField(): void;
  73830. /**
  73831. * Sets the Aperture amount
  73832. * @param amount amount of Aperture
  73833. */
  73834. setAperture(amount: number): void;
  73835. /**
  73836. * Sets the DarkenOutOfFocus amount
  73837. * @param amount amount of DarkenOutOfFocus
  73838. */
  73839. setDarkenOutOfFocus(amount: number): void;
  73840. private _pentagonBokehIsEnabled;
  73841. /**
  73842. * Creates a pentagon bokeh effect
  73843. */
  73844. enablePentagonBokeh(): void;
  73845. /**
  73846. * Disables the pentagon bokeh effect
  73847. */
  73848. disablePentagonBokeh(): void;
  73849. /**
  73850. * Enables noise blur
  73851. */
  73852. enableNoiseBlur(): void;
  73853. /**
  73854. * Disables noise blur
  73855. */
  73856. disableNoiseBlur(): void;
  73857. /**
  73858. * Sets the HighlightsGain amount
  73859. * @param amount amount of HighlightsGain
  73860. */
  73861. setHighlightsGain(amount: number): void;
  73862. /**
  73863. * Sets the HighlightsThreshold amount
  73864. * @param amount amount of HighlightsThreshold
  73865. */
  73866. setHighlightsThreshold(amount: number): void;
  73867. /**
  73868. * Disables highlights
  73869. */
  73870. disableHighlights(): void;
  73871. /**
  73872. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73873. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73874. */
  73875. dispose(disableDepthRender?: boolean): void;
  73876. private _createChromaticAberrationPostProcess;
  73877. private _createHighlightsPostProcess;
  73878. private _createDepthOfFieldPostProcess;
  73879. private _createGrainTexture;
  73880. }
  73881. }
  73882. declare module "babylonjs/Shaders/ssao2.fragment" {
  73883. /** @hidden */
  73884. export var ssao2PixelShader: {
  73885. name: string;
  73886. shader: string;
  73887. };
  73888. }
  73889. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73890. /** @hidden */
  73891. export var ssaoCombinePixelShader: {
  73892. name: string;
  73893. shader: string;
  73894. };
  73895. }
  73896. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73897. import { Camera } from "babylonjs/Cameras/camera";
  73898. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73899. import { Scene } from "babylonjs/scene";
  73900. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73901. import "babylonjs/Shaders/ssao2.fragment";
  73902. import "babylonjs/Shaders/ssaoCombine.fragment";
  73903. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73904. /**
  73905. * Render pipeline to produce ssao effect
  73906. */
  73907. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73908. /**
  73909. * @ignore
  73910. * The PassPostProcess id in the pipeline that contains the original scene color
  73911. */
  73912. SSAOOriginalSceneColorEffect: string;
  73913. /**
  73914. * @ignore
  73915. * The SSAO PostProcess id in the pipeline
  73916. */
  73917. SSAORenderEffect: string;
  73918. /**
  73919. * @ignore
  73920. * The horizontal blur PostProcess id in the pipeline
  73921. */
  73922. SSAOBlurHRenderEffect: string;
  73923. /**
  73924. * @ignore
  73925. * The vertical blur PostProcess id in the pipeline
  73926. */
  73927. SSAOBlurVRenderEffect: string;
  73928. /**
  73929. * @ignore
  73930. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73931. */
  73932. SSAOCombineRenderEffect: string;
  73933. /**
  73934. * The output strength of the SSAO post-process. Default value is 1.0.
  73935. */
  73936. totalStrength: number;
  73937. /**
  73938. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73939. */
  73940. maxZ: number;
  73941. /**
  73942. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73943. */
  73944. minZAspect: number;
  73945. private _samples;
  73946. /**
  73947. * Number of samples used for the SSAO calculations. Default value is 8
  73948. */
  73949. set samples(n: number);
  73950. get samples(): number;
  73951. private _textureSamples;
  73952. /**
  73953. * Number of samples to use for antialiasing
  73954. */
  73955. set textureSamples(n: number);
  73956. get textureSamples(): number;
  73957. /**
  73958. * Force rendering the geometry through geometry buffer
  73959. */
  73960. private _forceGeometryBuffer;
  73961. /**
  73962. * Ratio object used for SSAO ratio and blur ratio
  73963. */
  73964. private _ratio;
  73965. /**
  73966. * Dynamically generated sphere sampler.
  73967. */
  73968. private _sampleSphere;
  73969. /**
  73970. * Blur filter offsets
  73971. */
  73972. private _samplerOffsets;
  73973. private _expensiveBlur;
  73974. /**
  73975. * If bilateral blur should be used
  73976. */
  73977. set expensiveBlur(b: boolean);
  73978. get expensiveBlur(): boolean;
  73979. /**
  73980. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73981. */
  73982. radius: number;
  73983. /**
  73984. * The base color of the SSAO post-process
  73985. * The final result is "base + ssao" between [0, 1]
  73986. */
  73987. base: number;
  73988. /**
  73989. * Support test.
  73990. */
  73991. static get IsSupported(): boolean;
  73992. private _scene;
  73993. private _randomTexture;
  73994. private _originalColorPostProcess;
  73995. private _ssaoPostProcess;
  73996. private _blurHPostProcess;
  73997. private _blurVPostProcess;
  73998. private _ssaoCombinePostProcess;
  73999. private _prePassRenderer;
  74000. /**
  74001. * Gets active scene
  74002. */
  74003. get scene(): Scene;
  74004. /**
  74005. * @constructor
  74006. * @param name The rendering pipeline name
  74007. * @param scene The scene linked to this pipeline
  74008. * @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 }
  74009. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74010. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74011. */
  74012. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74013. /**
  74014. * Get the class name
  74015. * @returns "SSAO2RenderingPipeline"
  74016. */
  74017. getClassName(): string;
  74018. /**
  74019. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74020. */
  74021. dispose(disableGeometryBufferRenderer?: boolean): void;
  74022. private _createBlurPostProcess;
  74023. /** @hidden */
  74024. _rebuild(): void;
  74025. private _bits;
  74026. private _radicalInverse_VdC;
  74027. private _hammersley;
  74028. private _hemisphereSample_uniform;
  74029. private _generateHemisphere;
  74030. private _getDefinesForSSAO;
  74031. private _createSSAOPostProcess;
  74032. private _createSSAOCombinePostProcess;
  74033. private _createRandomTexture;
  74034. /**
  74035. * Serialize the rendering pipeline (Used when exporting)
  74036. * @returns the serialized object
  74037. */
  74038. serialize(): any;
  74039. /**
  74040. * Parse the serialized pipeline
  74041. * @param source Source pipeline.
  74042. * @param scene The scene to load the pipeline to.
  74043. * @param rootUrl The URL of the serialized pipeline.
  74044. * @returns An instantiated pipeline from the serialized object.
  74045. */
  74046. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74047. /**
  74048. * Sets the required values to the prepass renderer.
  74049. * @param prePassRenderer defines the prepass renderer to setup
  74050. * @returns true if the pre pass is needed.
  74051. */
  74052. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74053. }
  74054. }
  74055. declare module "babylonjs/Shaders/ssao.fragment" {
  74056. /** @hidden */
  74057. export var ssaoPixelShader: {
  74058. name: string;
  74059. shader: string;
  74060. };
  74061. }
  74062. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74063. import { Camera } from "babylonjs/Cameras/camera";
  74064. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74065. import { Scene } from "babylonjs/scene";
  74066. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74067. import "babylonjs/Shaders/ssao.fragment";
  74068. import "babylonjs/Shaders/ssaoCombine.fragment";
  74069. /**
  74070. * Render pipeline to produce ssao effect
  74071. */
  74072. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74073. /**
  74074. * @ignore
  74075. * The PassPostProcess id in the pipeline that contains the original scene color
  74076. */
  74077. SSAOOriginalSceneColorEffect: string;
  74078. /**
  74079. * @ignore
  74080. * The SSAO PostProcess id in the pipeline
  74081. */
  74082. SSAORenderEffect: string;
  74083. /**
  74084. * @ignore
  74085. * The horizontal blur PostProcess id in the pipeline
  74086. */
  74087. SSAOBlurHRenderEffect: string;
  74088. /**
  74089. * @ignore
  74090. * The vertical blur PostProcess id in the pipeline
  74091. */
  74092. SSAOBlurVRenderEffect: string;
  74093. /**
  74094. * @ignore
  74095. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74096. */
  74097. SSAOCombineRenderEffect: string;
  74098. /**
  74099. * The output strength of the SSAO post-process. Default value is 1.0.
  74100. */
  74101. totalStrength: number;
  74102. /**
  74103. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74104. */
  74105. radius: number;
  74106. /**
  74107. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74108. * Must not be equal to fallOff and superior to fallOff.
  74109. * Default value is 0.0075
  74110. */
  74111. area: number;
  74112. /**
  74113. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74114. * Must not be equal to area and inferior to area.
  74115. * Default value is 0.000001
  74116. */
  74117. fallOff: number;
  74118. /**
  74119. * The base color of the SSAO post-process
  74120. * The final result is "base + ssao" between [0, 1]
  74121. */
  74122. base: number;
  74123. private _scene;
  74124. private _depthTexture;
  74125. private _randomTexture;
  74126. private _originalColorPostProcess;
  74127. private _ssaoPostProcess;
  74128. private _blurHPostProcess;
  74129. private _blurVPostProcess;
  74130. private _ssaoCombinePostProcess;
  74131. private _firstUpdate;
  74132. /**
  74133. * Gets active scene
  74134. */
  74135. get scene(): Scene;
  74136. /**
  74137. * @constructor
  74138. * @param name - The rendering pipeline name
  74139. * @param scene - The scene linked to this pipeline
  74140. * @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 }
  74141. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74142. */
  74143. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74144. /**
  74145. * Get the class name
  74146. * @returns "SSAORenderingPipeline"
  74147. */
  74148. getClassName(): string;
  74149. /**
  74150. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74151. */
  74152. dispose(disableDepthRender?: boolean): void;
  74153. private _createBlurPostProcess;
  74154. /** @hidden */
  74155. _rebuild(): void;
  74156. private _createSSAOPostProcess;
  74157. private _createSSAOCombinePostProcess;
  74158. private _createRandomTexture;
  74159. }
  74160. }
  74161. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74162. /** @hidden */
  74163. export var screenSpaceReflectionPixelShader: {
  74164. name: string;
  74165. shader: string;
  74166. };
  74167. }
  74168. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74169. import { Nullable } from "babylonjs/types";
  74170. import { Camera } from "babylonjs/Cameras/camera";
  74171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74172. import { Scene } from "babylonjs/scene";
  74173. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74174. import { Engine } from "babylonjs/Engines/engine";
  74175. /**
  74176. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74177. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74178. */
  74179. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74180. /**
  74181. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74182. */
  74183. threshold: number;
  74184. /**
  74185. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74186. */
  74187. strength: number;
  74188. /**
  74189. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74190. */
  74191. reflectionSpecularFalloffExponent: number;
  74192. /**
  74193. * 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]
  74194. */
  74195. step: number;
  74196. /**
  74197. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74198. */
  74199. roughnessFactor: number;
  74200. private _geometryBufferRenderer;
  74201. private _enableSmoothReflections;
  74202. private _reflectionSamples;
  74203. private _smoothSteps;
  74204. /**
  74205. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74206. * @param name The name of the effect.
  74207. * @param scene The scene containing the objects to calculate reflections.
  74208. * @param options The required width/height ratio to downsize to before computing the render pass.
  74209. * @param camera The camera to apply the render pass to.
  74210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74211. * @param engine The engine which the post process will be applied. (default: current engine)
  74212. * @param reusable If the post process can be reused on the same frame. (default: false)
  74213. * @param textureType Type of textures used when performing the post process. (default: 0)
  74214. * @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)
  74215. */
  74216. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74217. /**
  74218. * Gets wether or not smoothing reflections is enabled.
  74219. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74220. */
  74221. get enableSmoothReflections(): boolean;
  74222. /**
  74223. * Sets wether or not smoothing reflections is enabled.
  74224. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74225. */
  74226. set enableSmoothReflections(enabled: boolean);
  74227. /**
  74228. * Gets the number of samples taken while computing reflections. More samples count is high,
  74229. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74230. */
  74231. get reflectionSamples(): number;
  74232. /**
  74233. * Sets the number of samples taken while computing reflections. More samples count is high,
  74234. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74235. */
  74236. set reflectionSamples(samples: number);
  74237. /**
  74238. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74239. * more the post-process will require GPU power and can generate a drop in FPS.
  74240. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74241. */
  74242. get smoothSteps(): number;
  74243. set smoothSteps(steps: number);
  74244. private _updateEffectDefines;
  74245. }
  74246. }
  74247. declare module "babylonjs/Shaders/standard.fragment" {
  74248. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74249. /** @hidden */
  74250. export var standardPixelShader: {
  74251. name: string;
  74252. shader: string;
  74253. };
  74254. }
  74255. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74256. import { Nullable } from "babylonjs/types";
  74257. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74258. import { Camera } from "babylonjs/Cameras/camera";
  74259. import { Texture } from "babylonjs/Materials/Textures/texture";
  74260. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74261. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74262. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74263. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74264. import { IDisposable } from "babylonjs/scene";
  74265. import { SpotLight } from "babylonjs/Lights/spotLight";
  74266. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74267. import { Scene } from "babylonjs/scene";
  74268. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74269. import { Animation } from "babylonjs/Animations/animation";
  74270. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74271. import "babylonjs/Shaders/standard.fragment";
  74272. /**
  74273. * Standard rendering pipeline
  74274. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74275. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74276. */
  74277. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74278. /**
  74279. * Public members
  74280. */
  74281. /**
  74282. * Post-process which contains the original scene color before the pipeline applies all the effects
  74283. */
  74284. originalPostProcess: Nullable<PostProcess>;
  74285. /**
  74286. * Post-process used to down scale an image x4
  74287. */
  74288. downSampleX4PostProcess: Nullable<PostProcess>;
  74289. /**
  74290. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74291. */
  74292. brightPassPostProcess: Nullable<PostProcess>;
  74293. /**
  74294. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74295. */
  74296. blurHPostProcesses: PostProcess[];
  74297. /**
  74298. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74299. */
  74300. blurVPostProcesses: PostProcess[];
  74301. /**
  74302. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74303. */
  74304. textureAdderPostProcess: Nullable<PostProcess>;
  74305. /**
  74306. * Post-process used to create volumetric lighting effect
  74307. */
  74308. volumetricLightPostProcess: Nullable<PostProcess>;
  74309. /**
  74310. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74311. */
  74312. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74313. /**
  74314. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74315. */
  74316. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74317. /**
  74318. * Post-process used to merge the volumetric light effect and the real scene color
  74319. */
  74320. volumetricLightMergePostProces: Nullable<PostProcess>;
  74321. /**
  74322. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74323. */
  74324. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74325. /**
  74326. * Base post-process used to calculate the average luminance of the final image for HDR
  74327. */
  74328. luminancePostProcess: Nullable<PostProcess>;
  74329. /**
  74330. * Post-processes used to create down sample post-processes in order to get
  74331. * the average luminance of the final image for HDR
  74332. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74333. */
  74334. luminanceDownSamplePostProcesses: PostProcess[];
  74335. /**
  74336. * Post-process used to create a HDR effect (light adaptation)
  74337. */
  74338. hdrPostProcess: Nullable<PostProcess>;
  74339. /**
  74340. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74341. */
  74342. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74343. /**
  74344. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74345. */
  74346. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74347. /**
  74348. * Post-process used to merge the final HDR post-process and the real scene color
  74349. */
  74350. hdrFinalPostProcess: Nullable<PostProcess>;
  74351. /**
  74352. * Post-process used to create a lens flare effect
  74353. */
  74354. lensFlarePostProcess: Nullable<PostProcess>;
  74355. /**
  74356. * Post-process that merges the result of the lens flare post-process and the real scene color
  74357. */
  74358. lensFlareComposePostProcess: Nullable<PostProcess>;
  74359. /**
  74360. * Post-process used to create a motion blur effect
  74361. */
  74362. motionBlurPostProcess: Nullable<PostProcess>;
  74363. /**
  74364. * Post-process used to create a depth of field effect
  74365. */
  74366. depthOfFieldPostProcess: Nullable<PostProcess>;
  74367. /**
  74368. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74369. */
  74370. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74371. /**
  74372. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74373. */
  74374. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74375. /**
  74376. * Represents the brightness threshold in order to configure the illuminated surfaces
  74377. */
  74378. brightThreshold: number;
  74379. /**
  74380. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74381. */
  74382. blurWidth: number;
  74383. /**
  74384. * Sets if the blur for highlighted surfaces must be only horizontal
  74385. */
  74386. horizontalBlur: boolean;
  74387. /**
  74388. * Gets the overall exposure used by the pipeline
  74389. */
  74390. get exposure(): number;
  74391. /**
  74392. * Sets the overall exposure used by the pipeline
  74393. */
  74394. set exposure(value: number);
  74395. /**
  74396. * Texture used typically to simulate "dirty" on camera lens
  74397. */
  74398. lensTexture: Nullable<Texture>;
  74399. /**
  74400. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74401. */
  74402. volumetricLightCoefficient: number;
  74403. /**
  74404. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74405. */
  74406. volumetricLightPower: number;
  74407. /**
  74408. * Used the set the blur intensity to smooth the volumetric lights
  74409. */
  74410. volumetricLightBlurScale: number;
  74411. /**
  74412. * Light (spot or directional) used to generate the volumetric lights rays
  74413. * The source light must have a shadow generate so the pipeline can get its
  74414. * depth map
  74415. */
  74416. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74417. /**
  74418. * For eye adaptation, represents the minimum luminance the eye can see
  74419. */
  74420. hdrMinimumLuminance: number;
  74421. /**
  74422. * For eye adaptation, represents the decrease luminance speed
  74423. */
  74424. hdrDecreaseRate: number;
  74425. /**
  74426. * For eye adaptation, represents the increase luminance speed
  74427. */
  74428. hdrIncreaseRate: number;
  74429. /**
  74430. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74431. */
  74432. get hdrAutoExposure(): boolean;
  74433. /**
  74434. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74435. */
  74436. set hdrAutoExposure(value: boolean);
  74437. /**
  74438. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74439. */
  74440. lensColorTexture: Nullable<Texture>;
  74441. /**
  74442. * The overall strengh for the lens flare effect
  74443. */
  74444. lensFlareStrength: number;
  74445. /**
  74446. * Dispersion coefficient for lens flare ghosts
  74447. */
  74448. lensFlareGhostDispersal: number;
  74449. /**
  74450. * Main lens flare halo width
  74451. */
  74452. lensFlareHaloWidth: number;
  74453. /**
  74454. * Based on the lens distortion effect, defines how much the lens flare result
  74455. * is distorted
  74456. */
  74457. lensFlareDistortionStrength: number;
  74458. /**
  74459. * Configures the blur intensity used for for lens flare (halo)
  74460. */
  74461. lensFlareBlurWidth: number;
  74462. /**
  74463. * Lens star texture must be used to simulate rays on the flares and is available
  74464. * in the documentation
  74465. */
  74466. lensStarTexture: Nullable<Texture>;
  74467. /**
  74468. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74469. * flare effect by taking account of the dirt texture
  74470. */
  74471. lensFlareDirtTexture: Nullable<Texture>;
  74472. /**
  74473. * Represents the focal length for the depth of field effect
  74474. */
  74475. depthOfFieldDistance: number;
  74476. /**
  74477. * Represents the blur intensity for the blurred part of the depth of field effect
  74478. */
  74479. depthOfFieldBlurWidth: number;
  74480. /**
  74481. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74482. */
  74483. get motionStrength(): number;
  74484. /**
  74485. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74486. */
  74487. set motionStrength(strength: number);
  74488. /**
  74489. * Gets wether or not the motion blur post-process is object based or screen based.
  74490. */
  74491. get objectBasedMotionBlur(): boolean;
  74492. /**
  74493. * Sets wether or not the motion blur post-process should be object based or screen based
  74494. */
  74495. set objectBasedMotionBlur(value: boolean);
  74496. /**
  74497. * List of animations for the pipeline (IAnimatable implementation)
  74498. */
  74499. animations: Animation[];
  74500. /**
  74501. * Private members
  74502. */
  74503. private _scene;
  74504. private _currentDepthOfFieldSource;
  74505. private _basePostProcess;
  74506. private _fixedExposure;
  74507. private _currentExposure;
  74508. private _hdrAutoExposure;
  74509. private _hdrCurrentLuminance;
  74510. private _motionStrength;
  74511. private _isObjectBasedMotionBlur;
  74512. private _floatTextureType;
  74513. private _camerasToBeAttached;
  74514. private _ratio;
  74515. private _bloomEnabled;
  74516. private _depthOfFieldEnabled;
  74517. private _vlsEnabled;
  74518. private _lensFlareEnabled;
  74519. private _hdrEnabled;
  74520. private _motionBlurEnabled;
  74521. private _fxaaEnabled;
  74522. private _screenSpaceReflectionsEnabled;
  74523. private _motionBlurSamples;
  74524. private _volumetricLightStepsCount;
  74525. private _samples;
  74526. /**
  74527. * @ignore
  74528. * Specifies if the bloom pipeline is enabled
  74529. */
  74530. get BloomEnabled(): boolean;
  74531. set BloomEnabled(enabled: boolean);
  74532. /**
  74533. * @ignore
  74534. * Specifies if the depth of field pipeline is enabed
  74535. */
  74536. get DepthOfFieldEnabled(): boolean;
  74537. set DepthOfFieldEnabled(enabled: boolean);
  74538. /**
  74539. * @ignore
  74540. * Specifies if the lens flare pipeline is enabed
  74541. */
  74542. get LensFlareEnabled(): boolean;
  74543. set LensFlareEnabled(enabled: boolean);
  74544. /**
  74545. * @ignore
  74546. * Specifies if the HDR pipeline is enabled
  74547. */
  74548. get HDREnabled(): boolean;
  74549. set HDREnabled(enabled: boolean);
  74550. /**
  74551. * @ignore
  74552. * Specifies if the volumetric lights scattering effect is enabled
  74553. */
  74554. get VLSEnabled(): boolean;
  74555. set VLSEnabled(enabled: boolean);
  74556. /**
  74557. * @ignore
  74558. * Specifies if the motion blur effect is enabled
  74559. */
  74560. get MotionBlurEnabled(): boolean;
  74561. set MotionBlurEnabled(enabled: boolean);
  74562. /**
  74563. * Specifies if anti-aliasing is enabled
  74564. */
  74565. get fxaaEnabled(): boolean;
  74566. set fxaaEnabled(enabled: boolean);
  74567. /**
  74568. * Specifies if screen space reflections are enabled.
  74569. */
  74570. get screenSpaceReflectionsEnabled(): boolean;
  74571. set screenSpaceReflectionsEnabled(enabled: boolean);
  74572. /**
  74573. * Specifies the number of steps used to calculate the volumetric lights
  74574. * Typically in interval [50, 200]
  74575. */
  74576. get volumetricLightStepsCount(): number;
  74577. set volumetricLightStepsCount(count: number);
  74578. /**
  74579. * Specifies the number of samples used for the motion blur effect
  74580. * Typically in interval [16, 64]
  74581. */
  74582. get motionBlurSamples(): number;
  74583. set motionBlurSamples(samples: number);
  74584. /**
  74585. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74586. */
  74587. get samples(): number;
  74588. set samples(sampleCount: number);
  74589. /**
  74590. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74591. * @constructor
  74592. * @param name The rendering pipeline name
  74593. * @param scene The scene linked to this pipeline
  74594. * @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)
  74595. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74596. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74597. */
  74598. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74599. private _buildPipeline;
  74600. private _createDownSampleX4PostProcess;
  74601. private _createBrightPassPostProcess;
  74602. private _createBlurPostProcesses;
  74603. private _createTextureAdderPostProcess;
  74604. private _createVolumetricLightPostProcess;
  74605. private _createLuminancePostProcesses;
  74606. private _createHdrPostProcess;
  74607. private _createLensFlarePostProcess;
  74608. private _createDepthOfFieldPostProcess;
  74609. private _createMotionBlurPostProcess;
  74610. private _getDepthTexture;
  74611. private _disposePostProcesses;
  74612. /**
  74613. * Dispose of the pipeline and stop all post processes
  74614. */
  74615. dispose(): void;
  74616. /**
  74617. * Serialize the rendering pipeline (Used when exporting)
  74618. * @returns the serialized object
  74619. */
  74620. serialize(): any;
  74621. /**
  74622. * Parse the serialized pipeline
  74623. * @param source Source pipeline.
  74624. * @param scene The scene to load the pipeline to.
  74625. * @param rootUrl The URL of the serialized pipeline.
  74626. * @returns An instantiated pipeline from the serialized object.
  74627. */
  74628. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74629. /**
  74630. * Luminance steps
  74631. */
  74632. static LuminanceSteps: number;
  74633. }
  74634. }
  74635. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74636. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74637. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74638. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74639. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74640. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74641. }
  74642. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74643. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74644. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74645. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74646. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74647. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74648. }
  74649. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74650. /** @hidden */
  74651. export var stereoscopicInterlacePixelShader: {
  74652. name: string;
  74653. shader: string;
  74654. };
  74655. }
  74656. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74657. import { Camera } from "babylonjs/Cameras/camera";
  74658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74659. import { Engine } from "babylonjs/Engines/engine";
  74660. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74661. /**
  74662. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74663. */
  74664. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74665. private _stepSize;
  74666. private _passedProcess;
  74667. /**
  74668. * Initializes a StereoscopicInterlacePostProcessI
  74669. * @param name The name of the effect.
  74670. * @param rigCameras The rig cameras to be appled to the post process
  74671. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74672. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74674. * @param engine The engine which the post process will be applied. (default: current engine)
  74675. * @param reusable If the post process can be reused on the same frame. (default: false)
  74676. */
  74677. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74678. }
  74679. /**
  74680. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74681. */
  74682. export class StereoscopicInterlacePostProcess extends PostProcess {
  74683. private _stepSize;
  74684. private _passedProcess;
  74685. /**
  74686. * Initializes a StereoscopicInterlacePostProcess
  74687. * @param name The name of the effect.
  74688. * @param rigCameras The rig cameras to be appled to the post process
  74689. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74691. * @param engine The engine which the post process will be applied. (default: current engine)
  74692. * @param reusable If the post process can be reused on the same frame. (default: false)
  74693. */
  74694. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74695. }
  74696. }
  74697. declare module "babylonjs/Shaders/tonemap.fragment" {
  74698. /** @hidden */
  74699. export var tonemapPixelShader: {
  74700. name: string;
  74701. shader: string;
  74702. };
  74703. }
  74704. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74705. import { Camera } from "babylonjs/Cameras/camera";
  74706. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74707. import "babylonjs/Shaders/tonemap.fragment";
  74708. import { Engine } from "babylonjs/Engines/engine";
  74709. /** Defines operator used for tonemapping */
  74710. export enum TonemappingOperator {
  74711. /** Hable */
  74712. Hable = 0,
  74713. /** Reinhard */
  74714. Reinhard = 1,
  74715. /** HejiDawson */
  74716. HejiDawson = 2,
  74717. /** Photographic */
  74718. Photographic = 3
  74719. }
  74720. /**
  74721. * Defines a post process to apply tone mapping
  74722. */
  74723. export class TonemapPostProcess extends PostProcess {
  74724. private _operator;
  74725. /** Defines the required exposure adjustement */
  74726. exposureAdjustment: number;
  74727. /**
  74728. * Creates a new TonemapPostProcess
  74729. * @param name defines the name of the postprocess
  74730. * @param _operator defines the operator to use
  74731. * @param exposureAdjustment defines the required exposure adjustement
  74732. * @param camera defines the camera to use (can be null)
  74733. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74734. * @param engine defines the hosting engine (can be ignore if camera is set)
  74735. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74736. */
  74737. constructor(name: string, _operator: TonemappingOperator,
  74738. /** Defines the required exposure adjustement */
  74739. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74740. }
  74741. }
  74742. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74743. /** @hidden */
  74744. export var volumetricLightScatteringPixelShader: {
  74745. name: string;
  74746. shader: string;
  74747. };
  74748. }
  74749. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74750. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74751. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74752. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74753. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74754. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74755. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74756. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74757. /** @hidden */
  74758. export var volumetricLightScatteringPassVertexShader: {
  74759. name: string;
  74760. shader: string;
  74761. };
  74762. }
  74763. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74764. /** @hidden */
  74765. export var volumetricLightScatteringPassPixelShader: {
  74766. name: string;
  74767. shader: string;
  74768. };
  74769. }
  74770. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74771. import { Vector3 } from "babylonjs/Maths/math.vector";
  74772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74773. import { Mesh } from "babylonjs/Meshes/mesh";
  74774. import { Camera } from "babylonjs/Cameras/camera";
  74775. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74776. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74777. import { Scene } from "babylonjs/scene";
  74778. import "babylonjs/Meshes/Builders/planeBuilder";
  74779. import "babylonjs/Shaders/depth.vertex";
  74780. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74781. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74782. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74783. import { Engine } from "babylonjs/Engines/engine";
  74784. /**
  74785. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74786. */
  74787. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74788. private _volumetricLightScatteringPass;
  74789. private _volumetricLightScatteringRTT;
  74790. private _viewPort;
  74791. private _screenCoordinates;
  74792. private _cachedDefines;
  74793. /**
  74794. * If not undefined, the mesh position is computed from the attached node position
  74795. */
  74796. attachedNode: {
  74797. position: Vector3;
  74798. };
  74799. /**
  74800. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74801. */
  74802. customMeshPosition: Vector3;
  74803. /**
  74804. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74805. */
  74806. useCustomMeshPosition: boolean;
  74807. /**
  74808. * If the post-process should inverse the light scattering direction
  74809. */
  74810. invert: boolean;
  74811. /**
  74812. * The internal mesh used by the post-process
  74813. */
  74814. mesh: Mesh;
  74815. /**
  74816. * @hidden
  74817. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74818. */
  74819. get useDiffuseColor(): boolean;
  74820. set useDiffuseColor(useDiffuseColor: boolean);
  74821. /**
  74822. * Array containing the excluded meshes not rendered in the internal pass
  74823. */
  74824. excludedMeshes: AbstractMesh[];
  74825. /**
  74826. * Controls the overall intensity of the post-process
  74827. */
  74828. exposure: number;
  74829. /**
  74830. * Dissipates each sample's contribution in range [0, 1]
  74831. */
  74832. decay: number;
  74833. /**
  74834. * Controls the overall intensity of each sample
  74835. */
  74836. weight: number;
  74837. /**
  74838. * Controls the density of each sample
  74839. */
  74840. density: number;
  74841. /**
  74842. * @constructor
  74843. * @param name The post-process name
  74844. * @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)
  74845. * @param camera The camera that the post-process will be attached to
  74846. * @param mesh The mesh used to create the light scattering
  74847. * @param samples The post-process quality, default 100
  74848. * @param samplingModeThe post-process filtering mode
  74849. * @param engine The babylon engine
  74850. * @param reusable If the post-process is reusable
  74851. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74852. */
  74853. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74854. /**
  74855. * Returns the string "VolumetricLightScatteringPostProcess"
  74856. * @returns "VolumetricLightScatteringPostProcess"
  74857. */
  74858. getClassName(): string;
  74859. private _isReady;
  74860. /**
  74861. * Sets the new light position for light scattering effect
  74862. * @param position The new custom light position
  74863. */
  74864. setCustomMeshPosition(position: Vector3): void;
  74865. /**
  74866. * Returns the light position for light scattering effect
  74867. * @return Vector3 The custom light position
  74868. */
  74869. getCustomMeshPosition(): Vector3;
  74870. /**
  74871. * Disposes the internal assets and detaches the post-process from the camera
  74872. */
  74873. dispose(camera: Camera): void;
  74874. /**
  74875. * Returns the render target texture used by the post-process
  74876. * @return the render target texture used by the post-process
  74877. */
  74878. getPass(): RenderTargetTexture;
  74879. private _meshExcluded;
  74880. private _createPass;
  74881. private _updateMeshScreenCoordinates;
  74882. /**
  74883. * Creates a default mesh for the Volumeric Light Scattering post-process
  74884. * @param name The mesh name
  74885. * @param scene The scene where to create the mesh
  74886. * @return the default mesh
  74887. */
  74888. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74889. }
  74890. }
  74891. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  74892. /** @hidden */
  74893. export var screenSpaceCurvaturePixelShader: {
  74894. name: string;
  74895. shader: string;
  74896. };
  74897. }
  74898. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  74899. import { Nullable } from "babylonjs/types";
  74900. import { Camera } from "babylonjs/Cameras/camera";
  74901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74902. import { Scene } from "babylonjs/scene";
  74903. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74904. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  74905. import { Engine } from "babylonjs/Engines/engine";
  74906. /**
  74907. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  74908. */
  74909. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  74910. /**
  74911. * Defines how much ridge the curvature effect displays.
  74912. */
  74913. ridge: number;
  74914. /**
  74915. * Defines how much valley the curvature effect displays.
  74916. */
  74917. valley: number;
  74918. private _geometryBufferRenderer;
  74919. /**
  74920. * Creates a new instance ScreenSpaceCurvaturePostProcess
  74921. * @param name The name of the effect.
  74922. * @param scene The scene containing the objects to blur according to their velocity.
  74923. * @param options The required width/height ratio to downsize to before computing the render pass.
  74924. * @param camera The camera to apply the render pass to.
  74925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74926. * @param engine The engine which the post process will be applied. (default: current engine)
  74927. * @param reusable If the post process can be reused on the same frame. (default: false)
  74928. * @param textureType Type of textures used when performing the post process. (default: 0)
  74929. * @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)
  74930. */
  74931. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74932. /**
  74933. * Support test.
  74934. */
  74935. static get IsSupported(): boolean;
  74936. }
  74937. }
  74938. declare module "babylonjs/PostProcesses/index" {
  74939. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74940. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74941. export * from "babylonjs/PostProcesses/bloomEffect";
  74942. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74943. export * from "babylonjs/PostProcesses/blurPostProcess";
  74944. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74945. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74946. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74947. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74948. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74949. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74950. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74951. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74952. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74953. export * from "babylonjs/PostProcesses/filterPostProcess";
  74954. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74955. export * from "babylonjs/PostProcesses/grainPostProcess";
  74956. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74957. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74958. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74959. export * from "babylonjs/PostProcesses/passPostProcess";
  74960. export * from "babylonjs/PostProcesses/postProcess";
  74961. export * from "babylonjs/PostProcesses/postProcessManager";
  74962. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74963. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74964. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74965. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74966. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74967. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74968. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74969. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74970. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74971. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  74972. }
  74973. declare module "babylonjs/Probes/index" {
  74974. export * from "babylonjs/Probes/reflectionProbe";
  74975. }
  74976. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74977. import { Scene } from "babylonjs/scene";
  74978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74979. import { SmartArray } from "babylonjs/Misc/smartArray";
  74980. import { ISceneComponent } from "babylonjs/sceneComponent";
  74981. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74982. import "babylonjs/Meshes/Builders/boxBuilder";
  74983. import "babylonjs/Shaders/color.fragment";
  74984. import "babylonjs/Shaders/color.vertex";
  74985. import { Color3 } from "babylonjs/Maths/math.color";
  74986. import { Observable } from "babylonjs/Misc/observable";
  74987. module "babylonjs/scene" {
  74988. interface Scene {
  74989. /** @hidden (Backing field) */
  74990. _boundingBoxRenderer: BoundingBoxRenderer;
  74991. /** @hidden (Backing field) */
  74992. _forceShowBoundingBoxes: boolean;
  74993. /**
  74994. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74995. */
  74996. forceShowBoundingBoxes: boolean;
  74997. /**
  74998. * Gets the bounding box renderer associated with the scene
  74999. * @returns a BoundingBoxRenderer
  75000. */
  75001. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75002. }
  75003. }
  75004. module "babylonjs/Meshes/abstractMesh" {
  75005. interface AbstractMesh {
  75006. /** @hidden (Backing field) */
  75007. _showBoundingBox: boolean;
  75008. /**
  75009. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75010. */
  75011. showBoundingBox: boolean;
  75012. }
  75013. }
  75014. /**
  75015. * Component responsible of rendering the bounding box of the meshes in a scene.
  75016. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75017. */
  75018. export class BoundingBoxRenderer implements ISceneComponent {
  75019. /**
  75020. * The component name helpfull to identify the component in the list of scene components.
  75021. */
  75022. readonly name: string;
  75023. /**
  75024. * The scene the component belongs to.
  75025. */
  75026. scene: Scene;
  75027. /**
  75028. * Color of the bounding box lines placed in front of an object
  75029. */
  75030. frontColor: Color3;
  75031. /**
  75032. * Color of the bounding box lines placed behind an object
  75033. */
  75034. backColor: Color3;
  75035. /**
  75036. * Defines if the renderer should show the back lines or not
  75037. */
  75038. showBackLines: boolean;
  75039. /**
  75040. * Observable raised before rendering a bounding box
  75041. */
  75042. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75043. /**
  75044. * Observable raised after rendering a bounding box
  75045. */
  75046. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75047. /**
  75048. * @hidden
  75049. */
  75050. renderList: SmartArray<BoundingBox>;
  75051. private _colorShader;
  75052. private _vertexBuffers;
  75053. private _indexBuffer;
  75054. private _fillIndexBuffer;
  75055. private _fillIndexData;
  75056. /**
  75057. * Instantiates a new bounding box renderer in a scene.
  75058. * @param scene the scene the renderer renders in
  75059. */
  75060. constructor(scene: Scene);
  75061. /**
  75062. * Registers the component in a given scene
  75063. */
  75064. register(): void;
  75065. private _evaluateSubMesh;
  75066. private _activeMesh;
  75067. private _prepareRessources;
  75068. private _createIndexBuffer;
  75069. /**
  75070. * Rebuilds the elements related to this component in case of
  75071. * context lost for instance.
  75072. */
  75073. rebuild(): void;
  75074. /**
  75075. * @hidden
  75076. */
  75077. reset(): void;
  75078. /**
  75079. * Render the bounding boxes of a specific rendering group
  75080. * @param renderingGroupId defines the rendering group to render
  75081. */
  75082. render(renderingGroupId: number): void;
  75083. /**
  75084. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75085. * @param mesh Define the mesh to render the occlusion bounding box for
  75086. */
  75087. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75088. /**
  75089. * Dispose and release the resources attached to this renderer.
  75090. */
  75091. dispose(): void;
  75092. }
  75093. }
  75094. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75095. import { Nullable } from "babylonjs/types";
  75096. import { Scene } from "babylonjs/scene";
  75097. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75098. import { Camera } from "babylonjs/Cameras/camera";
  75099. import { ISceneComponent } from "babylonjs/sceneComponent";
  75100. module "babylonjs/scene" {
  75101. interface Scene {
  75102. /** @hidden (Backing field) */
  75103. _depthRenderer: {
  75104. [id: string]: DepthRenderer;
  75105. };
  75106. /**
  75107. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75108. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75109. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75110. * @returns the created depth renderer
  75111. */
  75112. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75113. /**
  75114. * Disables a depth renderer for a given camera
  75115. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75116. */
  75117. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75118. }
  75119. }
  75120. /**
  75121. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75122. * in several rendering techniques.
  75123. */
  75124. export class DepthRendererSceneComponent implements ISceneComponent {
  75125. /**
  75126. * The component name helpfull to identify the component in the list of scene components.
  75127. */
  75128. readonly name: string;
  75129. /**
  75130. * The scene the component belongs to.
  75131. */
  75132. scene: Scene;
  75133. /**
  75134. * Creates a new instance of the component for the given scene
  75135. * @param scene Defines the scene to register the component in
  75136. */
  75137. constructor(scene: Scene);
  75138. /**
  75139. * Registers the component in a given scene
  75140. */
  75141. register(): void;
  75142. /**
  75143. * Rebuilds the elements related to this component in case of
  75144. * context lost for instance.
  75145. */
  75146. rebuild(): void;
  75147. /**
  75148. * Disposes the component and the associated ressources
  75149. */
  75150. dispose(): void;
  75151. private _gatherRenderTargets;
  75152. private _gatherActiveCameraRenderTargets;
  75153. }
  75154. }
  75155. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75156. import { Nullable } from "babylonjs/types";
  75157. import { Scene } from "babylonjs/scene";
  75158. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75159. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75160. import { AbstractScene } from "babylonjs/abstractScene";
  75161. module "babylonjs/abstractScene" {
  75162. interface AbstractScene {
  75163. /** @hidden (Backing field) */
  75164. _prePassRenderer: Nullable<PrePassRenderer>;
  75165. /**
  75166. * Gets or Sets the current prepass renderer associated to the scene.
  75167. */
  75168. prePassRenderer: Nullable<PrePassRenderer>;
  75169. /**
  75170. * Enables the prepass and associates it with the scene
  75171. * @returns the PrePassRenderer
  75172. */
  75173. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75174. /**
  75175. * Disables the prepass associated with the scene
  75176. */
  75177. disablePrePassRenderer(): void;
  75178. }
  75179. }
  75180. /**
  75181. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75182. * in several rendering techniques.
  75183. */
  75184. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75185. /**
  75186. * The component name helpful to identify the component in the list of scene components.
  75187. */
  75188. readonly name: string;
  75189. /**
  75190. * The scene the component belongs to.
  75191. */
  75192. scene: Scene;
  75193. /**
  75194. * Creates a new instance of the component for the given scene
  75195. * @param scene Defines the scene to register the component in
  75196. */
  75197. constructor(scene: Scene);
  75198. /**
  75199. * Registers the component in a given scene
  75200. */
  75201. register(): void;
  75202. private _beforeCameraDraw;
  75203. private _afterCameraDraw;
  75204. private _beforeClearStage;
  75205. /**
  75206. * Serializes the component data to the specified json object
  75207. * @param serializationObject The object to serialize to
  75208. */
  75209. serialize(serializationObject: any): void;
  75210. /**
  75211. * Adds all the elements from the container to the scene
  75212. * @param container the container holding the elements
  75213. */
  75214. addFromContainer(container: AbstractScene): void;
  75215. /**
  75216. * Removes all the elements in the container from the scene
  75217. * @param container contains the elements to remove
  75218. * @param dispose if the removed element should be disposed (default: false)
  75219. */
  75220. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75221. /**
  75222. * Rebuilds the elements related to this component in case of
  75223. * context lost for instance.
  75224. */
  75225. rebuild(): void;
  75226. /**
  75227. * Disposes the component and the associated ressources
  75228. */
  75229. dispose(): void;
  75230. }
  75231. }
  75232. declare module "babylonjs/Shaders/outline.fragment" {
  75233. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75234. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75235. /** @hidden */
  75236. export var outlinePixelShader: {
  75237. name: string;
  75238. shader: string;
  75239. };
  75240. }
  75241. declare module "babylonjs/Shaders/outline.vertex" {
  75242. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75245. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75246. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75247. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75248. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75249. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75250. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75251. /** @hidden */
  75252. export var outlineVertexShader: {
  75253. name: string;
  75254. shader: string;
  75255. };
  75256. }
  75257. declare module "babylonjs/Rendering/outlineRenderer" {
  75258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75259. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75260. import { Scene } from "babylonjs/scene";
  75261. import { ISceneComponent } from "babylonjs/sceneComponent";
  75262. import "babylonjs/Shaders/outline.fragment";
  75263. import "babylonjs/Shaders/outline.vertex";
  75264. module "babylonjs/scene" {
  75265. interface Scene {
  75266. /** @hidden */
  75267. _outlineRenderer: OutlineRenderer;
  75268. /**
  75269. * Gets the outline renderer associated with the scene
  75270. * @returns a OutlineRenderer
  75271. */
  75272. getOutlineRenderer(): OutlineRenderer;
  75273. }
  75274. }
  75275. module "babylonjs/Meshes/abstractMesh" {
  75276. interface AbstractMesh {
  75277. /** @hidden (Backing field) */
  75278. _renderOutline: boolean;
  75279. /**
  75280. * Gets or sets a boolean indicating if the outline must be rendered as well
  75281. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75282. */
  75283. renderOutline: boolean;
  75284. /** @hidden (Backing field) */
  75285. _renderOverlay: boolean;
  75286. /**
  75287. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75288. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75289. */
  75290. renderOverlay: boolean;
  75291. }
  75292. }
  75293. /**
  75294. * This class is responsible to draw bothe outline/overlay of meshes.
  75295. * It should not be used directly but through the available method on mesh.
  75296. */
  75297. export class OutlineRenderer implements ISceneComponent {
  75298. /**
  75299. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75300. */
  75301. private static _StencilReference;
  75302. /**
  75303. * The name of the component. Each component must have a unique name.
  75304. */
  75305. name: string;
  75306. /**
  75307. * The scene the component belongs to.
  75308. */
  75309. scene: Scene;
  75310. /**
  75311. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75312. */
  75313. zOffset: number;
  75314. private _engine;
  75315. private _effect;
  75316. private _cachedDefines;
  75317. private _savedDepthWrite;
  75318. /**
  75319. * Instantiates a new outline renderer. (There could be only one per scene).
  75320. * @param scene Defines the scene it belongs to
  75321. */
  75322. constructor(scene: Scene);
  75323. /**
  75324. * Register the component to one instance of a scene.
  75325. */
  75326. register(): void;
  75327. /**
  75328. * Rebuilds the elements related to this component in case of
  75329. * context lost for instance.
  75330. */
  75331. rebuild(): void;
  75332. /**
  75333. * Disposes the component and the associated ressources.
  75334. */
  75335. dispose(): void;
  75336. /**
  75337. * Renders the outline in the canvas.
  75338. * @param subMesh Defines the sumesh to render
  75339. * @param batch Defines the batch of meshes in case of instances
  75340. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75341. */
  75342. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75343. /**
  75344. * Returns whether or not the outline renderer is ready for a given submesh.
  75345. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75346. * @param subMesh Defines the submesh to check readyness for
  75347. * @param useInstances Defines wheter wee are trying to render instances or not
  75348. * @returns true if ready otherwise false
  75349. */
  75350. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75351. private _beforeRenderingMesh;
  75352. private _afterRenderingMesh;
  75353. }
  75354. }
  75355. declare module "babylonjs/Rendering/index" {
  75356. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75357. export * from "babylonjs/Rendering/depthRenderer";
  75358. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75359. export * from "babylonjs/Rendering/edgesRenderer";
  75360. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75361. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75362. export * from "babylonjs/Rendering/prePassRenderer";
  75363. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75364. export * from "babylonjs/Rendering/outlineRenderer";
  75365. export * from "babylonjs/Rendering/renderingGroup";
  75366. export * from "babylonjs/Rendering/renderingManager";
  75367. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75368. }
  75369. declare module "babylonjs/Sprites/ISprites" {
  75370. /**
  75371. * Defines the basic options interface of a Sprite Frame Source Size.
  75372. */
  75373. export interface ISpriteJSONSpriteSourceSize {
  75374. /**
  75375. * number of the original width of the Frame
  75376. */
  75377. w: number;
  75378. /**
  75379. * number of the original height of the Frame
  75380. */
  75381. h: number;
  75382. }
  75383. /**
  75384. * Defines the basic options interface of a Sprite Frame Data.
  75385. */
  75386. export interface ISpriteJSONSpriteFrameData {
  75387. /**
  75388. * number of the x offset of the Frame
  75389. */
  75390. x: number;
  75391. /**
  75392. * number of the y offset of the Frame
  75393. */
  75394. y: number;
  75395. /**
  75396. * number of the width of the Frame
  75397. */
  75398. w: number;
  75399. /**
  75400. * number of the height of the Frame
  75401. */
  75402. h: number;
  75403. }
  75404. /**
  75405. * Defines the basic options interface of a JSON Sprite.
  75406. */
  75407. export interface ISpriteJSONSprite {
  75408. /**
  75409. * string name of the Frame
  75410. */
  75411. filename: string;
  75412. /**
  75413. * ISpriteJSONSpriteFrame basic object of the frame data
  75414. */
  75415. frame: ISpriteJSONSpriteFrameData;
  75416. /**
  75417. * boolean to flag is the frame was rotated.
  75418. */
  75419. rotated: boolean;
  75420. /**
  75421. * boolean to flag is the frame was trimmed.
  75422. */
  75423. trimmed: boolean;
  75424. /**
  75425. * ISpriteJSONSpriteFrame basic object of the source data
  75426. */
  75427. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75428. /**
  75429. * ISpriteJSONSpriteFrame basic object of the source data
  75430. */
  75431. sourceSize: ISpriteJSONSpriteSourceSize;
  75432. }
  75433. /**
  75434. * Defines the basic options interface of a JSON atlas.
  75435. */
  75436. export interface ISpriteJSONAtlas {
  75437. /**
  75438. * Array of objects that contain the frame data.
  75439. */
  75440. frames: Array<ISpriteJSONSprite>;
  75441. /**
  75442. * object basic object containing the sprite meta data.
  75443. */
  75444. meta?: object;
  75445. }
  75446. }
  75447. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75448. /** @hidden */
  75449. export var spriteMapPixelShader: {
  75450. name: string;
  75451. shader: string;
  75452. };
  75453. }
  75454. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75455. /** @hidden */
  75456. export var spriteMapVertexShader: {
  75457. name: string;
  75458. shader: string;
  75459. };
  75460. }
  75461. declare module "babylonjs/Sprites/spriteMap" {
  75462. import { IDisposable, Scene } from "babylonjs/scene";
  75463. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75464. import { Texture } from "babylonjs/Materials/Textures/texture";
  75465. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75466. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75467. import "babylonjs/Meshes/Builders/planeBuilder";
  75468. import "babylonjs/Shaders/spriteMap.fragment";
  75469. import "babylonjs/Shaders/spriteMap.vertex";
  75470. /**
  75471. * Defines the basic options interface of a SpriteMap
  75472. */
  75473. export interface ISpriteMapOptions {
  75474. /**
  75475. * Vector2 of the number of cells in the grid.
  75476. */
  75477. stageSize?: Vector2;
  75478. /**
  75479. * Vector2 of the size of the output plane in World Units.
  75480. */
  75481. outputSize?: Vector2;
  75482. /**
  75483. * Vector3 of the position of the output plane in World Units.
  75484. */
  75485. outputPosition?: Vector3;
  75486. /**
  75487. * Vector3 of the rotation of the output plane.
  75488. */
  75489. outputRotation?: Vector3;
  75490. /**
  75491. * number of layers that the system will reserve in resources.
  75492. */
  75493. layerCount?: number;
  75494. /**
  75495. * number of max animation frames a single cell will reserve in resources.
  75496. */
  75497. maxAnimationFrames?: number;
  75498. /**
  75499. * number cell index of the base tile when the system compiles.
  75500. */
  75501. baseTile?: number;
  75502. /**
  75503. * boolean flip the sprite after its been repositioned by the framing data.
  75504. */
  75505. flipU?: boolean;
  75506. /**
  75507. * Vector3 scalar of the global RGB values of the SpriteMap.
  75508. */
  75509. colorMultiply?: Vector3;
  75510. }
  75511. /**
  75512. * Defines the IDisposable interface in order to be cleanable from resources.
  75513. */
  75514. export interface ISpriteMap extends IDisposable {
  75515. /**
  75516. * String name of the SpriteMap.
  75517. */
  75518. name: string;
  75519. /**
  75520. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75521. */
  75522. atlasJSON: ISpriteJSONAtlas;
  75523. /**
  75524. * Texture of the SpriteMap.
  75525. */
  75526. spriteSheet: Texture;
  75527. /**
  75528. * The parameters to initialize the SpriteMap with.
  75529. */
  75530. options: ISpriteMapOptions;
  75531. }
  75532. /**
  75533. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75534. */
  75535. export class SpriteMap implements ISpriteMap {
  75536. /** The Name of the spriteMap */
  75537. name: string;
  75538. /** The JSON file with the frame and meta data */
  75539. atlasJSON: ISpriteJSONAtlas;
  75540. /** The systems Sprite Sheet Texture */
  75541. spriteSheet: Texture;
  75542. /** Arguments passed with the Constructor */
  75543. options: ISpriteMapOptions;
  75544. /** Public Sprite Storage array, parsed from atlasJSON */
  75545. sprites: Array<ISpriteJSONSprite>;
  75546. /** Returns the Number of Sprites in the System */
  75547. get spriteCount(): number;
  75548. /** Returns the Position of Output Plane*/
  75549. get position(): Vector3;
  75550. /** Returns the Position of Output Plane*/
  75551. set position(v: Vector3);
  75552. /** Returns the Rotation of Output Plane*/
  75553. get rotation(): Vector3;
  75554. /** Returns the Rotation of Output Plane*/
  75555. set rotation(v: Vector3);
  75556. /** Sets the AnimationMap*/
  75557. get animationMap(): RawTexture;
  75558. /** Sets the AnimationMap*/
  75559. set animationMap(v: RawTexture);
  75560. /** Scene that the SpriteMap was created in */
  75561. private _scene;
  75562. /** Texture Buffer of Float32 that holds tile frame data*/
  75563. private _frameMap;
  75564. /** Texture Buffers of Float32 that holds tileMap data*/
  75565. private _tileMaps;
  75566. /** Texture Buffer of Float32 that holds Animation Data*/
  75567. private _animationMap;
  75568. /** Custom ShaderMaterial Central to the System*/
  75569. private _material;
  75570. /** Custom ShaderMaterial Central to the System*/
  75571. private _output;
  75572. /** Systems Time Ticker*/
  75573. private _time;
  75574. /**
  75575. * Creates a new SpriteMap
  75576. * @param name defines the SpriteMaps Name
  75577. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75578. * @param spriteSheet is the Texture that the Sprites are on.
  75579. * @param options a basic deployment configuration
  75580. * @param scene The Scene that the map is deployed on
  75581. */
  75582. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75583. /**
  75584. * Returns tileID location
  75585. * @returns Vector2 the cell position ID
  75586. */
  75587. getTileID(): Vector2;
  75588. /**
  75589. * Gets the UV location of the mouse over the SpriteMap.
  75590. * @returns Vector2 the UV position of the mouse interaction
  75591. */
  75592. getMousePosition(): Vector2;
  75593. /**
  75594. * Creates the "frame" texture Buffer
  75595. * -------------------------------------
  75596. * Structure of frames
  75597. * "filename": "Falling-Water-2.png",
  75598. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75599. * "rotated": true,
  75600. * "trimmed": true,
  75601. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75602. * "sourceSize": {"w":32,"h":32}
  75603. * @returns RawTexture of the frameMap
  75604. */
  75605. private _createFrameBuffer;
  75606. /**
  75607. * Creates the tileMap texture Buffer
  75608. * @param buffer normally and array of numbers, or a false to generate from scratch
  75609. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75610. * @returns RawTexture of the tileMap
  75611. */
  75612. private _createTileBuffer;
  75613. /**
  75614. * Modifies the data of the tileMaps
  75615. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75616. * @param pos is the iVector2 Coordinates of the Tile
  75617. * @param tile The SpriteIndex of the new Tile
  75618. */
  75619. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75620. /**
  75621. * Creates the animationMap texture Buffer
  75622. * @param buffer normally and array of numbers, or a false to generate from scratch
  75623. * @returns RawTexture of the animationMap
  75624. */
  75625. private _createTileAnimationBuffer;
  75626. /**
  75627. * Modifies the data of the animationMap
  75628. * @param cellID is the Index of the Sprite
  75629. * @param _frame is the target Animation frame
  75630. * @param toCell is the Target Index of the next frame of the animation
  75631. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75632. * @param speed is a global scalar of the time variable on the map.
  75633. */
  75634. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75635. /**
  75636. * Exports the .tilemaps file
  75637. */
  75638. saveTileMaps(): void;
  75639. /**
  75640. * Imports the .tilemaps file
  75641. * @param url of the .tilemaps file
  75642. */
  75643. loadTileMaps(url: string): void;
  75644. /**
  75645. * Release associated resources
  75646. */
  75647. dispose(): void;
  75648. }
  75649. }
  75650. declare module "babylonjs/Sprites/spritePackedManager" {
  75651. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75652. import { Scene } from "babylonjs/scene";
  75653. /**
  75654. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75655. * @see https://doc.babylonjs.com/babylon101/sprites
  75656. */
  75657. export class SpritePackedManager extends SpriteManager {
  75658. /** defines the packed manager's name */
  75659. name: string;
  75660. /**
  75661. * Creates a new sprite manager from a packed sprite sheet
  75662. * @param name defines the manager's name
  75663. * @param imgUrl defines the sprite sheet url
  75664. * @param capacity defines the maximum allowed number of sprites
  75665. * @param scene defines the hosting scene
  75666. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75667. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75668. * @param samplingMode defines the smapling mode to use with spritesheet
  75669. * @param fromPacked set to true; do not alter
  75670. */
  75671. constructor(
  75672. /** defines the packed manager's name */
  75673. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75674. }
  75675. }
  75676. declare module "babylonjs/Sprites/index" {
  75677. export * from "babylonjs/Sprites/sprite";
  75678. export * from "babylonjs/Sprites/ISprites";
  75679. export * from "babylonjs/Sprites/spriteManager";
  75680. export * from "babylonjs/Sprites/spriteMap";
  75681. export * from "babylonjs/Sprites/spritePackedManager";
  75682. export * from "babylonjs/Sprites/spriteSceneComponent";
  75683. }
  75684. declare module "babylonjs/States/index" {
  75685. export * from "babylonjs/States/alphaCullingState";
  75686. export * from "babylonjs/States/depthCullingState";
  75687. export * from "babylonjs/States/stencilState";
  75688. }
  75689. declare module "babylonjs/Misc/assetsManager" {
  75690. import { Scene } from "babylonjs/scene";
  75691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75692. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75693. import { Skeleton } from "babylonjs/Bones/skeleton";
  75694. import { Observable } from "babylonjs/Misc/observable";
  75695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75696. import { Texture } from "babylonjs/Materials/Textures/texture";
  75697. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75698. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75699. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75700. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75701. /**
  75702. * Defines the list of states available for a task inside a AssetsManager
  75703. */
  75704. export enum AssetTaskState {
  75705. /**
  75706. * Initialization
  75707. */
  75708. INIT = 0,
  75709. /**
  75710. * Running
  75711. */
  75712. RUNNING = 1,
  75713. /**
  75714. * Done
  75715. */
  75716. DONE = 2,
  75717. /**
  75718. * Error
  75719. */
  75720. ERROR = 3
  75721. }
  75722. /**
  75723. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75724. */
  75725. export abstract class AbstractAssetTask {
  75726. /**
  75727. * Task name
  75728. */ name: string;
  75729. /**
  75730. * Callback called when the task is successful
  75731. */
  75732. onSuccess: (task: any) => void;
  75733. /**
  75734. * Callback called when the task is not successful
  75735. */
  75736. onError: (task: any, message?: string, exception?: any) => void;
  75737. /**
  75738. * Creates a new AssetsManager
  75739. * @param name defines the name of the task
  75740. */
  75741. constructor(
  75742. /**
  75743. * Task name
  75744. */ name: string);
  75745. private _isCompleted;
  75746. private _taskState;
  75747. private _errorObject;
  75748. /**
  75749. * Get if the task is completed
  75750. */
  75751. get isCompleted(): boolean;
  75752. /**
  75753. * Gets the current state of the task
  75754. */
  75755. get taskState(): AssetTaskState;
  75756. /**
  75757. * Gets the current error object (if task is in error)
  75758. */
  75759. get errorObject(): {
  75760. message?: string;
  75761. exception?: any;
  75762. };
  75763. /**
  75764. * Internal only
  75765. * @hidden
  75766. */
  75767. _setErrorObject(message?: string, exception?: any): void;
  75768. /**
  75769. * Execute the current task
  75770. * @param scene defines the scene where you want your assets to be loaded
  75771. * @param onSuccess is a callback called when the task is successfully executed
  75772. * @param onError is a callback called if an error occurs
  75773. */
  75774. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75775. /**
  75776. * Execute the current task
  75777. * @param scene defines the scene where you want your assets to be loaded
  75778. * @param onSuccess is a callback called when the task is successfully executed
  75779. * @param onError is a callback called if an error occurs
  75780. */
  75781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75782. /**
  75783. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75784. * This can be used with failed tasks that have the reason for failure fixed.
  75785. */
  75786. reset(): void;
  75787. private onErrorCallback;
  75788. private onDoneCallback;
  75789. }
  75790. /**
  75791. * Define the interface used by progress events raised during assets loading
  75792. */
  75793. export interface IAssetsProgressEvent {
  75794. /**
  75795. * Defines the number of remaining tasks to process
  75796. */
  75797. remainingCount: number;
  75798. /**
  75799. * Defines the total number of tasks
  75800. */
  75801. totalCount: number;
  75802. /**
  75803. * Defines the task that was just processed
  75804. */
  75805. task: AbstractAssetTask;
  75806. }
  75807. /**
  75808. * Class used to share progress information about assets loading
  75809. */
  75810. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75811. /**
  75812. * Defines the number of remaining tasks to process
  75813. */
  75814. remainingCount: number;
  75815. /**
  75816. * Defines the total number of tasks
  75817. */
  75818. totalCount: number;
  75819. /**
  75820. * Defines the task that was just processed
  75821. */
  75822. task: AbstractAssetTask;
  75823. /**
  75824. * Creates a AssetsProgressEvent
  75825. * @param remainingCount defines the number of remaining tasks to process
  75826. * @param totalCount defines the total number of tasks
  75827. * @param task defines the task that was just processed
  75828. */
  75829. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75830. }
  75831. /**
  75832. * Define a task used by AssetsManager to load meshes
  75833. */
  75834. export class MeshAssetTask extends AbstractAssetTask {
  75835. /**
  75836. * Defines the name of the task
  75837. */
  75838. name: string;
  75839. /**
  75840. * Defines the list of mesh's names you want to load
  75841. */
  75842. meshesNames: any;
  75843. /**
  75844. * Defines the root url to use as a base to load your meshes and associated resources
  75845. */
  75846. rootUrl: string;
  75847. /**
  75848. * Defines the filename or File of the scene to load from
  75849. */
  75850. sceneFilename: string | File;
  75851. /**
  75852. * Gets the list of loaded meshes
  75853. */
  75854. loadedMeshes: Array<AbstractMesh>;
  75855. /**
  75856. * Gets the list of loaded particle systems
  75857. */
  75858. loadedParticleSystems: Array<IParticleSystem>;
  75859. /**
  75860. * Gets the list of loaded skeletons
  75861. */
  75862. loadedSkeletons: Array<Skeleton>;
  75863. /**
  75864. * Gets the list of loaded animation groups
  75865. */
  75866. loadedAnimationGroups: Array<AnimationGroup>;
  75867. /**
  75868. * Callback called when the task is successful
  75869. */
  75870. onSuccess: (task: MeshAssetTask) => void;
  75871. /**
  75872. * Callback called when the task is successful
  75873. */
  75874. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75875. /**
  75876. * Creates a new MeshAssetTask
  75877. * @param name defines the name of the task
  75878. * @param meshesNames defines the list of mesh's names you want to load
  75879. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75880. * @param sceneFilename defines the filename or File of the scene to load from
  75881. */
  75882. constructor(
  75883. /**
  75884. * Defines the name of the task
  75885. */
  75886. name: string,
  75887. /**
  75888. * Defines the list of mesh's names you want to load
  75889. */
  75890. meshesNames: any,
  75891. /**
  75892. * Defines the root url to use as a base to load your meshes and associated resources
  75893. */
  75894. rootUrl: string,
  75895. /**
  75896. * Defines the filename or File of the scene to load from
  75897. */
  75898. sceneFilename: string | File);
  75899. /**
  75900. * Execute the current task
  75901. * @param scene defines the scene where you want your assets to be loaded
  75902. * @param onSuccess is a callback called when the task is successfully executed
  75903. * @param onError is a callback called if an error occurs
  75904. */
  75905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75906. }
  75907. /**
  75908. * Define a task used by AssetsManager to load text content
  75909. */
  75910. export class TextFileAssetTask extends AbstractAssetTask {
  75911. /**
  75912. * Defines the name of the task
  75913. */
  75914. name: string;
  75915. /**
  75916. * Defines the location of the file to load
  75917. */
  75918. url: string;
  75919. /**
  75920. * Gets the loaded text string
  75921. */
  75922. text: string;
  75923. /**
  75924. * Callback called when the task is successful
  75925. */
  75926. onSuccess: (task: TextFileAssetTask) => void;
  75927. /**
  75928. * Callback called when the task is successful
  75929. */
  75930. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75931. /**
  75932. * Creates a new TextFileAssetTask object
  75933. * @param name defines the name of the task
  75934. * @param url defines the location of the file to load
  75935. */
  75936. constructor(
  75937. /**
  75938. * Defines the name of the task
  75939. */
  75940. name: string,
  75941. /**
  75942. * Defines the location of the file to load
  75943. */
  75944. url: string);
  75945. /**
  75946. * Execute the current task
  75947. * @param scene defines the scene where you want your assets to be loaded
  75948. * @param onSuccess is a callback called when the task is successfully executed
  75949. * @param onError is a callback called if an error occurs
  75950. */
  75951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75952. }
  75953. /**
  75954. * Define a task used by AssetsManager to load binary data
  75955. */
  75956. export class BinaryFileAssetTask extends AbstractAssetTask {
  75957. /**
  75958. * Defines the name of the task
  75959. */
  75960. name: string;
  75961. /**
  75962. * Defines the location of the file to load
  75963. */
  75964. url: string;
  75965. /**
  75966. * Gets the lodaded data (as an array buffer)
  75967. */
  75968. data: ArrayBuffer;
  75969. /**
  75970. * Callback called when the task is successful
  75971. */
  75972. onSuccess: (task: BinaryFileAssetTask) => void;
  75973. /**
  75974. * Callback called when the task is successful
  75975. */
  75976. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75977. /**
  75978. * Creates a new BinaryFileAssetTask object
  75979. * @param name defines the name of the new task
  75980. * @param url defines the location of the file to load
  75981. */
  75982. constructor(
  75983. /**
  75984. * Defines the name of the task
  75985. */
  75986. name: string,
  75987. /**
  75988. * Defines the location of the file to load
  75989. */
  75990. url: string);
  75991. /**
  75992. * Execute the current task
  75993. * @param scene defines the scene where you want your assets to be loaded
  75994. * @param onSuccess is a callback called when the task is successfully executed
  75995. * @param onError is a callback called if an error occurs
  75996. */
  75997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75998. }
  75999. /**
  76000. * Define a task used by AssetsManager to load images
  76001. */
  76002. export class ImageAssetTask extends AbstractAssetTask {
  76003. /**
  76004. * Defines the name of the task
  76005. */
  76006. name: string;
  76007. /**
  76008. * Defines the location of the image to load
  76009. */
  76010. url: string;
  76011. /**
  76012. * Gets the loaded images
  76013. */
  76014. image: HTMLImageElement;
  76015. /**
  76016. * Callback called when the task is successful
  76017. */
  76018. onSuccess: (task: ImageAssetTask) => void;
  76019. /**
  76020. * Callback called when the task is successful
  76021. */
  76022. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76023. /**
  76024. * Creates a new ImageAssetTask
  76025. * @param name defines the name of the task
  76026. * @param url defines the location of the image to load
  76027. */
  76028. constructor(
  76029. /**
  76030. * Defines the name of the task
  76031. */
  76032. name: string,
  76033. /**
  76034. * Defines the location of the image to load
  76035. */
  76036. url: string);
  76037. /**
  76038. * Execute the current task
  76039. * @param scene defines the scene where you want your assets to be loaded
  76040. * @param onSuccess is a callback called when the task is successfully executed
  76041. * @param onError is a callback called if an error occurs
  76042. */
  76043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76044. }
  76045. /**
  76046. * Defines the interface used by texture loading tasks
  76047. */
  76048. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76049. /**
  76050. * Gets the loaded texture
  76051. */
  76052. texture: TEX;
  76053. }
  76054. /**
  76055. * Define a task used by AssetsManager to load 2D textures
  76056. */
  76057. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76058. /**
  76059. * Defines the name of the task
  76060. */
  76061. name: string;
  76062. /**
  76063. * Defines the location of the file to load
  76064. */
  76065. url: string;
  76066. /**
  76067. * Defines if mipmap should not be generated (default is false)
  76068. */
  76069. noMipmap?: boolean | undefined;
  76070. /**
  76071. * Defines if texture must be inverted on Y axis (default is true)
  76072. */
  76073. invertY: boolean;
  76074. /**
  76075. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76076. */
  76077. samplingMode: number;
  76078. /**
  76079. * Gets the loaded texture
  76080. */
  76081. texture: Texture;
  76082. /**
  76083. * Callback called when the task is successful
  76084. */
  76085. onSuccess: (task: TextureAssetTask) => void;
  76086. /**
  76087. * Callback called when the task is successful
  76088. */
  76089. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76090. /**
  76091. * Creates a new TextureAssetTask object
  76092. * @param name defines the name of the task
  76093. * @param url defines the location of the file to load
  76094. * @param noMipmap defines if mipmap should not be generated (default is false)
  76095. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76096. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76097. */
  76098. constructor(
  76099. /**
  76100. * Defines the name of the task
  76101. */
  76102. name: string,
  76103. /**
  76104. * Defines the location of the file to load
  76105. */
  76106. url: string,
  76107. /**
  76108. * Defines if mipmap should not be generated (default is false)
  76109. */
  76110. noMipmap?: boolean | undefined,
  76111. /**
  76112. * Defines if texture must be inverted on Y axis (default is true)
  76113. */
  76114. invertY?: boolean,
  76115. /**
  76116. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76117. */
  76118. samplingMode?: number);
  76119. /**
  76120. * Execute the current task
  76121. * @param scene defines the scene where you want your assets to be loaded
  76122. * @param onSuccess is a callback called when the task is successfully executed
  76123. * @param onError is a callback called if an error occurs
  76124. */
  76125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76126. }
  76127. /**
  76128. * Define a task used by AssetsManager to load cube textures
  76129. */
  76130. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76131. /**
  76132. * Defines the name of the task
  76133. */
  76134. name: string;
  76135. /**
  76136. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76137. */
  76138. url: string;
  76139. /**
  76140. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76141. */
  76142. extensions?: string[] | undefined;
  76143. /**
  76144. * Defines if mipmaps should not be generated (default is false)
  76145. */
  76146. noMipmap?: boolean | undefined;
  76147. /**
  76148. * Defines the explicit list of files (undefined by default)
  76149. */
  76150. files?: string[] | undefined;
  76151. /**
  76152. * Gets the loaded texture
  76153. */
  76154. texture: CubeTexture;
  76155. /**
  76156. * Callback called when the task is successful
  76157. */
  76158. onSuccess: (task: CubeTextureAssetTask) => void;
  76159. /**
  76160. * Callback called when the task is successful
  76161. */
  76162. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76163. /**
  76164. * Creates a new CubeTextureAssetTask
  76165. * @param name defines the name of the task
  76166. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76167. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76168. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76169. * @param files defines the explicit list of files (undefined by default)
  76170. */
  76171. constructor(
  76172. /**
  76173. * Defines the name of the task
  76174. */
  76175. name: string,
  76176. /**
  76177. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76178. */
  76179. url: string,
  76180. /**
  76181. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76182. */
  76183. extensions?: string[] | undefined,
  76184. /**
  76185. * Defines if mipmaps should not be generated (default is false)
  76186. */
  76187. noMipmap?: boolean | undefined,
  76188. /**
  76189. * Defines the explicit list of files (undefined by default)
  76190. */
  76191. files?: string[] | undefined);
  76192. /**
  76193. * Execute the current task
  76194. * @param scene defines the scene where you want your assets to be loaded
  76195. * @param onSuccess is a callback called when the task is successfully executed
  76196. * @param onError is a callback called if an error occurs
  76197. */
  76198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76199. }
  76200. /**
  76201. * Define a task used by AssetsManager to load HDR cube textures
  76202. */
  76203. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76204. /**
  76205. * Defines the name of the task
  76206. */
  76207. name: string;
  76208. /**
  76209. * Defines the location of the file to load
  76210. */
  76211. url: string;
  76212. /**
  76213. * Defines the desired size (the more it increases the longer the generation will be)
  76214. */
  76215. size: number;
  76216. /**
  76217. * Defines if mipmaps should not be generated (default is false)
  76218. */
  76219. noMipmap: boolean;
  76220. /**
  76221. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76222. */
  76223. generateHarmonics: boolean;
  76224. /**
  76225. * 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)
  76226. */
  76227. gammaSpace: boolean;
  76228. /**
  76229. * Internal Use Only
  76230. */
  76231. reserved: boolean;
  76232. /**
  76233. * Gets the loaded texture
  76234. */
  76235. texture: HDRCubeTexture;
  76236. /**
  76237. * Callback called when the task is successful
  76238. */
  76239. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76240. /**
  76241. * Callback called when the task is successful
  76242. */
  76243. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76244. /**
  76245. * Creates a new HDRCubeTextureAssetTask object
  76246. * @param name defines the name of the task
  76247. * @param url defines the location of the file to load
  76248. * @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.
  76249. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76250. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76251. * @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)
  76252. * @param reserved Internal use only
  76253. */
  76254. constructor(
  76255. /**
  76256. * Defines the name of the task
  76257. */
  76258. name: string,
  76259. /**
  76260. * Defines the location of the file to load
  76261. */
  76262. url: string,
  76263. /**
  76264. * Defines the desired size (the more it increases the longer the generation will be)
  76265. */
  76266. size: number,
  76267. /**
  76268. * Defines if mipmaps should not be generated (default is false)
  76269. */
  76270. noMipmap?: boolean,
  76271. /**
  76272. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76273. */
  76274. generateHarmonics?: boolean,
  76275. /**
  76276. * 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)
  76277. */
  76278. gammaSpace?: boolean,
  76279. /**
  76280. * Internal Use Only
  76281. */
  76282. reserved?: boolean);
  76283. /**
  76284. * Execute the current task
  76285. * @param scene defines the scene where you want your assets to be loaded
  76286. * @param onSuccess is a callback called when the task is successfully executed
  76287. * @param onError is a callback called if an error occurs
  76288. */
  76289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76290. }
  76291. /**
  76292. * Define a task used by AssetsManager to load Equirectangular cube textures
  76293. */
  76294. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76295. /**
  76296. * Defines the name of the task
  76297. */
  76298. name: string;
  76299. /**
  76300. * Defines the location of the file to load
  76301. */
  76302. url: string;
  76303. /**
  76304. * Defines the desired size (the more it increases the longer the generation will be)
  76305. */
  76306. size: number;
  76307. /**
  76308. * Defines if mipmaps should not be generated (default is false)
  76309. */
  76310. noMipmap: boolean;
  76311. /**
  76312. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76313. * but the standard material would require them in Gamma space) (default is true)
  76314. */
  76315. gammaSpace: boolean;
  76316. /**
  76317. * Gets the loaded texture
  76318. */
  76319. texture: EquiRectangularCubeTexture;
  76320. /**
  76321. * Callback called when the task is successful
  76322. */
  76323. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76324. /**
  76325. * Callback called when the task is successful
  76326. */
  76327. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76328. /**
  76329. * Creates a new EquiRectangularCubeTextureAssetTask object
  76330. * @param name defines the name of the task
  76331. * @param url defines the location of the file to load
  76332. * @param size defines the desired size (the more it increases the longer the generation will be)
  76333. * If the size is omitted this implies you are using a preprocessed cubemap.
  76334. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76335. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76336. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76337. * (default is true)
  76338. */
  76339. constructor(
  76340. /**
  76341. * Defines the name of the task
  76342. */
  76343. name: string,
  76344. /**
  76345. * Defines the location of the file to load
  76346. */
  76347. url: string,
  76348. /**
  76349. * Defines the desired size (the more it increases the longer the generation will be)
  76350. */
  76351. size: number,
  76352. /**
  76353. * Defines if mipmaps should not be generated (default is false)
  76354. */
  76355. noMipmap?: boolean,
  76356. /**
  76357. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76358. * but the standard material would require them in Gamma space) (default is true)
  76359. */
  76360. gammaSpace?: boolean);
  76361. /**
  76362. * Execute the current task
  76363. * @param scene defines the scene where you want your assets to be loaded
  76364. * @param onSuccess is a callback called when the task is successfully executed
  76365. * @param onError is a callback called if an error occurs
  76366. */
  76367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76368. }
  76369. /**
  76370. * This class can be used to easily import assets into a scene
  76371. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76372. */
  76373. export class AssetsManager {
  76374. private _scene;
  76375. private _isLoading;
  76376. protected _tasks: AbstractAssetTask[];
  76377. protected _waitingTasksCount: number;
  76378. protected _totalTasksCount: number;
  76379. /**
  76380. * Callback called when all tasks are processed
  76381. */
  76382. onFinish: (tasks: AbstractAssetTask[]) => void;
  76383. /**
  76384. * Callback called when a task is successful
  76385. */
  76386. onTaskSuccess: (task: AbstractAssetTask) => void;
  76387. /**
  76388. * Callback called when a task had an error
  76389. */
  76390. onTaskError: (task: AbstractAssetTask) => void;
  76391. /**
  76392. * Callback called when a task is done (whatever the result is)
  76393. */
  76394. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76395. /**
  76396. * Observable called when all tasks are processed
  76397. */
  76398. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76399. /**
  76400. * Observable called when a task had an error
  76401. */
  76402. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76403. /**
  76404. * Observable called when all tasks were executed
  76405. */
  76406. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76407. /**
  76408. * Observable called when a task is done (whatever the result is)
  76409. */
  76410. onProgressObservable: Observable<IAssetsProgressEvent>;
  76411. /**
  76412. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76413. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76414. */
  76415. useDefaultLoadingScreen: boolean;
  76416. /**
  76417. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76418. * when all assets have been downloaded.
  76419. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76420. */
  76421. autoHideLoadingUI: boolean;
  76422. /**
  76423. * Creates a new AssetsManager
  76424. * @param scene defines the scene to work on
  76425. */
  76426. constructor(scene: Scene);
  76427. /**
  76428. * Add a MeshAssetTask to the list of active tasks
  76429. * @param taskName defines the name of the new task
  76430. * @param meshesNames defines the name of meshes to load
  76431. * @param rootUrl defines the root url to use to locate files
  76432. * @param sceneFilename defines the filename of the scene file
  76433. * @returns a new MeshAssetTask object
  76434. */
  76435. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76436. /**
  76437. * Add a TextFileAssetTask to the list of active tasks
  76438. * @param taskName defines the name of the new task
  76439. * @param url defines the url of the file to load
  76440. * @returns a new TextFileAssetTask object
  76441. */
  76442. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76443. /**
  76444. * Add a BinaryFileAssetTask to the list of active tasks
  76445. * @param taskName defines the name of the new task
  76446. * @param url defines the url of the file to load
  76447. * @returns a new BinaryFileAssetTask object
  76448. */
  76449. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76450. /**
  76451. * Add a ImageAssetTask to the list of active tasks
  76452. * @param taskName defines the name of the new task
  76453. * @param url defines the url of the file to load
  76454. * @returns a new ImageAssetTask object
  76455. */
  76456. addImageTask(taskName: string, url: string): ImageAssetTask;
  76457. /**
  76458. * Add a TextureAssetTask to the list of active tasks
  76459. * @param taskName defines the name of the new task
  76460. * @param url defines the url of the file to load
  76461. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76462. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76463. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76464. * @returns a new TextureAssetTask object
  76465. */
  76466. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76467. /**
  76468. * Add a CubeTextureAssetTask to the list of active tasks
  76469. * @param taskName defines the name of the new task
  76470. * @param url defines the url of the file to load
  76471. * @param extensions defines the extension to use to load the cube map (can be null)
  76472. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76473. * @param files defines the list of files to load (can be null)
  76474. * @returns a new CubeTextureAssetTask object
  76475. */
  76476. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76477. /**
  76478. *
  76479. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76480. * @param taskName defines the name of the new task
  76481. * @param url defines the url of the file to load
  76482. * @param size defines the size you want for the cubemap (can be null)
  76483. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76484. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76485. * @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)
  76486. * @param reserved Internal use only
  76487. * @returns a new HDRCubeTextureAssetTask object
  76488. */
  76489. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76490. /**
  76491. *
  76492. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76493. * @param taskName defines the name of the new task
  76494. * @param url defines the url of the file to load
  76495. * @param size defines the size you want for the cubemap (can be null)
  76496. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76497. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76498. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76499. * @returns a new EquiRectangularCubeTextureAssetTask object
  76500. */
  76501. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76502. /**
  76503. * Remove a task from the assets manager.
  76504. * @param task the task to remove
  76505. */
  76506. removeTask(task: AbstractAssetTask): void;
  76507. private _decreaseWaitingTasksCount;
  76508. private _runTask;
  76509. /**
  76510. * Reset the AssetsManager and remove all tasks
  76511. * @return the current instance of the AssetsManager
  76512. */
  76513. reset(): AssetsManager;
  76514. /**
  76515. * Start the loading process
  76516. * @return the current instance of the AssetsManager
  76517. */
  76518. load(): AssetsManager;
  76519. /**
  76520. * Start the loading process as an async operation
  76521. * @return a promise returning the list of failed tasks
  76522. */
  76523. loadAsync(): Promise<void>;
  76524. }
  76525. }
  76526. declare module "babylonjs/Misc/deferred" {
  76527. /**
  76528. * Wrapper class for promise with external resolve and reject.
  76529. */
  76530. export class Deferred<T> {
  76531. /**
  76532. * The promise associated with this deferred object.
  76533. */
  76534. readonly promise: Promise<T>;
  76535. private _resolve;
  76536. private _reject;
  76537. /**
  76538. * The resolve method of the promise associated with this deferred object.
  76539. */
  76540. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76541. /**
  76542. * The reject method of the promise associated with this deferred object.
  76543. */
  76544. get reject(): (reason?: any) => void;
  76545. /**
  76546. * Constructor for this deferred object.
  76547. */
  76548. constructor();
  76549. }
  76550. }
  76551. declare module "babylonjs/Misc/meshExploder" {
  76552. import { Mesh } from "babylonjs/Meshes/mesh";
  76553. /**
  76554. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76555. */
  76556. export class MeshExploder {
  76557. private _centerMesh;
  76558. private _meshes;
  76559. private _meshesOrigins;
  76560. private _toCenterVectors;
  76561. private _scaledDirection;
  76562. private _newPosition;
  76563. private _centerPosition;
  76564. /**
  76565. * Explodes meshes from a center mesh.
  76566. * @param meshes The meshes to explode.
  76567. * @param centerMesh The mesh to be center of explosion.
  76568. */
  76569. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76570. private _setCenterMesh;
  76571. /**
  76572. * Get class name
  76573. * @returns "MeshExploder"
  76574. */
  76575. getClassName(): string;
  76576. /**
  76577. * "Exploded meshes"
  76578. * @returns Array of meshes with the centerMesh at index 0.
  76579. */
  76580. getMeshes(): Array<Mesh>;
  76581. /**
  76582. * Explodes meshes giving a specific direction
  76583. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76584. */
  76585. explode(direction?: number): void;
  76586. }
  76587. }
  76588. declare module "babylonjs/Misc/filesInput" {
  76589. import { Engine } from "babylonjs/Engines/engine";
  76590. import { Scene } from "babylonjs/scene";
  76591. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76592. import { Nullable } from "babylonjs/types";
  76593. /**
  76594. * Class used to help managing file picking and drag'n'drop
  76595. */
  76596. export class FilesInput {
  76597. /**
  76598. * List of files ready to be loaded
  76599. */
  76600. static get FilesToLoad(): {
  76601. [key: string]: File;
  76602. };
  76603. /**
  76604. * Callback called when a file is processed
  76605. */
  76606. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76607. private _engine;
  76608. private _currentScene;
  76609. private _sceneLoadedCallback;
  76610. private _progressCallback;
  76611. private _additionalRenderLoopLogicCallback;
  76612. private _textureLoadingCallback;
  76613. private _startingProcessingFilesCallback;
  76614. private _onReloadCallback;
  76615. private _errorCallback;
  76616. private _elementToMonitor;
  76617. private _sceneFileToLoad;
  76618. private _filesToLoad;
  76619. /**
  76620. * Creates a new FilesInput
  76621. * @param engine defines the rendering engine
  76622. * @param scene defines the hosting scene
  76623. * @param sceneLoadedCallback callback called when scene is loaded
  76624. * @param progressCallback callback called to track progress
  76625. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76626. * @param textureLoadingCallback callback called when a texture is loading
  76627. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76628. * @param onReloadCallback callback called when a reload is requested
  76629. * @param errorCallback callback call if an error occurs
  76630. */
  76631. 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>);
  76632. private _dragEnterHandler;
  76633. private _dragOverHandler;
  76634. private _dropHandler;
  76635. /**
  76636. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76637. * @param elementToMonitor defines the DOM element to track
  76638. */
  76639. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76640. /** Gets the current list of files to load */
  76641. get filesToLoad(): File[];
  76642. /**
  76643. * Release all associated resources
  76644. */
  76645. dispose(): void;
  76646. private renderFunction;
  76647. private drag;
  76648. private drop;
  76649. private _traverseFolder;
  76650. private _processFiles;
  76651. /**
  76652. * Load files from a drop event
  76653. * @param event defines the drop event to use as source
  76654. */
  76655. loadFiles(event: any): void;
  76656. private _processReload;
  76657. /**
  76658. * Reload the current scene from the loaded files
  76659. */
  76660. reload(): void;
  76661. }
  76662. }
  76663. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76664. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76665. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76666. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76667. }
  76668. declare module "babylonjs/Misc/sceneOptimizer" {
  76669. import { Scene, IDisposable } from "babylonjs/scene";
  76670. import { Observable } from "babylonjs/Misc/observable";
  76671. /**
  76672. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76673. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76674. */
  76675. export class SceneOptimization {
  76676. /**
  76677. * Defines the priority of this optimization (0 by default which means first in the list)
  76678. */
  76679. priority: number;
  76680. /**
  76681. * Gets a string describing the action executed by the current optimization
  76682. * @returns description string
  76683. */
  76684. getDescription(): string;
  76685. /**
  76686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76687. * @param scene defines the current scene where to apply this optimization
  76688. * @param optimizer defines the current optimizer
  76689. * @returns true if everything that can be done was applied
  76690. */
  76691. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76692. /**
  76693. * Creates the SceneOptimization object
  76694. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76695. * @param desc defines the description associated with the optimization
  76696. */
  76697. constructor(
  76698. /**
  76699. * Defines the priority of this optimization (0 by default which means first in the list)
  76700. */
  76701. priority?: number);
  76702. }
  76703. /**
  76704. * Defines an optimization used to reduce the size of render target textures
  76705. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76706. */
  76707. export class TextureOptimization extends SceneOptimization {
  76708. /**
  76709. * Defines the priority of this optimization (0 by default which means first in the list)
  76710. */
  76711. priority: number;
  76712. /**
  76713. * 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
  76714. */
  76715. maximumSize: number;
  76716. /**
  76717. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76718. */
  76719. step: number;
  76720. /**
  76721. * Gets a string describing the action executed by the current optimization
  76722. * @returns description string
  76723. */
  76724. getDescription(): string;
  76725. /**
  76726. * Creates the TextureOptimization object
  76727. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76728. * @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
  76729. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76730. */
  76731. constructor(
  76732. /**
  76733. * Defines the priority of this optimization (0 by default which means first in the list)
  76734. */
  76735. priority?: number,
  76736. /**
  76737. * 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
  76738. */
  76739. maximumSize?: number,
  76740. /**
  76741. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76742. */
  76743. step?: number);
  76744. /**
  76745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76746. * @param scene defines the current scene where to apply this optimization
  76747. * @param optimizer defines the current optimizer
  76748. * @returns true if everything that can be done was applied
  76749. */
  76750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76751. }
  76752. /**
  76753. * Defines an optimization used to increase or decrease the rendering resolution
  76754. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76755. */
  76756. export class HardwareScalingOptimization extends SceneOptimization {
  76757. /**
  76758. * Defines the priority of this optimization (0 by default which means first in the list)
  76759. */
  76760. priority: number;
  76761. /**
  76762. * Defines the maximum scale to use (2 by default)
  76763. */
  76764. maximumScale: number;
  76765. /**
  76766. * Defines the step to use between two passes (0.5 by default)
  76767. */
  76768. step: number;
  76769. private _currentScale;
  76770. private _directionOffset;
  76771. /**
  76772. * Gets a string describing the action executed by the current optimization
  76773. * @return description string
  76774. */
  76775. getDescription(): string;
  76776. /**
  76777. * Creates the HardwareScalingOptimization object
  76778. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76779. * @param maximumScale defines the maximum scale to use (2 by default)
  76780. * @param step defines the step to use between two passes (0.5 by default)
  76781. */
  76782. constructor(
  76783. /**
  76784. * Defines the priority of this optimization (0 by default which means first in the list)
  76785. */
  76786. priority?: number,
  76787. /**
  76788. * Defines the maximum scale to use (2 by default)
  76789. */
  76790. maximumScale?: number,
  76791. /**
  76792. * Defines the step to use between two passes (0.5 by default)
  76793. */
  76794. step?: number);
  76795. /**
  76796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76797. * @param scene defines the current scene where to apply this optimization
  76798. * @param optimizer defines the current optimizer
  76799. * @returns true if everything that can be done was applied
  76800. */
  76801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76802. }
  76803. /**
  76804. * Defines an optimization used to remove shadows
  76805. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76806. */
  76807. export class ShadowsOptimization extends SceneOptimization {
  76808. /**
  76809. * Gets a string describing the action executed by the current optimization
  76810. * @return description string
  76811. */
  76812. getDescription(): string;
  76813. /**
  76814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76815. * @param scene defines the current scene where to apply this optimization
  76816. * @param optimizer defines the current optimizer
  76817. * @returns true if everything that can be done was applied
  76818. */
  76819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76820. }
  76821. /**
  76822. * Defines an optimization used to turn post-processes off
  76823. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76824. */
  76825. export class PostProcessesOptimization extends SceneOptimization {
  76826. /**
  76827. * Gets a string describing the action executed by the current optimization
  76828. * @return description string
  76829. */
  76830. getDescription(): string;
  76831. /**
  76832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76833. * @param scene defines the current scene where to apply this optimization
  76834. * @param optimizer defines the current optimizer
  76835. * @returns true if everything that can be done was applied
  76836. */
  76837. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76838. }
  76839. /**
  76840. * Defines an optimization used to turn lens flares off
  76841. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76842. */
  76843. export class LensFlaresOptimization extends SceneOptimization {
  76844. /**
  76845. * Gets a string describing the action executed by the current optimization
  76846. * @return description string
  76847. */
  76848. getDescription(): string;
  76849. /**
  76850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76851. * @param scene defines the current scene where to apply this optimization
  76852. * @param optimizer defines the current optimizer
  76853. * @returns true if everything that can be done was applied
  76854. */
  76855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76856. }
  76857. /**
  76858. * Defines an optimization based on user defined callback.
  76859. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76860. */
  76861. export class CustomOptimization extends SceneOptimization {
  76862. /**
  76863. * Callback called to apply the custom optimization.
  76864. */
  76865. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76866. /**
  76867. * Callback called to get custom description
  76868. */
  76869. onGetDescription: () => string;
  76870. /**
  76871. * Gets a string describing the action executed by the current optimization
  76872. * @returns description string
  76873. */
  76874. getDescription(): string;
  76875. /**
  76876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76877. * @param scene defines the current scene where to apply this optimization
  76878. * @param optimizer defines the current optimizer
  76879. * @returns true if everything that can be done was applied
  76880. */
  76881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76882. }
  76883. /**
  76884. * Defines an optimization used to turn particles off
  76885. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76886. */
  76887. export class ParticlesOptimization extends SceneOptimization {
  76888. /**
  76889. * Gets a string describing the action executed by the current optimization
  76890. * @return description string
  76891. */
  76892. getDescription(): string;
  76893. /**
  76894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76895. * @param scene defines the current scene where to apply this optimization
  76896. * @param optimizer defines the current optimizer
  76897. * @returns true if everything that can be done was applied
  76898. */
  76899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76900. }
  76901. /**
  76902. * Defines an optimization used to turn render targets off
  76903. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76904. */
  76905. export class RenderTargetsOptimization extends SceneOptimization {
  76906. /**
  76907. * Gets a string describing the action executed by the current optimization
  76908. * @return description string
  76909. */
  76910. getDescription(): string;
  76911. /**
  76912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76913. * @param scene defines the current scene where to apply this optimization
  76914. * @param optimizer defines the current optimizer
  76915. * @returns true if everything that can be done was applied
  76916. */
  76917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76918. }
  76919. /**
  76920. * Defines an optimization used to merge meshes with compatible materials
  76921. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76922. */
  76923. export class MergeMeshesOptimization extends SceneOptimization {
  76924. private static _UpdateSelectionTree;
  76925. /**
  76926. * Gets or sets a boolean which defines if optimization octree has to be updated
  76927. */
  76928. static get UpdateSelectionTree(): boolean;
  76929. /**
  76930. * Gets or sets a boolean which defines if optimization octree has to be updated
  76931. */
  76932. static set UpdateSelectionTree(value: boolean);
  76933. /**
  76934. * Gets a string describing the action executed by the current optimization
  76935. * @return description string
  76936. */
  76937. getDescription(): string;
  76938. private _canBeMerged;
  76939. /**
  76940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76941. * @param scene defines the current scene where to apply this optimization
  76942. * @param optimizer defines the current optimizer
  76943. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76944. * @returns true if everything that can be done was applied
  76945. */
  76946. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76947. }
  76948. /**
  76949. * Defines a list of options used by SceneOptimizer
  76950. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76951. */
  76952. export class SceneOptimizerOptions {
  76953. /**
  76954. * Defines the target frame rate to reach (60 by default)
  76955. */
  76956. targetFrameRate: number;
  76957. /**
  76958. * Defines the interval between two checkes (2000ms by default)
  76959. */
  76960. trackerDuration: number;
  76961. /**
  76962. * Gets the list of optimizations to apply
  76963. */
  76964. optimizations: SceneOptimization[];
  76965. /**
  76966. * Creates a new list of options used by SceneOptimizer
  76967. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76968. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76969. */
  76970. constructor(
  76971. /**
  76972. * Defines the target frame rate to reach (60 by default)
  76973. */
  76974. targetFrameRate?: number,
  76975. /**
  76976. * Defines the interval between two checkes (2000ms by default)
  76977. */
  76978. trackerDuration?: number);
  76979. /**
  76980. * Add a new optimization
  76981. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76982. * @returns the current SceneOptimizerOptions
  76983. */
  76984. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76985. /**
  76986. * Add a new custom optimization
  76987. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76988. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76989. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76990. * @returns the current SceneOptimizerOptions
  76991. */
  76992. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76993. /**
  76994. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76995. * @param targetFrameRate defines the target frame rate (60 by default)
  76996. * @returns a SceneOptimizerOptions object
  76997. */
  76998. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76999. /**
  77000. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77001. * @param targetFrameRate defines the target frame rate (60 by default)
  77002. * @returns a SceneOptimizerOptions object
  77003. */
  77004. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77005. /**
  77006. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77007. * @param targetFrameRate defines the target frame rate (60 by default)
  77008. * @returns a SceneOptimizerOptions object
  77009. */
  77010. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77011. }
  77012. /**
  77013. * Class used to run optimizations in order to reach a target frame rate
  77014. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77015. */
  77016. export class SceneOptimizer implements IDisposable {
  77017. private _isRunning;
  77018. private _options;
  77019. private _scene;
  77020. private _currentPriorityLevel;
  77021. private _targetFrameRate;
  77022. private _trackerDuration;
  77023. private _currentFrameRate;
  77024. private _sceneDisposeObserver;
  77025. private _improvementMode;
  77026. /**
  77027. * Defines an observable called when the optimizer reaches the target frame rate
  77028. */
  77029. onSuccessObservable: Observable<SceneOptimizer>;
  77030. /**
  77031. * Defines an observable called when the optimizer enables an optimization
  77032. */
  77033. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77034. /**
  77035. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77036. */
  77037. onFailureObservable: Observable<SceneOptimizer>;
  77038. /**
  77039. * Gets a boolean indicating if the optimizer is in improvement mode
  77040. */
  77041. get isInImprovementMode(): boolean;
  77042. /**
  77043. * Gets the current priority level (0 at start)
  77044. */
  77045. get currentPriorityLevel(): number;
  77046. /**
  77047. * Gets the current frame rate checked by the SceneOptimizer
  77048. */
  77049. get currentFrameRate(): number;
  77050. /**
  77051. * Gets or sets the current target frame rate (60 by default)
  77052. */
  77053. get targetFrameRate(): number;
  77054. /**
  77055. * Gets or sets the current target frame rate (60 by default)
  77056. */
  77057. set targetFrameRate(value: number);
  77058. /**
  77059. * Gets or sets the current interval between two checks (every 2000ms by default)
  77060. */
  77061. get trackerDuration(): number;
  77062. /**
  77063. * Gets or sets the current interval between two checks (every 2000ms by default)
  77064. */
  77065. set trackerDuration(value: number);
  77066. /**
  77067. * Gets the list of active optimizations
  77068. */
  77069. get optimizations(): SceneOptimization[];
  77070. /**
  77071. * Creates a new SceneOptimizer
  77072. * @param scene defines the scene to work on
  77073. * @param options defines the options to use with the SceneOptimizer
  77074. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77075. * @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)
  77076. */
  77077. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77078. /**
  77079. * Stops the current optimizer
  77080. */
  77081. stop(): void;
  77082. /**
  77083. * Reset the optimizer to initial step (current priority level = 0)
  77084. */
  77085. reset(): void;
  77086. /**
  77087. * Start the optimizer. By default it will try to reach a specific framerate
  77088. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77089. */
  77090. start(): void;
  77091. private _checkCurrentState;
  77092. /**
  77093. * Release all resources
  77094. */
  77095. dispose(): void;
  77096. /**
  77097. * Helper function to create a SceneOptimizer with one single line of code
  77098. * @param scene defines the scene to work on
  77099. * @param options defines the options to use with the SceneOptimizer
  77100. * @param onSuccess defines a callback to call on success
  77101. * @param onFailure defines a callback to call on failure
  77102. * @returns the new SceneOptimizer object
  77103. */
  77104. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77105. }
  77106. }
  77107. declare module "babylonjs/Misc/sceneSerializer" {
  77108. import { Scene } from "babylonjs/scene";
  77109. /**
  77110. * Class used to serialize a scene into a string
  77111. */
  77112. export class SceneSerializer {
  77113. /**
  77114. * Clear cache used by a previous serialization
  77115. */
  77116. static ClearCache(): void;
  77117. /**
  77118. * Serialize a scene into a JSON compatible object
  77119. * @param scene defines the scene to serialize
  77120. * @returns a JSON compatible object
  77121. */
  77122. static Serialize(scene: Scene): any;
  77123. /**
  77124. * Serialize a mesh into a JSON compatible object
  77125. * @param toSerialize defines the mesh to serialize
  77126. * @param withParents defines if parents must be serialized as well
  77127. * @param withChildren defines if children must be serialized as well
  77128. * @returns a JSON compatible object
  77129. */
  77130. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77131. }
  77132. }
  77133. declare module "babylonjs/Misc/textureTools" {
  77134. import { Texture } from "babylonjs/Materials/Textures/texture";
  77135. /**
  77136. * Class used to host texture specific utilities
  77137. */
  77138. export class TextureTools {
  77139. /**
  77140. * Uses the GPU to create a copy texture rescaled at a given size
  77141. * @param texture Texture to copy from
  77142. * @param width defines the desired width
  77143. * @param height defines the desired height
  77144. * @param useBilinearMode defines if bilinear mode has to be used
  77145. * @return the generated texture
  77146. */
  77147. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77148. }
  77149. }
  77150. declare module "babylonjs/Misc/videoRecorder" {
  77151. import { Nullable } from "babylonjs/types";
  77152. import { Engine } from "babylonjs/Engines/engine";
  77153. /**
  77154. * This represents the different options available for the video capture.
  77155. */
  77156. export interface VideoRecorderOptions {
  77157. /** Defines the mime type of the video. */
  77158. mimeType: string;
  77159. /** Defines the FPS the video should be recorded at. */
  77160. fps: number;
  77161. /** Defines the chunk size for the recording data. */
  77162. recordChunckSize: number;
  77163. /** The audio tracks to attach to the recording. */
  77164. audioTracks?: MediaStreamTrack[];
  77165. }
  77166. /**
  77167. * This can help with recording videos from BabylonJS.
  77168. * This is based on the available WebRTC functionalities of the browser.
  77169. *
  77170. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77171. */
  77172. export class VideoRecorder {
  77173. private static readonly _defaultOptions;
  77174. /**
  77175. * Returns whether or not the VideoRecorder is available in your browser.
  77176. * @param engine Defines the Babylon Engine.
  77177. * @returns true if supported otherwise false.
  77178. */
  77179. static IsSupported(engine: Engine): boolean;
  77180. private readonly _options;
  77181. private _canvas;
  77182. private _mediaRecorder;
  77183. private _recordedChunks;
  77184. private _fileName;
  77185. private _resolve;
  77186. private _reject;
  77187. /**
  77188. * True when a recording is already in progress.
  77189. */
  77190. get isRecording(): boolean;
  77191. /**
  77192. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77193. * @param engine Defines the BabylonJS Engine you wish to record.
  77194. * @param options Defines options that can be used to customize the capture.
  77195. */
  77196. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77197. /**
  77198. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77199. */
  77200. stopRecording(): void;
  77201. /**
  77202. * Starts recording the canvas for a max duration specified in parameters.
  77203. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77204. * If null no automatic download will start and you can rely on the promise to get the data back.
  77205. * @param maxDuration Defines the maximum recording time in seconds.
  77206. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77207. * @return A promise callback at the end of the recording with the video data in Blob.
  77208. */
  77209. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77210. /**
  77211. * Releases internal resources used during the recording.
  77212. */
  77213. dispose(): void;
  77214. private _handleDataAvailable;
  77215. private _handleError;
  77216. private _handleStop;
  77217. }
  77218. }
  77219. declare module "babylonjs/Misc/screenshotTools" {
  77220. import { Camera } from "babylonjs/Cameras/camera";
  77221. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77222. import { Engine } from "babylonjs/Engines/engine";
  77223. /**
  77224. * Class containing a set of static utilities functions for screenshots
  77225. */
  77226. export class ScreenshotTools {
  77227. /**
  77228. * Captures a screenshot of the current rendering
  77229. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77230. * @param engine defines the rendering engine
  77231. * @param camera defines the source camera
  77232. * @param size This parameter can be set to a single number or to an object with the
  77233. * following (optional) properties: precision, width, height. If a single number is passed,
  77234. * it will be used for both width and height. If an object is passed, the screenshot size
  77235. * will be derived from the parameters. The precision property is a multiplier allowing
  77236. * rendering at a higher or lower resolution
  77237. * @param successCallback defines the callback receives a single parameter which contains the
  77238. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77239. * src parameter of an <img> to display it
  77240. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77241. * Check your browser for supported MIME types
  77242. */
  77243. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77244. /**
  77245. * Captures a screenshot of the current rendering
  77246. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77247. * @param engine defines the rendering engine
  77248. * @param camera defines the source camera
  77249. * @param size This parameter can be set to a single number or to an object with the
  77250. * following (optional) properties: precision, width, height. If a single number is passed,
  77251. * it will be used for both width and height. If an object is passed, the screenshot size
  77252. * will be derived from the parameters. The precision property is a multiplier allowing
  77253. * rendering at a higher or lower resolution
  77254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77255. * Check your browser for supported MIME types
  77256. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77257. * to the src parameter of an <img> to display it
  77258. */
  77259. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77260. /**
  77261. * Generates an image screenshot from the specified camera.
  77262. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77263. * @param engine The engine to use for rendering
  77264. * @param camera The camera to use for rendering
  77265. * @param size This parameter can be set to a single number or to an object with the
  77266. * following (optional) properties: precision, width, height. If a single number is passed,
  77267. * it will be used for both width and height. If an object is passed, the screenshot size
  77268. * will be derived from the parameters. The precision property is a multiplier allowing
  77269. * rendering at a higher or lower resolution
  77270. * @param successCallback The callback receives a single parameter which contains the
  77271. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77272. * src parameter of an <img> to display it
  77273. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77274. * Check your browser for supported MIME types
  77275. * @param samples Texture samples (default: 1)
  77276. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77277. * @param fileName A name for for the downloaded file.
  77278. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77279. */
  77280. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77281. /**
  77282. * Generates an image screenshot from the specified camera.
  77283. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77284. * @param engine The engine to use for rendering
  77285. * @param camera The camera to use for rendering
  77286. * @param size This parameter can be set to a single number or to an object with the
  77287. * following (optional) properties: precision, width, height. If a single number is passed,
  77288. * it will be used for both width and height. If an object is passed, the screenshot size
  77289. * will be derived from the parameters. The precision property is a multiplier allowing
  77290. * rendering at a higher or lower resolution
  77291. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77292. * Check your browser for supported MIME types
  77293. * @param samples Texture samples (default: 1)
  77294. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77295. * @param fileName A name for for the downloaded file.
  77296. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77297. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77298. * to the src parameter of an <img> to display it
  77299. */
  77300. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77301. /**
  77302. * Gets height and width for screenshot size
  77303. * @private
  77304. */
  77305. private static _getScreenshotSize;
  77306. }
  77307. }
  77308. declare module "babylonjs/Misc/dataReader" {
  77309. /**
  77310. * Interface for a data buffer
  77311. */
  77312. export interface IDataBuffer {
  77313. /**
  77314. * Reads bytes from the data buffer.
  77315. * @param byteOffset The byte offset to read
  77316. * @param byteLength The byte length to read
  77317. * @returns A promise that resolves when the bytes are read
  77318. */
  77319. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77320. /**
  77321. * The byte length of the buffer.
  77322. */
  77323. readonly byteLength: number;
  77324. }
  77325. /**
  77326. * Utility class for reading from a data buffer
  77327. */
  77328. export class DataReader {
  77329. /**
  77330. * The data buffer associated with this data reader.
  77331. */
  77332. readonly buffer: IDataBuffer;
  77333. /**
  77334. * The current byte offset from the beginning of the data buffer.
  77335. */
  77336. byteOffset: number;
  77337. private _dataView;
  77338. private _dataByteOffset;
  77339. /**
  77340. * Constructor
  77341. * @param buffer The buffer to read
  77342. */
  77343. constructor(buffer: IDataBuffer);
  77344. /**
  77345. * Loads the given byte length.
  77346. * @param byteLength The byte length to load
  77347. * @returns A promise that resolves when the load is complete
  77348. */
  77349. loadAsync(byteLength: number): Promise<void>;
  77350. /**
  77351. * Read a unsigned 32-bit integer from the currently loaded data range.
  77352. * @returns The 32-bit integer read
  77353. */
  77354. readUint32(): number;
  77355. /**
  77356. * Read a byte array from the currently loaded data range.
  77357. * @param byteLength The byte length to read
  77358. * @returns The byte array read
  77359. */
  77360. readUint8Array(byteLength: number): Uint8Array;
  77361. /**
  77362. * Read a string from the currently loaded data range.
  77363. * @param byteLength The byte length to read
  77364. * @returns The string read
  77365. */
  77366. readString(byteLength: number): string;
  77367. /**
  77368. * Skips the given byte length the currently loaded data range.
  77369. * @param byteLength The byte length to skip
  77370. */
  77371. skipBytes(byteLength: number): void;
  77372. }
  77373. }
  77374. declare module "babylonjs/Misc/dataStorage" {
  77375. /**
  77376. * Class for storing data to local storage if available or in-memory storage otherwise
  77377. */
  77378. export class DataStorage {
  77379. private static _Storage;
  77380. private static _GetStorage;
  77381. /**
  77382. * Reads a string from the data storage
  77383. * @param key The key to read
  77384. * @param defaultValue The value if the key doesn't exist
  77385. * @returns The string value
  77386. */
  77387. static ReadString(key: string, defaultValue: string): string;
  77388. /**
  77389. * Writes a string to the data storage
  77390. * @param key The key to write
  77391. * @param value The value to write
  77392. */
  77393. static WriteString(key: string, value: string): void;
  77394. /**
  77395. * Reads a boolean from the data storage
  77396. * @param key The key to read
  77397. * @param defaultValue The value if the key doesn't exist
  77398. * @returns The boolean value
  77399. */
  77400. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77401. /**
  77402. * Writes a boolean to the data storage
  77403. * @param key The key to write
  77404. * @param value The value to write
  77405. */
  77406. static WriteBoolean(key: string, value: boolean): void;
  77407. /**
  77408. * Reads a number from the data storage
  77409. * @param key The key to read
  77410. * @param defaultValue The value if the key doesn't exist
  77411. * @returns The number value
  77412. */
  77413. static ReadNumber(key: string, defaultValue: number): number;
  77414. /**
  77415. * Writes a number to the data storage
  77416. * @param key The key to write
  77417. * @param value The value to write
  77418. */
  77419. static WriteNumber(key: string, value: number): void;
  77420. }
  77421. }
  77422. declare module "babylonjs/Misc/index" {
  77423. export * from "babylonjs/Misc/andOrNotEvaluator";
  77424. export * from "babylonjs/Misc/assetsManager";
  77425. export * from "babylonjs/Misc/basis";
  77426. export * from "babylonjs/Misc/dds";
  77427. export * from "babylonjs/Misc/decorators";
  77428. export * from "babylonjs/Misc/deferred";
  77429. export * from "babylonjs/Misc/environmentTextureTools";
  77430. export * from "babylonjs/Misc/meshExploder";
  77431. export * from "babylonjs/Misc/filesInput";
  77432. export * from "babylonjs/Misc/HighDynamicRange/index";
  77433. export * from "babylonjs/Misc/khronosTextureContainer";
  77434. export * from "babylonjs/Misc/observable";
  77435. export * from "babylonjs/Misc/performanceMonitor";
  77436. export * from "babylonjs/Misc/promise";
  77437. export * from "babylonjs/Misc/sceneOptimizer";
  77438. export * from "babylonjs/Misc/sceneSerializer";
  77439. export * from "babylonjs/Misc/smartArray";
  77440. export * from "babylonjs/Misc/stringDictionary";
  77441. export * from "babylonjs/Misc/tags";
  77442. export * from "babylonjs/Misc/textureTools";
  77443. export * from "babylonjs/Misc/tga";
  77444. export * from "babylonjs/Misc/tools";
  77445. export * from "babylonjs/Misc/videoRecorder";
  77446. export * from "babylonjs/Misc/virtualJoystick";
  77447. export * from "babylonjs/Misc/workerPool";
  77448. export * from "babylonjs/Misc/logger";
  77449. export * from "babylonjs/Misc/typeStore";
  77450. export * from "babylonjs/Misc/filesInputStore";
  77451. export * from "babylonjs/Misc/deepCopier";
  77452. export * from "babylonjs/Misc/pivotTools";
  77453. export * from "babylonjs/Misc/precisionDate";
  77454. export * from "babylonjs/Misc/screenshotTools";
  77455. export * from "babylonjs/Misc/typeStore";
  77456. export * from "babylonjs/Misc/webRequest";
  77457. export * from "babylonjs/Misc/iInspectable";
  77458. export * from "babylonjs/Misc/brdfTextureTools";
  77459. export * from "babylonjs/Misc/rgbdTextureTools";
  77460. export * from "babylonjs/Misc/gradients";
  77461. export * from "babylonjs/Misc/perfCounter";
  77462. export * from "babylonjs/Misc/fileRequest";
  77463. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77464. export * from "babylonjs/Misc/retryStrategy";
  77465. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77466. export * from "babylonjs/Misc/canvasGenerator";
  77467. export * from "babylonjs/Misc/fileTools";
  77468. export * from "babylonjs/Misc/stringTools";
  77469. export * from "babylonjs/Misc/dataReader";
  77470. export * from "babylonjs/Misc/minMaxReducer";
  77471. export * from "babylonjs/Misc/depthReducer";
  77472. export * from "babylonjs/Misc/dataStorage";
  77473. }
  77474. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77475. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77476. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77477. import { Observable } from "babylonjs/Misc/observable";
  77478. import { Matrix } from "babylonjs/Maths/math.vector";
  77479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77480. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77481. /**
  77482. * An interface for all Hit test features
  77483. */
  77484. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77485. /**
  77486. * Triggered when new babylon (transformed) hit test results are available
  77487. */
  77488. onHitTestResultObservable: Observable<T[]>;
  77489. }
  77490. /**
  77491. * Options used for hit testing
  77492. */
  77493. export interface IWebXRLegacyHitTestOptions {
  77494. /**
  77495. * Only test when user interacted with the scene. Default - hit test every frame
  77496. */
  77497. testOnPointerDownOnly?: boolean;
  77498. /**
  77499. * The node to use to transform the local results to world coordinates
  77500. */
  77501. worldParentNode?: TransformNode;
  77502. }
  77503. /**
  77504. * Interface defining the babylon result of raycasting/hit-test
  77505. */
  77506. export interface IWebXRLegacyHitResult {
  77507. /**
  77508. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77509. */
  77510. transformationMatrix: Matrix;
  77511. /**
  77512. * The native hit test result
  77513. */
  77514. xrHitResult: XRHitResult | XRHitTestResult;
  77515. }
  77516. /**
  77517. * The currently-working hit-test module.
  77518. * Hit test (or Ray-casting) is used to interact with the real world.
  77519. * For further information read here - https://github.com/immersive-web/hit-test
  77520. */
  77521. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77522. /**
  77523. * options to use when constructing this feature
  77524. */
  77525. readonly options: IWebXRLegacyHitTestOptions;
  77526. private _direction;
  77527. private _mat;
  77528. private _onSelectEnabled;
  77529. private _origin;
  77530. /**
  77531. * The module's name
  77532. */
  77533. static readonly Name: string;
  77534. /**
  77535. * The (Babylon) version of this module.
  77536. * This is an integer representing the implementation version.
  77537. * This number does not correspond to the WebXR specs version
  77538. */
  77539. static readonly Version: number;
  77540. /**
  77541. * Populated with the last native XR Hit Results
  77542. */
  77543. lastNativeXRHitResults: XRHitResult[];
  77544. /**
  77545. * Triggered when new babylon (transformed) hit test results are available
  77546. */
  77547. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77548. /**
  77549. * Creates a new instance of the (legacy version) hit test feature
  77550. * @param _xrSessionManager an instance of WebXRSessionManager
  77551. * @param options options to use when constructing this feature
  77552. */
  77553. constructor(_xrSessionManager: WebXRSessionManager,
  77554. /**
  77555. * options to use when constructing this feature
  77556. */
  77557. options?: IWebXRLegacyHitTestOptions);
  77558. /**
  77559. * execute a hit test with an XR Ray
  77560. *
  77561. * @param xrSession a native xrSession that will execute this hit test
  77562. * @param xrRay the ray (position and direction) to use for ray-casting
  77563. * @param referenceSpace native XR reference space to use for the hit-test
  77564. * @param filter filter function that will filter the results
  77565. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77566. */
  77567. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77568. /**
  77569. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77570. * @param event the (select) event to use to select with
  77571. * @param referenceSpace the reference space to use for this hit test
  77572. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77573. */
  77574. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77575. /**
  77576. * attach this feature
  77577. * Will usually be called by the features manager
  77578. *
  77579. * @returns true if successful.
  77580. */
  77581. attach(): boolean;
  77582. /**
  77583. * detach this feature.
  77584. * Will usually be called by the features manager
  77585. *
  77586. * @returns true if successful.
  77587. */
  77588. detach(): boolean;
  77589. /**
  77590. * Dispose this feature and all of the resources attached
  77591. */
  77592. dispose(): void;
  77593. protected _onXRFrame(frame: XRFrame): void;
  77594. private _onHitTestResults;
  77595. private _onSelect;
  77596. }
  77597. }
  77598. declare module "babylonjs/XR/features/WebXRHitTest" {
  77599. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77600. import { Observable } from "babylonjs/Misc/observable";
  77601. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77602. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77603. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77604. /**
  77605. * Options used for hit testing (version 2)
  77606. */
  77607. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77608. /**
  77609. * Do not create a permanent hit test. Will usually be used when only
  77610. * transient inputs are needed.
  77611. */
  77612. disablePermanentHitTest?: boolean;
  77613. /**
  77614. * Enable transient (for example touch-based) hit test inspections
  77615. */
  77616. enableTransientHitTest?: boolean;
  77617. /**
  77618. * Offset ray for the permanent hit test
  77619. */
  77620. offsetRay?: Vector3;
  77621. /**
  77622. * Offset ray for the transient hit test
  77623. */
  77624. transientOffsetRay?: Vector3;
  77625. /**
  77626. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77627. */
  77628. useReferenceSpace?: boolean;
  77629. }
  77630. /**
  77631. * Interface defining the babylon result of hit-test
  77632. */
  77633. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77634. /**
  77635. * The input source that generated this hit test (if transient)
  77636. */
  77637. inputSource?: XRInputSource;
  77638. /**
  77639. * Is this a transient hit test
  77640. */
  77641. isTransient?: boolean;
  77642. /**
  77643. * Position of the hit test result
  77644. */
  77645. position: Vector3;
  77646. /**
  77647. * Rotation of the hit test result
  77648. */
  77649. rotationQuaternion: Quaternion;
  77650. /**
  77651. * The native hit test result
  77652. */
  77653. xrHitResult: XRHitTestResult;
  77654. }
  77655. /**
  77656. * The currently-working hit-test module.
  77657. * Hit test (or Ray-casting) is used to interact with the real world.
  77658. * For further information read here - https://github.com/immersive-web/hit-test
  77659. *
  77660. * Tested on chrome (mobile) 80.
  77661. */
  77662. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77663. /**
  77664. * options to use when constructing this feature
  77665. */
  77666. readonly options: IWebXRHitTestOptions;
  77667. private _tmpMat;
  77668. private _tmpPos;
  77669. private _tmpQuat;
  77670. private _transientXrHitTestSource;
  77671. private _xrHitTestSource;
  77672. private initHitTestSource;
  77673. /**
  77674. * The module's name
  77675. */
  77676. static readonly Name: string;
  77677. /**
  77678. * The (Babylon) version of this module.
  77679. * This is an integer representing the implementation version.
  77680. * This number does not correspond to the WebXR specs version
  77681. */
  77682. static readonly Version: number;
  77683. /**
  77684. * When set to true, each hit test will have its own position/rotation objects
  77685. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77686. * the developers will clone them or copy them as they see fit.
  77687. */
  77688. autoCloneTransformation: boolean;
  77689. /**
  77690. * Triggered when new babylon (transformed) hit test results are available
  77691. */
  77692. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77693. /**
  77694. * Use this to temporarily pause hit test checks.
  77695. */
  77696. paused: boolean;
  77697. /**
  77698. * Creates a new instance of the hit test feature
  77699. * @param _xrSessionManager an instance of WebXRSessionManager
  77700. * @param options options to use when constructing this feature
  77701. */
  77702. constructor(_xrSessionManager: WebXRSessionManager,
  77703. /**
  77704. * options to use when constructing this feature
  77705. */
  77706. options?: IWebXRHitTestOptions);
  77707. /**
  77708. * attach this feature
  77709. * Will usually be called by the features manager
  77710. *
  77711. * @returns true if successful.
  77712. */
  77713. attach(): boolean;
  77714. /**
  77715. * detach this feature.
  77716. * Will usually be called by the features manager
  77717. *
  77718. * @returns true if successful.
  77719. */
  77720. detach(): boolean;
  77721. /**
  77722. * Dispose this feature and all of the resources attached
  77723. */
  77724. dispose(): void;
  77725. protected _onXRFrame(frame: XRFrame): void;
  77726. private _processWebXRHitTestResult;
  77727. }
  77728. }
  77729. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77730. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77731. import { Observable } from "babylonjs/Misc/observable";
  77732. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77734. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77735. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77736. /**
  77737. * Configuration options of the anchor system
  77738. */
  77739. export interface IWebXRAnchorSystemOptions {
  77740. /**
  77741. * a node that will be used to convert local to world coordinates
  77742. */
  77743. worldParentNode?: TransformNode;
  77744. /**
  77745. * If set to true a reference of the created anchors will be kept until the next session starts
  77746. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77747. */
  77748. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77749. }
  77750. /**
  77751. * A babylon container for an XR Anchor
  77752. */
  77753. export interface IWebXRAnchor {
  77754. /**
  77755. * A babylon-assigned ID for this anchor
  77756. */
  77757. id: number;
  77758. /**
  77759. * Transformation matrix to apply to an object attached to this anchor
  77760. */
  77761. transformationMatrix: Matrix;
  77762. /**
  77763. * The native anchor object
  77764. */
  77765. xrAnchor: XRAnchor;
  77766. /**
  77767. * if defined, this object will be constantly updated by the anchor's position and rotation
  77768. */
  77769. attachedNode?: TransformNode;
  77770. }
  77771. /**
  77772. * An implementation of the anchor system for WebXR.
  77773. * For further information see https://github.com/immersive-web/anchors/
  77774. */
  77775. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77776. private _options;
  77777. private _lastFrameDetected;
  77778. private _trackedAnchors;
  77779. private _referenceSpaceForFrameAnchors;
  77780. private _futureAnchors;
  77781. /**
  77782. * The module's name
  77783. */
  77784. static readonly Name: string;
  77785. /**
  77786. * The (Babylon) version of this module.
  77787. * This is an integer representing the implementation version.
  77788. * This number does not correspond to the WebXR specs version
  77789. */
  77790. static readonly Version: number;
  77791. /**
  77792. * Observers registered here will be executed when a new anchor was added to the session
  77793. */
  77794. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77795. /**
  77796. * Observers registered here will be executed when an anchor was removed from the session
  77797. */
  77798. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77799. /**
  77800. * Observers registered here will be executed when an existing anchor updates
  77801. * This can execute N times every frame
  77802. */
  77803. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77804. /**
  77805. * Set the reference space to use for anchor creation, when not using a hit test.
  77806. * Will default to the session's reference space if not defined
  77807. */
  77808. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77809. /**
  77810. * constructs a new anchor system
  77811. * @param _xrSessionManager an instance of WebXRSessionManager
  77812. * @param _options configuration object for this feature
  77813. */
  77814. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77815. private _tmpVector;
  77816. private _tmpQuaternion;
  77817. private _populateTmpTransformation;
  77818. /**
  77819. * Create a new anchor point using a hit test result at a specific point in the scene
  77820. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77821. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77822. *
  77823. * @param hitTestResult The hit test result to use for this anchor creation
  77824. * @param position an optional position offset for this anchor
  77825. * @param rotationQuaternion an optional rotation offset for this anchor
  77826. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77827. */
  77828. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77829. /**
  77830. * Add a new anchor at a specific position and rotation
  77831. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77832. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77833. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77834. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77835. *
  77836. * @param position the position in which to add an anchor
  77837. * @param rotationQuaternion an optional rotation for the anchor transformation
  77838. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77839. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77840. */
  77841. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77842. /**
  77843. * detach this feature.
  77844. * Will usually be called by the features manager
  77845. *
  77846. * @returns true if successful.
  77847. */
  77848. detach(): boolean;
  77849. /**
  77850. * Dispose this feature and all of the resources attached
  77851. */
  77852. dispose(): void;
  77853. protected _onXRFrame(frame: XRFrame): void;
  77854. /**
  77855. * avoiding using Array.find for global support.
  77856. * @param xrAnchor the plane to find in the array
  77857. */
  77858. private _findIndexInAnchorArray;
  77859. private _updateAnchorWithXRFrame;
  77860. private _createAnchorAtTransformation;
  77861. }
  77862. }
  77863. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77864. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77865. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77866. import { Observable } from "babylonjs/Misc/observable";
  77867. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77868. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77869. /**
  77870. * Options used in the plane detector module
  77871. */
  77872. export interface IWebXRPlaneDetectorOptions {
  77873. /**
  77874. * The node to use to transform the local results to world coordinates
  77875. */
  77876. worldParentNode?: TransformNode;
  77877. /**
  77878. * If set to true a reference of the created planes will be kept until the next session starts
  77879. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77880. */
  77881. doNotRemovePlanesOnSessionEnded?: boolean;
  77882. }
  77883. /**
  77884. * A babylon interface for a WebXR plane.
  77885. * A Plane is actually a polygon, built from N points in space
  77886. *
  77887. * Supported in chrome 79, not supported in canary 81 ATM
  77888. */
  77889. export interface IWebXRPlane {
  77890. /**
  77891. * a babylon-assigned ID for this polygon
  77892. */
  77893. id: number;
  77894. /**
  77895. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77896. */
  77897. polygonDefinition: Array<Vector3>;
  77898. /**
  77899. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77900. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77901. */
  77902. transformationMatrix: Matrix;
  77903. /**
  77904. * the native xr-plane object
  77905. */
  77906. xrPlane: XRPlane;
  77907. }
  77908. /**
  77909. * The plane detector is used to detect planes in the real world when in AR
  77910. * For more information see https://github.com/immersive-web/real-world-geometry/
  77911. */
  77912. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77913. private _options;
  77914. private _detectedPlanes;
  77915. private _enabled;
  77916. private _lastFrameDetected;
  77917. /**
  77918. * The module's name
  77919. */
  77920. static readonly Name: string;
  77921. /**
  77922. * The (Babylon) version of this module.
  77923. * This is an integer representing the implementation version.
  77924. * This number does not correspond to the WebXR specs version
  77925. */
  77926. static readonly Version: number;
  77927. /**
  77928. * Observers registered here will be executed when a new plane was added to the session
  77929. */
  77930. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77931. /**
  77932. * Observers registered here will be executed when a plane is no longer detected in the session
  77933. */
  77934. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77935. /**
  77936. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77937. * This can execute N times every frame
  77938. */
  77939. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77940. /**
  77941. * construct a new Plane Detector
  77942. * @param _xrSessionManager an instance of xr Session manager
  77943. * @param _options configuration to use when constructing this feature
  77944. */
  77945. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77946. /**
  77947. * detach this feature.
  77948. * Will usually be called by the features manager
  77949. *
  77950. * @returns true if successful.
  77951. */
  77952. detach(): boolean;
  77953. /**
  77954. * Dispose this feature and all of the resources attached
  77955. */
  77956. dispose(): void;
  77957. protected _onXRFrame(frame: XRFrame): void;
  77958. private _init;
  77959. private _updatePlaneWithXRPlane;
  77960. /**
  77961. * avoiding using Array.find for global support.
  77962. * @param xrPlane the plane to find in the array
  77963. */
  77964. private findIndexInPlaneArray;
  77965. }
  77966. }
  77967. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77968. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77970. import { Observable } from "babylonjs/Misc/observable";
  77971. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77972. /**
  77973. * Options interface for the background remover plugin
  77974. */
  77975. export interface IWebXRBackgroundRemoverOptions {
  77976. /**
  77977. * Further background meshes to disable when entering AR
  77978. */
  77979. backgroundMeshes?: AbstractMesh[];
  77980. /**
  77981. * flags to configure the removal of the environment helper.
  77982. * If not set, the entire background will be removed. If set, flags should be set as well.
  77983. */
  77984. environmentHelperRemovalFlags?: {
  77985. /**
  77986. * Should the skybox be removed (default false)
  77987. */
  77988. skyBox?: boolean;
  77989. /**
  77990. * Should the ground be removed (default false)
  77991. */
  77992. ground?: boolean;
  77993. };
  77994. /**
  77995. * don't disable the environment helper
  77996. */
  77997. ignoreEnvironmentHelper?: boolean;
  77998. }
  77999. /**
  78000. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78001. */
  78002. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78003. /**
  78004. * read-only options to be used in this module
  78005. */
  78006. readonly options: IWebXRBackgroundRemoverOptions;
  78007. /**
  78008. * The module's name
  78009. */
  78010. static readonly Name: string;
  78011. /**
  78012. * The (Babylon) version of this module.
  78013. * This is an integer representing the implementation version.
  78014. * This number does not correspond to the WebXR specs version
  78015. */
  78016. static readonly Version: number;
  78017. /**
  78018. * registered observers will be triggered when the background state changes
  78019. */
  78020. onBackgroundStateChangedObservable: Observable<boolean>;
  78021. /**
  78022. * constructs a new background remover module
  78023. * @param _xrSessionManager the session manager for this module
  78024. * @param options read-only options to be used in this module
  78025. */
  78026. constructor(_xrSessionManager: WebXRSessionManager,
  78027. /**
  78028. * read-only options to be used in this module
  78029. */
  78030. options?: IWebXRBackgroundRemoverOptions);
  78031. /**
  78032. * attach this feature
  78033. * Will usually be called by the features manager
  78034. *
  78035. * @returns true if successful.
  78036. */
  78037. attach(): boolean;
  78038. /**
  78039. * detach this feature.
  78040. * Will usually be called by the features manager
  78041. *
  78042. * @returns true if successful.
  78043. */
  78044. detach(): boolean;
  78045. /**
  78046. * Dispose this feature and all of the resources attached
  78047. */
  78048. dispose(): void;
  78049. protected _onXRFrame(_xrFrame: XRFrame): void;
  78050. private _setBackgroundState;
  78051. }
  78052. }
  78053. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78054. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78055. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78056. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78057. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78058. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78059. import { Nullable } from "babylonjs/types";
  78060. /**
  78061. * Options for the controller physics feature
  78062. */
  78063. export class IWebXRControllerPhysicsOptions {
  78064. /**
  78065. * Should the headset get its own impostor
  78066. */
  78067. enableHeadsetImpostor?: boolean;
  78068. /**
  78069. * Optional parameters for the headset impostor
  78070. */
  78071. headsetImpostorParams?: {
  78072. /**
  78073. * The type of impostor to create. Default is sphere
  78074. */
  78075. impostorType: number;
  78076. /**
  78077. * the size of the impostor. Defaults to 10cm
  78078. */
  78079. impostorSize?: number | {
  78080. width: number;
  78081. height: number;
  78082. depth: number;
  78083. };
  78084. /**
  78085. * Friction definitions
  78086. */
  78087. friction?: number;
  78088. /**
  78089. * Restitution
  78090. */
  78091. restitution?: number;
  78092. };
  78093. /**
  78094. * The physics properties of the future impostors
  78095. */
  78096. physicsProperties?: {
  78097. /**
  78098. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78099. * Note that this requires a physics engine that supports mesh impostors!
  78100. */
  78101. useControllerMesh?: boolean;
  78102. /**
  78103. * The type of impostor to create. Default is sphere
  78104. */
  78105. impostorType?: number;
  78106. /**
  78107. * the size of the impostor. Defaults to 10cm
  78108. */
  78109. impostorSize?: number | {
  78110. width: number;
  78111. height: number;
  78112. depth: number;
  78113. };
  78114. /**
  78115. * Friction definitions
  78116. */
  78117. friction?: number;
  78118. /**
  78119. * Restitution
  78120. */
  78121. restitution?: number;
  78122. };
  78123. /**
  78124. * the xr input to use with this pointer selection
  78125. */
  78126. xrInput: WebXRInput;
  78127. }
  78128. /**
  78129. * Add physics impostor to your webxr controllers,
  78130. * including naive calculation of their linear and angular velocity
  78131. */
  78132. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78133. private readonly _options;
  78134. private _attachController;
  78135. private _controllers;
  78136. private _debugMode;
  78137. private _delta;
  78138. private _headsetImpostor?;
  78139. private _headsetMesh?;
  78140. private _lastTimestamp;
  78141. private _tmpQuaternion;
  78142. private _tmpVector;
  78143. /**
  78144. * The module's name
  78145. */
  78146. static readonly Name: string;
  78147. /**
  78148. * The (Babylon) version of this module.
  78149. * This is an integer representing the implementation version.
  78150. * This number does not correspond to the webxr specs version
  78151. */
  78152. static readonly Version: number;
  78153. /**
  78154. * Construct a new Controller Physics Feature
  78155. * @param _xrSessionManager the corresponding xr session manager
  78156. * @param _options options to create this feature with
  78157. */
  78158. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78159. /**
  78160. * @hidden
  78161. * enable debugging - will show console outputs and the impostor mesh
  78162. */
  78163. _enablePhysicsDebug(): void;
  78164. /**
  78165. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78166. * @param xrController the controller to add
  78167. */
  78168. addController(xrController: WebXRInputSource): void;
  78169. /**
  78170. * attach this feature
  78171. * Will usually be called by the features manager
  78172. *
  78173. * @returns true if successful.
  78174. */
  78175. attach(): boolean;
  78176. /**
  78177. * detach this feature.
  78178. * Will usually be called by the features manager
  78179. *
  78180. * @returns true if successful.
  78181. */
  78182. detach(): boolean;
  78183. /**
  78184. * Get the headset impostor, if enabled
  78185. * @returns the impostor
  78186. */
  78187. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78188. /**
  78189. * Get the physics impostor of a specific controller.
  78190. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78191. * @param controller the controller or the controller id of which to get the impostor
  78192. * @returns the impostor or null
  78193. */
  78194. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78195. /**
  78196. * Update the physics properties provided in the constructor
  78197. * @param newProperties the new properties object
  78198. */
  78199. setPhysicsProperties(newProperties: {
  78200. impostorType?: number;
  78201. impostorSize?: number | {
  78202. width: number;
  78203. height: number;
  78204. depth: number;
  78205. };
  78206. friction?: number;
  78207. restitution?: number;
  78208. }): void;
  78209. protected _onXRFrame(_xrFrame: any): void;
  78210. private _detachController;
  78211. }
  78212. }
  78213. declare module "babylonjs/XR/features/index" {
  78214. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78215. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78216. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78217. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78218. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78219. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78220. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78221. export * from "babylonjs/XR/features/WebXRHitTest";
  78222. }
  78223. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78224. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78226. import { Scene } from "babylonjs/scene";
  78227. /**
  78228. * The motion controller class for all microsoft mixed reality controllers
  78229. */
  78230. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78231. protected readonly _mapping: {
  78232. defaultButton: {
  78233. valueNodeName: string;
  78234. unpressedNodeName: string;
  78235. pressedNodeName: string;
  78236. };
  78237. defaultAxis: {
  78238. valueNodeName: string;
  78239. minNodeName: string;
  78240. maxNodeName: string;
  78241. };
  78242. buttons: {
  78243. "xr-standard-trigger": {
  78244. rootNodeName: string;
  78245. componentProperty: string;
  78246. states: string[];
  78247. };
  78248. "xr-standard-squeeze": {
  78249. rootNodeName: string;
  78250. componentProperty: string;
  78251. states: string[];
  78252. };
  78253. "xr-standard-touchpad": {
  78254. rootNodeName: string;
  78255. labelAnchorNodeName: string;
  78256. touchPointNodeName: string;
  78257. };
  78258. "xr-standard-thumbstick": {
  78259. rootNodeName: string;
  78260. componentProperty: string;
  78261. states: string[];
  78262. };
  78263. };
  78264. axes: {
  78265. "xr-standard-touchpad": {
  78266. "x-axis": {
  78267. rootNodeName: string;
  78268. };
  78269. "y-axis": {
  78270. rootNodeName: string;
  78271. };
  78272. };
  78273. "xr-standard-thumbstick": {
  78274. "x-axis": {
  78275. rootNodeName: string;
  78276. };
  78277. "y-axis": {
  78278. rootNodeName: string;
  78279. };
  78280. };
  78281. };
  78282. };
  78283. /**
  78284. * The base url used to load the left and right controller models
  78285. */
  78286. static MODEL_BASE_URL: string;
  78287. /**
  78288. * The name of the left controller model file
  78289. */
  78290. static MODEL_LEFT_FILENAME: string;
  78291. /**
  78292. * The name of the right controller model file
  78293. */
  78294. static MODEL_RIGHT_FILENAME: string;
  78295. profileId: string;
  78296. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78297. protected _getFilenameAndPath(): {
  78298. filename: string;
  78299. path: string;
  78300. };
  78301. protected _getModelLoadingConstraints(): boolean;
  78302. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78303. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78304. protected _updateModel(): void;
  78305. }
  78306. }
  78307. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78308. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78310. import { Scene } from "babylonjs/scene";
  78311. /**
  78312. * The motion controller class for oculus touch (quest, rift).
  78313. * This class supports legacy mapping as well the standard xr mapping
  78314. */
  78315. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78316. private _forceLegacyControllers;
  78317. private _modelRootNode;
  78318. /**
  78319. * The base url used to load the left and right controller models
  78320. */
  78321. static MODEL_BASE_URL: string;
  78322. /**
  78323. * The name of the left controller model file
  78324. */
  78325. static MODEL_LEFT_FILENAME: string;
  78326. /**
  78327. * The name of the right controller model file
  78328. */
  78329. static MODEL_RIGHT_FILENAME: string;
  78330. /**
  78331. * Base Url for the Quest controller model.
  78332. */
  78333. static QUEST_MODEL_BASE_URL: string;
  78334. profileId: string;
  78335. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78336. protected _getFilenameAndPath(): {
  78337. filename: string;
  78338. path: string;
  78339. };
  78340. protected _getModelLoadingConstraints(): boolean;
  78341. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78342. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78343. protected _updateModel(): void;
  78344. /**
  78345. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78346. * between the touch and touch 2.
  78347. */
  78348. private _isQuest;
  78349. }
  78350. }
  78351. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78352. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78353. import { Scene } from "babylonjs/scene";
  78354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78355. /**
  78356. * The motion controller class for the standard HTC-Vive controllers
  78357. */
  78358. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78359. private _modelRootNode;
  78360. /**
  78361. * The base url used to load the left and right controller models
  78362. */
  78363. static MODEL_BASE_URL: string;
  78364. /**
  78365. * File name for the controller model.
  78366. */
  78367. static MODEL_FILENAME: string;
  78368. profileId: string;
  78369. /**
  78370. * Create a new Vive motion controller object
  78371. * @param scene the scene to use to create this controller
  78372. * @param gamepadObject the corresponding gamepad object
  78373. * @param handedness the handedness of the controller
  78374. */
  78375. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78376. protected _getFilenameAndPath(): {
  78377. filename: string;
  78378. path: string;
  78379. };
  78380. protected _getModelLoadingConstraints(): boolean;
  78381. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78382. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78383. protected _updateModel(): void;
  78384. }
  78385. }
  78386. declare module "babylonjs/XR/motionController/index" {
  78387. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78388. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78389. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78390. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78391. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78392. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78393. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78394. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78395. }
  78396. declare module "babylonjs/XR/index" {
  78397. export * from "babylonjs/XR/webXRCamera";
  78398. export * from "babylonjs/XR/webXREnterExitUI";
  78399. export * from "babylonjs/XR/webXRExperienceHelper";
  78400. export * from "babylonjs/XR/webXRInput";
  78401. export * from "babylonjs/XR/webXRInputSource";
  78402. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78403. export * from "babylonjs/XR/webXRTypes";
  78404. export * from "babylonjs/XR/webXRSessionManager";
  78405. export * from "babylonjs/XR/webXRDefaultExperience";
  78406. export * from "babylonjs/XR/webXRFeaturesManager";
  78407. export * from "babylonjs/XR/features/index";
  78408. export * from "babylonjs/XR/motionController/index";
  78409. }
  78410. declare module "babylonjs/index" {
  78411. export * from "babylonjs/abstractScene";
  78412. export * from "babylonjs/Actions/index";
  78413. export * from "babylonjs/Animations/index";
  78414. export * from "babylonjs/assetContainer";
  78415. export * from "babylonjs/Audio/index";
  78416. export * from "babylonjs/Behaviors/index";
  78417. export * from "babylonjs/Bones/index";
  78418. export * from "babylonjs/Cameras/index";
  78419. export * from "babylonjs/Collisions/index";
  78420. export * from "babylonjs/Culling/index";
  78421. export * from "babylonjs/Debug/index";
  78422. export * from "babylonjs/DeviceInput/index";
  78423. export * from "babylonjs/Engines/index";
  78424. export * from "babylonjs/Events/index";
  78425. export * from "babylonjs/Gamepads/index";
  78426. export * from "babylonjs/Gizmos/index";
  78427. export * from "babylonjs/Helpers/index";
  78428. export * from "babylonjs/Instrumentation/index";
  78429. export * from "babylonjs/Layers/index";
  78430. export * from "babylonjs/LensFlares/index";
  78431. export * from "babylonjs/Lights/index";
  78432. export * from "babylonjs/Loading/index";
  78433. export * from "babylonjs/Materials/index";
  78434. export * from "babylonjs/Maths/index";
  78435. export * from "babylonjs/Meshes/index";
  78436. export * from "babylonjs/Morph/index";
  78437. export * from "babylonjs/Navigation/index";
  78438. export * from "babylonjs/node";
  78439. export * from "babylonjs/Offline/index";
  78440. export * from "babylonjs/Particles/index";
  78441. export * from "babylonjs/Physics/index";
  78442. export * from "babylonjs/PostProcesses/index";
  78443. export * from "babylonjs/Probes/index";
  78444. export * from "babylonjs/Rendering/index";
  78445. export * from "babylonjs/scene";
  78446. export * from "babylonjs/sceneComponent";
  78447. export * from "babylonjs/Sprites/index";
  78448. export * from "babylonjs/States/index";
  78449. export * from "babylonjs/Misc/index";
  78450. export * from "babylonjs/XR/index";
  78451. export * from "babylonjs/types";
  78452. }
  78453. declare module "babylonjs/Animations/pathCursor" {
  78454. import { Vector3 } from "babylonjs/Maths/math.vector";
  78455. import { Path2 } from "babylonjs/Maths/math.path";
  78456. /**
  78457. * A cursor which tracks a point on a path
  78458. */
  78459. export class PathCursor {
  78460. private path;
  78461. /**
  78462. * Stores path cursor callbacks for when an onchange event is triggered
  78463. */
  78464. private _onchange;
  78465. /**
  78466. * The value of the path cursor
  78467. */
  78468. value: number;
  78469. /**
  78470. * The animation array of the path cursor
  78471. */
  78472. animations: Animation[];
  78473. /**
  78474. * Initializes the path cursor
  78475. * @param path The path to track
  78476. */
  78477. constructor(path: Path2);
  78478. /**
  78479. * Gets the cursor point on the path
  78480. * @returns A point on the path cursor at the cursor location
  78481. */
  78482. getPoint(): Vector3;
  78483. /**
  78484. * Moves the cursor ahead by the step amount
  78485. * @param step The amount to move the cursor forward
  78486. * @returns This path cursor
  78487. */
  78488. moveAhead(step?: number): PathCursor;
  78489. /**
  78490. * Moves the cursor behind by the step amount
  78491. * @param step The amount to move the cursor back
  78492. * @returns This path cursor
  78493. */
  78494. moveBack(step?: number): PathCursor;
  78495. /**
  78496. * Moves the cursor by the step amount
  78497. * If the step amount is greater than one, an exception is thrown
  78498. * @param step The amount to move the cursor
  78499. * @returns This path cursor
  78500. */
  78501. move(step: number): PathCursor;
  78502. /**
  78503. * Ensures that the value is limited between zero and one
  78504. * @returns This path cursor
  78505. */
  78506. private ensureLimits;
  78507. /**
  78508. * Runs onchange callbacks on change (used by the animation engine)
  78509. * @returns This path cursor
  78510. */
  78511. private raiseOnChange;
  78512. /**
  78513. * Executes a function on change
  78514. * @param f A path cursor onchange callback
  78515. * @returns This path cursor
  78516. */
  78517. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78518. }
  78519. }
  78520. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78521. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78522. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78523. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78524. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78525. }
  78526. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78527. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78528. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78529. }
  78530. declare module "babylonjs/Engines/Processors/index" {
  78531. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78532. export * from "babylonjs/Engines/Processors/Expressions/index";
  78533. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78534. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78535. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78536. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78537. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78538. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78539. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78540. }
  78541. declare module "babylonjs/Legacy/legacy" {
  78542. import * as Babylon from "babylonjs/index";
  78543. export * from "babylonjs/index";
  78544. }
  78545. declare module "babylonjs/Shaders/blur.fragment" {
  78546. /** @hidden */
  78547. export var blurPixelShader: {
  78548. name: string;
  78549. shader: string;
  78550. };
  78551. }
  78552. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78553. /** @hidden */
  78554. export var pointCloudVertexDeclaration: {
  78555. name: string;
  78556. shader: string;
  78557. };
  78558. }
  78559. declare module "babylonjs" {
  78560. export * from "babylonjs/Legacy/legacy";
  78561. }
  78562. declare module BABYLON {
  78563. /** Alias type for value that can be null */
  78564. export type Nullable<T> = T | null;
  78565. /**
  78566. * Alias type for number that are floats
  78567. * @ignorenaming
  78568. */
  78569. export type float = number;
  78570. /**
  78571. * Alias type for number that are doubles.
  78572. * @ignorenaming
  78573. */
  78574. export type double = number;
  78575. /**
  78576. * Alias type for number that are integer
  78577. * @ignorenaming
  78578. */
  78579. export type int = number;
  78580. /** Alias type for number array or Float32Array */
  78581. export type FloatArray = number[] | Float32Array;
  78582. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78583. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78584. /**
  78585. * Alias for types that can be used by a Buffer or VertexBuffer.
  78586. */
  78587. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78588. /**
  78589. * Alias type for primitive types
  78590. * @ignorenaming
  78591. */
  78592. type Primitive = undefined | null | boolean | string | number | Function;
  78593. /**
  78594. * Type modifier to make all the properties of an object Readonly
  78595. */
  78596. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78597. /**
  78598. * Type modifier to make all the properties of an object Readonly recursively
  78599. */
  78600. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78601. /**
  78602. * Type modifier to make object properties readonly.
  78603. */
  78604. export type DeepImmutableObject<T> = {
  78605. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78606. };
  78607. /** @hidden */
  78608. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78609. }
  78610. }
  78611. declare module BABYLON {
  78612. /**
  78613. * A class serves as a medium between the observable and its observers
  78614. */
  78615. export class EventState {
  78616. /**
  78617. * Create a new EventState
  78618. * @param mask defines the mask associated with this state
  78619. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78620. * @param target defines the original target of the state
  78621. * @param currentTarget defines the current target of the state
  78622. */
  78623. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78624. /**
  78625. * Initialize the current event state
  78626. * @param mask defines the mask associated with this state
  78627. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78628. * @param target defines the original target of the state
  78629. * @param currentTarget defines the current target of the state
  78630. * @returns the current event state
  78631. */
  78632. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78633. /**
  78634. * An Observer can set this property to true to prevent subsequent observers of being notified
  78635. */
  78636. skipNextObservers: boolean;
  78637. /**
  78638. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78639. */
  78640. mask: number;
  78641. /**
  78642. * The object that originally notified the event
  78643. */
  78644. target?: any;
  78645. /**
  78646. * The current object in the bubbling phase
  78647. */
  78648. currentTarget?: any;
  78649. /**
  78650. * This will be populated with the return value of the last function that was executed.
  78651. * If it is the first function in the callback chain it will be the event data.
  78652. */
  78653. lastReturnValue?: any;
  78654. }
  78655. /**
  78656. * Represent an Observer registered to a given Observable object.
  78657. */
  78658. export class Observer<T> {
  78659. /**
  78660. * Defines the callback to call when the observer is notified
  78661. */
  78662. callback: (eventData: T, eventState: EventState) => void;
  78663. /**
  78664. * Defines the mask of the observer (used to filter notifications)
  78665. */
  78666. mask: number;
  78667. /**
  78668. * Defines the current scope used to restore the JS context
  78669. */
  78670. scope: any;
  78671. /** @hidden */
  78672. _willBeUnregistered: boolean;
  78673. /**
  78674. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78675. */
  78676. unregisterOnNextCall: boolean;
  78677. /**
  78678. * Creates a new observer
  78679. * @param callback defines the callback to call when the observer is notified
  78680. * @param mask defines the mask of the observer (used to filter notifications)
  78681. * @param scope defines the current scope used to restore the JS context
  78682. */
  78683. constructor(
  78684. /**
  78685. * Defines the callback to call when the observer is notified
  78686. */
  78687. callback: (eventData: T, eventState: EventState) => void,
  78688. /**
  78689. * Defines the mask of the observer (used to filter notifications)
  78690. */
  78691. mask: number,
  78692. /**
  78693. * Defines the current scope used to restore the JS context
  78694. */
  78695. scope?: any);
  78696. }
  78697. /**
  78698. * Represent a list of observers registered to multiple Observables object.
  78699. */
  78700. export class MultiObserver<T> {
  78701. private _observers;
  78702. private _observables;
  78703. /**
  78704. * Release associated resources
  78705. */
  78706. dispose(): void;
  78707. /**
  78708. * Raise a callback when one of the observable will notify
  78709. * @param observables defines a list of observables to watch
  78710. * @param callback defines the callback to call on notification
  78711. * @param mask defines the mask used to filter notifications
  78712. * @param scope defines the current scope used to restore the JS context
  78713. * @returns the new MultiObserver
  78714. */
  78715. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78716. }
  78717. /**
  78718. * The Observable class is a simple implementation of the Observable pattern.
  78719. *
  78720. * 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.
  78721. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78722. * 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).
  78723. * 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.
  78724. */
  78725. export class Observable<T> {
  78726. private _observers;
  78727. private _eventState;
  78728. private _onObserverAdded;
  78729. /**
  78730. * Gets the list of observers
  78731. */
  78732. get observers(): Array<Observer<T>>;
  78733. /**
  78734. * Creates a new observable
  78735. * @param onObserverAdded defines a callback to call when a new observer is added
  78736. */
  78737. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78738. /**
  78739. * Create a new Observer with the specified callback
  78740. * @param callback the callback that will be executed for that Observer
  78741. * @param mask the mask used to filter observers
  78742. * @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.
  78743. * @param scope optional scope for the callback to be called from
  78744. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78745. * @returns the new observer created for the callback
  78746. */
  78747. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78748. /**
  78749. * Create a new Observer with the specified callback and unregisters after the next notification
  78750. * @param callback the callback that will be executed for that Observer
  78751. * @returns the new observer created for the callback
  78752. */
  78753. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78754. /**
  78755. * Remove an Observer from the Observable object
  78756. * @param observer the instance of the Observer to remove
  78757. * @returns false if it doesn't belong to this Observable
  78758. */
  78759. remove(observer: Nullable<Observer<T>>): boolean;
  78760. /**
  78761. * Remove a callback from the Observable object
  78762. * @param callback the callback to remove
  78763. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78764. * @returns false if it doesn't belong to this Observable
  78765. */
  78766. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78767. private _deferUnregister;
  78768. private _remove;
  78769. /**
  78770. * Moves the observable to the top of the observer list making it get called first when notified
  78771. * @param observer the observer to move
  78772. */
  78773. makeObserverTopPriority(observer: Observer<T>): void;
  78774. /**
  78775. * Moves the observable to the bottom of the observer list making it get called last when notified
  78776. * @param observer the observer to move
  78777. */
  78778. makeObserverBottomPriority(observer: Observer<T>): void;
  78779. /**
  78780. * Notify all Observers by calling their respective callback with the given data
  78781. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78782. * @param eventData defines the data to send to all observers
  78783. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78784. * @param target defines the original target of the state
  78785. * @param currentTarget defines the current target of the state
  78786. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78787. */
  78788. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78789. /**
  78790. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78791. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78792. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78793. * and it is crucial that all callbacks will be executed.
  78794. * The order of the callbacks is kept, callbacks are not executed parallel.
  78795. *
  78796. * @param eventData The data to be sent to each callback
  78797. * @param mask is used to filter observers defaults to -1
  78798. * @param target defines the callback target (see EventState)
  78799. * @param currentTarget defines he current object in the bubbling phase
  78800. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78801. */
  78802. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78803. /**
  78804. * Notify a specific observer
  78805. * @param observer defines the observer to notify
  78806. * @param eventData defines the data to be sent to each callback
  78807. * @param mask is used to filter observers defaults to -1
  78808. */
  78809. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78810. /**
  78811. * Gets a boolean indicating if the observable has at least one observer
  78812. * @returns true is the Observable has at least one Observer registered
  78813. */
  78814. hasObservers(): boolean;
  78815. /**
  78816. * Clear the list of observers
  78817. */
  78818. clear(): void;
  78819. /**
  78820. * Clone the current observable
  78821. * @returns a new observable
  78822. */
  78823. clone(): Observable<T>;
  78824. /**
  78825. * Does this observable handles observer registered with a given mask
  78826. * @param mask defines the mask to be tested
  78827. * @return whether or not one observer registered with the given mask is handeled
  78828. **/
  78829. hasSpecificMask(mask?: number): boolean;
  78830. }
  78831. }
  78832. declare module BABYLON {
  78833. /**
  78834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78835. * Babylon.js
  78836. */
  78837. export class DomManagement {
  78838. /**
  78839. * Checks if the window object exists
  78840. * @returns true if the window object exists
  78841. */
  78842. static IsWindowObjectExist(): boolean;
  78843. /**
  78844. * Checks if the navigator object exists
  78845. * @returns true if the navigator object exists
  78846. */
  78847. static IsNavigatorAvailable(): boolean;
  78848. /**
  78849. * Check if the document object exists
  78850. * @returns true if the document object exists
  78851. */
  78852. static IsDocumentAvailable(): boolean;
  78853. /**
  78854. * Extracts text content from a DOM element hierarchy
  78855. * @param element defines the root element
  78856. * @returns a string
  78857. */
  78858. static GetDOMTextContent(element: HTMLElement): string;
  78859. }
  78860. }
  78861. declare module BABYLON {
  78862. /**
  78863. * Logger used througouht the application to allow configuration of
  78864. * the log level required for the messages.
  78865. */
  78866. export class Logger {
  78867. /**
  78868. * No log
  78869. */
  78870. static readonly NoneLogLevel: number;
  78871. /**
  78872. * Only message logs
  78873. */
  78874. static readonly MessageLogLevel: number;
  78875. /**
  78876. * Only warning logs
  78877. */
  78878. static readonly WarningLogLevel: number;
  78879. /**
  78880. * Only error logs
  78881. */
  78882. static readonly ErrorLogLevel: number;
  78883. /**
  78884. * All logs
  78885. */
  78886. static readonly AllLogLevel: number;
  78887. private static _LogCache;
  78888. /**
  78889. * Gets a value indicating the number of loading errors
  78890. * @ignorenaming
  78891. */
  78892. static errorsCount: number;
  78893. /**
  78894. * Callback called when a new log is added
  78895. */
  78896. static OnNewCacheEntry: (entry: string) => void;
  78897. private static _AddLogEntry;
  78898. private static _FormatMessage;
  78899. private static _LogDisabled;
  78900. private static _LogEnabled;
  78901. private static _WarnDisabled;
  78902. private static _WarnEnabled;
  78903. private static _ErrorDisabled;
  78904. private static _ErrorEnabled;
  78905. /**
  78906. * Log a message to the console
  78907. */
  78908. static Log: (message: string) => void;
  78909. /**
  78910. * Write a warning message to the console
  78911. */
  78912. static Warn: (message: string) => void;
  78913. /**
  78914. * Write an error message to the console
  78915. */
  78916. static Error: (message: string) => void;
  78917. /**
  78918. * Gets current log cache (list of logs)
  78919. */
  78920. static get LogCache(): string;
  78921. /**
  78922. * Clears the log cache
  78923. */
  78924. static ClearLogCache(): void;
  78925. /**
  78926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78927. */
  78928. static set LogLevels(level: number);
  78929. }
  78930. }
  78931. declare module BABYLON {
  78932. /** @hidden */
  78933. export class _TypeStore {
  78934. /** @hidden */
  78935. static RegisteredTypes: {
  78936. [key: string]: Object;
  78937. };
  78938. /** @hidden */
  78939. static GetClass(fqdn: string): any;
  78940. }
  78941. }
  78942. declare module BABYLON {
  78943. /**
  78944. * Helper to manipulate strings
  78945. */
  78946. export class StringTools {
  78947. /**
  78948. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78949. * @param str Source string
  78950. * @param suffix Suffix to search for in the source string
  78951. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78952. */
  78953. static EndsWith(str: string, suffix: string): boolean;
  78954. /**
  78955. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78956. * @param str Source string
  78957. * @param suffix Suffix to search for in the source string
  78958. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78959. */
  78960. static StartsWith(str: string, suffix: string): boolean;
  78961. /**
  78962. * Decodes a buffer into a string
  78963. * @param buffer The buffer to decode
  78964. * @returns The decoded string
  78965. */
  78966. static Decode(buffer: Uint8Array | Uint16Array): string;
  78967. /**
  78968. * Encode a buffer to a base64 string
  78969. * @param buffer defines the buffer to encode
  78970. * @returns the encoded string
  78971. */
  78972. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78973. /**
  78974. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78975. * @param num the number to convert and pad
  78976. * @param length the expected length of the string
  78977. * @returns the padded string
  78978. */
  78979. static PadNumber(num: number, length: number): string;
  78980. }
  78981. }
  78982. declare module BABYLON {
  78983. /**
  78984. * Class containing a set of static utilities functions for deep copy.
  78985. */
  78986. export class DeepCopier {
  78987. /**
  78988. * Tries to copy an object by duplicating every property
  78989. * @param source defines the source object
  78990. * @param destination defines the target object
  78991. * @param doNotCopyList defines a list of properties to avoid
  78992. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78993. */
  78994. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78995. }
  78996. }
  78997. declare module BABYLON {
  78998. /**
  78999. * Class containing a set of static utilities functions for precision date
  79000. */
  79001. export class PrecisionDate {
  79002. /**
  79003. * Gets either window.performance.now() if supported or Date.now() else
  79004. */
  79005. static get Now(): number;
  79006. }
  79007. }
  79008. declare module BABYLON {
  79009. /** @hidden */
  79010. export class _DevTools {
  79011. static WarnImport(name: string): string;
  79012. }
  79013. }
  79014. declare module BABYLON {
  79015. /**
  79016. * Interface used to define the mechanism to get data from the network
  79017. */
  79018. export interface IWebRequest {
  79019. /**
  79020. * Returns client's response url
  79021. */
  79022. responseURL: string;
  79023. /**
  79024. * Returns client's status
  79025. */
  79026. status: number;
  79027. /**
  79028. * Returns client's status as a text
  79029. */
  79030. statusText: string;
  79031. }
  79032. }
  79033. declare module BABYLON {
  79034. /**
  79035. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79036. */
  79037. export class WebRequest implements IWebRequest {
  79038. private _xhr;
  79039. /**
  79040. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79041. * i.e. when loading files, where the server/service expects an Authorization header
  79042. */
  79043. static CustomRequestHeaders: {
  79044. [key: string]: string;
  79045. };
  79046. /**
  79047. * Add callback functions in this array to update all the requests before they get sent to the network
  79048. */
  79049. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79050. private _injectCustomRequestHeaders;
  79051. /**
  79052. * Gets or sets a function to be called when loading progress changes
  79053. */
  79054. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79055. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79056. /**
  79057. * Returns client's state
  79058. */
  79059. get readyState(): number;
  79060. /**
  79061. * Returns client's status
  79062. */
  79063. get status(): number;
  79064. /**
  79065. * Returns client's status as a text
  79066. */
  79067. get statusText(): string;
  79068. /**
  79069. * Returns client's response
  79070. */
  79071. get response(): any;
  79072. /**
  79073. * Returns client's response url
  79074. */
  79075. get responseURL(): string;
  79076. /**
  79077. * Returns client's response as text
  79078. */
  79079. get responseText(): string;
  79080. /**
  79081. * Gets or sets the expected response type
  79082. */
  79083. get responseType(): XMLHttpRequestResponseType;
  79084. set responseType(value: XMLHttpRequestResponseType);
  79085. /** @hidden */
  79086. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79087. /** @hidden */
  79088. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79089. /**
  79090. * Cancels any network activity
  79091. */
  79092. abort(): void;
  79093. /**
  79094. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79095. * @param body defines an optional request body
  79096. */
  79097. send(body?: Document | BodyInit | null): void;
  79098. /**
  79099. * Sets the request method, request URL
  79100. * @param method defines the method to use (GET, POST, etc..)
  79101. * @param url defines the url to connect with
  79102. */
  79103. open(method: string, url: string): void;
  79104. /**
  79105. * Sets the value of a request header.
  79106. * @param name The name of the header whose value is to be set
  79107. * @param value The value to set as the body of the header
  79108. */
  79109. setRequestHeader(name: string, value: string): void;
  79110. /**
  79111. * Get the string containing the text of a particular header's value.
  79112. * @param name The name of the header
  79113. * @returns The string containing the text of the given header name
  79114. */
  79115. getResponseHeader(name: string): Nullable<string>;
  79116. }
  79117. }
  79118. declare module BABYLON {
  79119. /**
  79120. * File request interface
  79121. */
  79122. export interface IFileRequest {
  79123. /**
  79124. * Raised when the request is complete (success or error).
  79125. */
  79126. onCompleteObservable: Observable<IFileRequest>;
  79127. /**
  79128. * Aborts the request for a file.
  79129. */
  79130. abort: () => void;
  79131. }
  79132. }
  79133. declare module BABYLON {
  79134. /**
  79135. * Define options used to create a render target texture
  79136. */
  79137. export class RenderTargetCreationOptions {
  79138. /**
  79139. * Specifies is mipmaps must be generated
  79140. */
  79141. generateMipMaps?: boolean;
  79142. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79143. generateDepthBuffer?: boolean;
  79144. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79145. generateStencilBuffer?: boolean;
  79146. /** Defines texture type (int by default) */
  79147. type?: number;
  79148. /** Defines sampling mode (trilinear by default) */
  79149. samplingMode?: number;
  79150. /** Defines format (RGBA by default) */
  79151. format?: number;
  79152. }
  79153. }
  79154. declare module BABYLON {
  79155. /** Defines the cross module used constants to avoid circular dependncies */
  79156. export class Constants {
  79157. /** Defines that alpha blending is disabled */
  79158. static readonly ALPHA_DISABLE: number;
  79159. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79160. static readonly ALPHA_ADD: number;
  79161. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79162. static readonly ALPHA_COMBINE: number;
  79163. /** Defines that alpha blending is DEST - SRC * DEST */
  79164. static readonly ALPHA_SUBTRACT: number;
  79165. /** Defines that alpha blending is SRC * DEST */
  79166. static readonly ALPHA_MULTIPLY: number;
  79167. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79168. static readonly ALPHA_MAXIMIZED: number;
  79169. /** Defines that alpha blending is SRC + DEST */
  79170. static readonly ALPHA_ONEONE: number;
  79171. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79172. static readonly ALPHA_PREMULTIPLIED: number;
  79173. /**
  79174. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79175. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79176. */
  79177. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79178. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79179. static readonly ALPHA_INTERPOLATE: number;
  79180. /**
  79181. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79182. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79183. */
  79184. static readonly ALPHA_SCREENMODE: number;
  79185. /**
  79186. * Defines that alpha blending is SRC + DST
  79187. * Alpha will be set to SRC ALPHA + DST ALPHA
  79188. */
  79189. static readonly ALPHA_ONEONE_ONEONE: number;
  79190. /**
  79191. * Defines that alpha blending is SRC * DST ALPHA + DST
  79192. * Alpha will be set to 0
  79193. */
  79194. static readonly ALPHA_ALPHATOCOLOR: number;
  79195. /**
  79196. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79197. */
  79198. static readonly ALPHA_REVERSEONEMINUS: number;
  79199. /**
  79200. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79201. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79202. */
  79203. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79204. /**
  79205. * Defines that alpha blending is SRC + DST
  79206. * Alpha will be set to SRC ALPHA
  79207. */
  79208. static readonly ALPHA_ONEONE_ONEZERO: number;
  79209. /**
  79210. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79211. * Alpha will be set to DST ALPHA
  79212. */
  79213. static readonly ALPHA_EXCLUSION: number;
  79214. /** Defines that alpha blending equation a SUM */
  79215. static readonly ALPHA_EQUATION_ADD: number;
  79216. /** Defines that alpha blending equation a SUBSTRACTION */
  79217. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79218. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79219. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79220. /** Defines that alpha blending equation a MAX operation */
  79221. static readonly ALPHA_EQUATION_MAX: number;
  79222. /** Defines that alpha blending equation a MIN operation */
  79223. static readonly ALPHA_EQUATION_MIN: number;
  79224. /**
  79225. * Defines that alpha blending equation a DARKEN operation:
  79226. * It takes the min of the src and sums the alpha channels.
  79227. */
  79228. static readonly ALPHA_EQUATION_DARKEN: number;
  79229. /** Defines that the ressource is not delayed*/
  79230. static readonly DELAYLOADSTATE_NONE: number;
  79231. /** Defines that the ressource was successfully delay loaded */
  79232. static readonly DELAYLOADSTATE_LOADED: number;
  79233. /** Defines that the ressource is currently delay loading */
  79234. static readonly DELAYLOADSTATE_LOADING: number;
  79235. /** Defines that the ressource is delayed and has not started loading */
  79236. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79237. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79238. static readonly NEVER: number;
  79239. /** 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 */
  79240. static readonly ALWAYS: number;
  79241. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79242. static readonly LESS: number;
  79243. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79244. static readonly EQUAL: number;
  79245. /** 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 */
  79246. static readonly LEQUAL: number;
  79247. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79248. static readonly GREATER: number;
  79249. /** 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 */
  79250. static readonly GEQUAL: number;
  79251. /** 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 */
  79252. static readonly NOTEQUAL: number;
  79253. /** Passed to stencilOperation to specify that stencil value must be kept */
  79254. static readonly KEEP: number;
  79255. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79256. static readonly REPLACE: number;
  79257. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79258. static readonly INCR: number;
  79259. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79260. static readonly DECR: number;
  79261. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79262. static readonly INVERT: number;
  79263. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79264. static readonly INCR_WRAP: number;
  79265. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79266. static readonly DECR_WRAP: number;
  79267. /** Texture is not repeating outside of 0..1 UVs */
  79268. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79269. /** Texture is repeating outside of 0..1 UVs */
  79270. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79271. /** Texture is repeating and mirrored */
  79272. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79273. /** ALPHA */
  79274. static readonly TEXTUREFORMAT_ALPHA: number;
  79275. /** LUMINANCE */
  79276. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79277. /** LUMINANCE_ALPHA */
  79278. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79279. /** RGB */
  79280. static readonly TEXTUREFORMAT_RGB: number;
  79281. /** RGBA */
  79282. static readonly TEXTUREFORMAT_RGBA: number;
  79283. /** RED */
  79284. static readonly TEXTUREFORMAT_RED: number;
  79285. /** RED (2nd reference) */
  79286. static readonly TEXTUREFORMAT_R: number;
  79287. /** RG */
  79288. static readonly TEXTUREFORMAT_RG: number;
  79289. /** RED_INTEGER */
  79290. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79291. /** RED_INTEGER (2nd reference) */
  79292. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79293. /** RG_INTEGER */
  79294. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79295. /** RGB_INTEGER */
  79296. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79297. /** RGBA_INTEGER */
  79298. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79299. /** UNSIGNED_BYTE */
  79300. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79301. /** UNSIGNED_BYTE (2nd reference) */
  79302. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79303. /** FLOAT */
  79304. static readonly TEXTURETYPE_FLOAT: number;
  79305. /** HALF_FLOAT */
  79306. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79307. /** BYTE */
  79308. static readonly TEXTURETYPE_BYTE: number;
  79309. /** SHORT */
  79310. static readonly TEXTURETYPE_SHORT: number;
  79311. /** UNSIGNED_SHORT */
  79312. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79313. /** INT */
  79314. static readonly TEXTURETYPE_INT: number;
  79315. /** UNSIGNED_INT */
  79316. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79317. /** UNSIGNED_SHORT_4_4_4_4 */
  79318. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79319. /** UNSIGNED_SHORT_5_5_5_1 */
  79320. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79321. /** UNSIGNED_SHORT_5_6_5 */
  79322. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79323. /** UNSIGNED_INT_2_10_10_10_REV */
  79324. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79325. /** UNSIGNED_INT_24_8 */
  79326. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79327. /** UNSIGNED_INT_10F_11F_11F_REV */
  79328. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79329. /** UNSIGNED_INT_5_9_9_9_REV */
  79330. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79331. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79332. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79333. /** nearest is mag = nearest and min = nearest and no mip */
  79334. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79335. /** mag = nearest and min = nearest and mip = none */
  79336. static readonly TEXTURE_NEAREST_NEAREST: number;
  79337. /** Bilinear is mag = linear and min = linear and no mip */
  79338. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79339. /** mag = linear and min = linear and mip = none */
  79340. static readonly TEXTURE_LINEAR_LINEAR: number;
  79341. /** Trilinear is mag = linear and min = linear and mip = linear */
  79342. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79343. /** Trilinear is mag = linear and min = linear and mip = linear */
  79344. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79345. /** mag = nearest and min = nearest and mip = nearest */
  79346. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79347. /** mag = nearest and min = linear and mip = nearest */
  79348. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79349. /** mag = nearest and min = linear and mip = linear */
  79350. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79351. /** mag = nearest and min = linear and mip = none */
  79352. static readonly TEXTURE_NEAREST_LINEAR: number;
  79353. /** nearest is mag = nearest and min = nearest and mip = linear */
  79354. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79355. /** mag = linear and min = nearest and mip = nearest */
  79356. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79357. /** mag = linear and min = nearest and mip = linear */
  79358. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79359. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79360. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79361. /** mag = linear and min = nearest and mip = none */
  79362. static readonly TEXTURE_LINEAR_NEAREST: number;
  79363. /** Explicit coordinates mode */
  79364. static readonly TEXTURE_EXPLICIT_MODE: number;
  79365. /** Spherical coordinates mode */
  79366. static readonly TEXTURE_SPHERICAL_MODE: number;
  79367. /** Planar coordinates mode */
  79368. static readonly TEXTURE_PLANAR_MODE: number;
  79369. /** Cubic coordinates mode */
  79370. static readonly TEXTURE_CUBIC_MODE: number;
  79371. /** Projection coordinates mode */
  79372. static readonly TEXTURE_PROJECTION_MODE: number;
  79373. /** Skybox coordinates mode */
  79374. static readonly TEXTURE_SKYBOX_MODE: number;
  79375. /** Inverse Cubic coordinates mode */
  79376. static readonly TEXTURE_INVCUBIC_MODE: number;
  79377. /** Equirectangular coordinates mode */
  79378. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79379. /** Equirectangular Fixed coordinates mode */
  79380. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79381. /** Equirectangular Fixed Mirrored coordinates mode */
  79382. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79383. /** Offline (baking) quality for texture filtering */
  79384. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79385. /** High quality for texture filtering */
  79386. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79387. /** Medium quality for texture filtering */
  79388. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79389. /** Low quality for texture filtering */
  79390. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79391. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79392. static readonly SCALEMODE_FLOOR: number;
  79393. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79394. static readonly SCALEMODE_NEAREST: number;
  79395. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79396. static readonly SCALEMODE_CEILING: number;
  79397. /**
  79398. * The dirty texture flag value
  79399. */
  79400. static readonly MATERIAL_TextureDirtyFlag: number;
  79401. /**
  79402. * The dirty light flag value
  79403. */
  79404. static readonly MATERIAL_LightDirtyFlag: number;
  79405. /**
  79406. * The dirty fresnel flag value
  79407. */
  79408. static readonly MATERIAL_FresnelDirtyFlag: number;
  79409. /**
  79410. * The dirty attribute flag value
  79411. */
  79412. static readonly MATERIAL_AttributesDirtyFlag: number;
  79413. /**
  79414. * The dirty misc flag value
  79415. */
  79416. static readonly MATERIAL_MiscDirtyFlag: number;
  79417. /**
  79418. * The all dirty flag value
  79419. */
  79420. static readonly MATERIAL_AllDirtyFlag: number;
  79421. /**
  79422. * Returns the triangle fill mode
  79423. */
  79424. static readonly MATERIAL_TriangleFillMode: number;
  79425. /**
  79426. * Returns the wireframe mode
  79427. */
  79428. static readonly MATERIAL_WireFrameFillMode: number;
  79429. /**
  79430. * Returns the point fill mode
  79431. */
  79432. static readonly MATERIAL_PointFillMode: number;
  79433. /**
  79434. * Returns the point list draw mode
  79435. */
  79436. static readonly MATERIAL_PointListDrawMode: number;
  79437. /**
  79438. * Returns the line list draw mode
  79439. */
  79440. static readonly MATERIAL_LineListDrawMode: number;
  79441. /**
  79442. * Returns the line loop draw mode
  79443. */
  79444. static readonly MATERIAL_LineLoopDrawMode: number;
  79445. /**
  79446. * Returns the line strip draw mode
  79447. */
  79448. static readonly MATERIAL_LineStripDrawMode: number;
  79449. /**
  79450. * Returns the triangle strip draw mode
  79451. */
  79452. static readonly MATERIAL_TriangleStripDrawMode: number;
  79453. /**
  79454. * Returns the triangle fan draw mode
  79455. */
  79456. static readonly MATERIAL_TriangleFanDrawMode: number;
  79457. /**
  79458. * Stores the clock-wise side orientation
  79459. */
  79460. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79461. /**
  79462. * Stores the counter clock-wise side orientation
  79463. */
  79464. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79465. /**
  79466. * Nothing
  79467. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79468. */
  79469. static readonly ACTION_NothingTrigger: number;
  79470. /**
  79471. * On pick
  79472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79473. */
  79474. static readonly ACTION_OnPickTrigger: number;
  79475. /**
  79476. * On left pick
  79477. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79478. */
  79479. static readonly ACTION_OnLeftPickTrigger: number;
  79480. /**
  79481. * On right pick
  79482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79483. */
  79484. static readonly ACTION_OnRightPickTrigger: number;
  79485. /**
  79486. * On center pick
  79487. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79488. */
  79489. static readonly ACTION_OnCenterPickTrigger: number;
  79490. /**
  79491. * On pick down
  79492. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79493. */
  79494. static readonly ACTION_OnPickDownTrigger: number;
  79495. /**
  79496. * On double pick
  79497. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79498. */
  79499. static readonly ACTION_OnDoublePickTrigger: number;
  79500. /**
  79501. * On pick up
  79502. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79503. */
  79504. static readonly ACTION_OnPickUpTrigger: number;
  79505. /**
  79506. * On pick out.
  79507. * This trigger will only be raised if you also declared a OnPickDown
  79508. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79509. */
  79510. static readonly ACTION_OnPickOutTrigger: number;
  79511. /**
  79512. * On long press
  79513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79514. */
  79515. static readonly ACTION_OnLongPressTrigger: number;
  79516. /**
  79517. * On pointer over
  79518. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79519. */
  79520. static readonly ACTION_OnPointerOverTrigger: number;
  79521. /**
  79522. * On pointer out
  79523. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79524. */
  79525. static readonly ACTION_OnPointerOutTrigger: number;
  79526. /**
  79527. * On every frame
  79528. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79529. */
  79530. static readonly ACTION_OnEveryFrameTrigger: number;
  79531. /**
  79532. * On intersection enter
  79533. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79534. */
  79535. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79536. /**
  79537. * On intersection exit
  79538. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79539. */
  79540. static readonly ACTION_OnIntersectionExitTrigger: number;
  79541. /**
  79542. * On key down
  79543. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79544. */
  79545. static readonly ACTION_OnKeyDownTrigger: number;
  79546. /**
  79547. * On key up
  79548. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79549. */
  79550. static readonly ACTION_OnKeyUpTrigger: number;
  79551. /**
  79552. * Billboard mode will only apply to Y axis
  79553. */
  79554. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79555. /**
  79556. * Billboard mode will apply to all axes
  79557. */
  79558. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79559. /**
  79560. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79561. */
  79562. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79563. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79564. * Test order :
  79565. * Is the bounding sphere outside the frustum ?
  79566. * If not, are the bounding box vertices outside the frustum ?
  79567. * It not, then the cullable object is in the frustum.
  79568. */
  79569. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79570. /** Culling strategy : Bounding Sphere Only.
  79571. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79572. * It's also less accurate than the standard because some not visible objects can still be selected.
  79573. * Test : is the bounding sphere outside the frustum ?
  79574. * If not, then the cullable object is in the frustum.
  79575. */
  79576. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79577. /** Culling strategy : Optimistic Inclusion.
  79578. * This in an inclusion test first, then the standard exclusion test.
  79579. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79580. * 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.
  79581. * Anyway, it's as accurate as the standard strategy.
  79582. * Test :
  79583. * Is the cullable object bounding sphere center in the frustum ?
  79584. * If not, apply the default culling strategy.
  79585. */
  79586. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79587. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79588. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79589. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79590. * 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.
  79591. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79592. * Test :
  79593. * Is the cullable object bounding sphere center in the frustum ?
  79594. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79595. */
  79596. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79597. /**
  79598. * No logging while loading
  79599. */
  79600. static readonly SCENELOADER_NO_LOGGING: number;
  79601. /**
  79602. * Minimal logging while loading
  79603. */
  79604. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79605. /**
  79606. * Summary logging while loading
  79607. */
  79608. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79609. /**
  79610. * Detailled logging while loading
  79611. */
  79612. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79613. /**
  79614. * Prepass texture index for color
  79615. */
  79616. static readonly PREPASS_COLOR_INDEX: number;
  79617. /**
  79618. * Prepass texture index for irradiance
  79619. */
  79620. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79621. /**
  79622. * Prepass texture index for depth + normal
  79623. */
  79624. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79625. /**
  79626. * Prepass texture index for albedo
  79627. */
  79628. static readonly PREPASS_ALBEDO_INDEX: number;
  79629. }
  79630. }
  79631. declare module BABYLON {
  79632. /**
  79633. * This represents the required contract to create a new type of texture loader.
  79634. */
  79635. export interface IInternalTextureLoader {
  79636. /**
  79637. * Defines wether the loader supports cascade loading the different faces.
  79638. */
  79639. supportCascades: boolean;
  79640. /**
  79641. * This returns if the loader support the current file information.
  79642. * @param extension defines the file extension of the file being loaded
  79643. * @param mimeType defines the optional mime type of the file being loaded
  79644. * @returns true if the loader can load the specified file
  79645. */
  79646. canLoad(extension: string, mimeType?: string): boolean;
  79647. /**
  79648. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79649. * @param data contains the texture data
  79650. * @param texture defines the BabylonJS internal texture
  79651. * @param createPolynomials will be true if polynomials have been requested
  79652. * @param onLoad defines the callback to trigger once the texture is ready
  79653. * @param onError defines the callback to trigger in case of error
  79654. */
  79655. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79656. /**
  79657. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79658. * @param data contains the texture data
  79659. * @param texture defines the BabylonJS internal texture
  79660. * @param callback defines the method to call once ready to upload
  79661. */
  79662. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79663. }
  79664. }
  79665. declare module BABYLON {
  79666. /**
  79667. * Class used to store and describe the pipeline context associated with an effect
  79668. */
  79669. export interface IPipelineContext {
  79670. /**
  79671. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79672. */
  79673. isAsync: boolean;
  79674. /**
  79675. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79676. */
  79677. isReady: boolean;
  79678. /** @hidden */
  79679. _getVertexShaderCode(): string | null;
  79680. /** @hidden */
  79681. _getFragmentShaderCode(): string | null;
  79682. /** @hidden */
  79683. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79684. }
  79685. }
  79686. declare module BABYLON {
  79687. /**
  79688. * Class used to store gfx data (like WebGLBuffer)
  79689. */
  79690. export class DataBuffer {
  79691. /**
  79692. * Gets or sets the number of objects referencing this buffer
  79693. */
  79694. references: number;
  79695. /** Gets or sets the size of the underlying buffer */
  79696. capacity: number;
  79697. /**
  79698. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79699. */
  79700. is32Bits: boolean;
  79701. /**
  79702. * Gets the underlying buffer
  79703. */
  79704. get underlyingResource(): any;
  79705. }
  79706. }
  79707. declare module BABYLON {
  79708. /** @hidden */
  79709. export interface IShaderProcessor {
  79710. attributeProcessor?: (attribute: string) => string;
  79711. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79712. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79713. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79714. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79715. lineProcessor?: (line: string, isFragment: boolean) => string;
  79716. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79717. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79718. }
  79719. }
  79720. declare module BABYLON {
  79721. /** @hidden */
  79722. export interface ProcessingOptions {
  79723. defines: string[];
  79724. indexParameters: any;
  79725. isFragment: boolean;
  79726. shouldUseHighPrecisionShader: boolean;
  79727. supportsUniformBuffers: boolean;
  79728. shadersRepository: string;
  79729. includesShadersStore: {
  79730. [key: string]: string;
  79731. };
  79732. processor?: IShaderProcessor;
  79733. version: string;
  79734. platformName: string;
  79735. lookForClosingBracketForUniformBuffer?: boolean;
  79736. }
  79737. }
  79738. declare module BABYLON {
  79739. /** @hidden */
  79740. export class ShaderCodeNode {
  79741. line: string;
  79742. children: ShaderCodeNode[];
  79743. additionalDefineKey?: string;
  79744. additionalDefineValue?: string;
  79745. isValid(preprocessors: {
  79746. [key: string]: string;
  79747. }): boolean;
  79748. process(preprocessors: {
  79749. [key: string]: string;
  79750. }, options: ProcessingOptions): string;
  79751. }
  79752. }
  79753. declare module BABYLON {
  79754. /** @hidden */
  79755. export class ShaderCodeCursor {
  79756. private _lines;
  79757. lineIndex: number;
  79758. get currentLine(): string;
  79759. get canRead(): boolean;
  79760. set lines(value: string[]);
  79761. }
  79762. }
  79763. declare module BABYLON {
  79764. /** @hidden */
  79765. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79766. process(preprocessors: {
  79767. [key: string]: string;
  79768. }, options: ProcessingOptions): string;
  79769. }
  79770. }
  79771. declare module BABYLON {
  79772. /** @hidden */
  79773. export class ShaderDefineExpression {
  79774. isTrue(preprocessors: {
  79775. [key: string]: string;
  79776. }): boolean;
  79777. private static _OperatorPriority;
  79778. private static _Stack;
  79779. static postfixToInfix(postfix: string[]): string;
  79780. static infixToPostfix(infix: string): string[];
  79781. }
  79782. }
  79783. declare module BABYLON {
  79784. /** @hidden */
  79785. export class ShaderCodeTestNode extends ShaderCodeNode {
  79786. testExpression: ShaderDefineExpression;
  79787. isValid(preprocessors: {
  79788. [key: string]: string;
  79789. }): boolean;
  79790. }
  79791. }
  79792. declare module BABYLON {
  79793. /** @hidden */
  79794. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79795. define: string;
  79796. not: boolean;
  79797. constructor(define: string, not?: boolean);
  79798. isTrue(preprocessors: {
  79799. [key: string]: string;
  79800. }): boolean;
  79801. }
  79802. }
  79803. declare module BABYLON {
  79804. /** @hidden */
  79805. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79806. leftOperand: ShaderDefineExpression;
  79807. rightOperand: ShaderDefineExpression;
  79808. isTrue(preprocessors: {
  79809. [key: string]: string;
  79810. }): boolean;
  79811. }
  79812. }
  79813. declare module BABYLON {
  79814. /** @hidden */
  79815. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79816. leftOperand: ShaderDefineExpression;
  79817. rightOperand: ShaderDefineExpression;
  79818. isTrue(preprocessors: {
  79819. [key: string]: string;
  79820. }): boolean;
  79821. }
  79822. }
  79823. declare module BABYLON {
  79824. /** @hidden */
  79825. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79826. define: string;
  79827. operand: string;
  79828. testValue: string;
  79829. constructor(define: string, operand: string, testValue: string);
  79830. isTrue(preprocessors: {
  79831. [key: string]: string;
  79832. }): boolean;
  79833. }
  79834. }
  79835. declare module BABYLON {
  79836. /**
  79837. * Class used to enable access to offline support
  79838. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79839. */
  79840. export interface IOfflineProvider {
  79841. /**
  79842. * Gets a boolean indicating if scene must be saved in the database
  79843. */
  79844. enableSceneOffline: boolean;
  79845. /**
  79846. * Gets a boolean indicating if textures must be saved in the database
  79847. */
  79848. enableTexturesOffline: boolean;
  79849. /**
  79850. * Open the offline support and make it available
  79851. * @param successCallback defines the callback to call on success
  79852. * @param errorCallback defines the callback to call on error
  79853. */
  79854. open(successCallback: () => void, errorCallback: () => void): void;
  79855. /**
  79856. * Loads an image from the offline support
  79857. * @param url defines the url to load from
  79858. * @param image defines the target DOM image
  79859. */
  79860. loadImage(url: string, image: HTMLImageElement): void;
  79861. /**
  79862. * Loads a file from offline support
  79863. * @param url defines the URL to load from
  79864. * @param sceneLoaded defines a callback to call on success
  79865. * @param progressCallBack defines a callback to call when progress changed
  79866. * @param errorCallback defines a callback to call on error
  79867. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79868. */
  79869. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79870. }
  79871. }
  79872. declare module BABYLON {
  79873. /**
  79874. * Class used to help managing file picking and drag'n'drop
  79875. * File Storage
  79876. */
  79877. export class FilesInputStore {
  79878. /**
  79879. * List of files ready to be loaded
  79880. */
  79881. static FilesToLoad: {
  79882. [key: string]: File;
  79883. };
  79884. }
  79885. }
  79886. declare module BABYLON {
  79887. /**
  79888. * Class used to define a retry strategy when error happens while loading assets
  79889. */
  79890. export class RetryStrategy {
  79891. /**
  79892. * Function used to defines an exponential back off strategy
  79893. * @param maxRetries defines the maximum number of retries (3 by default)
  79894. * @param baseInterval defines the interval between retries
  79895. * @returns the strategy function to use
  79896. */
  79897. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79898. }
  79899. }
  79900. declare module BABYLON {
  79901. /**
  79902. * @ignore
  79903. * Application error to support additional information when loading a file
  79904. */
  79905. export abstract class BaseError extends Error {
  79906. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79907. }
  79908. }
  79909. declare module BABYLON {
  79910. /** @ignore */
  79911. export class LoadFileError extends BaseError {
  79912. request?: WebRequest;
  79913. file?: File;
  79914. /**
  79915. * Creates a new LoadFileError
  79916. * @param message defines the message of the error
  79917. * @param request defines the optional web request
  79918. * @param file defines the optional file
  79919. */
  79920. constructor(message: string, object?: WebRequest | File);
  79921. }
  79922. /** @ignore */
  79923. export class RequestFileError extends BaseError {
  79924. request: WebRequest;
  79925. /**
  79926. * Creates a new LoadFileError
  79927. * @param message defines the message of the error
  79928. * @param request defines the optional web request
  79929. */
  79930. constructor(message: string, request: WebRequest);
  79931. }
  79932. /** @ignore */
  79933. export class ReadFileError extends BaseError {
  79934. file: File;
  79935. /**
  79936. * Creates a new ReadFileError
  79937. * @param message defines the message of the error
  79938. * @param file defines the optional file
  79939. */
  79940. constructor(message: string, file: File);
  79941. }
  79942. /**
  79943. * @hidden
  79944. */
  79945. export class FileTools {
  79946. /**
  79947. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79948. */
  79949. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79950. /**
  79951. * Gets or sets the base URL to use to load assets
  79952. */
  79953. static BaseUrl: string;
  79954. /**
  79955. * Default behaviour for cors in the application.
  79956. * It can be a string if the expected behavior is identical in the entire app.
  79957. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79958. */
  79959. static CorsBehavior: string | ((url: string | string[]) => string);
  79960. /**
  79961. * Gets or sets a function used to pre-process url before using them to load assets
  79962. */
  79963. static PreprocessUrl: (url: string) => string;
  79964. /**
  79965. * Removes unwanted characters from an url
  79966. * @param url defines the url to clean
  79967. * @returns the cleaned url
  79968. */
  79969. private static _CleanUrl;
  79970. /**
  79971. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79972. * @param url define the url we are trying
  79973. * @param element define the dom element where to configure the cors policy
  79974. */
  79975. static SetCorsBehavior(url: string | string[], element: {
  79976. crossOrigin: string | null;
  79977. }): void;
  79978. /**
  79979. * Loads an image as an HTMLImageElement.
  79980. * @param input url string, ArrayBuffer, or Blob to load
  79981. * @param onLoad callback called when the image successfully loads
  79982. * @param onError callback called when the image fails to load
  79983. * @param offlineProvider offline provider for caching
  79984. * @param mimeType optional mime type
  79985. * @returns the HTMLImageElement of the loaded image
  79986. */
  79987. 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>;
  79988. /**
  79989. * Reads a file from a File object
  79990. * @param file defines the file to load
  79991. * @param onSuccess defines the callback to call when data is loaded
  79992. * @param onProgress defines the callback to call during loading process
  79993. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79994. * @param onError defines the callback to call when an error occurs
  79995. * @returns a file request object
  79996. */
  79997. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79998. /**
  79999. * Loads a file from a url
  80000. * @param url url to load
  80001. * @param onSuccess callback called when the file successfully loads
  80002. * @param onProgress callback called while file is loading (if the server supports this mode)
  80003. * @param offlineProvider defines the offline provider for caching
  80004. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80005. * @param onError callback called when the file fails to load
  80006. * @returns a file request object
  80007. */
  80008. 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;
  80009. /**
  80010. * Loads a file
  80011. * @param url url to load
  80012. * @param onSuccess callback called when the file successfully loads
  80013. * @param onProgress callback called while file is loading (if the server supports this mode)
  80014. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80015. * @param onError callback called when the file fails to load
  80016. * @param onOpened callback called when the web request is opened
  80017. * @returns a file request object
  80018. */
  80019. 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;
  80020. /**
  80021. * Checks if the loaded document was accessed via `file:`-Protocol.
  80022. * @returns boolean
  80023. */
  80024. static IsFileURL(): boolean;
  80025. }
  80026. }
  80027. declare module BABYLON {
  80028. /** @hidden */
  80029. export class ShaderProcessor {
  80030. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80031. private static _ProcessPrecision;
  80032. private static _ExtractOperation;
  80033. private static _BuildSubExpression;
  80034. private static _BuildExpression;
  80035. private static _MoveCursorWithinIf;
  80036. private static _MoveCursor;
  80037. private static _EvaluatePreProcessors;
  80038. private static _PreparePreProcessors;
  80039. private static _ProcessShaderConversion;
  80040. private static _ProcessIncludes;
  80041. /**
  80042. * Loads a file from a url
  80043. * @param url url to load
  80044. * @param onSuccess callback called when the file successfully loads
  80045. * @param onProgress callback called while file is loading (if the server supports this mode)
  80046. * @param offlineProvider defines the offline provider for caching
  80047. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80048. * @param onError callback called when the file fails to load
  80049. * @returns a file request object
  80050. * @hidden
  80051. */
  80052. 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;
  80053. }
  80054. }
  80055. declare module BABYLON {
  80056. /**
  80057. * @hidden
  80058. */
  80059. export interface IColor4Like {
  80060. r: float;
  80061. g: float;
  80062. b: float;
  80063. a: float;
  80064. }
  80065. /**
  80066. * @hidden
  80067. */
  80068. export interface IColor3Like {
  80069. r: float;
  80070. g: float;
  80071. b: float;
  80072. }
  80073. /**
  80074. * @hidden
  80075. */
  80076. export interface IVector4Like {
  80077. x: float;
  80078. y: float;
  80079. z: float;
  80080. w: float;
  80081. }
  80082. /**
  80083. * @hidden
  80084. */
  80085. export interface IVector3Like {
  80086. x: float;
  80087. y: float;
  80088. z: float;
  80089. }
  80090. /**
  80091. * @hidden
  80092. */
  80093. export interface IVector2Like {
  80094. x: float;
  80095. y: float;
  80096. }
  80097. /**
  80098. * @hidden
  80099. */
  80100. export interface IMatrixLike {
  80101. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80102. updateFlag: int;
  80103. }
  80104. /**
  80105. * @hidden
  80106. */
  80107. export interface IViewportLike {
  80108. x: float;
  80109. y: float;
  80110. width: float;
  80111. height: float;
  80112. }
  80113. /**
  80114. * @hidden
  80115. */
  80116. export interface IPlaneLike {
  80117. normal: IVector3Like;
  80118. d: float;
  80119. normalize(): void;
  80120. }
  80121. }
  80122. declare module BABYLON {
  80123. /**
  80124. * Interface used to define common properties for effect fallbacks
  80125. */
  80126. export interface IEffectFallbacks {
  80127. /**
  80128. * Removes the defines that should be removed when falling back.
  80129. * @param currentDefines defines the current define statements for the shader.
  80130. * @param effect defines the current effect we try to compile
  80131. * @returns The resulting defines with defines of the current rank removed.
  80132. */
  80133. reduce(currentDefines: string, effect: Effect): string;
  80134. /**
  80135. * Removes the fallback from the bound mesh.
  80136. */
  80137. unBindMesh(): void;
  80138. /**
  80139. * Checks to see if more fallbacks are still availible.
  80140. */
  80141. hasMoreFallbacks: boolean;
  80142. }
  80143. }
  80144. declare module BABYLON {
  80145. /**
  80146. * Class used to evalaute queries containing `and` and `or` operators
  80147. */
  80148. export class AndOrNotEvaluator {
  80149. /**
  80150. * Evaluate a query
  80151. * @param query defines the query to evaluate
  80152. * @param evaluateCallback defines the callback used to filter result
  80153. * @returns true if the query matches
  80154. */
  80155. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80156. private static _HandleParenthesisContent;
  80157. private static _SimplifyNegation;
  80158. }
  80159. }
  80160. declare module BABYLON {
  80161. /**
  80162. * Class used to store custom tags
  80163. */
  80164. export class Tags {
  80165. /**
  80166. * Adds support for tags on the given object
  80167. * @param obj defines the object to use
  80168. */
  80169. static EnableFor(obj: any): void;
  80170. /**
  80171. * Removes tags support
  80172. * @param obj defines the object to use
  80173. */
  80174. static DisableFor(obj: any): void;
  80175. /**
  80176. * Gets a boolean indicating if the given object has tags
  80177. * @param obj defines the object to use
  80178. * @returns a boolean
  80179. */
  80180. static HasTags(obj: any): boolean;
  80181. /**
  80182. * Gets the tags available on a given object
  80183. * @param obj defines the object to use
  80184. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80185. * @returns the tags
  80186. */
  80187. static GetTags(obj: any, asString?: boolean): any;
  80188. /**
  80189. * Adds tags to an object
  80190. * @param obj defines the object to use
  80191. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80192. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80193. */
  80194. static AddTagsTo(obj: any, tagsString: string): void;
  80195. /**
  80196. * @hidden
  80197. */
  80198. static _AddTagTo(obj: any, tag: string): void;
  80199. /**
  80200. * Removes specific tags from a specific object
  80201. * @param obj defines the object to use
  80202. * @param tagsString defines the tags to remove
  80203. */
  80204. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80205. /**
  80206. * @hidden
  80207. */
  80208. static _RemoveTagFrom(obj: any, tag: string): void;
  80209. /**
  80210. * Defines if tags hosted on an object match a given query
  80211. * @param obj defines the object to use
  80212. * @param tagsQuery defines the tag query
  80213. * @returns a boolean
  80214. */
  80215. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80216. }
  80217. }
  80218. declare module BABYLON {
  80219. /**
  80220. * Scalar computation library
  80221. */
  80222. export class Scalar {
  80223. /**
  80224. * Two pi constants convenient for computation.
  80225. */
  80226. static TwoPi: number;
  80227. /**
  80228. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80229. * @param a number
  80230. * @param b number
  80231. * @param epsilon (default = 1.401298E-45)
  80232. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80233. */
  80234. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80235. /**
  80236. * Returns a string : the upper case translation of the number i to hexadecimal.
  80237. * @param i number
  80238. * @returns the upper case translation of the number i to hexadecimal.
  80239. */
  80240. static ToHex(i: number): string;
  80241. /**
  80242. * Returns -1 if value is negative and +1 is value is positive.
  80243. * @param value the value
  80244. * @returns the value itself if it's equal to zero.
  80245. */
  80246. static Sign(value: number): number;
  80247. /**
  80248. * Returns the value itself if it's between min and max.
  80249. * Returns min if the value is lower than min.
  80250. * Returns max if the value is greater than max.
  80251. * @param value the value to clmap
  80252. * @param min the min value to clamp to (default: 0)
  80253. * @param max the max value to clamp to (default: 1)
  80254. * @returns the clamped value
  80255. */
  80256. static Clamp(value: number, min?: number, max?: number): number;
  80257. /**
  80258. * the log2 of value.
  80259. * @param value the value to compute log2 of
  80260. * @returns the log2 of value.
  80261. */
  80262. static Log2(value: number): number;
  80263. /**
  80264. * Loops the value, so that it is never larger than length and never smaller than 0.
  80265. *
  80266. * This is similar to the modulo operator but it works with floating point numbers.
  80267. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80268. * With t = 5 and length = 2.5, the result would be 0.0.
  80269. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80270. * @param value the value
  80271. * @param length the length
  80272. * @returns the looped value
  80273. */
  80274. static Repeat(value: number, length: number): number;
  80275. /**
  80276. * Normalize the value between 0.0 and 1.0 using min and max values
  80277. * @param value value to normalize
  80278. * @param min max to normalize between
  80279. * @param max min to normalize between
  80280. * @returns the normalized value
  80281. */
  80282. static Normalize(value: number, min: number, max: number): number;
  80283. /**
  80284. * Denormalize the value from 0.0 and 1.0 using min and max values
  80285. * @param normalized value to denormalize
  80286. * @param min max to denormalize between
  80287. * @param max min to denormalize between
  80288. * @returns the denormalized value
  80289. */
  80290. static Denormalize(normalized: number, min: number, max: number): number;
  80291. /**
  80292. * Calculates the shortest difference between two given angles given in degrees.
  80293. * @param current current angle in degrees
  80294. * @param target target angle in degrees
  80295. * @returns the delta
  80296. */
  80297. static DeltaAngle(current: number, target: number): number;
  80298. /**
  80299. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80300. * @param tx value
  80301. * @param length length
  80302. * @returns The returned value will move back and forth between 0 and length
  80303. */
  80304. static PingPong(tx: number, length: number): number;
  80305. /**
  80306. * Interpolates between min and max with smoothing at the limits.
  80307. *
  80308. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80309. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80310. * @param from from
  80311. * @param to to
  80312. * @param tx value
  80313. * @returns the smooth stepped value
  80314. */
  80315. static SmoothStep(from: number, to: number, tx: number): number;
  80316. /**
  80317. * Moves a value current towards target.
  80318. *
  80319. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80320. * Negative values of maxDelta pushes the value away from target.
  80321. * @param current current value
  80322. * @param target target value
  80323. * @param maxDelta max distance to move
  80324. * @returns resulting value
  80325. */
  80326. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80327. /**
  80328. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80329. *
  80330. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80331. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80332. * @param current current value
  80333. * @param target target value
  80334. * @param maxDelta max distance to move
  80335. * @returns resulting angle
  80336. */
  80337. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80338. /**
  80339. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80340. * @param start start value
  80341. * @param end target value
  80342. * @param amount amount to lerp between
  80343. * @returns the lerped value
  80344. */
  80345. static Lerp(start: number, end: number, amount: number): number;
  80346. /**
  80347. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80348. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80349. * @param start start value
  80350. * @param end target value
  80351. * @param amount amount to lerp between
  80352. * @returns the lerped value
  80353. */
  80354. static LerpAngle(start: number, end: number, amount: number): number;
  80355. /**
  80356. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80357. * @param a start value
  80358. * @param b target value
  80359. * @param value value between a and b
  80360. * @returns the inverseLerp value
  80361. */
  80362. static InverseLerp(a: number, b: number, value: number): number;
  80363. /**
  80364. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80365. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80366. * @param value1 spline value
  80367. * @param tangent1 spline value
  80368. * @param value2 spline value
  80369. * @param tangent2 spline value
  80370. * @param amount input value
  80371. * @returns hermite result
  80372. */
  80373. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80374. /**
  80375. * Returns a random float number between and min and max values
  80376. * @param min min value of random
  80377. * @param max max value of random
  80378. * @returns random value
  80379. */
  80380. static RandomRange(min: number, max: number): number;
  80381. /**
  80382. * This function returns percentage of a number in a given range.
  80383. *
  80384. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80385. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80386. * @param number to convert to percentage
  80387. * @param min min range
  80388. * @param max max range
  80389. * @returns the percentage
  80390. */
  80391. static RangeToPercent(number: number, min: number, max: number): number;
  80392. /**
  80393. * This function returns number that corresponds to the percentage in a given range.
  80394. *
  80395. * PercentToRange(0.34,0,100) will return 34.
  80396. * @param percent to convert to number
  80397. * @param min min range
  80398. * @param max max range
  80399. * @returns the number
  80400. */
  80401. static PercentToRange(percent: number, min: number, max: number): number;
  80402. /**
  80403. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80404. * @param angle The angle to normalize in radian.
  80405. * @return The converted angle.
  80406. */
  80407. static NormalizeRadians(angle: number): number;
  80408. }
  80409. }
  80410. declare module BABYLON {
  80411. /**
  80412. * Constant used to convert a value to gamma space
  80413. * @ignorenaming
  80414. */
  80415. export const ToGammaSpace: number;
  80416. /**
  80417. * Constant used to convert a value to linear space
  80418. * @ignorenaming
  80419. */
  80420. export const ToLinearSpace = 2.2;
  80421. /**
  80422. * Constant used to define the minimal number value in Babylon.js
  80423. * @ignorenaming
  80424. */
  80425. let Epsilon: number;
  80426. }
  80427. declare module BABYLON {
  80428. /**
  80429. * Class used to represent a viewport on screen
  80430. */
  80431. export class Viewport {
  80432. /** viewport left coordinate */
  80433. x: number;
  80434. /** viewport top coordinate */
  80435. y: number;
  80436. /**viewport width */
  80437. width: number;
  80438. /** viewport height */
  80439. height: number;
  80440. /**
  80441. * Creates a Viewport object located at (x, y) and sized (width, height)
  80442. * @param x defines viewport left coordinate
  80443. * @param y defines viewport top coordinate
  80444. * @param width defines the viewport width
  80445. * @param height defines the viewport height
  80446. */
  80447. constructor(
  80448. /** viewport left coordinate */
  80449. x: number,
  80450. /** viewport top coordinate */
  80451. y: number,
  80452. /**viewport width */
  80453. width: number,
  80454. /** viewport height */
  80455. height: number);
  80456. /**
  80457. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80458. * @param renderWidth defines the rendering width
  80459. * @param renderHeight defines the rendering height
  80460. * @returns a new Viewport
  80461. */
  80462. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80463. /**
  80464. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80465. * @param renderWidth defines the rendering width
  80466. * @param renderHeight defines the rendering height
  80467. * @param ref defines the target viewport
  80468. * @returns the current viewport
  80469. */
  80470. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80471. /**
  80472. * Returns a new Viewport copied from the current one
  80473. * @returns a new Viewport
  80474. */
  80475. clone(): Viewport;
  80476. }
  80477. }
  80478. declare module BABYLON {
  80479. /**
  80480. * Class containing a set of static utilities functions for arrays.
  80481. */
  80482. export class ArrayTools {
  80483. /**
  80484. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80485. * @param size the number of element to construct and put in the array
  80486. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80487. * @returns a new array filled with new objects
  80488. */
  80489. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80490. }
  80491. }
  80492. declare module BABYLON {
  80493. /**
  80494. * Represents a plane by the equation ax + by + cz + d = 0
  80495. */
  80496. export class Plane {
  80497. private static _TmpMatrix;
  80498. /**
  80499. * Normal of the plane (a,b,c)
  80500. */
  80501. normal: Vector3;
  80502. /**
  80503. * d component of the plane
  80504. */
  80505. d: number;
  80506. /**
  80507. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80508. * @param a a component of the plane
  80509. * @param b b component of the plane
  80510. * @param c c component of the plane
  80511. * @param d d component of the plane
  80512. */
  80513. constructor(a: number, b: number, c: number, d: number);
  80514. /**
  80515. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80516. */
  80517. asArray(): number[];
  80518. /**
  80519. * @returns a new plane copied from the current Plane.
  80520. */
  80521. clone(): Plane;
  80522. /**
  80523. * @returns the string "Plane".
  80524. */
  80525. getClassName(): string;
  80526. /**
  80527. * @returns the Plane hash code.
  80528. */
  80529. getHashCode(): number;
  80530. /**
  80531. * Normalize the current Plane in place.
  80532. * @returns the updated Plane.
  80533. */
  80534. normalize(): Plane;
  80535. /**
  80536. * Applies a transformation the plane and returns the result
  80537. * @param transformation the transformation matrix to be applied to the plane
  80538. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80539. */
  80540. transform(transformation: DeepImmutable<Matrix>): Plane;
  80541. /**
  80542. * Compute the dot product between the point and the plane normal
  80543. * @param point point to calculate the dot product with
  80544. * @returns the dot product (float) of the point coordinates and the plane normal.
  80545. */
  80546. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80547. /**
  80548. * Updates the current Plane from the plane defined by the three given points.
  80549. * @param point1 one of the points used to contruct the plane
  80550. * @param point2 one of the points used to contruct the plane
  80551. * @param point3 one of the points used to contruct the plane
  80552. * @returns the updated Plane.
  80553. */
  80554. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80555. /**
  80556. * Checks if the plane is facing a given direction
  80557. * @param direction the direction to check if the plane is facing
  80558. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80559. * @returns True is the vector "direction" is the same side than the plane normal.
  80560. */
  80561. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80562. /**
  80563. * Calculates the distance to a point
  80564. * @param point point to calculate distance to
  80565. * @returns the signed distance (float) from the given point to the Plane.
  80566. */
  80567. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80568. /**
  80569. * Creates a plane from an array
  80570. * @param array the array to create a plane from
  80571. * @returns a new Plane from the given array.
  80572. */
  80573. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80574. /**
  80575. * Creates a plane from three points
  80576. * @param point1 point used to create the plane
  80577. * @param point2 point used to create the plane
  80578. * @param point3 point used to create the plane
  80579. * @returns a new Plane defined by the three given points.
  80580. */
  80581. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80582. /**
  80583. * Creates a plane from an origin point and a normal
  80584. * @param origin origin of the plane to be constructed
  80585. * @param normal normal of the plane to be constructed
  80586. * @returns a new Plane the normal vector to this plane at the given origin point.
  80587. * Note : the vector "normal" is updated because normalized.
  80588. */
  80589. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80590. /**
  80591. * Calculates the distance from a plane and a point
  80592. * @param origin origin of the plane to be constructed
  80593. * @param normal normal of the plane to be constructed
  80594. * @param point point to calculate distance to
  80595. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80596. */
  80597. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80598. }
  80599. }
  80600. declare module BABYLON {
  80601. /** @hidden */
  80602. export class PerformanceConfigurator {
  80603. /** @hidden */
  80604. static MatrixUse64Bits: boolean;
  80605. /** @hidden */
  80606. static MatrixTrackPrecisionChange: boolean;
  80607. /** @hidden */
  80608. static MatrixCurrentType: any;
  80609. /** @hidden */
  80610. static MatrixTrackedMatrices: Array<any> | null;
  80611. /** @hidden */
  80612. static SetMatrixPrecision(use64bits: boolean): void;
  80613. }
  80614. }
  80615. declare module BABYLON {
  80616. /**
  80617. * Class representing a vector containing 2 coordinates
  80618. */
  80619. export class Vector2 {
  80620. /** defines the first coordinate */
  80621. x: number;
  80622. /** defines the second coordinate */
  80623. y: number;
  80624. /**
  80625. * Creates a new Vector2 from the given x and y coordinates
  80626. * @param x defines the first coordinate
  80627. * @param y defines the second coordinate
  80628. */
  80629. constructor(
  80630. /** defines the first coordinate */
  80631. x?: number,
  80632. /** defines the second coordinate */
  80633. y?: number);
  80634. /**
  80635. * Gets a string with the Vector2 coordinates
  80636. * @returns a string with the Vector2 coordinates
  80637. */
  80638. toString(): string;
  80639. /**
  80640. * Gets class name
  80641. * @returns the string "Vector2"
  80642. */
  80643. getClassName(): string;
  80644. /**
  80645. * Gets current vector hash code
  80646. * @returns the Vector2 hash code as a number
  80647. */
  80648. getHashCode(): number;
  80649. /**
  80650. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80651. * @param array defines the source array
  80652. * @param index defines the offset in source array
  80653. * @returns the current Vector2
  80654. */
  80655. toArray(array: FloatArray, index?: number): Vector2;
  80656. /**
  80657. * Copy the current vector to an array
  80658. * @returns a new array with 2 elements: the Vector2 coordinates.
  80659. */
  80660. asArray(): number[];
  80661. /**
  80662. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80663. * @param source defines the source Vector2
  80664. * @returns the current updated Vector2
  80665. */
  80666. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80667. /**
  80668. * Sets the Vector2 coordinates with the given floats
  80669. * @param x defines the first coordinate
  80670. * @param y defines the second coordinate
  80671. * @returns the current updated Vector2
  80672. */
  80673. copyFromFloats(x: number, y: number): Vector2;
  80674. /**
  80675. * Sets the Vector2 coordinates with the given floats
  80676. * @param x defines the first coordinate
  80677. * @param y defines the second coordinate
  80678. * @returns the current updated Vector2
  80679. */
  80680. set(x: number, y: number): Vector2;
  80681. /**
  80682. * Add another vector with the current one
  80683. * @param otherVector defines the other vector
  80684. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80685. */
  80686. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80687. /**
  80688. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80689. * @param otherVector defines the other vector
  80690. * @param result defines the target vector
  80691. * @returns the unmodified current Vector2
  80692. */
  80693. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80694. /**
  80695. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80696. * @param otherVector defines the other vector
  80697. * @returns the current updated Vector2
  80698. */
  80699. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80700. /**
  80701. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80702. * @param otherVector defines the other vector
  80703. * @returns a new Vector2
  80704. */
  80705. addVector3(otherVector: Vector3): Vector2;
  80706. /**
  80707. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80708. * @param otherVector defines the other vector
  80709. * @returns a new Vector2
  80710. */
  80711. subtract(otherVector: Vector2): Vector2;
  80712. /**
  80713. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80714. * @param otherVector defines the other vector
  80715. * @param result defines the target vector
  80716. * @returns the unmodified current Vector2
  80717. */
  80718. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80719. /**
  80720. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80721. * @param otherVector defines the other vector
  80722. * @returns the current updated Vector2
  80723. */
  80724. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80725. /**
  80726. * Multiplies in place the current Vector2 coordinates by the given ones
  80727. * @param otherVector defines the other vector
  80728. * @returns the current updated Vector2
  80729. */
  80730. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80731. /**
  80732. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80733. * @param otherVector defines the other vector
  80734. * @returns a new Vector2
  80735. */
  80736. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80737. /**
  80738. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80739. * @param otherVector defines the other vector
  80740. * @param result defines the target vector
  80741. * @returns the unmodified current Vector2
  80742. */
  80743. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80744. /**
  80745. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80746. * @param x defines the first coordinate
  80747. * @param y defines the second coordinate
  80748. * @returns a new Vector2
  80749. */
  80750. multiplyByFloats(x: number, y: number): Vector2;
  80751. /**
  80752. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80753. * @param otherVector defines the other vector
  80754. * @returns a new Vector2
  80755. */
  80756. divide(otherVector: Vector2): Vector2;
  80757. /**
  80758. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80759. * @param otherVector defines the other vector
  80760. * @param result defines the target vector
  80761. * @returns the unmodified current Vector2
  80762. */
  80763. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80764. /**
  80765. * Divides the current Vector2 coordinates by the given ones
  80766. * @param otherVector defines the other vector
  80767. * @returns the current updated Vector2
  80768. */
  80769. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80770. /**
  80771. * Gets a new Vector2 with current Vector2 negated coordinates
  80772. * @returns a new Vector2
  80773. */
  80774. negate(): Vector2;
  80775. /**
  80776. * Negate this vector in place
  80777. * @returns this
  80778. */
  80779. negateInPlace(): Vector2;
  80780. /**
  80781. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80782. * @param result defines the Vector3 object where to store the result
  80783. * @returns the current Vector2
  80784. */
  80785. negateToRef(result: Vector2): Vector2;
  80786. /**
  80787. * Multiply the Vector2 coordinates by scale
  80788. * @param scale defines the scaling factor
  80789. * @returns the current updated Vector2
  80790. */
  80791. scaleInPlace(scale: number): Vector2;
  80792. /**
  80793. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80794. * @param scale defines the scaling factor
  80795. * @returns a new Vector2
  80796. */
  80797. scale(scale: number): Vector2;
  80798. /**
  80799. * Scale the current Vector2 values by a factor to a given Vector2
  80800. * @param scale defines the scale factor
  80801. * @param result defines the Vector2 object where to store the result
  80802. * @returns the unmodified current Vector2
  80803. */
  80804. scaleToRef(scale: number, result: Vector2): Vector2;
  80805. /**
  80806. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80807. * @param scale defines the scale factor
  80808. * @param result defines the Vector2 object where to store the result
  80809. * @returns the unmodified current Vector2
  80810. */
  80811. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80812. /**
  80813. * Gets a boolean if two vectors are equals
  80814. * @param otherVector defines the other vector
  80815. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80816. */
  80817. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80818. /**
  80819. * Gets a boolean if two vectors are equals (using an epsilon value)
  80820. * @param otherVector defines the other vector
  80821. * @param epsilon defines the minimal distance to consider equality
  80822. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80823. */
  80824. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80825. /**
  80826. * Gets a new Vector2 from current Vector2 floored values
  80827. * @returns a new Vector2
  80828. */
  80829. floor(): Vector2;
  80830. /**
  80831. * Gets a new Vector2 from current Vector2 floored values
  80832. * @returns a new Vector2
  80833. */
  80834. fract(): Vector2;
  80835. /**
  80836. * Gets the length of the vector
  80837. * @returns the vector length (float)
  80838. */
  80839. length(): number;
  80840. /**
  80841. * Gets the vector squared length
  80842. * @returns the vector squared length (float)
  80843. */
  80844. lengthSquared(): number;
  80845. /**
  80846. * Normalize the vector
  80847. * @returns the current updated Vector2
  80848. */
  80849. normalize(): Vector2;
  80850. /**
  80851. * Gets a new Vector2 copied from the Vector2
  80852. * @returns a new Vector2
  80853. */
  80854. clone(): Vector2;
  80855. /**
  80856. * Gets a new Vector2(0, 0)
  80857. * @returns a new Vector2
  80858. */
  80859. static Zero(): Vector2;
  80860. /**
  80861. * Gets a new Vector2(1, 1)
  80862. * @returns a new Vector2
  80863. */
  80864. static One(): Vector2;
  80865. /**
  80866. * Gets a new Vector2 set from the given index element of the given array
  80867. * @param array defines the data source
  80868. * @param offset defines the offset in the data source
  80869. * @returns a new Vector2
  80870. */
  80871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80872. /**
  80873. * Sets "result" from the given index element of the given array
  80874. * @param array defines the data source
  80875. * @param offset defines the offset in the data source
  80876. * @param result defines the target vector
  80877. */
  80878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80879. /**
  80880. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80881. * @param value1 defines 1st point of control
  80882. * @param value2 defines 2nd point of control
  80883. * @param value3 defines 3rd point of control
  80884. * @param value4 defines 4th point of control
  80885. * @param amount defines the interpolation factor
  80886. * @returns a new Vector2
  80887. */
  80888. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80889. /**
  80890. * 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".
  80891. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80892. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80893. * @param value defines the value to clamp
  80894. * @param min defines the lower limit
  80895. * @param max defines the upper limit
  80896. * @returns a new Vector2
  80897. */
  80898. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80899. /**
  80900. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80901. * @param value1 defines the 1st control point
  80902. * @param tangent1 defines the outgoing tangent
  80903. * @param value2 defines the 2nd control point
  80904. * @param tangent2 defines the incoming tangent
  80905. * @param amount defines the interpolation factor
  80906. * @returns a new Vector2
  80907. */
  80908. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80909. /**
  80910. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80911. * @param start defines the start vector
  80912. * @param end defines the end vector
  80913. * @param amount defines the interpolation factor
  80914. * @returns a new Vector2
  80915. */
  80916. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80917. /**
  80918. * Gets the dot product of the vector "left" and the vector "right"
  80919. * @param left defines first vector
  80920. * @param right defines second vector
  80921. * @returns the dot product (float)
  80922. */
  80923. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80924. /**
  80925. * Returns a new Vector2 equal to the normalized given vector
  80926. * @param vector defines the vector to normalize
  80927. * @returns a new Vector2
  80928. */
  80929. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80930. /**
  80931. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80932. * @param left defines 1st vector
  80933. * @param right defines 2nd vector
  80934. * @returns a new Vector2
  80935. */
  80936. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80937. /**
  80938. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80939. * @param left defines 1st vector
  80940. * @param right defines 2nd vector
  80941. * @returns a new Vector2
  80942. */
  80943. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80944. /**
  80945. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80946. * @param vector defines the vector to transform
  80947. * @param transformation defines the matrix to apply
  80948. * @returns a new Vector2
  80949. */
  80950. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80951. /**
  80952. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80953. * @param vector defines the vector to transform
  80954. * @param transformation defines the matrix to apply
  80955. * @param result defines the target vector
  80956. */
  80957. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80958. /**
  80959. * Determines if a given vector is included in a triangle
  80960. * @param p defines the vector to test
  80961. * @param p0 defines 1st triangle point
  80962. * @param p1 defines 2nd triangle point
  80963. * @param p2 defines 3rd triangle point
  80964. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80965. */
  80966. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80967. /**
  80968. * Gets the distance between the vectors "value1" and "value2"
  80969. * @param value1 defines first vector
  80970. * @param value2 defines second vector
  80971. * @returns the distance between vectors
  80972. */
  80973. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80974. /**
  80975. * Returns the squared distance between the vectors "value1" and "value2"
  80976. * @param value1 defines first vector
  80977. * @param value2 defines second vector
  80978. * @returns the squared distance between vectors
  80979. */
  80980. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80981. /**
  80982. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80983. * @param value1 defines first vector
  80984. * @param value2 defines second vector
  80985. * @returns a new Vector2
  80986. */
  80987. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80988. /**
  80989. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80990. * @param p defines the middle point
  80991. * @param segA defines one point of the segment
  80992. * @param segB defines the other point of the segment
  80993. * @returns the shortest distance
  80994. */
  80995. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80996. }
  80997. /**
  80998. * Class used to store (x,y,z) vector representation
  80999. * A Vector3 is the main object used in 3D geometry
  81000. * It can represent etiher the coordinates of a point the space, either a direction
  81001. * Reminder: js uses a left handed forward facing system
  81002. */
  81003. export class Vector3 {
  81004. private static _UpReadOnly;
  81005. private static _ZeroReadOnly;
  81006. /** @hidden */
  81007. _x: number;
  81008. /** @hidden */
  81009. _y: number;
  81010. /** @hidden */
  81011. _z: number;
  81012. /** @hidden */
  81013. _isDirty: boolean;
  81014. /** Gets or sets the x coordinate */
  81015. get x(): number;
  81016. set x(value: number);
  81017. /** Gets or sets the y coordinate */
  81018. get y(): number;
  81019. set y(value: number);
  81020. /** Gets or sets the z coordinate */
  81021. get z(): number;
  81022. set z(value: number);
  81023. /**
  81024. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81025. * @param x defines the first coordinates (on X axis)
  81026. * @param y defines the second coordinates (on Y axis)
  81027. * @param z defines the third coordinates (on Z axis)
  81028. */
  81029. constructor(x?: number, y?: number, z?: number);
  81030. /**
  81031. * Creates a string representation of the Vector3
  81032. * @returns a string with the Vector3 coordinates.
  81033. */
  81034. toString(): string;
  81035. /**
  81036. * Gets the class name
  81037. * @returns the string "Vector3"
  81038. */
  81039. getClassName(): string;
  81040. /**
  81041. * Creates the Vector3 hash code
  81042. * @returns a number which tends to be unique between Vector3 instances
  81043. */
  81044. getHashCode(): number;
  81045. /**
  81046. * Creates an array containing three elements : the coordinates of the Vector3
  81047. * @returns a new array of numbers
  81048. */
  81049. asArray(): number[];
  81050. /**
  81051. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81052. * @param array defines the destination array
  81053. * @param index defines the offset in the destination array
  81054. * @returns the current Vector3
  81055. */
  81056. toArray(array: FloatArray, index?: number): Vector3;
  81057. /**
  81058. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81059. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81060. */
  81061. toQuaternion(): Quaternion;
  81062. /**
  81063. * Adds the given vector to the current Vector3
  81064. * @param otherVector defines the second operand
  81065. * @returns the current updated Vector3
  81066. */
  81067. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81068. /**
  81069. * Adds the given coordinates to the current Vector3
  81070. * @param x defines the x coordinate of the operand
  81071. * @param y defines the y coordinate of the operand
  81072. * @param z defines the z coordinate of the operand
  81073. * @returns the current updated Vector3
  81074. */
  81075. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81076. /**
  81077. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81078. * @param otherVector defines the second operand
  81079. * @returns the resulting Vector3
  81080. */
  81081. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81082. /**
  81083. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81084. * @param otherVector defines the second operand
  81085. * @param result defines the Vector3 object where to store the result
  81086. * @returns the current Vector3
  81087. */
  81088. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81089. /**
  81090. * Subtract the given vector from the current Vector3
  81091. * @param otherVector defines the second operand
  81092. * @returns the current updated Vector3
  81093. */
  81094. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81095. /**
  81096. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81097. * @param otherVector defines the second operand
  81098. * @returns the resulting Vector3
  81099. */
  81100. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81101. /**
  81102. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81103. * @param otherVector defines the second operand
  81104. * @param result defines the Vector3 object where to store the result
  81105. * @returns the current Vector3
  81106. */
  81107. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81108. /**
  81109. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81110. * @param x defines the x coordinate of the operand
  81111. * @param y defines the y coordinate of the operand
  81112. * @param z defines the z coordinate of the operand
  81113. * @returns the resulting Vector3
  81114. */
  81115. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81116. /**
  81117. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81118. * @param x defines the x coordinate of the operand
  81119. * @param y defines the y coordinate of the operand
  81120. * @param z defines the z coordinate of the operand
  81121. * @param result defines the Vector3 object where to store the result
  81122. * @returns the current Vector3
  81123. */
  81124. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81125. /**
  81126. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81127. * @returns a new Vector3
  81128. */
  81129. negate(): Vector3;
  81130. /**
  81131. * Negate this vector in place
  81132. * @returns this
  81133. */
  81134. negateInPlace(): Vector3;
  81135. /**
  81136. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81137. * @param result defines the Vector3 object where to store the result
  81138. * @returns the current Vector3
  81139. */
  81140. negateToRef(result: Vector3): Vector3;
  81141. /**
  81142. * Multiplies the Vector3 coordinates by the float "scale"
  81143. * @param scale defines the multiplier factor
  81144. * @returns the current updated Vector3
  81145. */
  81146. scaleInPlace(scale: number): Vector3;
  81147. /**
  81148. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81149. * @param scale defines the multiplier factor
  81150. * @returns a new Vector3
  81151. */
  81152. scale(scale: number): Vector3;
  81153. /**
  81154. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81155. * @param scale defines the multiplier factor
  81156. * @param result defines the Vector3 object where to store the result
  81157. * @returns the current Vector3
  81158. */
  81159. scaleToRef(scale: number, result: Vector3): Vector3;
  81160. /**
  81161. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81162. * @param scale defines the scale factor
  81163. * @param result defines the Vector3 object where to store the result
  81164. * @returns the unmodified current Vector3
  81165. */
  81166. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81167. /**
  81168. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81169. * @param origin defines the origin of the projection ray
  81170. * @param plane defines the plane to project to
  81171. * @returns the projected vector3
  81172. */
  81173. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81174. /**
  81175. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81176. * @param origin defines the origin of the projection ray
  81177. * @param plane defines the plane to project to
  81178. * @param result defines the Vector3 where to store the result
  81179. */
  81180. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81181. /**
  81182. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81183. * @param otherVector defines the second operand
  81184. * @returns true if both vectors are equals
  81185. */
  81186. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81187. /**
  81188. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81189. * @param otherVector defines the second operand
  81190. * @param epsilon defines the minimal distance to define values as equals
  81191. * @returns true if both vectors are distant less than epsilon
  81192. */
  81193. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81194. /**
  81195. * Returns true if the current Vector3 coordinates equals the given floats
  81196. * @param x defines the x coordinate of the operand
  81197. * @param y defines the y coordinate of the operand
  81198. * @param z defines the z coordinate of the operand
  81199. * @returns true if both vectors are equals
  81200. */
  81201. equalsToFloats(x: number, y: number, z: number): boolean;
  81202. /**
  81203. * Multiplies the current Vector3 coordinates by the given ones
  81204. * @param otherVector defines the second operand
  81205. * @returns the current updated Vector3
  81206. */
  81207. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81208. /**
  81209. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81210. * @param otherVector defines the second operand
  81211. * @returns the new Vector3
  81212. */
  81213. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81214. /**
  81215. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81216. * @param otherVector defines the second operand
  81217. * @param result defines the Vector3 object where to store the result
  81218. * @returns the current Vector3
  81219. */
  81220. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81221. /**
  81222. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81223. * @param x defines the x coordinate of the operand
  81224. * @param y defines the y coordinate of the operand
  81225. * @param z defines the z coordinate of the operand
  81226. * @returns the new Vector3
  81227. */
  81228. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81229. /**
  81230. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81231. * @param otherVector defines the second operand
  81232. * @returns the new Vector3
  81233. */
  81234. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81235. /**
  81236. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81237. * @param otherVector defines the second operand
  81238. * @param result defines the Vector3 object where to store the result
  81239. * @returns the current Vector3
  81240. */
  81241. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81242. /**
  81243. * Divides the current Vector3 coordinates by the given ones.
  81244. * @param otherVector defines the second operand
  81245. * @returns the current updated Vector3
  81246. */
  81247. divideInPlace(otherVector: Vector3): Vector3;
  81248. /**
  81249. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81250. * @param other defines the second operand
  81251. * @returns the current updated Vector3
  81252. */
  81253. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81254. /**
  81255. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81256. * @param other defines the second operand
  81257. * @returns the current updated Vector3
  81258. */
  81259. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81260. /**
  81261. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81262. * @param x defines the x coordinate of the operand
  81263. * @param y defines the y coordinate of the operand
  81264. * @param z defines the z coordinate of the operand
  81265. * @returns the current updated Vector3
  81266. */
  81267. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81268. /**
  81269. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81270. * @param x defines the x coordinate of the operand
  81271. * @param y defines the y coordinate of the operand
  81272. * @param z defines the z coordinate of the operand
  81273. * @returns the current updated Vector3
  81274. */
  81275. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81276. /**
  81277. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81278. * Check if is non uniform within a certain amount of decimal places to account for this
  81279. * @param epsilon the amount the values can differ
  81280. * @returns if the the vector is non uniform to a certain number of decimal places
  81281. */
  81282. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81283. /**
  81284. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81285. */
  81286. get isNonUniform(): boolean;
  81287. /**
  81288. * Gets a new Vector3 from current Vector3 floored values
  81289. * @returns a new Vector3
  81290. */
  81291. floor(): Vector3;
  81292. /**
  81293. * Gets a new Vector3 from current Vector3 floored values
  81294. * @returns a new Vector3
  81295. */
  81296. fract(): Vector3;
  81297. /**
  81298. * Gets the length of the Vector3
  81299. * @returns the length of the Vector3
  81300. */
  81301. length(): number;
  81302. /**
  81303. * Gets the squared length of the Vector3
  81304. * @returns squared length of the Vector3
  81305. */
  81306. lengthSquared(): number;
  81307. /**
  81308. * Normalize the current Vector3.
  81309. * Please note that this is an in place operation.
  81310. * @returns the current updated Vector3
  81311. */
  81312. normalize(): Vector3;
  81313. /**
  81314. * Reorders the x y z properties of the vector in place
  81315. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81316. * @returns the current updated vector
  81317. */
  81318. reorderInPlace(order: string): this;
  81319. /**
  81320. * Rotates the vector around 0,0,0 by a quaternion
  81321. * @param quaternion the rotation quaternion
  81322. * @param result vector to store the result
  81323. * @returns the resulting vector
  81324. */
  81325. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81326. /**
  81327. * Rotates a vector around a given point
  81328. * @param quaternion the rotation quaternion
  81329. * @param point the point to rotate around
  81330. * @param result vector to store the result
  81331. * @returns the resulting vector
  81332. */
  81333. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81334. /**
  81335. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81336. * The cross product is then orthogonal to both current and "other"
  81337. * @param other defines the right operand
  81338. * @returns the cross product
  81339. */
  81340. cross(other: Vector3): Vector3;
  81341. /**
  81342. * Normalize the current Vector3 with the given input length.
  81343. * Please note that this is an in place operation.
  81344. * @param len the length of the vector
  81345. * @returns the current updated Vector3
  81346. */
  81347. normalizeFromLength(len: number): Vector3;
  81348. /**
  81349. * Normalize the current Vector3 to a new vector
  81350. * @returns the new Vector3
  81351. */
  81352. normalizeToNew(): Vector3;
  81353. /**
  81354. * Normalize the current Vector3 to the reference
  81355. * @param reference define the Vector3 to update
  81356. * @returns the updated Vector3
  81357. */
  81358. normalizeToRef(reference: Vector3): Vector3;
  81359. /**
  81360. * Creates a new Vector3 copied from the current Vector3
  81361. * @returns the new Vector3
  81362. */
  81363. clone(): Vector3;
  81364. /**
  81365. * Copies the given vector coordinates to the current Vector3 ones
  81366. * @param source defines the source Vector3
  81367. * @returns the current updated Vector3
  81368. */
  81369. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81370. /**
  81371. * Copies the given floats to the current Vector3 coordinates
  81372. * @param x defines the x coordinate of the operand
  81373. * @param y defines the y coordinate of the operand
  81374. * @param z defines the z coordinate of the operand
  81375. * @returns the current updated Vector3
  81376. */
  81377. copyFromFloats(x: number, y: number, z: number): Vector3;
  81378. /**
  81379. * Copies the given floats to the current Vector3 coordinates
  81380. * @param x defines the x coordinate of the operand
  81381. * @param y defines the y coordinate of the operand
  81382. * @param z defines the z coordinate of the operand
  81383. * @returns the current updated Vector3
  81384. */
  81385. set(x: number, y: number, z: number): Vector3;
  81386. /**
  81387. * Copies the given float to the current Vector3 coordinates
  81388. * @param v defines the x, y and z coordinates of the operand
  81389. * @returns the current updated Vector3
  81390. */
  81391. setAll(v: number): Vector3;
  81392. /**
  81393. * Get the clip factor between two vectors
  81394. * @param vector0 defines the first operand
  81395. * @param vector1 defines the second operand
  81396. * @param axis defines the axis to use
  81397. * @param size defines the size along the axis
  81398. * @returns the clip factor
  81399. */
  81400. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81401. /**
  81402. * Get angle between two vectors
  81403. * @param vector0 angle between vector0 and vector1
  81404. * @param vector1 angle between vector0 and vector1
  81405. * @param normal direction of the normal
  81406. * @return the angle between vector0 and vector1
  81407. */
  81408. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81409. /**
  81410. * Returns a new Vector3 set from the index "offset" of the given array
  81411. * @param array defines the source array
  81412. * @param offset defines the offset in the source array
  81413. * @returns the new Vector3
  81414. */
  81415. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81416. /**
  81417. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81418. * @param array defines the source array
  81419. * @param offset defines the offset in the source array
  81420. * @returns the new Vector3
  81421. * @deprecated Please use FromArray instead.
  81422. */
  81423. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81424. /**
  81425. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81426. * @param array defines the source array
  81427. * @param offset defines the offset in the source array
  81428. * @param result defines the Vector3 where to store the result
  81429. */
  81430. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81431. /**
  81432. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81433. * @param array defines the source array
  81434. * @param offset defines the offset in the source array
  81435. * @param result defines the Vector3 where to store the result
  81436. * @deprecated Please use FromArrayToRef instead.
  81437. */
  81438. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81439. /**
  81440. * Sets the given vector "result" with the given floats.
  81441. * @param x defines the x coordinate of the source
  81442. * @param y defines the y coordinate of the source
  81443. * @param z defines the z coordinate of the source
  81444. * @param result defines the Vector3 where to store the result
  81445. */
  81446. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81447. /**
  81448. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81449. * @returns a new empty Vector3
  81450. */
  81451. static Zero(): Vector3;
  81452. /**
  81453. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81454. * @returns a new unit Vector3
  81455. */
  81456. static One(): Vector3;
  81457. /**
  81458. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81459. * @returns a new up Vector3
  81460. */
  81461. static Up(): Vector3;
  81462. /**
  81463. * Gets a up Vector3 that must not be updated
  81464. */
  81465. static get UpReadOnly(): DeepImmutable<Vector3>;
  81466. /**
  81467. * Gets a zero Vector3 that must not be updated
  81468. */
  81469. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81470. /**
  81471. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81472. * @returns a new down Vector3
  81473. */
  81474. static Down(): Vector3;
  81475. /**
  81476. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81477. * @param rightHandedSystem is the scene right-handed (negative z)
  81478. * @returns a new forward Vector3
  81479. */
  81480. static Forward(rightHandedSystem?: boolean): Vector3;
  81481. /**
  81482. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81483. * @param rightHandedSystem is the scene right-handed (negative-z)
  81484. * @returns a new forward Vector3
  81485. */
  81486. static Backward(rightHandedSystem?: boolean): Vector3;
  81487. /**
  81488. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81489. * @returns a new right Vector3
  81490. */
  81491. static Right(): Vector3;
  81492. /**
  81493. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81494. * @returns a new left Vector3
  81495. */
  81496. static Left(): Vector3;
  81497. /**
  81498. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81499. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81500. * @param vector defines the Vector3 to transform
  81501. * @param transformation defines the transformation matrix
  81502. * @returns the transformed Vector3
  81503. */
  81504. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81505. /**
  81506. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81507. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81508. * @param vector defines the Vector3 to transform
  81509. * @param transformation defines the transformation matrix
  81510. * @param result defines the Vector3 where to store the result
  81511. */
  81512. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81513. /**
  81514. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81515. * This method computes tranformed coordinates only, not transformed direction vectors
  81516. * @param x define the x coordinate of the source vector
  81517. * @param y define the y coordinate of the source vector
  81518. * @param z define the z coordinate of the source vector
  81519. * @param transformation defines the transformation matrix
  81520. * @param result defines the Vector3 where to store the result
  81521. */
  81522. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81523. /**
  81524. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81525. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81526. * @param vector defines the Vector3 to transform
  81527. * @param transformation defines the transformation matrix
  81528. * @returns the new Vector3
  81529. */
  81530. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81531. /**
  81532. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81533. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81534. * @param vector defines the Vector3 to transform
  81535. * @param transformation defines the transformation matrix
  81536. * @param result defines the Vector3 where to store the result
  81537. */
  81538. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81539. /**
  81540. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81541. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81542. * @param x define the x coordinate of the source vector
  81543. * @param y define the y coordinate of the source vector
  81544. * @param z define the z coordinate of the source vector
  81545. * @param transformation defines the transformation matrix
  81546. * @param result defines the Vector3 where to store the result
  81547. */
  81548. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81549. /**
  81550. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81551. * @param value1 defines the first control point
  81552. * @param value2 defines the second control point
  81553. * @param value3 defines the third control point
  81554. * @param value4 defines the fourth control point
  81555. * @param amount defines the amount on the spline to use
  81556. * @returns the new Vector3
  81557. */
  81558. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81559. /**
  81560. * 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"
  81561. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81562. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81563. * @param value defines the current value
  81564. * @param min defines the lower range value
  81565. * @param max defines the upper range value
  81566. * @returns the new Vector3
  81567. */
  81568. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81569. /**
  81570. * 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"
  81571. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81572. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81573. * @param value defines the current value
  81574. * @param min defines the lower range value
  81575. * @param max defines the upper range value
  81576. * @param result defines the Vector3 where to store the result
  81577. */
  81578. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81579. /**
  81580. * Checks if a given vector is inside a specific range
  81581. * @param v defines the vector to test
  81582. * @param min defines the minimum range
  81583. * @param max defines the maximum range
  81584. */
  81585. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81586. /**
  81587. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81588. * @param value1 defines the first control point
  81589. * @param tangent1 defines the first tangent vector
  81590. * @param value2 defines the second control point
  81591. * @param tangent2 defines the second tangent vector
  81592. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81593. * @returns the new Vector3
  81594. */
  81595. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81596. /**
  81597. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81598. * @param start defines the start value
  81599. * @param end defines the end value
  81600. * @param amount max defines amount between both (between 0 and 1)
  81601. * @returns the new Vector3
  81602. */
  81603. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81604. /**
  81605. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81606. * @param start defines the start value
  81607. * @param end defines the end value
  81608. * @param amount max defines amount between both (between 0 and 1)
  81609. * @param result defines the Vector3 where to store the result
  81610. */
  81611. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81612. /**
  81613. * Returns the dot product (float) between the vectors "left" and "right"
  81614. * @param left defines the left operand
  81615. * @param right defines the right operand
  81616. * @returns the dot product
  81617. */
  81618. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81619. /**
  81620. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81621. * The cross product is then orthogonal to both "left" and "right"
  81622. * @param left defines the left operand
  81623. * @param right defines the right operand
  81624. * @returns the cross product
  81625. */
  81626. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81627. /**
  81628. * Sets the given vector "result" with the cross product of "left" and "right"
  81629. * The cross product is then orthogonal to both "left" and "right"
  81630. * @param left defines the left operand
  81631. * @param right defines the right operand
  81632. * @param result defines the Vector3 where to store the result
  81633. */
  81634. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81635. /**
  81636. * Returns a new Vector3 as the normalization of the given vector
  81637. * @param vector defines the Vector3 to normalize
  81638. * @returns the new Vector3
  81639. */
  81640. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81641. /**
  81642. * Sets the given vector "result" with the normalization of the given first vector
  81643. * @param vector defines the Vector3 to normalize
  81644. * @param result defines the Vector3 where to store the result
  81645. */
  81646. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81647. /**
  81648. * Project a Vector3 onto screen space
  81649. * @param vector defines the Vector3 to project
  81650. * @param world defines the world matrix to use
  81651. * @param transform defines the transform (view x projection) matrix to use
  81652. * @param viewport defines the screen viewport to use
  81653. * @returns the new Vector3
  81654. */
  81655. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81656. /** @hidden */
  81657. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81658. /**
  81659. * Unproject from screen space to object space
  81660. * @param source defines the screen space Vector3 to use
  81661. * @param viewportWidth defines the current width of the viewport
  81662. * @param viewportHeight defines the current height of the viewport
  81663. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81664. * @param transform defines the transform (view x projection) matrix to use
  81665. * @returns the new Vector3
  81666. */
  81667. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81668. /**
  81669. * Unproject from screen space to object space
  81670. * @param source defines the screen space Vector3 to use
  81671. * @param viewportWidth defines the current width of the viewport
  81672. * @param viewportHeight defines the current height of the viewport
  81673. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81674. * @param view defines the view matrix to use
  81675. * @param projection defines the projection matrix to use
  81676. * @returns the new Vector3
  81677. */
  81678. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81679. /**
  81680. * Unproject from screen space to object space
  81681. * @param source defines the screen space Vector3 to use
  81682. * @param viewportWidth defines the current width of the viewport
  81683. * @param viewportHeight defines the current height of the viewport
  81684. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81685. * @param view defines the view matrix to use
  81686. * @param projection defines the projection matrix to use
  81687. * @param result defines the Vector3 where to store the result
  81688. */
  81689. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81690. /**
  81691. * Unproject from screen space to object space
  81692. * @param sourceX defines the screen space x coordinate to use
  81693. * @param sourceY defines the screen space y coordinate to use
  81694. * @param sourceZ defines the screen space z coordinate to use
  81695. * @param viewportWidth defines the current width of the viewport
  81696. * @param viewportHeight defines the current height of the viewport
  81697. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81698. * @param view defines the view matrix to use
  81699. * @param projection defines the projection matrix to use
  81700. * @param result defines the Vector3 where to store the result
  81701. */
  81702. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81703. /**
  81704. * Gets the minimal coordinate values between two Vector3
  81705. * @param left defines the first operand
  81706. * @param right defines the second operand
  81707. * @returns the new Vector3
  81708. */
  81709. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81710. /**
  81711. * Gets the maximal coordinate values between two Vector3
  81712. * @param left defines the first operand
  81713. * @param right defines the second operand
  81714. * @returns the new Vector3
  81715. */
  81716. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81717. /**
  81718. * Returns the distance between the vectors "value1" and "value2"
  81719. * @param value1 defines the first operand
  81720. * @param value2 defines the second operand
  81721. * @returns the distance
  81722. */
  81723. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81724. /**
  81725. * Returns the squared distance between the vectors "value1" and "value2"
  81726. * @param value1 defines the first operand
  81727. * @param value2 defines the second operand
  81728. * @returns the squared distance
  81729. */
  81730. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81731. /**
  81732. * Returns a new Vector3 located at the center between "value1" and "value2"
  81733. * @param value1 defines the first operand
  81734. * @param value2 defines the second operand
  81735. * @returns the new Vector3
  81736. */
  81737. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81738. /**
  81739. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81740. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81741. * to something in order to rotate it from its local system to the given target system
  81742. * Note: axis1, axis2 and axis3 are normalized during this operation
  81743. * @param axis1 defines the first axis
  81744. * @param axis2 defines the second axis
  81745. * @param axis3 defines the third axis
  81746. * @returns a new Vector3
  81747. */
  81748. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81749. /**
  81750. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81751. * @param axis1 defines the first axis
  81752. * @param axis2 defines the second axis
  81753. * @param axis3 defines the third axis
  81754. * @param ref defines the Vector3 where to store the result
  81755. */
  81756. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81757. }
  81758. /**
  81759. * Vector4 class created for EulerAngle class conversion to Quaternion
  81760. */
  81761. export class Vector4 {
  81762. /** x value of the vector */
  81763. x: number;
  81764. /** y value of the vector */
  81765. y: number;
  81766. /** z value of the vector */
  81767. z: number;
  81768. /** w value of the vector */
  81769. w: number;
  81770. /**
  81771. * Creates a Vector4 object from the given floats.
  81772. * @param x x value of the vector
  81773. * @param y y value of the vector
  81774. * @param z z value of the vector
  81775. * @param w w value of the vector
  81776. */
  81777. constructor(
  81778. /** x value of the vector */
  81779. x: number,
  81780. /** y value of the vector */
  81781. y: number,
  81782. /** z value of the vector */
  81783. z: number,
  81784. /** w value of the vector */
  81785. w: number);
  81786. /**
  81787. * Returns the string with the Vector4 coordinates.
  81788. * @returns a string containing all the vector values
  81789. */
  81790. toString(): string;
  81791. /**
  81792. * Returns the string "Vector4".
  81793. * @returns "Vector4"
  81794. */
  81795. getClassName(): string;
  81796. /**
  81797. * Returns the Vector4 hash code.
  81798. * @returns a unique hash code
  81799. */
  81800. getHashCode(): number;
  81801. /**
  81802. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81803. * @returns the resulting array
  81804. */
  81805. asArray(): number[];
  81806. /**
  81807. * Populates the given array from the given index with the Vector4 coordinates.
  81808. * @param array array to populate
  81809. * @param index index of the array to start at (default: 0)
  81810. * @returns the Vector4.
  81811. */
  81812. toArray(array: FloatArray, index?: number): Vector4;
  81813. /**
  81814. * Adds the given vector to the current Vector4.
  81815. * @param otherVector the vector to add
  81816. * @returns the updated Vector4.
  81817. */
  81818. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81819. /**
  81820. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81821. * @param otherVector the vector to add
  81822. * @returns the resulting vector
  81823. */
  81824. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81825. /**
  81826. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81827. * @param otherVector the vector to add
  81828. * @param result the vector to store the result
  81829. * @returns the current Vector4.
  81830. */
  81831. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81832. /**
  81833. * Subtract in place the given vector from the current Vector4.
  81834. * @param otherVector the vector to subtract
  81835. * @returns the updated Vector4.
  81836. */
  81837. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81838. /**
  81839. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81840. * @param otherVector the vector to add
  81841. * @returns the new vector with the result
  81842. */
  81843. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81844. /**
  81845. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81846. * @param otherVector the vector to subtract
  81847. * @param result the vector to store the result
  81848. * @returns the current Vector4.
  81849. */
  81850. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81851. /**
  81852. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81853. */
  81854. /**
  81855. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81856. * @param x value to subtract
  81857. * @param y value to subtract
  81858. * @param z value to subtract
  81859. * @param w value to subtract
  81860. * @returns new vector containing the result
  81861. */
  81862. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81863. /**
  81864. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81865. * @param x value to subtract
  81866. * @param y value to subtract
  81867. * @param z value to subtract
  81868. * @param w value to subtract
  81869. * @param result the vector to store the result in
  81870. * @returns the current Vector4.
  81871. */
  81872. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81873. /**
  81874. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81875. * @returns a new vector with the negated values
  81876. */
  81877. negate(): Vector4;
  81878. /**
  81879. * Negate this vector in place
  81880. * @returns this
  81881. */
  81882. negateInPlace(): Vector4;
  81883. /**
  81884. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81885. * @param result defines the Vector3 object where to store the result
  81886. * @returns the current Vector4
  81887. */
  81888. negateToRef(result: Vector4): Vector4;
  81889. /**
  81890. * Multiplies the current Vector4 coordinates by scale (float).
  81891. * @param scale the number to scale with
  81892. * @returns the updated Vector4.
  81893. */
  81894. scaleInPlace(scale: number): Vector4;
  81895. /**
  81896. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81897. * @param scale the number to scale with
  81898. * @returns a new vector with the result
  81899. */
  81900. scale(scale: number): Vector4;
  81901. /**
  81902. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81903. * @param scale the number to scale with
  81904. * @param result a vector to store the result in
  81905. * @returns the current Vector4.
  81906. */
  81907. scaleToRef(scale: number, result: Vector4): Vector4;
  81908. /**
  81909. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81910. * @param scale defines the scale factor
  81911. * @param result defines the Vector4 object where to store the result
  81912. * @returns the unmodified current Vector4
  81913. */
  81914. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81915. /**
  81916. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81917. * @param otherVector the vector to compare against
  81918. * @returns true if they are equal
  81919. */
  81920. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81921. /**
  81922. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81923. * @param otherVector vector to compare against
  81924. * @param epsilon (Default: very small number)
  81925. * @returns true if they are equal
  81926. */
  81927. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81928. /**
  81929. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81930. * @param x x value to compare against
  81931. * @param y y value to compare against
  81932. * @param z z value to compare against
  81933. * @param w w value to compare against
  81934. * @returns true if equal
  81935. */
  81936. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81937. /**
  81938. * Multiplies in place the current Vector4 by the given one.
  81939. * @param otherVector vector to multiple with
  81940. * @returns the updated Vector4.
  81941. */
  81942. multiplyInPlace(otherVector: Vector4): Vector4;
  81943. /**
  81944. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81945. * @param otherVector vector to multiple with
  81946. * @returns resulting new vector
  81947. */
  81948. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81949. /**
  81950. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81951. * @param otherVector vector to multiple with
  81952. * @param result vector to store the result
  81953. * @returns the current Vector4.
  81954. */
  81955. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81956. /**
  81957. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81958. * @param x x value multiply with
  81959. * @param y y value multiply with
  81960. * @param z z value multiply with
  81961. * @param w w value multiply with
  81962. * @returns resulting new vector
  81963. */
  81964. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81965. /**
  81966. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81967. * @param otherVector vector to devide with
  81968. * @returns resulting new vector
  81969. */
  81970. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81971. /**
  81972. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81973. * @param otherVector vector to devide with
  81974. * @param result vector to store the result
  81975. * @returns the current Vector4.
  81976. */
  81977. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81978. /**
  81979. * Divides the current Vector3 coordinates by the given ones.
  81980. * @param otherVector vector to devide with
  81981. * @returns the updated Vector3.
  81982. */
  81983. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81984. /**
  81985. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81986. * @param other defines the second operand
  81987. * @returns the current updated Vector4
  81988. */
  81989. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81990. /**
  81991. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81992. * @param other defines the second operand
  81993. * @returns the current updated Vector4
  81994. */
  81995. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81996. /**
  81997. * Gets a new Vector4 from current Vector4 floored values
  81998. * @returns a new Vector4
  81999. */
  82000. floor(): Vector4;
  82001. /**
  82002. * Gets a new Vector4 from current Vector3 floored values
  82003. * @returns a new Vector4
  82004. */
  82005. fract(): Vector4;
  82006. /**
  82007. * Returns the Vector4 length (float).
  82008. * @returns the length
  82009. */
  82010. length(): number;
  82011. /**
  82012. * Returns the Vector4 squared length (float).
  82013. * @returns the length squared
  82014. */
  82015. lengthSquared(): number;
  82016. /**
  82017. * Normalizes in place the Vector4.
  82018. * @returns the updated Vector4.
  82019. */
  82020. normalize(): Vector4;
  82021. /**
  82022. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82023. * @returns this converted to a new vector3
  82024. */
  82025. toVector3(): Vector3;
  82026. /**
  82027. * Returns a new Vector4 copied from the current one.
  82028. * @returns the new cloned vector
  82029. */
  82030. clone(): Vector4;
  82031. /**
  82032. * Updates the current Vector4 with the given one coordinates.
  82033. * @param source the source vector to copy from
  82034. * @returns the updated Vector4.
  82035. */
  82036. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82037. /**
  82038. * Updates the current Vector4 coordinates with the given floats.
  82039. * @param x float to copy from
  82040. * @param y float to copy from
  82041. * @param z float to copy from
  82042. * @param w float to copy from
  82043. * @returns the updated Vector4.
  82044. */
  82045. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82046. /**
  82047. * Updates the current Vector4 coordinates with the given floats.
  82048. * @param x float to set from
  82049. * @param y float to set from
  82050. * @param z float to set from
  82051. * @param w float to set from
  82052. * @returns the updated Vector4.
  82053. */
  82054. set(x: number, y: number, z: number, w: number): Vector4;
  82055. /**
  82056. * Copies the given float to the current Vector3 coordinates
  82057. * @param v defines the x, y, z and w coordinates of the operand
  82058. * @returns the current updated Vector3
  82059. */
  82060. setAll(v: number): Vector4;
  82061. /**
  82062. * Returns a new Vector4 set from the starting index of the given array.
  82063. * @param array the array to pull values from
  82064. * @param offset the offset into the array to start at
  82065. * @returns the new vector
  82066. */
  82067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82068. /**
  82069. * Updates the given vector "result" from the starting index of the given array.
  82070. * @param array the array to pull values from
  82071. * @param offset the offset into the array to start at
  82072. * @param result the vector to store the result in
  82073. */
  82074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82075. /**
  82076. * Updates the given vector "result" from the starting index of the given Float32Array.
  82077. * @param array the array to pull values from
  82078. * @param offset the offset into the array to start at
  82079. * @param result the vector to store the result in
  82080. */
  82081. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82082. /**
  82083. * Updates the given vector "result" coordinates from the given floats.
  82084. * @param x float to set from
  82085. * @param y float to set from
  82086. * @param z float to set from
  82087. * @param w float to set from
  82088. * @param result the vector to the floats in
  82089. */
  82090. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82091. /**
  82092. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82093. * @returns the new vector
  82094. */
  82095. static Zero(): Vector4;
  82096. /**
  82097. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82098. * @returns the new vector
  82099. */
  82100. static One(): Vector4;
  82101. /**
  82102. * Returns a new normalized Vector4 from the given one.
  82103. * @param vector the vector to normalize
  82104. * @returns the vector
  82105. */
  82106. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82107. /**
  82108. * Updates the given vector "result" from the normalization of the given one.
  82109. * @param vector the vector to normalize
  82110. * @param result the vector to store the result in
  82111. */
  82112. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82113. /**
  82114. * Returns a vector with the minimum values from the left and right vectors
  82115. * @param left left vector to minimize
  82116. * @param right right vector to minimize
  82117. * @returns a new vector with the minimum of the left and right vector values
  82118. */
  82119. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82120. /**
  82121. * Returns a vector with the maximum values from the left and right vectors
  82122. * @param left left vector to maximize
  82123. * @param right right vector to maximize
  82124. * @returns a new vector with the maximum of the left and right vector values
  82125. */
  82126. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82127. /**
  82128. * Returns the distance (float) between the vectors "value1" and "value2".
  82129. * @param value1 value to calulate the distance between
  82130. * @param value2 value to calulate the distance between
  82131. * @return the distance between the two vectors
  82132. */
  82133. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82134. /**
  82135. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82136. * @param value1 value to calulate the distance between
  82137. * @param value2 value to calulate the distance between
  82138. * @return the distance between the two vectors squared
  82139. */
  82140. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82141. /**
  82142. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82143. * @param value1 value to calulate the center between
  82144. * @param value2 value to calulate the center between
  82145. * @return the center between the two vectors
  82146. */
  82147. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82148. /**
  82149. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82150. * This methods computes transformed normalized direction vectors only.
  82151. * @param vector the vector to transform
  82152. * @param transformation the transformation matrix to apply
  82153. * @returns the new vector
  82154. */
  82155. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82156. /**
  82157. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82158. * This methods computes transformed normalized direction vectors only.
  82159. * @param vector the vector to transform
  82160. * @param transformation the transformation matrix to apply
  82161. * @param result the vector to store the result in
  82162. */
  82163. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82164. /**
  82165. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82166. * This methods computes transformed normalized direction vectors only.
  82167. * @param x value to transform
  82168. * @param y value to transform
  82169. * @param z value to transform
  82170. * @param w value to transform
  82171. * @param transformation the transformation matrix to apply
  82172. * @param result the vector to store the results in
  82173. */
  82174. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82175. /**
  82176. * Creates a new Vector4 from a Vector3
  82177. * @param source defines the source data
  82178. * @param w defines the 4th component (default is 0)
  82179. * @returns a new Vector4
  82180. */
  82181. static FromVector3(source: Vector3, w?: number): Vector4;
  82182. }
  82183. /**
  82184. * Class used to store quaternion data
  82185. * @see https://en.wikipedia.org/wiki/Quaternion
  82186. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82187. */
  82188. export class Quaternion {
  82189. /** @hidden */
  82190. _x: number;
  82191. /** @hidden */
  82192. _y: number;
  82193. /** @hidden */
  82194. _z: number;
  82195. /** @hidden */
  82196. _w: number;
  82197. /** @hidden */
  82198. _isDirty: boolean;
  82199. /** Gets or sets the x coordinate */
  82200. get x(): number;
  82201. set x(value: number);
  82202. /** Gets or sets the y coordinate */
  82203. get y(): number;
  82204. set y(value: number);
  82205. /** Gets or sets the z coordinate */
  82206. get z(): number;
  82207. set z(value: number);
  82208. /** Gets or sets the w coordinate */
  82209. get w(): number;
  82210. set w(value: number);
  82211. /**
  82212. * Creates a new Quaternion from the given floats
  82213. * @param x defines the first component (0 by default)
  82214. * @param y defines the second component (0 by default)
  82215. * @param z defines the third component (0 by default)
  82216. * @param w defines the fourth component (1.0 by default)
  82217. */
  82218. constructor(x?: number, y?: number, z?: number, w?: number);
  82219. /**
  82220. * Gets a string representation for the current quaternion
  82221. * @returns a string with the Quaternion coordinates
  82222. */
  82223. toString(): string;
  82224. /**
  82225. * Gets the class name of the quaternion
  82226. * @returns the string "Quaternion"
  82227. */
  82228. getClassName(): string;
  82229. /**
  82230. * Gets a hash code for this quaternion
  82231. * @returns the quaternion hash code
  82232. */
  82233. getHashCode(): number;
  82234. /**
  82235. * Copy the quaternion to an array
  82236. * @returns a new array populated with 4 elements from the quaternion coordinates
  82237. */
  82238. asArray(): number[];
  82239. /**
  82240. * Check if two quaternions are equals
  82241. * @param otherQuaternion defines the second operand
  82242. * @return true if the current quaternion and the given one coordinates are strictly equals
  82243. */
  82244. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82245. /**
  82246. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82247. * @param otherQuaternion defines the other quaternion
  82248. * @param epsilon defines the minimal distance to consider equality
  82249. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82250. */
  82251. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82252. /**
  82253. * Clone the current quaternion
  82254. * @returns a new quaternion copied from the current one
  82255. */
  82256. clone(): Quaternion;
  82257. /**
  82258. * Copy a quaternion to the current one
  82259. * @param other defines the other quaternion
  82260. * @returns the updated current quaternion
  82261. */
  82262. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82263. /**
  82264. * Updates the current quaternion with the given float coordinates
  82265. * @param x defines the x coordinate
  82266. * @param y defines the y coordinate
  82267. * @param z defines the z coordinate
  82268. * @param w defines the w coordinate
  82269. * @returns the updated current quaternion
  82270. */
  82271. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82272. /**
  82273. * Updates the current quaternion from the given float coordinates
  82274. * @param x defines the x coordinate
  82275. * @param y defines the y coordinate
  82276. * @param z defines the z coordinate
  82277. * @param w defines the w coordinate
  82278. * @returns the updated current quaternion
  82279. */
  82280. set(x: number, y: number, z: number, w: number): Quaternion;
  82281. /**
  82282. * Adds two quaternions
  82283. * @param other defines the second operand
  82284. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82285. */
  82286. add(other: DeepImmutable<Quaternion>): Quaternion;
  82287. /**
  82288. * Add a quaternion to the current one
  82289. * @param other defines the quaternion to add
  82290. * @returns the current quaternion
  82291. */
  82292. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82293. /**
  82294. * Subtract two quaternions
  82295. * @param other defines the second operand
  82296. * @returns a new quaternion as the subtraction result of the given one from the current one
  82297. */
  82298. subtract(other: Quaternion): Quaternion;
  82299. /**
  82300. * Multiplies the current quaternion by a scale factor
  82301. * @param value defines the scale factor
  82302. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82303. */
  82304. scale(value: number): Quaternion;
  82305. /**
  82306. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82307. * @param scale defines the scale factor
  82308. * @param result defines the Quaternion object where to store the result
  82309. * @returns the unmodified current quaternion
  82310. */
  82311. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82312. /**
  82313. * Multiplies in place the current quaternion by a scale factor
  82314. * @param value defines the scale factor
  82315. * @returns the current modified quaternion
  82316. */
  82317. scaleInPlace(value: number): Quaternion;
  82318. /**
  82319. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82320. * @param scale defines the scale factor
  82321. * @param result defines the Quaternion object where to store the result
  82322. * @returns the unmodified current quaternion
  82323. */
  82324. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82325. /**
  82326. * Multiplies two quaternions
  82327. * @param q1 defines the second operand
  82328. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82329. */
  82330. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82331. /**
  82332. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82333. * @param q1 defines the second operand
  82334. * @param result defines the target quaternion
  82335. * @returns the current quaternion
  82336. */
  82337. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82338. /**
  82339. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82340. * @param q1 defines the second operand
  82341. * @returns the currentupdated quaternion
  82342. */
  82343. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82344. /**
  82345. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82346. * @param ref defines the target quaternion
  82347. * @returns the current quaternion
  82348. */
  82349. conjugateToRef(ref: Quaternion): Quaternion;
  82350. /**
  82351. * Conjugates in place (1-q) the current quaternion
  82352. * @returns the current updated quaternion
  82353. */
  82354. conjugateInPlace(): Quaternion;
  82355. /**
  82356. * Conjugates in place (1-q) the current quaternion
  82357. * @returns a new quaternion
  82358. */
  82359. conjugate(): Quaternion;
  82360. /**
  82361. * Gets length of current quaternion
  82362. * @returns the quaternion length (float)
  82363. */
  82364. length(): number;
  82365. /**
  82366. * Normalize in place the current quaternion
  82367. * @returns the current updated quaternion
  82368. */
  82369. normalize(): Quaternion;
  82370. /**
  82371. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82372. * @param order is a reserved parameter and is ignore for now
  82373. * @returns a new Vector3 containing the Euler angles
  82374. */
  82375. toEulerAngles(order?: string): Vector3;
  82376. /**
  82377. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82378. * @param result defines the vector which will be filled with the Euler angles
  82379. * @param order is a reserved parameter and is ignore for now
  82380. * @returns the current unchanged quaternion
  82381. */
  82382. toEulerAnglesToRef(result: Vector3): Quaternion;
  82383. /**
  82384. * Updates the given rotation matrix with the current quaternion values
  82385. * @param result defines the target matrix
  82386. * @returns the current unchanged quaternion
  82387. */
  82388. toRotationMatrix(result: Matrix): Quaternion;
  82389. /**
  82390. * Updates the current quaternion from the given rotation matrix values
  82391. * @param matrix defines the source matrix
  82392. * @returns the current updated quaternion
  82393. */
  82394. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82395. /**
  82396. * Creates a new quaternion from a rotation matrix
  82397. * @param matrix defines the source matrix
  82398. * @returns a new quaternion created from the given rotation matrix values
  82399. */
  82400. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82401. /**
  82402. * Updates the given quaternion with the given rotation matrix values
  82403. * @param matrix defines the source matrix
  82404. * @param result defines the target quaternion
  82405. */
  82406. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82407. /**
  82408. * Returns the dot product (float) between the quaternions "left" and "right"
  82409. * @param left defines the left operand
  82410. * @param right defines the right operand
  82411. * @returns the dot product
  82412. */
  82413. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82414. /**
  82415. * Checks if the two quaternions are close to each other
  82416. * @param quat0 defines the first quaternion to check
  82417. * @param quat1 defines the second quaternion to check
  82418. * @returns true if the two quaternions are close to each other
  82419. */
  82420. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82421. /**
  82422. * Creates an empty quaternion
  82423. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82424. */
  82425. static Zero(): Quaternion;
  82426. /**
  82427. * Inverse a given quaternion
  82428. * @param q defines the source quaternion
  82429. * @returns a new quaternion as the inverted current quaternion
  82430. */
  82431. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82432. /**
  82433. * Inverse a given quaternion
  82434. * @param q defines the source quaternion
  82435. * @param result the quaternion the result will be stored in
  82436. * @returns the result quaternion
  82437. */
  82438. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82439. /**
  82440. * Creates an identity quaternion
  82441. * @returns the identity quaternion
  82442. */
  82443. static Identity(): Quaternion;
  82444. /**
  82445. * Gets a boolean indicating if the given quaternion is identity
  82446. * @param quaternion defines the quaternion to check
  82447. * @returns true if the quaternion is identity
  82448. */
  82449. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82450. /**
  82451. * Creates a quaternion from a rotation around an axis
  82452. * @param axis defines the axis to use
  82453. * @param angle defines the angle to use
  82454. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82455. */
  82456. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82457. /**
  82458. * Creates a rotation around an axis and stores it into the given quaternion
  82459. * @param axis defines the axis to use
  82460. * @param angle defines the angle to use
  82461. * @param result defines the target quaternion
  82462. * @returns the target quaternion
  82463. */
  82464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82465. /**
  82466. * Creates a new quaternion from data stored into an array
  82467. * @param array defines the data source
  82468. * @param offset defines the offset in the source array where the data starts
  82469. * @returns a new quaternion
  82470. */
  82471. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82472. /**
  82473. * Updates the given quaternion "result" from the starting index of the given array.
  82474. * @param array the array to pull values from
  82475. * @param offset the offset into the array to start at
  82476. * @param result the quaternion to store the result in
  82477. */
  82478. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82479. /**
  82480. * Create a quaternion from Euler rotation angles
  82481. * @param x Pitch
  82482. * @param y Yaw
  82483. * @param z Roll
  82484. * @returns the new Quaternion
  82485. */
  82486. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82487. /**
  82488. * Updates a quaternion from Euler rotation angles
  82489. * @param x Pitch
  82490. * @param y Yaw
  82491. * @param z Roll
  82492. * @param result the quaternion to store the result
  82493. * @returns the updated quaternion
  82494. */
  82495. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82496. /**
  82497. * Create a quaternion from Euler rotation vector
  82498. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82499. * @returns the new Quaternion
  82500. */
  82501. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82502. /**
  82503. * Updates a quaternion from Euler rotation vector
  82504. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82505. * @param result the quaternion to store the result
  82506. * @returns the updated quaternion
  82507. */
  82508. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82509. /**
  82510. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82511. * @param yaw defines the rotation around Y axis
  82512. * @param pitch defines the rotation around X axis
  82513. * @param roll defines the rotation around Z axis
  82514. * @returns the new quaternion
  82515. */
  82516. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82517. /**
  82518. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82519. * @param yaw defines the rotation around Y axis
  82520. * @param pitch defines the rotation around X axis
  82521. * @param roll defines the rotation around Z axis
  82522. * @param result defines the target quaternion
  82523. */
  82524. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82525. /**
  82526. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82527. * @param alpha defines the rotation around first axis
  82528. * @param beta defines the rotation around second axis
  82529. * @param gamma defines the rotation around third axis
  82530. * @returns the new quaternion
  82531. */
  82532. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82533. /**
  82534. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82535. * @param alpha defines the rotation around first axis
  82536. * @param beta defines the rotation around second axis
  82537. * @param gamma defines the rotation around third axis
  82538. * @param result defines the target quaternion
  82539. */
  82540. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82541. /**
  82542. * 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)
  82543. * @param axis1 defines the first axis
  82544. * @param axis2 defines the second axis
  82545. * @param axis3 defines the third axis
  82546. * @returns the new quaternion
  82547. */
  82548. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82549. /**
  82550. * 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
  82551. * @param axis1 defines the first axis
  82552. * @param axis2 defines the second axis
  82553. * @param axis3 defines the third axis
  82554. * @param ref defines the target quaternion
  82555. */
  82556. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82557. /**
  82558. * Interpolates between two quaternions
  82559. * @param left defines first quaternion
  82560. * @param right defines second quaternion
  82561. * @param amount defines the gradient to use
  82562. * @returns the new interpolated quaternion
  82563. */
  82564. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82565. /**
  82566. * Interpolates between two quaternions and stores it into a target quaternion
  82567. * @param left defines first quaternion
  82568. * @param right defines second quaternion
  82569. * @param amount defines the gradient to use
  82570. * @param result defines the target quaternion
  82571. */
  82572. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82573. /**
  82574. * Interpolate between two quaternions using Hermite interpolation
  82575. * @param value1 defines first quaternion
  82576. * @param tangent1 defines the incoming tangent
  82577. * @param value2 defines second quaternion
  82578. * @param tangent2 defines the outgoing tangent
  82579. * @param amount defines the target quaternion
  82580. * @returns the new interpolated quaternion
  82581. */
  82582. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82583. }
  82584. /**
  82585. * Class used to store matrix data (4x4)
  82586. */
  82587. export class Matrix {
  82588. /**
  82589. * Gets the precision of matrix computations
  82590. */
  82591. static get Use64Bits(): boolean;
  82592. private static _updateFlagSeed;
  82593. private static _identityReadOnly;
  82594. private _isIdentity;
  82595. private _isIdentityDirty;
  82596. private _isIdentity3x2;
  82597. private _isIdentity3x2Dirty;
  82598. /**
  82599. * Gets the update flag of the matrix which is an unique number for the matrix.
  82600. * It will be incremented every time the matrix data change.
  82601. * You can use it to speed the comparison between two versions of the same matrix.
  82602. */
  82603. updateFlag: number;
  82604. private readonly _m;
  82605. /**
  82606. * Gets the internal data of the matrix
  82607. */
  82608. get m(): DeepImmutable<Float32Array | Array<number>>;
  82609. /** @hidden */
  82610. _markAsUpdated(): void;
  82611. /** @hidden */
  82612. private _updateIdentityStatus;
  82613. /**
  82614. * Creates an empty matrix (filled with zeros)
  82615. */
  82616. constructor();
  82617. /**
  82618. * Check if the current matrix is identity
  82619. * @returns true is the matrix is the identity matrix
  82620. */
  82621. isIdentity(): boolean;
  82622. /**
  82623. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82624. * @returns true is the matrix is the identity matrix
  82625. */
  82626. isIdentityAs3x2(): boolean;
  82627. /**
  82628. * Gets the determinant of the matrix
  82629. * @returns the matrix determinant
  82630. */
  82631. determinant(): number;
  82632. /**
  82633. * Returns the matrix as a Float32Array or Array<number>
  82634. * @returns the matrix underlying array
  82635. */
  82636. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82637. /**
  82638. * Returns the matrix as a Float32Array or Array<number>
  82639. * @returns the matrix underlying array.
  82640. */
  82641. asArray(): DeepImmutable<Float32Array | Array<number>>;
  82642. /**
  82643. * Inverts the current matrix in place
  82644. * @returns the current inverted matrix
  82645. */
  82646. invert(): Matrix;
  82647. /**
  82648. * Sets all the matrix elements to zero
  82649. * @returns the current matrix
  82650. */
  82651. reset(): Matrix;
  82652. /**
  82653. * Adds the current matrix with a second one
  82654. * @param other defines the matrix to add
  82655. * @returns a new matrix as the addition of the current matrix and the given one
  82656. */
  82657. add(other: DeepImmutable<Matrix>): Matrix;
  82658. /**
  82659. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82660. * @param other defines the matrix to add
  82661. * @param result defines the target matrix
  82662. * @returns the current matrix
  82663. */
  82664. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82665. /**
  82666. * Adds in place the given matrix to the current matrix
  82667. * @param other defines the second operand
  82668. * @returns the current updated matrix
  82669. */
  82670. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82671. /**
  82672. * Sets the given matrix to the current inverted Matrix
  82673. * @param other defines the target matrix
  82674. * @returns the unmodified current matrix
  82675. */
  82676. invertToRef(other: Matrix): Matrix;
  82677. /**
  82678. * add a value at the specified position in the current Matrix
  82679. * @param index the index of the value within the matrix. between 0 and 15.
  82680. * @param value the value to be added
  82681. * @returns the current updated matrix
  82682. */
  82683. addAtIndex(index: number, value: number): Matrix;
  82684. /**
  82685. * mutiply the specified position in the current Matrix by a value
  82686. * @param index the index of the value within the matrix. between 0 and 15.
  82687. * @param value the value to be added
  82688. * @returns the current updated matrix
  82689. */
  82690. multiplyAtIndex(index: number, value: number): Matrix;
  82691. /**
  82692. * Inserts the translation vector (using 3 floats) in the current matrix
  82693. * @param x defines the 1st component of the translation
  82694. * @param y defines the 2nd component of the translation
  82695. * @param z defines the 3rd component of the translation
  82696. * @returns the current updated matrix
  82697. */
  82698. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82699. /**
  82700. * Adds the translation vector (using 3 floats) in the current matrix
  82701. * @param x defines the 1st component of the translation
  82702. * @param y defines the 2nd component of the translation
  82703. * @param z defines the 3rd component of the translation
  82704. * @returns the current updated matrix
  82705. */
  82706. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82707. /**
  82708. * Inserts the translation vector in the current matrix
  82709. * @param vector3 defines the translation to insert
  82710. * @returns the current updated matrix
  82711. */
  82712. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82713. /**
  82714. * Gets the translation value of the current matrix
  82715. * @returns a new Vector3 as the extracted translation from the matrix
  82716. */
  82717. getTranslation(): Vector3;
  82718. /**
  82719. * Fill a Vector3 with the extracted translation from the matrix
  82720. * @param result defines the Vector3 where to store the translation
  82721. * @returns the current matrix
  82722. */
  82723. getTranslationToRef(result: Vector3): Matrix;
  82724. /**
  82725. * Remove rotation and scaling part from the matrix
  82726. * @returns the updated matrix
  82727. */
  82728. removeRotationAndScaling(): Matrix;
  82729. /**
  82730. * Multiply two matrices
  82731. * @param other defines the second operand
  82732. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82733. */
  82734. multiply(other: DeepImmutable<Matrix>): Matrix;
  82735. /**
  82736. * Copy the current matrix from the given one
  82737. * @param other defines the source matrix
  82738. * @returns the current updated matrix
  82739. */
  82740. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82741. /**
  82742. * Populates the given array from the starting index with the current matrix values
  82743. * @param array defines the target array
  82744. * @param offset defines the offset in the target array where to start storing values
  82745. * @returns the current matrix
  82746. */
  82747. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  82748. /**
  82749. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82750. * @param other defines the second operand
  82751. * @param result defines the matrix where to store the multiplication
  82752. * @returns the current matrix
  82753. */
  82754. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82755. /**
  82756. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82757. * @param other defines the second operand
  82758. * @param result defines the array where to store the multiplication
  82759. * @param offset defines the offset in the target array where to start storing values
  82760. * @returns the current matrix
  82761. */
  82762. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  82763. /**
  82764. * Check equality between this matrix and a second one
  82765. * @param value defines the second matrix to compare
  82766. * @returns true is the current matrix and the given one values are strictly equal
  82767. */
  82768. equals(value: DeepImmutable<Matrix>): boolean;
  82769. /**
  82770. * Clone the current matrix
  82771. * @returns a new matrix from the current matrix
  82772. */
  82773. clone(): Matrix;
  82774. /**
  82775. * Returns the name of the current matrix class
  82776. * @returns the string "Matrix"
  82777. */
  82778. getClassName(): string;
  82779. /**
  82780. * Gets the hash code of the current matrix
  82781. * @returns the hash code
  82782. */
  82783. getHashCode(): number;
  82784. /**
  82785. * Decomposes the current Matrix into a translation, rotation and scaling components
  82786. * @param scale defines the scale vector3 given as a reference to update
  82787. * @param rotation defines the rotation quaternion given as a reference to update
  82788. * @param translation defines the translation vector3 given as a reference to update
  82789. * @returns true if operation was successful
  82790. */
  82791. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82792. /**
  82793. * Gets specific row of the matrix
  82794. * @param index defines the number of the row to get
  82795. * @returns the index-th row of the current matrix as a new Vector4
  82796. */
  82797. getRow(index: number): Nullable<Vector4>;
  82798. /**
  82799. * Sets the index-th row of the current matrix to the vector4 values
  82800. * @param index defines the number of the row to set
  82801. * @param row defines the target vector4
  82802. * @returns the updated current matrix
  82803. */
  82804. setRow(index: number, row: Vector4): Matrix;
  82805. /**
  82806. * Compute the transpose of the matrix
  82807. * @returns the new transposed matrix
  82808. */
  82809. transpose(): Matrix;
  82810. /**
  82811. * Compute the transpose of the matrix and store it in a given matrix
  82812. * @param result defines the target matrix
  82813. * @returns the current matrix
  82814. */
  82815. transposeToRef(result: Matrix): Matrix;
  82816. /**
  82817. * Sets the index-th row of the current matrix with the given 4 x float values
  82818. * @param index defines the row index
  82819. * @param x defines the x component to set
  82820. * @param y defines the y component to set
  82821. * @param z defines the z component to set
  82822. * @param w defines the w component to set
  82823. * @returns the updated current matrix
  82824. */
  82825. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82826. /**
  82827. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82828. * @param scale defines the scale factor
  82829. * @returns a new matrix
  82830. */
  82831. scale(scale: number): Matrix;
  82832. /**
  82833. * Scale the current matrix values by a factor to a given result matrix
  82834. * @param scale defines the scale factor
  82835. * @param result defines the matrix to store the result
  82836. * @returns the current matrix
  82837. */
  82838. scaleToRef(scale: number, result: Matrix): Matrix;
  82839. /**
  82840. * Scale the current matrix values by a factor and add the result to a given matrix
  82841. * @param scale defines the scale factor
  82842. * @param result defines the Matrix to store the result
  82843. * @returns the current matrix
  82844. */
  82845. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82846. /**
  82847. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82848. * @param ref matrix to store the result
  82849. */
  82850. toNormalMatrix(ref: Matrix): void;
  82851. /**
  82852. * Gets only rotation part of the current matrix
  82853. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82854. */
  82855. getRotationMatrix(): Matrix;
  82856. /**
  82857. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82858. * @param result defines the target matrix to store data to
  82859. * @returns the current matrix
  82860. */
  82861. getRotationMatrixToRef(result: Matrix): Matrix;
  82862. /**
  82863. * Toggles model matrix from being right handed to left handed in place and vice versa
  82864. */
  82865. toggleModelMatrixHandInPlace(): void;
  82866. /**
  82867. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82868. */
  82869. toggleProjectionMatrixHandInPlace(): void;
  82870. /**
  82871. * Creates a matrix from an array
  82872. * @param array defines the source array
  82873. * @param offset defines an offset in the source array
  82874. * @returns a new Matrix set from the starting index of the given array
  82875. */
  82876. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82877. /**
  82878. * Copy the content of an array into a given matrix
  82879. * @param array defines the source array
  82880. * @param offset defines an offset in the source array
  82881. * @param result defines the target matrix
  82882. */
  82883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82884. /**
  82885. * Stores an array into a matrix after having multiplied each component by a given factor
  82886. * @param array defines the source array
  82887. * @param offset defines the offset in the source array
  82888. * @param scale defines the scaling factor
  82889. * @param result defines the target matrix
  82890. */
  82891. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  82892. /**
  82893. * Gets an identity matrix that must not be updated
  82894. */
  82895. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82896. /**
  82897. * Stores a list of values (16) inside a given matrix
  82898. * @param initialM11 defines 1st value of 1st row
  82899. * @param initialM12 defines 2nd value of 1st row
  82900. * @param initialM13 defines 3rd value of 1st row
  82901. * @param initialM14 defines 4th value of 1st row
  82902. * @param initialM21 defines 1st value of 2nd row
  82903. * @param initialM22 defines 2nd value of 2nd row
  82904. * @param initialM23 defines 3rd value of 2nd row
  82905. * @param initialM24 defines 4th value of 2nd row
  82906. * @param initialM31 defines 1st value of 3rd row
  82907. * @param initialM32 defines 2nd value of 3rd row
  82908. * @param initialM33 defines 3rd value of 3rd row
  82909. * @param initialM34 defines 4th value of 3rd row
  82910. * @param initialM41 defines 1st value of 4th row
  82911. * @param initialM42 defines 2nd value of 4th row
  82912. * @param initialM43 defines 3rd value of 4th row
  82913. * @param initialM44 defines 4th value of 4th row
  82914. * @param result defines the target matrix
  82915. */
  82916. 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;
  82917. /**
  82918. * Creates new matrix from a list of values (16)
  82919. * @param initialM11 defines 1st value of 1st row
  82920. * @param initialM12 defines 2nd value of 1st row
  82921. * @param initialM13 defines 3rd value of 1st row
  82922. * @param initialM14 defines 4th value of 1st row
  82923. * @param initialM21 defines 1st value of 2nd row
  82924. * @param initialM22 defines 2nd value of 2nd row
  82925. * @param initialM23 defines 3rd value of 2nd row
  82926. * @param initialM24 defines 4th value of 2nd row
  82927. * @param initialM31 defines 1st value of 3rd row
  82928. * @param initialM32 defines 2nd value of 3rd row
  82929. * @param initialM33 defines 3rd value of 3rd row
  82930. * @param initialM34 defines 4th value of 3rd row
  82931. * @param initialM41 defines 1st value of 4th row
  82932. * @param initialM42 defines 2nd value of 4th row
  82933. * @param initialM43 defines 3rd value of 4th row
  82934. * @param initialM44 defines 4th value of 4th row
  82935. * @returns the new matrix
  82936. */
  82937. 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;
  82938. /**
  82939. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82940. * @param scale defines the scale vector3
  82941. * @param rotation defines the rotation quaternion
  82942. * @param translation defines the translation vector3
  82943. * @returns a new matrix
  82944. */
  82945. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82946. /**
  82947. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82948. * @param scale defines the scale vector3
  82949. * @param rotation defines the rotation quaternion
  82950. * @param translation defines the translation vector3
  82951. * @param result defines the target matrix
  82952. */
  82953. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82954. /**
  82955. * Creates a new identity matrix
  82956. * @returns a new identity matrix
  82957. */
  82958. static Identity(): Matrix;
  82959. /**
  82960. * Creates a new identity matrix and stores the result in a given matrix
  82961. * @param result defines the target matrix
  82962. */
  82963. static IdentityToRef(result: Matrix): void;
  82964. /**
  82965. * Creates a new zero matrix
  82966. * @returns a new zero matrix
  82967. */
  82968. static Zero(): Matrix;
  82969. /**
  82970. * Creates a new rotation matrix for "angle" radians around the X axis
  82971. * @param angle defines the angle (in radians) to use
  82972. * @return the new matrix
  82973. */
  82974. static RotationX(angle: number): Matrix;
  82975. /**
  82976. * Creates a new matrix as the invert of a given matrix
  82977. * @param source defines the source matrix
  82978. * @returns the new matrix
  82979. */
  82980. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82981. /**
  82982. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82983. * @param angle defines the angle (in radians) to use
  82984. * @param result defines the target matrix
  82985. */
  82986. static RotationXToRef(angle: number, result: Matrix): void;
  82987. /**
  82988. * Creates a new rotation matrix for "angle" radians around the Y axis
  82989. * @param angle defines the angle (in radians) to use
  82990. * @return the new matrix
  82991. */
  82992. static RotationY(angle: number): Matrix;
  82993. /**
  82994. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82995. * @param angle defines the angle (in radians) to use
  82996. * @param result defines the target matrix
  82997. */
  82998. static RotationYToRef(angle: number, result: Matrix): void;
  82999. /**
  83000. * Creates a new rotation matrix for "angle" radians around the Z axis
  83001. * @param angle defines the angle (in radians) to use
  83002. * @return the new matrix
  83003. */
  83004. static RotationZ(angle: number): Matrix;
  83005. /**
  83006. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83007. * @param angle defines the angle (in radians) to use
  83008. * @param result defines the target matrix
  83009. */
  83010. static RotationZToRef(angle: number, result: Matrix): void;
  83011. /**
  83012. * Creates a new rotation matrix for "angle" radians around the given axis
  83013. * @param axis defines the axis to use
  83014. * @param angle defines the angle (in radians) to use
  83015. * @return the new matrix
  83016. */
  83017. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83018. /**
  83019. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83020. * @param axis defines the axis to use
  83021. * @param angle defines the angle (in radians) to use
  83022. * @param result defines the target matrix
  83023. */
  83024. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83025. /**
  83026. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83027. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83028. * @param from defines the vector to align
  83029. * @param to defines the vector to align to
  83030. * @param result defines the target matrix
  83031. */
  83032. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83033. /**
  83034. * Creates a rotation matrix
  83035. * @param yaw defines the yaw angle in radians (Y axis)
  83036. * @param pitch defines the pitch angle in radians (X axis)
  83037. * @param roll defines the roll angle in radians (Z axis)
  83038. * @returns the new rotation matrix
  83039. */
  83040. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83041. /**
  83042. * Creates a rotation matrix and stores it in a given matrix
  83043. * @param yaw defines the yaw angle in radians (Y axis)
  83044. * @param pitch defines the pitch angle in radians (X axis)
  83045. * @param roll defines the roll angle in radians (Z axis)
  83046. * @param result defines the target matrix
  83047. */
  83048. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83049. /**
  83050. * Creates a scaling matrix
  83051. * @param x defines the scale factor on X axis
  83052. * @param y defines the scale factor on Y axis
  83053. * @param z defines the scale factor on Z axis
  83054. * @returns the new matrix
  83055. */
  83056. static Scaling(x: number, y: number, z: number): Matrix;
  83057. /**
  83058. * Creates a scaling matrix and stores it in a given matrix
  83059. * @param x defines the scale factor on X axis
  83060. * @param y defines the scale factor on Y axis
  83061. * @param z defines the scale factor on Z axis
  83062. * @param result defines the target matrix
  83063. */
  83064. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83065. /**
  83066. * Creates a translation matrix
  83067. * @param x defines the translation on X axis
  83068. * @param y defines the translation on Y axis
  83069. * @param z defines the translationon Z axis
  83070. * @returns the new matrix
  83071. */
  83072. static Translation(x: number, y: number, z: number): Matrix;
  83073. /**
  83074. * Creates a translation matrix and stores it in a given matrix
  83075. * @param x defines the translation on X axis
  83076. * @param y defines the translation on Y axis
  83077. * @param z defines the translationon Z axis
  83078. * @param result defines the target matrix
  83079. */
  83080. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83081. /**
  83082. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83083. * @param startValue defines the start value
  83084. * @param endValue defines the end value
  83085. * @param gradient defines the gradient factor
  83086. * @returns the new matrix
  83087. */
  83088. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83089. /**
  83090. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83091. * @param startValue defines the start value
  83092. * @param endValue defines the end value
  83093. * @param gradient defines the gradient factor
  83094. * @param result defines the Matrix object where to store data
  83095. */
  83096. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83097. /**
  83098. * Builds a new matrix whose values are computed by:
  83099. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83100. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83101. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83102. * @param startValue defines the first matrix
  83103. * @param endValue defines the second matrix
  83104. * @param gradient defines the gradient between the two matrices
  83105. * @returns the new matrix
  83106. */
  83107. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83108. /**
  83109. * Update a matrix to values which are computed by:
  83110. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83111. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83112. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83113. * @param startValue defines the first matrix
  83114. * @param endValue defines the second matrix
  83115. * @param gradient defines the gradient between the two matrices
  83116. * @param result defines the target matrix
  83117. */
  83118. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83119. /**
  83120. * 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"
  83121. * This function works in left handed mode
  83122. * @param eye defines the final position of the entity
  83123. * @param target defines where the entity should look at
  83124. * @param up defines the up vector for the entity
  83125. * @returns the new matrix
  83126. */
  83127. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83128. /**
  83129. * 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".
  83130. * This function works in left handed mode
  83131. * @param eye defines the final position of the entity
  83132. * @param target defines where the entity should look at
  83133. * @param up defines the up vector for the entity
  83134. * @param result defines the target matrix
  83135. */
  83136. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83137. /**
  83138. * 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"
  83139. * This function works in right handed mode
  83140. * @param eye defines the final position of the entity
  83141. * @param target defines where the entity should look at
  83142. * @param up defines the up vector for the entity
  83143. * @returns the new matrix
  83144. */
  83145. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83146. /**
  83147. * 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".
  83148. * This function works in right handed mode
  83149. * @param eye defines the final position of the entity
  83150. * @param target defines where the entity should look at
  83151. * @param up defines the up vector for the entity
  83152. * @param result defines the target matrix
  83153. */
  83154. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83155. /**
  83156. * Create a left-handed orthographic projection matrix
  83157. * @param width defines the viewport width
  83158. * @param height defines the viewport height
  83159. * @param znear defines the near clip plane
  83160. * @param zfar defines the far clip plane
  83161. * @returns a new matrix as a left-handed orthographic projection matrix
  83162. */
  83163. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83164. /**
  83165. * Store a left-handed orthographic projection to a given matrix
  83166. * @param width defines the viewport width
  83167. * @param height defines the viewport height
  83168. * @param znear defines the near clip plane
  83169. * @param zfar defines the far clip plane
  83170. * @param result defines the target matrix
  83171. */
  83172. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83173. /**
  83174. * Create a left-handed orthographic projection matrix
  83175. * @param left defines the viewport left coordinate
  83176. * @param right defines the viewport right coordinate
  83177. * @param bottom defines the viewport bottom coordinate
  83178. * @param top defines the viewport top coordinate
  83179. * @param znear defines the near clip plane
  83180. * @param zfar defines the far clip plane
  83181. * @returns a new matrix as a left-handed orthographic projection matrix
  83182. */
  83183. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83184. /**
  83185. * Stores a left-handed orthographic projection into a given matrix
  83186. * @param left defines the viewport left coordinate
  83187. * @param right defines the viewport right coordinate
  83188. * @param bottom defines the viewport bottom coordinate
  83189. * @param top defines the viewport top coordinate
  83190. * @param znear defines the near clip plane
  83191. * @param zfar defines the far clip plane
  83192. * @param result defines the target matrix
  83193. */
  83194. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83195. /**
  83196. * Creates a right-handed orthographic projection matrix
  83197. * @param left defines the viewport left coordinate
  83198. * @param right defines the viewport right coordinate
  83199. * @param bottom defines the viewport bottom coordinate
  83200. * @param top defines the viewport top coordinate
  83201. * @param znear defines the near clip plane
  83202. * @param zfar defines the far clip plane
  83203. * @returns a new matrix as a right-handed orthographic projection matrix
  83204. */
  83205. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83206. /**
  83207. * Stores a right-handed orthographic projection into a given matrix
  83208. * @param left defines the viewport left coordinate
  83209. * @param right defines the viewport right coordinate
  83210. * @param bottom defines the viewport bottom coordinate
  83211. * @param top defines the viewport top coordinate
  83212. * @param znear defines the near clip plane
  83213. * @param zfar defines the far clip plane
  83214. * @param result defines the target matrix
  83215. */
  83216. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83217. /**
  83218. * Creates a left-handed perspective projection matrix
  83219. * @param width defines the viewport width
  83220. * @param height defines the viewport height
  83221. * @param znear defines the near clip plane
  83222. * @param zfar defines the far clip plane
  83223. * @returns a new matrix as a left-handed perspective projection matrix
  83224. */
  83225. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83226. /**
  83227. * Creates a left-handed perspective projection matrix
  83228. * @param fov defines the horizontal field of view
  83229. * @param aspect defines the aspect ratio
  83230. * @param znear defines the near clip plane
  83231. * @param zfar defines the far clip plane
  83232. * @returns a new matrix as a left-handed perspective projection matrix
  83233. */
  83234. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83235. /**
  83236. * Stores a left-handed perspective projection into a given matrix
  83237. * @param fov defines the horizontal field of view
  83238. * @param aspect defines the aspect ratio
  83239. * @param znear defines the near clip plane
  83240. * @param zfar defines the far clip plane
  83241. * @param result defines the target matrix
  83242. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83243. */
  83244. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83245. /**
  83246. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83247. * @param fov defines the horizontal field of view
  83248. * @param aspect defines the aspect ratio
  83249. * @param znear defines the near clip plane
  83250. * @param zfar not used as infinity is used as far clip
  83251. * @param result defines the target matrix
  83252. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83253. */
  83254. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83255. /**
  83256. * Creates a right-handed perspective projection matrix
  83257. * @param fov defines the horizontal field of view
  83258. * @param aspect defines the aspect ratio
  83259. * @param znear defines the near clip plane
  83260. * @param zfar defines the far clip plane
  83261. * @returns a new matrix as a right-handed perspective projection matrix
  83262. */
  83263. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83264. /**
  83265. * Stores a right-handed perspective projection into a given matrix
  83266. * @param fov defines the horizontal field of view
  83267. * @param aspect defines the aspect ratio
  83268. * @param znear defines the near clip plane
  83269. * @param zfar defines the far clip plane
  83270. * @param result defines the target matrix
  83271. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83272. */
  83273. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83274. /**
  83275. * Stores a right-handed perspective projection into a given matrix
  83276. * @param fov defines the horizontal field of view
  83277. * @param aspect defines the aspect ratio
  83278. * @param znear defines the near clip plane
  83279. * @param zfar not used as infinity is used as far clip
  83280. * @param result defines the target matrix
  83281. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83282. */
  83283. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83284. /**
  83285. * Stores a perspective projection for WebVR info a given matrix
  83286. * @param fov defines the field of view
  83287. * @param znear defines the near clip plane
  83288. * @param zfar defines the far clip plane
  83289. * @param result defines the target matrix
  83290. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83291. */
  83292. static PerspectiveFovWebVRToRef(fov: {
  83293. upDegrees: number;
  83294. downDegrees: number;
  83295. leftDegrees: number;
  83296. rightDegrees: number;
  83297. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83298. /**
  83299. * Computes a complete transformation matrix
  83300. * @param viewport defines the viewport to use
  83301. * @param world defines the world matrix
  83302. * @param view defines the view matrix
  83303. * @param projection defines the projection matrix
  83304. * @param zmin defines the near clip plane
  83305. * @param zmax defines the far clip plane
  83306. * @returns the transformation matrix
  83307. */
  83308. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83309. /**
  83310. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83311. * @param matrix defines the matrix to use
  83312. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83313. */
  83314. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83315. /**
  83316. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83317. * @param matrix defines the matrix to use
  83318. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83319. */
  83320. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83321. /**
  83322. * Compute the transpose of a given matrix
  83323. * @param matrix defines the matrix to transpose
  83324. * @returns the new matrix
  83325. */
  83326. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83327. /**
  83328. * Compute the transpose of a matrix and store it in a target matrix
  83329. * @param matrix defines the matrix to transpose
  83330. * @param result defines the target matrix
  83331. */
  83332. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83333. /**
  83334. * Computes a reflection matrix from a plane
  83335. * @param plane defines the reflection plane
  83336. * @returns a new matrix
  83337. */
  83338. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83339. /**
  83340. * Computes a reflection matrix from a plane
  83341. * @param plane defines the reflection plane
  83342. * @param result defines the target matrix
  83343. */
  83344. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83345. /**
  83346. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83347. * @param xaxis defines the value of the 1st axis
  83348. * @param yaxis defines the value of the 2nd axis
  83349. * @param zaxis defines the value of the 3rd axis
  83350. * @param result defines the target matrix
  83351. */
  83352. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83353. /**
  83354. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83355. * @param quat defines the quaternion to use
  83356. * @param result defines the target matrix
  83357. */
  83358. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83359. }
  83360. /**
  83361. * @hidden
  83362. */
  83363. export class TmpVectors {
  83364. static Vector2: Vector2[];
  83365. static Vector3: Vector3[];
  83366. static Vector4: Vector4[];
  83367. static Quaternion: Quaternion[];
  83368. static Matrix: Matrix[];
  83369. }
  83370. }
  83371. declare module BABYLON {
  83372. /**
  83373. * Defines potential orientation for back face culling
  83374. */
  83375. export enum Orientation {
  83376. /**
  83377. * Clockwise
  83378. */
  83379. CW = 0,
  83380. /** Counter clockwise */
  83381. CCW = 1
  83382. }
  83383. /** Class used to represent a Bezier curve */
  83384. export class BezierCurve {
  83385. /**
  83386. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83387. * @param t defines the time
  83388. * @param x1 defines the left coordinate on X axis
  83389. * @param y1 defines the left coordinate on Y axis
  83390. * @param x2 defines the right coordinate on X axis
  83391. * @param y2 defines the right coordinate on Y axis
  83392. * @returns the interpolated value
  83393. */
  83394. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83395. }
  83396. /**
  83397. * Defines angle representation
  83398. */
  83399. export class Angle {
  83400. private _radians;
  83401. /**
  83402. * Creates an Angle object of "radians" radians (float).
  83403. * @param radians the angle in radians
  83404. */
  83405. constructor(radians: number);
  83406. /**
  83407. * Get value in degrees
  83408. * @returns the Angle value in degrees (float)
  83409. */
  83410. degrees(): number;
  83411. /**
  83412. * Get value in radians
  83413. * @returns the Angle value in radians (float)
  83414. */
  83415. radians(): number;
  83416. /**
  83417. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83418. * @param a defines first point as the origin
  83419. * @param b defines point
  83420. * @returns a new Angle
  83421. */
  83422. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83423. /**
  83424. * Gets a new Angle object from the given float in radians
  83425. * @param radians defines the angle value in radians
  83426. * @returns a new Angle
  83427. */
  83428. static FromRadians(radians: number): Angle;
  83429. /**
  83430. * Gets a new Angle object from the given float in degrees
  83431. * @param degrees defines the angle value in degrees
  83432. * @returns a new Angle
  83433. */
  83434. static FromDegrees(degrees: number): Angle;
  83435. }
  83436. /**
  83437. * This represents an arc in a 2d space.
  83438. */
  83439. export class Arc2 {
  83440. /** Defines the start point of the arc */
  83441. startPoint: Vector2;
  83442. /** Defines the mid point of the arc */
  83443. midPoint: Vector2;
  83444. /** Defines the end point of the arc */
  83445. endPoint: Vector2;
  83446. /**
  83447. * Defines the center point of the arc.
  83448. */
  83449. centerPoint: Vector2;
  83450. /**
  83451. * Defines the radius of the arc.
  83452. */
  83453. radius: number;
  83454. /**
  83455. * Defines the angle of the arc (from mid point to end point).
  83456. */
  83457. angle: Angle;
  83458. /**
  83459. * Defines the start angle of the arc (from start point to middle point).
  83460. */
  83461. startAngle: Angle;
  83462. /**
  83463. * Defines the orientation of the arc (clock wise/counter clock wise).
  83464. */
  83465. orientation: Orientation;
  83466. /**
  83467. * Creates an Arc object from the three given points : start, middle and end.
  83468. * @param startPoint Defines the start point of the arc
  83469. * @param midPoint Defines the midlle point of the arc
  83470. * @param endPoint Defines the end point of the arc
  83471. */
  83472. constructor(
  83473. /** Defines the start point of the arc */
  83474. startPoint: Vector2,
  83475. /** Defines the mid point of the arc */
  83476. midPoint: Vector2,
  83477. /** Defines the end point of the arc */
  83478. endPoint: Vector2);
  83479. }
  83480. /**
  83481. * Represents a 2D path made up of multiple 2D points
  83482. */
  83483. export class Path2 {
  83484. private _points;
  83485. private _length;
  83486. /**
  83487. * If the path start and end point are the same
  83488. */
  83489. closed: boolean;
  83490. /**
  83491. * Creates a Path2 object from the starting 2D coordinates x and y.
  83492. * @param x the starting points x value
  83493. * @param y the starting points y value
  83494. */
  83495. constructor(x: number, y: number);
  83496. /**
  83497. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83498. * @param x the added points x value
  83499. * @param y the added points y value
  83500. * @returns the updated Path2.
  83501. */
  83502. addLineTo(x: number, y: number): Path2;
  83503. /**
  83504. * 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.
  83505. * @param midX middle point x value
  83506. * @param midY middle point y value
  83507. * @param endX end point x value
  83508. * @param endY end point y value
  83509. * @param numberOfSegments (default: 36)
  83510. * @returns the updated Path2.
  83511. */
  83512. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83513. /**
  83514. * Closes the Path2.
  83515. * @returns the Path2.
  83516. */
  83517. close(): Path2;
  83518. /**
  83519. * Gets the sum of the distance between each sequential point in the path
  83520. * @returns the Path2 total length (float).
  83521. */
  83522. length(): number;
  83523. /**
  83524. * Gets the points which construct the path
  83525. * @returns the Path2 internal array of points.
  83526. */
  83527. getPoints(): Vector2[];
  83528. /**
  83529. * Retreives the point at the distance aways from the starting point
  83530. * @param normalizedLengthPosition the length along the path to retreive the point from
  83531. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83532. */
  83533. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83534. /**
  83535. * Creates a new path starting from an x and y position
  83536. * @param x starting x value
  83537. * @param y starting y value
  83538. * @returns a new Path2 starting at the coordinates (x, y).
  83539. */
  83540. static StartingAt(x: number, y: number): Path2;
  83541. }
  83542. /**
  83543. * Represents a 3D path made up of multiple 3D points
  83544. */
  83545. export class Path3D {
  83546. /**
  83547. * an array of Vector3, the curve axis of the Path3D
  83548. */
  83549. path: Vector3[];
  83550. private _curve;
  83551. private _distances;
  83552. private _tangents;
  83553. private _normals;
  83554. private _binormals;
  83555. private _raw;
  83556. private _alignTangentsWithPath;
  83557. private readonly _pointAtData;
  83558. /**
  83559. * new Path3D(path, normal, raw)
  83560. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83561. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83562. * @param path an array of Vector3, the curve axis of the Path3D
  83563. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83564. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83565. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83566. */
  83567. constructor(
  83568. /**
  83569. * an array of Vector3, the curve axis of the Path3D
  83570. */
  83571. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83572. /**
  83573. * Returns the Path3D array of successive Vector3 designing its curve.
  83574. * @returns the Path3D array of successive Vector3 designing its curve.
  83575. */
  83576. getCurve(): Vector3[];
  83577. /**
  83578. * Returns the Path3D array of successive Vector3 designing its curve.
  83579. * @returns the Path3D array of successive Vector3 designing its curve.
  83580. */
  83581. getPoints(): Vector3[];
  83582. /**
  83583. * @returns the computed length (float) of the path.
  83584. */
  83585. length(): number;
  83586. /**
  83587. * Returns an array populated with tangent vectors on each Path3D curve point.
  83588. * @returns an array populated with tangent vectors on each Path3D curve point.
  83589. */
  83590. getTangents(): Vector3[];
  83591. /**
  83592. * Returns an array populated with normal vectors on each Path3D curve point.
  83593. * @returns an array populated with normal vectors on each Path3D curve point.
  83594. */
  83595. getNormals(): Vector3[];
  83596. /**
  83597. * Returns an array populated with binormal vectors on each Path3D curve point.
  83598. * @returns an array populated with binormal vectors on each Path3D curve point.
  83599. */
  83600. getBinormals(): Vector3[];
  83601. /**
  83602. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83603. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83604. */
  83605. getDistances(): number[];
  83606. /**
  83607. * Returns an interpolated point along this path
  83608. * @param position the position of the point along this path, from 0.0 to 1.0
  83609. * @returns a new Vector3 as the point
  83610. */
  83611. getPointAt(position: number): Vector3;
  83612. /**
  83613. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83614. * @param position the position of the point along this path, from 0.0 to 1.0
  83615. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83616. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83617. */
  83618. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83619. /**
  83620. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83621. * @param position the position of the point along this path, from 0.0 to 1.0
  83622. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83623. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83624. */
  83625. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83626. /**
  83627. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83628. * @param position the position of the point along this path, from 0.0 to 1.0
  83629. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83630. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83631. */
  83632. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83633. /**
  83634. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83635. * @param position the position of the point along this path, from 0.0 to 1.0
  83636. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83637. */
  83638. getDistanceAt(position: number): number;
  83639. /**
  83640. * Returns the array index of the previous point of an interpolated point along this path
  83641. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83642. * @returns the array index
  83643. */
  83644. getPreviousPointIndexAt(position: number): number;
  83645. /**
  83646. * 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)
  83647. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83648. * @returns the sub position
  83649. */
  83650. getSubPositionAt(position: number): number;
  83651. /**
  83652. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83653. * @param target the vector of which to get the closest position to
  83654. * @returns the position of the closest virtual point on this path to the target vector
  83655. */
  83656. getClosestPositionTo(target: Vector3): number;
  83657. /**
  83658. * Returns a sub path (slice) of this path
  83659. * @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
  83660. * @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
  83661. * @returns a sub path (slice) of this path
  83662. */
  83663. slice(start?: number, end?: number): Path3D;
  83664. /**
  83665. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83666. * @param path path which all values are copied into the curves points
  83667. * @param firstNormal which should be projected onto the curve
  83668. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83669. * @returns the same object updated.
  83670. */
  83671. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83672. private _compute;
  83673. private _getFirstNonNullVector;
  83674. private _getLastNonNullVector;
  83675. private _normalVector;
  83676. /**
  83677. * Updates the point at data for an interpolated point along this curve
  83678. * @param position the position of the point along this curve, from 0.0 to 1.0
  83679. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83680. * @returns the (updated) point at data
  83681. */
  83682. private _updatePointAtData;
  83683. /**
  83684. * Updates the point at data from the specified parameters
  83685. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83686. * @param point the interpolated point
  83687. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83688. */
  83689. private _setPointAtData;
  83690. /**
  83691. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83692. */
  83693. private _updateInterpolationMatrix;
  83694. }
  83695. /**
  83696. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83697. * A Curve3 is designed from a series of successive Vector3.
  83698. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83699. */
  83700. export class Curve3 {
  83701. private _points;
  83702. private _length;
  83703. /**
  83704. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83705. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83706. * @param v1 (Vector3) the control point
  83707. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83708. * @param nbPoints (integer) the wanted number of points in the curve
  83709. * @returns the created Curve3
  83710. */
  83711. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83712. /**
  83713. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83714. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83715. * @param v1 (Vector3) the first control point
  83716. * @param v2 (Vector3) the second control point
  83717. * @param v3 (Vector3) the end point of the Cubic Bezier
  83718. * @param nbPoints (integer) the wanted number of points in the curve
  83719. * @returns the created Curve3
  83720. */
  83721. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83722. /**
  83723. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83724. * @param p1 (Vector3) the origin point of the Hermite Spline
  83725. * @param t1 (Vector3) the tangent vector at the origin point
  83726. * @param p2 (Vector3) the end point of the Hermite Spline
  83727. * @param t2 (Vector3) the tangent vector at the end point
  83728. * @param nbPoints (integer) the wanted number of points in the curve
  83729. * @returns the created Curve3
  83730. */
  83731. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83732. /**
  83733. * Returns a Curve3 object along a CatmullRom Spline curve :
  83734. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83735. * @param nbPoints (integer) the wanted number of points between each curve control points
  83736. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83737. * @returns the created Curve3
  83738. */
  83739. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83740. /**
  83741. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83742. * A Curve3 is designed from a series of successive Vector3.
  83743. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83744. * @param points points which make up the curve
  83745. */
  83746. constructor(points: Vector3[]);
  83747. /**
  83748. * @returns the Curve3 stored array of successive Vector3
  83749. */
  83750. getPoints(): Vector3[];
  83751. /**
  83752. * @returns the computed length (float) of the curve.
  83753. */
  83754. length(): number;
  83755. /**
  83756. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83757. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83758. * curveA and curveB keep unchanged.
  83759. * @param curve the curve to continue from this curve
  83760. * @returns the newly constructed curve
  83761. */
  83762. continue(curve: DeepImmutable<Curve3>): Curve3;
  83763. private _computeLength;
  83764. }
  83765. }
  83766. declare module BABYLON {
  83767. /**
  83768. * This represents the main contract an easing function should follow.
  83769. * Easing functions are used throughout the animation system.
  83770. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83771. */
  83772. export interface IEasingFunction {
  83773. /**
  83774. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83775. * of the easing function.
  83776. * The link below provides some of the most common examples of easing functions.
  83777. * @see https://easings.net/
  83778. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83779. * @returns the corresponding value on the curve defined by the easing function
  83780. */
  83781. ease(gradient: number): number;
  83782. }
  83783. /**
  83784. * Base class used for every default easing function.
  83785. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83786. */
  83787. export class EasingFunction implements IEasingFunction {
  83788. /**
  83789. * Interpolation follows the mathematical formula associated with the easing function.
  83790. */
  83791. static readonly EASINGMODE_EASEIN: number;
  83792. /**
  83793. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83794. */
  83795. static readonly EASINGMODE_EASEOUT: number;
  83796. /**
  83797. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83798. */
  83799. static readonly EASINGMODE_EASEINOUT: number;
  83800. private _easingMode;
  83801. /**
  83802. * Sets the easing mode of the current function.
  83803. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83804. */
  83805. setEasingMode(easingMode: number): void;
  83806. /**
  83807. * Gets the current easing mode.
  83808. * @returns the easing mode
  83809. */
  83810. getEasingMode(): number;
  83811. /**
  83812. * @hidden
  83813. */
  83814. easeInCore(gradient: number): number;
  83815. /**
  83816. * Given an input gradient between 0 and 1, this returns the corresponding value
  83817. * of the easing function.
  83818. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83819. * @returns the corresponding value on the curve defined by the easing function
  83820. */
  83821. ease(gradient: number): number;
  83822. }
  83823. /**
  83824. * Easing function with a circle shape (see link below).
  83825. * @see https://easings.net/#easeInCirc
  83826. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83827. */
  83828. export class CircleEase extends EasingFunction implements IEasingFunction {
  83829. /** @hidden */
  83830. easeInCore(gradient: number): number;
  83831. }
  83832. /**
  83833. * Easing function with a ease back shape (see link below).
  83834. * @see https://easings.net/#easeInBack
  83835. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83836. */
  83837. export class BackEase extends EasingFunction implements IEasingFunction {
  83838. /** Defines the amplitude of the function */
  83839. amplitude: number;
  83840. /**
  83841. * Instantiates a back ease easing
  83842. * @see https://easings.net/#easeInBack
  83843. * @param amplitude Defines the amplitude of the function
  83844. */
  83845. constructor(
  83846. /** Defines the amplitude of the function */
  83847. amplitude?: number);
  83848. /** @hidden */
  83849. easeInCore(gradient: number): number;
  83850. }
  83851. /**
  83852. * Easing function with a bouncing shape (see link below).
  83853. * @see https://easings.net/#easeInBounce
  83854. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83855. */
  83856. export class BounceEase extends EasingFunction implements IEasingFunction {
  83857. /** Defines the number of bounces */
  83858. bounces: number;
  83859. /** Defines the amplitude of the bounce */
  83860. bounciness: number;
  83861. /**
  83862. * Instantiates a bounce easing
  83863. * @see https://easings.net/#easeInBounce
  83864. * @param bounces Defines the number of bounces
  83865. * @param bounciness Defines the amplitude of the bounce
  83866. */
  83867. constructor(
  83868. /** Defines the number of bounces */
  83869. bounces?: number,
  83870. /** Defines the amplitude of the bounce */
  83871. bounciness?: number);
  83872. /** @hidden */
  83873. easeInCore(gradient: number): number;
  83874. }
  83875. /**
  83876. * Easing function with a power of 3 shape (see link below).
  83877. * @see https://easings.net/#easeInCubic
  83878. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83879. */
  83880. export class CubicEase extends EasingFunction implements IEasingFunction {
  83881. /** @hidden */
  83882. easeInCore(gradient: number): number;
  83883. }
  83884. /**
  83885. * Easing function with an elastic shape (see link below).
  83886. * @see https://easings.net/#easeInElastic
  83887. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83888. */
  83889. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83890. /** Defines the number of oscillations*/
  83891. oscillations: number;
  83892. /** Defines the amplitude of the oscillations*/
  83893. springiness: number;
  83894. /**
  83895. * Instantiates an elastic easing function
  83896. * @see https://easings.net/#easeInElastic
  83897. * @param oscillations Defines the number of oscillations
  83898. * @param springiness Defines the amplitude of the oscillations
  83899. */
  83900. constructor(
  83901. /** Defines the number of oscillations*/
  83902. oscillations?: number,
  83903. /** Defines the amplitude of the oscillations*/
  83904. springiness?: number);
  83905. /** @hidden */
  83906. easeInCore(gradient: number): number;
  83907. }
  83908. /**
  83909. * Easing function with an exponential shape (see link below).
  83910. * @see https://easings.net/#easeInExpo
  83911. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83912. */
  83913. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83914. /** Defines the exponent of the function */
  83915. exponent: number;
  83916. /**
  83917. * Instantiates an exponential easing function
  83918. * @see https://easings.net/#easeInExpo
  83919. * @param exponent Defines the exponent of the function
  83920. */
  83921. constructor(
  83922. /** Defines the exponent of the function */
  83923. exponent?: number);
  83924. /** @hidden */
  83925. easeInCore(gradient: number): number;
  83926. }
  83927. /**
  83928. * Easing function with a power shape (see link below).
  83929. * @see https://easings.net/#easeInQuad
  83930. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83931. */
  83932. export class PowerEase extends EasingFunction implements IEasingFunction {
  83933. /** Defines the power of the function */
  83934. power: number;
  83935. /**
  83936. * Instantiates an power base easing function
  83937. * @see https://easings.net/#easeInQuad
  83938. * @param power Defines the power of the function
  83939. */
  83940. constructor(
  83941. /** Defines the power of the function */
  83942. power?: number);
  83943. /** @hidden */
  83944. easeInCore(gradient: number): number;
  83945. }
  83946. /**
  83947. * Easing function with a power of 2 shape (see link below).
  83948. * @see https://easings.net/#easeInQuad
  83949. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83950. */
  83951. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83952. /** @hidden */
  83953. easeInCore(gradient: number): number;
  83954. }
  83955. /**
  83956. * Easing function with a power of 4 shape (see link below).
  83957. * @see https://easings.net/#easeInQuart
  83958. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83959. */
  83960. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83961. /** @hidden */
  83962. easeInCore(gradient: number): number;
  83963. }
  83964. /**
  83965. * Easing function with a power of 5 shape (see link below).
  83966. * @see https://easings.net/#easeInQuint
  83967. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83968. */
  83969. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83970. /** @hidden */
  83971. easeInCore(gradient: number): number;
  83972. }
  83973. /**
  83974. * Easing function with a sin shape (see link below).
  83975. * @see https://easings.net/#easeInSine
  83976. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83977. */
  83978. export class SineEase extends EasingFunction implements IEasingFunction {
  83979. /** @hidden */
  83980. easeInCore(gradient: number): number;
  83981. }
  83982. /**
  83983. * Easing function with a bezier shape (see link below).
  83984. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83985. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83986. */
  83987. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83988. /** Defines the x component of the start tangent in the bezier curve */
  83989. x1: number;
  83990. /** Defines the y component of the start tangent in the bezier curve */
  83991. y1: number;
  83992. /** Defines the x component of the end tangent in the bezier curve */
  83993. x2: number;
  83994. /** Defines the y component of the end tangent in the bezier curve */
  83995. y2: number;
  83996. /**
  83997. * Instantiates a bezier function
  83998. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83999. * @param x1 Defines the x component of the start tangent in the bezier curve
  84000. * @param y1 Defines the y component of the start tangent in the bezier curve
  84001. * @param x2 Defines the x component of the end tangent in the bezier curve
  84002. * @param y2 Defines the y component of the end tangent in the bezier curve
  84003. */
  84004. constructor(
  84005. /** Defines the x component of the start tangent in the bezier curve */
  84006. x1?: number,
  84007. /** Defines the y component of the start tangent in the bezier curve */
  84008. y1?: number,
  84009. /** Defines the x component of the end tangent in the bezier curve */
  84010. x2?: number,
  84011. /** Defines the y component of the end tangent in the bezier curve */
  84012. y2?: number);
  84013. /** @hidden */
  84014. easeInCore(gradient: number): number;
  84015. }
  84016. }
  84017. declare module BABYLON {
  84018. /**
  84019. * Class used to hold a RBG color
  84020. */
  84021. export class Color3 {
  84022. /**
  84023. * Defines the red component (between 0 and 1, default is 0)
  84024. */
  84025. r: number;
  84026. /**
  84027. * Defines the green component (between 0 and 1, default is 0)
  84028. */
  84029. g: number;
  84030. /**
  84031. * Defines the blue component (between 0 and 1, default is 0)
  84032. */
  84033. b: number;
  84034. /**
  84035. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84036. * @param r defines the red component (between 0 and 1, default is 0)
  84037. * @param g defines the green component (between 0 and 1, default is 0)
  84038. * @param b defines the blue component (between 0 and 1, default is 0)
  84039. */
  84040. constructor(
  84041. /**
  84042. * Defines the red component (between 0 and 1, default is 0)
  84043. */
  84044. r?: number,
  84045. /**
  84046. * Defines the green component (between 0 and 1, default is 0)
  84047. */
  84048. g?: number,
  84049. /**
  84050. * Defines the blue component (between 0 and 1, default is 0)
  84051. */
  84052. b?: number);
  84053. /**
  84054. * Creates a string with the Color3 current values
  84055. * @returns the string representation of the Color3 object
  84056. */
  84057. toString(): string;
  84058. /**
  84059. * Returns the string "Color3"
  84060. * @returns "Color3"
  84061. */
  84062. getClassName(): string;
  84063. /**
  84064. * Compute the Color3 hash code
  84065. * @returns an unique number that can be used to hash Color3 objects
  84066. */
  84067. getHashCode(): number;
  84068. /**
  84069. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84070. * @param array defines the array where to store the r,g,b components
  84071. * @param index defines an optional index in the target array to define where to start storing values
  84072. * @returns the current Color3 object
  84073. */
  84074. toArray(array: FloatArray, index?: number): Color3;
  84075. /**
  84076. * Returns a new Color4 object from the current Color3 and the given alpha
  84077. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84078. * @returns a new Color4 object
  84079. */
  84080. toColor4(alpha?: number): Color4;
  84081. /**
  84082. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84083. * @returns the new array
  84084. */
  84085. asArray(): number[];
  84086. /**
  84087. * Returns the luminance value
  84088. * @returns a float value
  84089. */
  84090. toLuminance(): number;
  84091. /**
  84092. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84093. * @param otherColor defines the second operand
  84094. * @returns the new Color3 object
  84095. */
  84096. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84097. /**
  84098. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84099. * @param otherColor defines the second operand
  84100. * @param result defines the Color3 object where to store the result
  84101. * @returns the current Color3
  84102. */
  84103. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84104. /**
  84105. * Determines equality between Color3 objects
  84106. * @param otherColor defines the second operand
  84107. * @returns true if the rgb values are equal to the given ones
  84108. */
  84109. equals(otherColor: DeepImmutable<Color3>): boolean;
  84110. /**
  84111. * Determines equality between the current Color3 object and a set of r,b,g values
  84112. * @param r defines the red component to check
  84113. * @param g defines the green component to check
  84114. * @param b defines the blue component to check
  84115. * @returns true if the rgb values are equal to the given ones
  84116. */
  84117. equalsFloats(r: number, g: number, b: number): boolean;
  84118. /**
  84119. * Multiplies in place each rgb value by scale
  84120. * @param scale defines the scaling factor
  84121. * @returns the updated Color3
  84122. */
  84123. scale(scale: number): Color3;
  84124. /**
  84125. * Multiplies the rgb values by scale and stores the result into "result"
  84126. * @param scale defines the scaling factor
  84127. * @param result defines the Color3 object where to store the result
  84128. * @returns the unmodified current Color3
  84129. */
  84130. scaleToRef(scale: number, result: Color3): Color3;
  84131. /**
  84132. * Scale the current Color3 values by a factor and add the result to a given Color3
  84133. * @param scale defines the scale factor
  84134. * @param result defines color to store the result into
  84135. * @returns the unmodified current Color3
  84136. */
  84137. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84138. /**
  84139. * Clamps the rgb values by the min and max values and stores the result into "result"
  84140. * @param min defines minimum clamping value (default is 0)
  84141. * @param max defines maximum clamping value (default is 1)
  84142. * @param result defines color to store the result into
  84143. * @returns the original Color3
  84144. */
  84145. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84146. /**
  84147. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84148. * @param otherColor defines the second operand
  84149. * @returns the new Color3
  84150. */
  84151. add(otherColor: DeepImmutable<Color3>): Color3;
  84152. /**
  84153. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84154. * @param otherColor defines the second operand
  84155. * @param result defines Color3 object to store the result into
  84156. * @returns the unmodified current Color3
  84157. */
  84158. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84159. /**
  84160. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84161. * @param otherColor defines the second operand
  84162. * @returns the new Color3
  84163. */
  84164. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84165. /**
  84166. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84167. * @param otherColor defines the second operand
  84168. * @param result defines Color3 object to store the result into
  84169. * @returns the unmodified current Color3
  84170. */
  84171. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84172. /**
  84173. * Copy the current object
  84174. * @returns a new Color3 copied the current one
  84175. */
  84176. clone(): Color3;
  84177. /**
  84178. * Copies the rgb values from the source in the current Color3
  84179. * @param source defines the source Color3 object
  84180. * @returns the updated Color3 object
  84181. */
  84182. copyFrom(source: DeepImmutable<Color3>): Color3;
  84183. /**
  84184. * Updates the Color3 rgb values from the given floats
  84185. * @param r defines the red component to read from
  84186. * @param g defines the green component to read from
  84187. * @param b defines the blue component to read from
  84188. * @returns the current Color3 object
  84189. */
  84190. copyFromFloats(r: number, g: number, b: number): Color3;
  84191. /**
  84192. * Updates the Color3 rgb values from the given floats
  84193. * @param r defines the red component to read from
  84194. * @param g defines the green component to read from
  84195. * @param b defines the blue component to read from
  84196. * @returns the current Color3 object
  84197. */
  84198. set(r: number, g: number, b: number): Color3;
  84199. /**
  84200. * Compute the Color3 hexadecimal code as a string
  84201. * @returns a string containing the hexadecimal representation of the Color3 object
  84202. */
  84203. toHexString(): string;
  84204. /**
  84205. * Computes a new Color3 converted from the current one to linear space
  84206. * @returns a new Color3 object
  84207. */
  84208. toLinearSpace(): Color3;
  84209. /**
  84210. * Converts current color in rgb space to HSV values
  84211. * @returns a new color3 representing the HSV values
  84212. */
  84213. toHSV(): Color3;
  84214. /**
  84215. * Converts current color in rgb space to HSV values
  84216. * @param result defines the Color3 where to store the HSV values
  84217. */
  84218. toHSVToRef(result: Color3): void;
  84219. /**
  84220. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84221. * @param convertedColor defines the Color3 object where to store the linear space version
  84222. * @returns the unmodified Color3
  84223. */
  84224. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84225. /**
  84226. * Computes a new Color3 converted from the current one to gamma space
  84227. * @returns a new Color3 object
  84228. */
  84229. toGammaSpace(): Color3;
  84230. /**
  84231. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84232. * @param convertedColor defines the Color3 object where to store the gamma space version
  84233. * @returns the unmodified Color3
  84234. */
  84235. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84236. private static _BlackReadOnly;
  84237. /**
  84238. * Convert Hue, saturation and value to a Color3 (RGB)
  84239. * @param hue defines the hue
  84240. * @param saturation defines the saturation
  84241. * @param value defines the value
  84242. * @param result defines the Color3 where to store the RGB values
  84243. */
  84244. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84245. /**
  84246. * Creates a new Color3 from the string containing valid hexadecimal values
  84247. * @param hex defines a string containing valid hexadecimal values
  84248. * @returns a new Color3 object
  84249. */
  84250. static FromHexString(hex: string): Color3;
  84251. /**
  84252. * Creates a new Color3 from the starting index of the given array
  84253. * @param array defines the source array
  84254. * @param offset defines an offset in the source array
  84255. * @returns a new Color3 object
  84256. */
  84257. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84258. /**
  84259. * Creates a new Color3 from integer values (< 256)
  84260. * @param r defines the red component to read from (value between 0 and 255)
  84261. * @param g defines the green component to read from (value between 0 and 255)
  84262. * @param b defines the blue component to read from (value between 0 and 255)
  84263. * @returns a new Color3 object
  84264. */
  84265. static FromInts(r: number, g: number, b: number): Color3;
  84266. /**
  84267. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84268. * @param start defines the start Color3 value
  84269. * @param end defines the end Color3 value
  84270. * @param amount defines the gradient value between start and end
  84271. * @returns a new Color3 object
  84272. */
  84273. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84274. /**
  84275. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84276. * @param left defines the start value
  84277. * @param right defines the end value
  84278. * @param amount defines the gradient factor
  84279. * @param result defines the Color3 object where to store the result
  84280. */
  84281. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84282. /**
  84283. * Returns a Color3 value containing a red color
  84284. * @returns a new Color3 object
  84285. */
  84286. static Red(): Color3;
  84287. /**
  84288. * Returns a Color3 value containing a green color
  84289. * @returns a new Color3 object
  84290. */
  84291. static Green(): Color3;
  84292. /**
  84293. * Returns a Color3 value containing a blue color
  84294. * @returns a new Color3 object
  84295. */
  84296. static Blue(): Color3;
  84297. /**
  84298. * Returns a Color3 value containing a black color
  84299. * @returns a new Color3 object
  84300. */
  84301. static Black(): Color3;
  84302. /**
  84303. * Gets a Color3 value containing a black color that must not be updated
  84304. */
  84305. static get BlackReadOnly(): DeepImmutable<Color3>;
  84306. /**
  84307. * Returns a Color3 value containing a white color
  84308. * @returns a new Color3 object
  84309. */
  84310. static White(): Color3;
  84311. /**
  84312. * Returns a Color3 value containing a purple color
  84313. * @returns a new Color3 object
  84314. */
  84315. static Purple(): Color3;
  84316. /**
  84317. * Returns a Color3 value containing a magenta color
  84318. * @returns a new Color3 object
  84319. */
  84320. static Magenta(): Color3;
  84321. /**
  84322. * Returns a Color3 value containing a yellow color
  84323. * @returns a new Color3 object
  84324. */
  84325. static Yellow(): Color3;
  84326. /**
  84327. * Returns a Color3 value containing a gray color
  84328. * @returns a new Color3 object
  84329. */
  84330. static Gray(): Color3;
  84331. /**
  84332. * Returns a Color3 value containing a teal color
  84333. * @returns a new Color3 object
  84334. */
  84335. static Teal(): Color3;
  84336. /**
  84337. * Returns a Color3 value containing a random color
  84338. * @returns a new Color3 object
  84339. */
  84340. static Random(): Color3;
  84341. }
  84342. /**
  84343. * Class used to hold a RBGA color
  84344. */
  84345. export class Color4 {
  84346. /**
  84347. * Defines the red component (between 0 and 1, default is 0)
  84348. */
  84349. r: number;
  84350. /**
  84351. * Defines the green component (between 0 and 1, default is 0)
  84352. */
  84353. g: number;
  84354. /**
  84355. * Defines the blue component (between 0 and 1, default is 0)
  84356. */
  84357. b: number;
  84358. /**
  84359. * Defines the alpha component (between 0 and 1, default is 1)
  84360. */
  84361. a: number;
  84362. /**
  84363. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84364. * @param r defines the red component (between 0 and 1, default is 0)
  84365. * @param g defines the green component (between 0 and 1, default is 0)
  84366. * @param b defines the blue component (between 0 and 1, default is 0)
  84367. * @param a defines the alpha component (between 0 and 1, default is 1)
  84368. */
  84369. constructor(
  84370. /**
  84371. * Defines the red component (between 0 and 1, default is 0)
  84372. */
  84373. r?: number,
  84374. /**
  84375. * Defines the green component (between 0 and 1, default is 0)
  84376. */
  84377. g?: number,
  84378. /**
  84379. * Defines the blue component (between 0 and 1, default is 0)
  84380. */
  84381. b?: number,
  84382. /**
  84383. * Defines the alpha component (between 0 and 1, default is 1)
  84384. */
  84385. a?: number);
  84386. /**
  84387. * Adds in place the given Color4 values to the current Color4 object
  84388. * @param right defines the second operand
  84389. * @returns the current updated Color4 object
  84390. */
  84391. addInPlace(right: DeepImmutable<Color4>): Color4;
  84392. /**
  84393. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84394. * @returns the new array
  84395. */
  84396. asArray(): number[];
  84397. /**
  84398. * Stores from the starting index in the given array the Color4 successive values
  84399. * @param array defines the array where to store the r,g,b components
  84400. * @param index defines an optional index in the target array to define where to start storing values
  84401. * @returns the current Color4 object
  84402. */
  84403. toArray(array: number[], index?: number): Color4;
  84404. /**
  84405. * Determines equality between Color4 objects
  84406. * @param otherColor defines the second operand
  84407. * @returns true if the rgba values are equal to the given ones
  84408. */
  84409. equals(otherColor: DeepImmutable<Color4>): boolean;
  84410. /**
  84411. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84412. * @param right defines the second operand
  84413. * @returns a new Color4 object
  84414. */
  84415. add(right: DeepImmutable<Color4>): Color4;
  84416. /**
  84417. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84418. * @param right defines the second operand
  84419. * @returns a new Color4 object
  84420. */
  84421. subtract(right: DeepImmutable<Color4>): Color4;
  84422. /**
  84423. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84424. * @param right defines the second operand
  84425. * @param result defines the Color4 object where to store the result
  84426. * @returns the current Color4 object
  84427. */
  84428. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84429. /**
  84430. * Creates a new Color4 with the current Color4 values multiplied by scale
  84431. * @param scale defines the scaling factor to apply
  84432. * @returns a new Color4 object
  84433. */
  84434. scale(scale: number): Color4;
  84435. /**
  84436. * Multiplies the current Color4 values by scale and stores the result in "result"
  84437. * @param scale defines the scaling factor to apply
  84438. * @param result defines the Color4 object where to store the result
  84439. * @returns the current unmodified Color4
  84440. */
  84441. scaleToRef(scale: number, result: Color4): Color4;
  84442. /**
  84443. * Scale the current Color4 values by a factor and add the result to a given Color4
  84444. * @param scale defines the scale factor
  84445. * @param result defines the Color4 object where to store the result
  84446. * @returns the unmodified current Color4
  84447. */
  84448. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84449. /**
  84450. * Clamps the rgb values by the min and max values and stores the result into "result"
  84451. * @param min defines minimum clamping value (default is 0)
  84452. * @param max defines maximum clamping value (default is 1)
  84453. * @param result defines color to store the result into.
  84454. * @returns the cuurent Color4
  84455. */
  84456. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84457. /**
  84458. * Multipy an Color4 value by another and return a new Color4 object
  84459. * @param color defines the Color4 value to multiply by
  84460. * @returns a new Color4 object
  84461. */
  84462. multiply(color: Color4): Color4;
  84463. /**
  84464. * Multipy a Color4 value by another and push the result in a reference value
  84465. * @param color defines the Color4 value to multiply by
  84466. * @param result defines the Color4 to fill the result in
  84467. * @returns the result Color4
  84468. */
  84469. multiplyToRef(color: Color4, result: Color4): Color4;
  84470. /**
  84471. * Creates a string with the Color4 current values
  84472. * @returns the string representation of the Color4 object
  84473. */
  84474. toString(): string;
  84475. /**
  84476. * Returns the string "Color4"
  84477. * @returns "Color4"
  84478. */
  84479. getClassName(): string;
  84480. /**
  84481. * Compute the Color4 hash code
  84482. * @returns an unique number that can be used to hash Color4 objects
  84483. */
  84484. getHashCode(): number;
  84485. /**
  84486. * Creates a new Color4 copied from the current one
  84487. * @returns a new Color4 object
  84488. */
  84489. clone(): Color4;
  84490. /**
  84491. * Copies the given Color4 values into the current one
  84492. * @param source defines the source Color4 object
  84493. * @returns the current updated Color4 object
  84494. */
  84495. copyFrom(source: Color4): Color4;
  84496. /**
  84497. * Copies the given float values into the current one
  84498. * @param r defines the red component to read from
  84499. * @param g defines the green component to read from
  84500. * @param b defines the blue component to read from
  84501. * @param a defines the alpha component to read from
  84502. * @returns the current updated Color4 object
  84503. */
  84504. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84505. /**
  84506. * Copies the given float values into the current one
  84507. * @param r defines the red component to read from
  84508. * @param g defines the green component to read from
  84509. * @param b defines the blue component to read from
  84510. * @param a defines the alpha component to read from
  84511. * @returns the current updated Color4 object
  84512. */
  84513. set(r: number, g: number, b: number, a: number): Color4;
  84514. /**
  84515. * Compute the Color4 hexadecimal code as a string
  84516. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84517. * @returns a string containing the hexadecimal representation of the Color4 object
  84518. */
  84519. toHexString(returnAsColor3?: boolean): string;
  84520. /**
  84521. * Computes a new Color4 converted from the current one to linear space
  84522. * @returns a new Color4 object
  84523. */
  84524. toLinearSpace(): Color4;
  84525. /**
  84526. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84527. * @param convertedColor defines the Color4 object where to store the linear space version
  84528. * @returns the unmodified Color4
  84529. */
  84530. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84531. /**
  84532. * Computes a new Color4 converted from the current one to gamma space
  84533. * @returns a new Color4 object
  84534. */
  84535. toGammaSpace(): Color4;
  84536. /**
  84537. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84538. * @param convertedColor defines the Color4 object where to store the gamma space version
  84539. * @returns the unmodified Color4
  84540. */
  84541. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84542. /**
  84543. * Creates a new Color4 from the string containing valid hexadecimal values
  84544. * @param hex defines a string containing valid hexadecimal values
  84545. * @returns a new Color4 object
  84546. */
  84547. static FromHexString(hex: string): Color4;
  84548. /**
  84549. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84550. * @param left defines the start value
  84551. * @param right defines the end value
  84552. * @param amount defines the gradient factor
  84553. * @returns a new Color4 object
  84554. */
  84555. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84556. /**
  84557. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84558. * @param left defines the start value
  84559. * @param right defines the end value
  84560. * @param amount defines the gradient factor
  84561. * @param result defines the Color4 object where to store data
  84562. */
  84563. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84564. /**
  84565. * Creates a new Color4 from a Color3 and an alpha value
  84566. * @param color3 defines the source Color3 to read from
  84567. * @param alpha defines the alpha component (1.0 by default)
  84568. * @returns a new Color4 object
  84569. */
  84570. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84571. /**
  84572. * Creates a new Color4 from the starting index element of the given array
  84573. * @param array defines the source array to read from
  84574. * @param offset defines the offset in the source array
  84575. * @returns a new Color4 object
  84576. */
  84577. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84578. /**
  84579. * Creates a new Color3 from integer values (< 256)
  84580. * @param r defines the red component to read from (value between 0 and 255)
  84581. * @param g defines the green component to read from (value between 0 and 255)
  84582. * @param b defines the blue component to read from (value between 0 and 255)
  84583. * @param a defines the alpha component to read from (value between 0 and 255)
  84584. * @returns a new Color3 object
  84585. */
  84586. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84587. /**
  84588. * Check the content of a given array and convert it to an array containing RGBA data
  84589. * If the original array was already containing count * 4 values then it is returned directly
  84590. * @param colors defines the array to check
  84591. * @param count defines the number of RGBA data to expect
  84592. * @returns an array containing count * 4 values (RGBA)
  84593. */
  84594. static CheckColors4(colors: number[], count: number): number[];
  84595. }
  84596. /**
  84597. * @hidden
  84598. */
  84599. export class TmpColors {
  84600. static Color3: Color3[];
  84601. static Color4: Color4[];
  84602. }
  84603. }
  84604. declare module BABYLON {
  84605. /**
  84606. * Defines an interface which represents an animation key frame
  84607. */
  84608. export interface IAnimationKey {
  84609. /**
  84610. * Frame of the key frame
  84611. */
  84612. frame: number;
  84613. /**
  84614. * Value at the specifies key frame
  84615. */
  84616. value: any;
  84617. /**
  84618. * The input tangent for the cubic hermite spline
  84619. */
  84620. inTangent?: any;
  84621. /**
  84622. * The output tangent for the cubic hermite spline
  84623. */
  84624. outTangent?: any;
  84625. /**
  84626. * The animation interpolation type
  84627. */
  84628. interpolation?: AnimationKeyInterpolation;
  84629. }
  84630. /**
  84631. * Enum for the animation key frame interpolation type
  84632. */
  84633. export enum AnimationKeyInterpolation {
  84634. /**
  84635. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84636. */
  84637. STEP = 1
  84638. }
  84639. }
  84640. declare module BABYLON {
  84641. /**
  84642. * Represents the range of an animation
  84643. */
  84644. export class AnimationRange {
  84645. /**The name of the animation range**/
  84646. name: string;
  84647. /**The starting frame of the animation */
  84648. from: number;
  84649. /**The ending frame of the animation*/
  84650. to: number;
  84651. /**
  84652. * Initializes the range of an animation
  84653. * @param name The name of the animation range
  84654. * @param from The starting frame of the animation
  84655. * @param to The ending frame of the animation
  84656. */
  84657. constructor(
  84658. /**The name of the animation range**/
  84659. name: string,
  84660. /**The starting frame of the animation */
  84661. from: number,
  84662. /**The ending frame of the animation*/
  84663. to: number);
  84664. /**
  84665. * Makes a copy of the animation range
  84666. * @returns A copy of the animation range
  84667. */
  84668. clone(): AnimationRange;
  84669. }
  84670. }
  84671. declare module BABYLON {
  84672. /**
  84673. * Composed of a frame, and an action function
  84674. */
  84675. export class AnimationEvent {
  84676. /** The frame for which the event is triggered **/
  84677. frame: number;
  84678. /** The event to perform when triggered **/
  84679. action: (currentFrame: number) => void;
  84680. /** Specifies if the event should be triggered only once**/
  84681. onlyOnce?: boolean | undefined;
  84682. /**
  84683. * Specifies if the animation event is done
  84684. */
  84685. isDone: boolean;
  84686. /**
  84687. * Initializes the animation event
  84688. * @param frame The frame for which the event is triggered
  84689. * @param action The event to perform when triggered
  84690. * @param onlyOnce Specifies if the event should be triggered only once
  84691. */
  84692. constructor(
  84693. /** The frame for which the event is triggered **/
  84694. frame: number,
  84695. /** The event to perform when triggered **/
  84696. action: (currentFrame: number) => void,
  84697. /** Specifies if the event should be triggered only once**/
  84698. onlyOnce?: boolean | undefined);
  84699. /** @hidden */
  84700. _clone(): AnimationEvent;
  84701. }
  84702. }
  84703. declare module BABYLON {
  84704. /**
  84705. * Interface used to define a behavior
  84706. */
  84707. export interface Behavior<T> {
  84708. /** gets or sets behavior's name */
  84709. name: string;
  84710. /**
  84711. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84712. */
  84713. init(): void;
  84714. /**
  84715. * Called when the behavior is attached to a target
  84716. * @param target defines the target where the behavior is attached to
  84717. */
  84718. attach(target: T): void;
  84719. /**
  84720. * Called when the behavior is detached from its target
  84721. */
  84722. detach(): void;
  84723. }
  84724. /**
  84725. * Interface implemented by classes supporting behaviors
  84726. */
  84727. export interface IBehaviorAware<T> {
  84728. /**
  84729. * Attach a behavior
  84730. * @param behavior defines the behavior to attach
  84731. * @returns the current host
  84732. */
  84733. addBehavior(behavior: Behavior<T>): T;
  84734. /**
  84735. * Remove a behavior from the current object
  84736. * @param behavior defines the behavior to detach
  84737. * @returns the current host
  84738. */
  84739. removeBehavior(behavior: Behavior<T>): T;
  84740. /**
  84741. * Gets a behavior using its name to search
  84742. * @param name defines the name to search
  84743. * @returns the behavior or null if not found
  84744. */
  84745. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84746. }
  84747. }
  84748. declare module BABYLON {
  84749. /**
  84750. * Defines an array and its length.
  84751. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84752. */
  84753. export interface ISmartArrayLike<T> {
  84754. /**
  84755. * The data of the array.
  84756. */
  84757. data: Array<T>;
  84758. /**
  84759. * The active length of the array.
  84760. */
  84761. length: number;
  84762. }
  84763. /**
  84764. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84765. */
  84766. export class SmartArray<T> implements ISmartArrayLike<T> {
  84767. /**
  84768. * The full set of data from the array.
  84769. */
  84770. data: Array<T>;
  84771. /**
  84772. * The active length of the array.
  84773. */
  84774. length: number;
  84775. protected _id: number;
  84776. /**
  84777. * Instantiates a Smart Array.
  84778. * @param capacity defines the default capacity of the array.
  84779. */
  84780. constructor(capacity: number);
  84781. /**
  84782. * Pushes a value at the end of the active data.
  84783. * @param value defines the object to push in the array.
  84784. */
  84785. push(value: T): void;
  84786. /**
  84787. * Iterates over the active data and apply the lambda to them.
  84788. * @param func defines the action to apply on each value.
  84789. */
  84790. forEach(func: (content: T) => void): void;
  84791. /**
  84792. * Sorts the full sets of data.
  84793. * @param compareFn defines the comparison function to apply.
  84794. */
  84795. sort(compareFn: (a: T, b: T) => number): void;
  84796. /**
  84797. * Resets the active data to an empty array.
  84798. */
  84799. reset(): void;
  84800. /**
  84801. * Releases all the data from the array as well as the array.
  84802. */
  84803. dispose(): void;
  84804. /**
  84805. * Concats the active data with a given array.
  84806. * @param array defines the data to concatenate with.
  84807. */
  84808. concat(array: any): void;
  84809. /**
  84810. * Returns the position of a value in the active data.
  84811. * @param value defines the value to find the index for
  84812. * @returns the index if found in the active data otherwise -1
  84813. */
  84814. indexOf(value: T): number;
  84815. /**
  84816. * Returns whether an element is part of the active data.
  84817. * @param value defines the value to look for
  84818. * @returns true if found in the active data otherwise false
  84819. */
  84820. contains(value: T): boolean;
  84821. private static _GlobalId;
  84822. }
  84823. /**
  84824. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84825. * The data in this array can only be present once
  84826. */
  84827. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84828. private _duplicateId;
  84829. /**
  84830. * Pushes a value at the end of the active data.
  84831. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84832. * @param value defines the object to push in the array.
  84833. */
  84834. push(value: T): void;
  84835. /**
  84836. * Pushes a value at the end of the active data.
  84837. * If the data is already present, it won t be added again
  84838. * @param value defines the object to push in the array.
  84839. * @returns true if added false if it was already present
  84840. */
  84841. pushNoDuplicate(value: T): boolean;
  84842. /**
  84843. * Resets the active data to an empty array.
  84844. */
  84845. reset(): void;
  84846. /**
  84847. * Concats the active data with a given array.
  84848. * This ensures no dupplicate will be present in the result.
  84849. * @param array defines the data to concatenate with.
  84850. */
  84851. concatWithNoDuplicate(array: any): void;
  84852. }
  84853. }
  84854. declare module BABYLON {
  84855. /**
  84856. * @ignore
  84857. * This is a list of all the different input types that are available in the application.
  84858. * Fo instance: ArcRotateCameraGamepadInput...
  84859. */
  84860. export var CameraInputTypes: {};
  84861. /**
  84862. * This is the contract to implement in order to create a new input class.
  84863. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84864. */
  84865. export interface ICameraInput<TCamera extends Camera> {
  84866. /**
  84867. * Defines the camera the input is attached to.
  84868. */
  84869. camera: Nullable<TCamera>;
  84870. /**
  84871. * Gets the class name of the current intput.
  84872. * @returns the class name
  84873. */
  84874. getClassName(): string;
  84875. /**
  84876. * Get the friendly name associated with the input class.
  84877. * @returns the input friendly name
  84878. */
  84879. getSimpleName(): string;
  84880. /**
  84881. * Attach the input controls to a specific dom element to get the input from.
  84882. * @param element Defines the element the controls should be listened from
  84883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84884. */
  84885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84886. /**
  84887. * Detach the current controls from the specified dom element.
  84888. * @param element Defines the element to stop listening the inputs from
  84889. */
  84890. detachControl(element: Nullable<HTMLElement>): void;
  84891. /**
  84892. * Update the current camera state depending on the inputs that have been used this frame.
  84893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84894. */
  84895. checkInputs?: () => void;
  84896. }
  84897. /**
  84898. * Represents a map of input types to input instance or input index to input instance.
  84899. */
  84900. export interface CameraInputsMap<TCamera extends Camera> {
  84901. /**
  84902. * Accessor to the input by input type.
  84903. */
  84904. [name: string]: ICameraInput<TCamera>;
  84905. /**
  84906. * Accessor to the input by input index.
  84907. */
  84908. [idx: number]: ICameraInput<TCamera>;
  84909. }
  84910. /**
  84911. * This represents the input manager used within a camera.
  84912. * It helps dealing with all the different kind of input attached to a camera.
  84913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84914. */
  84915. export class CameraInputsManager<TCamera extends Camera> {
  84916. /**
  84917. * Defines the list of inputs attahed to the camera.
  84918. */
  84919. attached: CameraInputsMap<TCamera>;
  84920. /**
  84921. * Defines the dom element the camera is collecting inputs from.
  84922. * This is null if the controls have not been attached.
  84923. */
  84924. attachedElement: Nullable<HTMLElement>;
  84925. /**
  84926. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84927. */
  84928. noPreventDefault: boolean;
  84929. /**
  84930. * Defined the camera the input manager belongs to.
  84931. */
  84932. camera: TCamera;
  84933. /**
  84934. * Update the current camera state depending on the inputs that have been used this frame.
  84935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84936. */
  84937. checkInputs: () => void;
  84938. /**
  84939. * Instantiate a new Camera Input Manager.
  84940. * @param camera Defines the camera the input manager blongs to
  84941. */
  84942. constructor(camera: TCamera);
  84943. /**
  84944. * Add an input method to a camera
  84945. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84946. * @param input camera input method
  84947. */
  84948. add(input: ICameraInput<TCamera>): void;
  84949. /**
  84950. * Remove a specific input method from a camera
  84951. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84952. * @param inputToRemove camera input method
  84953. */
  84954. remove(inputToRemove: ICameraInput<TCamera>): void;
  84955. /**
  84956. * Remove a specific input type from a camera
  84957. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84958. * @param inputType the type of the input to remove
  84959. */
  84960. removeByType(inputType: string): void;
  84961. private _addCheckInputs;
  84962. /**
  84963. * Attach the input controls to the currently attached dom element to listen the events from.
  84964. * @param input Defines the input to attach
  84965. */
  84966. attachInput(input: ICameraInput<TCamera>): void;
  84967. /**
  84968. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84969. * @param element Defines the dom element to collect the events from
  84970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84971. */
  84972. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84973. /**
  84974. * Detach the current manager inputs controls from a specific dom element.
  84975. * @param element Defines the dom element to collect the events from
  84976. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84977. */
  84978. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84979. /**
  84980. * Rebuild the dynamic inputCheck function from the current list of
  84981. * defined inputs in the manager.
  84982. */
  84983. rebuildInputCheck(): void;
  84984. /**
  84985. * Remove all attached input methods from a camera
  84986. */
  84987. clear(): void;
  84988. /**
  84989. * Serialize the current input manager attached to a camera.
  84990. * This ensures than once parsed,
  84991. * the input associated to the camera will be identical to the current ones
  84992. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84993. */
  84994. serialize(serializedCamera: any): void;
  84995. /**
  84996. * Parses an input manager serialized JSON to restore the previous list of inputs
  84997. * and states associated to a camera.
  84998. * @param parsedCamera Defines the JSON to parse
  84999. */
  85000. parse(parsedCamera: any): void;
  85001. }
  85002. }
  85003. declare module BABYLON {
  85004. /**
  85005. * Class used to store data that will be store in GPU memory
  85006. */
  85007. export class Buffer {
  85008. private _engine;
  85009. private _buffer;
  85010. /** @hidden */
  85011. _data: Nullable<DataArray>;
  85012. private _updatable;
  85013. private _instanced;
  85014. private _divisor;
  85015. /**
  85016. * Gets the byte stride.
  85017. */
  85018. readonly byteStride: number;
  85019. /**
  85020. * Constructor
  85021. * @param engine the engine
  85022. * @param data the data to use for this buffer
  85023. * @param updatable whether the data is updatable
  85024. * @param stride the stride (optional)
  85025. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85026. * @param instanced whether the buffer is instanced (optional)
  85027. * @param useBytes set to true if the stride in in bytes (optional)
  85028. * @param divisor sets an optional divisor for instances (1 by default)
  85029. */
  85030. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85031. /**
  85032. * Create a new VertexBuffer based on the current buffer
  85033. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85034. * @param offset defines offset in the buffer (0 by default)
  85035. * @param size defines the size in floats of attributes (position is 3 for instance)
  85036. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85037. * @param instanced defines if the vertex buffer contains indexed data
  85038. * @param useBytes defines if the offset and stride are in bytes *
  85039. * @param divisor sets an optional divisor for instances (1 by default)
  85040. * @returns the new vertex buffer
  85041. */
  85042. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85043. /**
  85044. * Gets a boolean indicating if the Buffer is updatable?
  85045. * @returns true if the buffer is updatable
  85046. */
  85047. isUpdatable(): boolean;
  85048. /**
  85049. * Gets current buffer's data
  85050. * @returns a DataArray or null
  85051. */
  85052. getData(): Nullable<DataArray>;
  85053. /**
  85054. * Gets underlying native buffer
  85055. * @returns underlying native buffer
  85056. */
  85057. getBuffer(): Nullable<DataBuffer>;
  85058. /**
  85059. * Gets the stride in float32 units (i.e. byte stride / 4).
  85060. * May not be an integer if the byte stride is not divisible by 4.
  85061. * @returns the stride in float32 units
  85062. * @deprecated Please use byteStride instead.
  85063. */
  85064. getStrideSize(): number;
  85065. /**
  85066. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85067. * @param data defines the data to store
  85068. */
  85069. create(data?: Nullable<DataArray>): void;
  85070. /** @hidden */
  85071. _rebuild(): void;
  85072. /**
  85073. * Update current buffer data
  85074. * @param data defines the data to store
  85075. */
  85076. update(data: DataArray): void;
  85077. /**
  85078. * Updates the data directly.
  85079. * @param data the new data
  85080. * @param offset the new offset
  85081. * @param vertexCount the vertex count (optional)
  85082. * @param useBytes set to true if the offset is in bytes
  85083. */
  85084. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85085. /**
  85086. * Release all resources
  85087. */
  85088. dispose(): void;
  85089. }
  85090. /**
  85091. * Specialized buffer used to store vertex data
  85092. */
  85093. export class VertexBuffer {
  85094. /** @hidden */
  85095. _buffer: Buffer;
  85096. private _kind;
  85097. private _size;
  85098. private _ownsBuffer;
  85099. private _instanced;
  85100. private _instanceDivisor;
  85101. /**
  85102. * The byte type.
  85103. */
  85104. static readonly BYTE: number;
  85105. /**
  85106. * The unsigned byte type.
  85107. */
  85108. static readonly UNSIGNED_BYTE: number;
  85109. /**
  85110. * The short type.
  85111. */
  85112. static readonly SHORT: number;
  85113. /**
  85114. * The unsigned short type.
  85115. */
  85116. static readonly UNSIGNED_SHORT: number;
  85117. /**
  85118. * The integer type.
  85119. */
  85120. static readonly INT: number;
  85121. /**
  85122. * The unsigned integer type.
  85123. */
  85124. static readonly UNSIGNED_INT: number;
  85125. /**
  85126. * The float type.
  85127. */
  85128. static readonly FLOAT: number;
  85129. /**
  85130. * Gets or sets the instance divisor when in instanced mode
  85131. */
  85132. get instanceDivisor(): number;
  85133. set instanceDivisor(value: number);
  85134. /**
  85135. * Gets the byte stride.
  85136. */
  85137. readonly byteStride: number;
  85138. /**
  85139. * Gets the byte offset.
  85140. */
  85141. readonly byteOffset: number;
  85142. /**
  85143. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85144. */
  85145. readonly normalized: boolean;
  85146. /**
  85147. * Gets the data type of each component in the array.
  85148. */
  85149. readonly type: number;
  85150. /**
  85151. * Constructor
  85152. * @param engine the engine
  85153. * @param data the data to use for this vertex buffer
  85154. * @param kind the vertex buffer kind
  85155. * @param updatable whether the data is updatable
  85156. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85157. * @param stride the stride (optional)
  85158. * @param instanced whether the buffer is instanced (optional)
  85159. * @param offset the offset of the data (optional)
  85160. * @param size the number of components (optional)
  85161. * @param type the type of the component (optional)
  85162. * @param normalized whether the data contains normalized data (optional)
  85163. * @param useBytes set to true if stride and offset are in bytes (optional)
  85164. * @param divisor defines the instance divisor to use (1 by default)
  85165. */
  85166. 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);
  85167. /** @hidden */
  85168. _rebuild(): void;
  85169. /**
  85170. * Returns the kind of the VertexBuffer (string)
  85171. * @returns a string
  85172. */
  85173. getKind(): string;
  85174. /**
  85175. * Gets a boolean indicating if the VertexBuffer is updatable?
  85176. * @returns true if the buffer is updatable
  85177. */
  85178. isUpdatable(): boolean;
  85179. /**
  85180. * Gets current buffer's data
  85181. * @returns a DataArray or null
  85182. */
  85183. getData(): Nullable<DataArray>;
  85184. /**
  85185. * Gets underlying native buffer
  85186. * @returns underlying native buffer
  85187. */
  85188. getBuffer(): Nullable<DataBuffer>;
  85189. /**
  85190. * Gets the stride in float32 units (i.e. byte stride / 4).
  85191. * May not be an integer if the byte stride is not divisible by 4.
  85192. * @returns the stride in float32 units
  85193. * @deprecated Please use byteStride instead.
  85194. */
  85195. getStrideSize(): number;
  85196. /**
  85197. * Returns the offset as a multiple of the type byte length.
  85198. * @returns the offset in bytes
  85199. * @deprecated Please use byteOffset instead.
  85200. */
  85201. getOffset(): number;
  85202. /**
  85203. * Returns the number of components per vertex attribute (integer)
  85204. * @returns the size in float
  85205. */
  85206. getSize(): number;
  85207. /**
  85208. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85209. * @returns true if this buffer is instanced
  85210. */
  85211. getIsInstanced(): boolean;
  85212. /**
  85213. * Returns the instancing divisor, zero for non-instanced (integer).
  85214. * @returns a number
  85215. */
  85216. getInstanceDivisor(): number;
  85217. /**
  85218. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85219. * @param data defines the data to store
  85220. */
  85221. create(data?: DataArray): void;
  85222. /**
  85223. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85224. * This function will create a new buffer if the current one is not updatable
  85225. * @param data defines the data to store
  85226. */
  85227. update(data: DataArray): void;
  85228. /**
  85229. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85230. * Returns the directly updated WebGLBuffer.
  85231. * @param data the new data
  85232. * @param offset the new offset
  85233. * @param useBytes set to true if the offset is in bytes
  85234. */
  85235. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85236. /**
  85237. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85238. */
  85239. dispose(): void;
  85240. /**
  85241. * Enumerates each value of this vertex buffer as numbers.
  85242. * @param count the number of values to enumerate
  85243. * @param callback the callback function called for each value
  85244. */
  85245. forEach(count: number, callback: (value: number, index: number) => void): void;
  85246. /**
  85247. * Positions
  85248. */
  85249. static readonly PositionKind: string;
  85250. /**
  85251. * Normals
  85252. */
  85253. static readonly NormalKind: string;
  85254. /**
  85255. * Tangents
  85256. */
  85257. static readonly TangentKind: string;
  85258. /**
  85259. * Texture coordinates
  85260. */
  85261. static readonly UVKind: string;
  85262. /**
  85263. * Texture coordinates 2
  85264. */
  85265. static readonly UV2Kind: string;
  85266. /**
  85267. * Texture coordinates 3
  85268. */
  85269. static readonly UV3Kind: string;
  85270. /**
  85271. * Texture coordinates 4
  85272. */
  85273. static readonly UV4Kind: string;
  85274. /**
  85275. * Texture coordinates 5
  85276. */
  85277. static readonly UV5Kind: string;
  85278. /**
  85279. * Texture coordinates 6
  85280. */
  85281. static readonly UV6Kind: string;
  85282. /**
  85283. * Colors
  85284. */
  85285. static readonly ColorKind: string;
  85286. /**
  85287. * Matrix indices (for bones)
  85288. */
  85289. static readonly MatricesIndicesKind: string;
  85290. /**
  85291. * Matrix weights (for bones)
  85292. */
  85293. static readonly MatricesWeightsKind: string;
  85294. /**
  85295. * Additional matrix indices (for bones)
  85296. */
  85297. static readonly MatricesIndicesExtraKind: string;
  85298. /**
  85299. * Additional matrix weights (for bones)
  85300. */
  85301. static readonly MatricesWeightsExtraKind: string;
  85302. /**
  85303. * Deduces the stride given a kind.
  85304. * @param kind The kind string to deduce
  85305. * @returns The deduced stride
  85306. */
  85307. static DeduceStride(kind: string): number;
  85308. /**
  85309. * Gets the byte length of the given type.
  85310. * @param type the type
  85311. * @returns the number of bytes
  85312. */
  85313. static GetTypeByteLength(type: number): number;
  85314. /**
  85315. * Enumerates each value of the given parameters as numbers.
  85316. * @param data the data to enumerate
  85317. * @param byteOffset the byte offset of the data
  85318. * @param byteStride the byte stride of the data
  85319. * @param componentCount the number of components per element
  85320. * @param componentType the type of the component
  85321. * @param count the number of values to enumerate
  85322. * @param normalized whether the data is normalized
  85323. * @param callback the callback function called for each value
  85324. */
  85325. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85326. private static _GetFloatValue;
  85327. }
  85328. }
  85329. declare module BABYLON {
  85330. /**
  85331. * @hidden
  85332. */
  85333. export class IntersectionInfo {
  85334. bu: Nullable<number>;
  85335. bv: Nullable<number>;
  85336. distance: number;
  85337. faceId: number;
  85338. subMeshId: number;
  85339. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85340. }
  85341. }
  85342. declare module BABYLON {
  85343. /**
  85344. * Class used to store bounding sphere information
  85345. */
  85346. export class BoundingSphere {
  85347. /**
  85348. * Gets the center of the bounding sphere in local space
  85349. */
  85350. readonly center: Vector3;
  85351. /**
  85352. * Radius of the bounding sphere in local space
  85353. */
  85354. radius: number;
  85355. /**
  85356. * Gets the center of the bounding sphere in world space
  85357. */
  85358. readonly centerWorld: Vector3;
  85359. /**
  85360. * Radius of the bounding sphere in world space
  85361. */
  85362. radiusWorld: number;
  85363. /**
  85364. * Gets the minimum vector in local space
  85365. */
  85366. readonly minimum: Vector3;
  85367. /**
  85368. * Gets the maximum vector in local space
  85369. */
  85370. readonly maximum: Vector3;
  85371. private _worldMatrix;
  85372. private static readonly TmpVector3;
  85373. /**
  85374. * Creates a new bounding sphere
  85375. * @param min defines the minimum vector (in local space)
  85376. * @param max defines the maximum vector (in local space)
  85377. * @param worldMatrix defines the new world matrix
  85378. */
  85379. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85380. /**
  85381. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85382. * @param min defines the new minimum vector (in local space)
  85383. * @param max defines the new maximum vector (in local space)
  85384. * @param worldMatrix defines the new world matrix
  85385. */
  85386. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85387. /**
  85388. * Scale the current bounding sphere by applying a scale factor
  85389. * @param factor defines the scale factor to apply
  85390. * @returns the current bounding box
  85391. */
  85392. scale(factor: number): BoundingSphere;
  85393. /**
  85394. * Gets the world matrix of the bounding box
  85395. * @returns a matrix
  85396. */
  85397. getWorldMatrix(): DeepImmutable<Matrix>;
  85398. /** @hidden */
  85399. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85400. /**
  85401. * Tests if the bounding sphere is intersecting the frustum planes
  85402. * @param frustumPlanes defines the frustum planes to test
  85403. * @returns true if there is an intersection
  85404. */
  85405. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85406. /**
  85407. * Tests if the bounding sphere center is in between the frustum planes.
  85408. * Used for optimistic fast inclusion.
  85409. * @param frustumPlanes defines the frustum planes to test
  85410. * @returns true if the sphere center is in between the frustum planes
  85411. */
  85412. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85413. /**
  85414. * Tests if a point is inside the bounding sphere
  85415. * @param point defines the point to test
  85416. * @returns true if the point is inside the bounding sphere
  85417. */
  85418. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85419. /**
  85420. * Checks if two sphere intersct
  85421. * @param sphere0 sphere 0
  85422. * @param sphere1 sphere 1
  85423. * @returns true if the speres intersect
  85424. */
  85425. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85426. }
  85427. }
  85428. declare module BABYLON {
  85429. /**
  85430. * Class used to store bounding box information
  85431. */
  85432. export class BoundingBox implements ICullable {
  85433. /**
  85434. * Gets the 8 vectors representing the bounding box in local space
  85435. */
  85436. readonly vectors: Vector3[];
  85437. /**
  85438. * Gets the center of the bounding box in local space
  85439. */
  85440. readonly center: Vector3;
  85441. /**
  85442. * Gets the center of the bounding box in world space
  85443. */
  85444. readonly centerWorld: Vector3;
  85445. /**
  85446. * Gets the extend size in local space
  85447. */
  85448. readonly extendSize: Vector3;
  85449. /**
  85450. * Gets the extend size in world space
  85451. */
  85452. readonly extendSizeWorld: Vector3;
  85453. /**
  85454. * Gets the OBB (object bounding box) directions
  85455. */
  85456. readonly directions: Vector3[];
  85457. /**
  85458. * Gets the 8 vectors representing the bounding box in world space
  85459. */
  85460. readonly vectorsWorld: Vector3[];
  85461. /**
  85462. * Gets the minimum vector in world space
  85463. */
  85464. readonly minimumWorld: Vector3;
  85465. /**
  85466. * Gets the maximum vector in world space
  85467. */
  85468. readonly maximumWorld: Vector3;
  85469. /**
  85470. * Gets the minimum vector in local space
  85471. */
  85472. readonly minimum: Vector3;
  85473. /**
  85474. * Gets the maximum vector in local space
  85475. */
  85476. readonly maximum: Vector3;
  85477. private _worldMatrix;
  85478. private static readonly TmpVector3;
  85479. /**
  85480. * @hidden
  85481. */
  85482. _tag: number;
  85483. /**
  85484. * Creates a new bounding box
  85485. * @param min defines the minimum vector (in local space)
  85486. * @param max defines the maximum vector (in local space)
  85487. * @param worldMatrix defines the new world matrix
  85488. */
  85489. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85490. /**
  85491. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85492. * @param min defines the new minimum vector (in local space)
  85493. * @param max defines the new maximum vector (in local space)
  85494. * @param worldMatrix defines the new world matrix
  85495. */
  85496. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85497. /**
  85498. * Scale the current bounding box by applying a scale factor
  85499. * @param factor defines the scale factor to apply
  85500. * @returns the current bounding box
  85501. */
  85502. scale(factor: number): BoundingBox;
  85503. /**
  85504. * Gets the world matrix of the bounding box
  85505. * @returns a matrix
  85506. */
  85507. getWorldMatrix(): DeepImmutable<Matrix>;
  85508. /** @hidden */
  85509. _update(world: DeepImmutable<Matrix>): void;
  85510. /**
  85511. * Tests if the bounding box is intersecting the frustum planes
  85512. * @param frustumPlanes defines the frustum planes to test
  85513. * @returns true if there is an intersection
  85514. */
  85515. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85516. /**
  85517. * Tests if the bounding box is entirely inside the frustum planes
  85518. * @param frustumPlanes defines the frustum planes to test
  85519. * @returns true if there is an inclusion
  85520. */
  85521. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85522. /**
  85523. * Tests if a point is inside the bounding box
  85524. * @param point defines the point to test
  85525. * @returns true if the point is inside the bounding box
  85526. */
  85527. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85528. /**
  85529. * Tests if the bounding box intersects with a bounding sphere
  85530. * @param sphere defines the sphere to test
  85531. * @returns true if there is an intersection
  85532. */
  85533. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85534. /**
  85535. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85536. * @param min defines the min vector to use
  85537. * @param max defines the max vector to use
  85538. * @returns true if there is an intersection
  85539. */
  85540. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85541. /**
  85542. * Tests if two bounding boxes are intersections
  85543. * @param box0 defines the first box to test
  85544. * @param box1 defines the second box to test
  85545. * @returns true if there is an intersection
  85546. */
  85547. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85548. /**
  85549. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85550. * @param minPoint defines the minimum vector of the bounding box
  85551. * @param maxPoint defines the maximum vector of the bounding box
  85552. * @param sphereCenter defines the sphere center
  85553. * @param sphereRadius defines the sphere radius
  85554. * @returns true if there is an intersection
  85555. */
  85556. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85557. /**
  85558. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85559. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85560. * @param frustumPlanes defines the frustum planes to test
  85561. * @return true if there is an inclusion
  85562. */
  85563. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85564. /**
  85565. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85566. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85567. * @param frustumPlanes defines the frustum planes to test
  85568. * @return true if there is an intersection
  85569. */
  85570. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85571. }
  85572. }
  85573. declare module BABYLON {
  85574. /** @hidden */
  85575. export class Collider {
  85576. /** Define if a collision was found */
  85577. collisionFound: boolean;
  85578. /**
  85579. * Define last intersection point in local space
  85580. */
  85581. intersectionPoint: Vector3;
  85582. /**
  85583. * Define last collided mesh
  85584. */
  85585. collidedMesh: Nullable<AbstractMesh>;
  85586. private _collisionPoint;
  85587. private _planeIntersectionPoint;
  85588. private _tempVector;
  85589. private _tempVector2;
  85590. private _tempVector3;
  85591. private _tempVector4;
  85592. private _edge;
  85593. private _baseToVertex;
  85594. private _destinationPoint;
  85595. private _slidePlaneNormal;
  85596. private _displacementVector;
  85597. /** @hidden */
  85598. _radius: Vector3;
  85599. /** @hidden */
  85600. _retry: number;
  85601. private _velocity;
  85602. private _basePoint;
  85603. private _epsilon;
  85604. /** @hidden */
  85605. _velocityWorldLength: number;
  85606. /** @hidden */
  85607. _basePointWorld: Vector3;
  85608. private _velocityWorld;
  85609. private _normalizedVelocity;
  85610. /** @hidden */
  85611. _initialVelocity: Vector3;
  85612. /** @hidden */
  85613. _initialPosition: Vector3;
  85614. private _nearestDistance;
  85615. private _collisionMask;
  85616. get collisionMask(): number;
  85617. set collisionMask(mask: number);
  85618. /**
  85619. * Gets the plane normal used to compute the sliding response (in local space)
  85620. */
  85621. get slidePlaneNormal(): Vector3;
  85622. /** @hidden */
  85623. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85624. /** @hidden */
  85625. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85626. /** @hidden */
  85627. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85628. /** @hidden */
  85629. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85630. /** @hidden */
  85631. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85632. /** @hidden */
  85633. _getResponse(pos: Vector3, vel: Vector3): void;
  85634. }
  85635. }
  85636. declare module BABYLON {
  85637. /**
  85638. * Interface for cullable objects
  85639. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85640. */
  85641. export interface ICullable {
  85642. /**
  85643. * Checks if the object or part of the object is in the frustum
  85644. * @param frustumPlanes Camera near/planes
  85645. * @returns true if the object is in frustum otherwise false
  85646. */
  85647. isInFrustum(frustumPlanes: Plane[]): boolean;
  85648. /**
  85649. * Checks if a cullable object (mesh...) is in the camera frustum
  85650. * Unlike isInFrustum this cheks the full bounding box
  85651. * @param frustumPlanes Camera near/planes
  85652. * @returns true if the object is in frustum otherwise false
  85653. */
  85654. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85655. }
  85656. /**
  85657. * Info for a bounding data of a mesh
  85658. */
  85659. export class BoundingInfo implements ICullable {
  85660. /**
  85661. * Bounding box for the mesh
  85662. */
  85663. readonly boundingBox: BoundingBox;
  85664. /**
  85665. * Bounding sphere for the mesh
  85666. */
  85667. readonly boundingSphere: BoundingSphere;
  85668. private _isLocked;
  85669. private static readonly TmpVector3;
  85670. /**
  85671. * Constructs bounding info
  85672. * @param minimum min vector of the bounding box/sphere
  85673. * @param maximum max vector of the bounding box/sphere
  85674. * @param worldMatrix defines the new world matrix
  85675. */
  85676. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85677. /**
  85678. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85679. * @param min defines the new minimum vector (in local space)
  85680. * @param max defines the new maximum vector (in local space)
  85681. * @param worldMatrix defines the new world matrix
  85682. */
  85683. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85684. /**
  85685. * min vector of the bounding box/sphere
  85686. */
  85687. get minimum(): Vector3;
  85688. /**
  85689. * max vector of the bounding box/sphere
  85690. */
  85691. get maximum(): Vector3;
  85692. /**
  85693. * If the info is locked and won't be updated to avoid perf overhead
  85694. */
  85695. get isLocked(): boolean;
  85696. set isLocked(value: boolean);
  85697. /**
  85698. * Updates the bounding sphere and box
  85699. * @param world world matrix to be used to update
  85700. */
  85701. update(world: DeepImmutable<Matrix>): void;
  85702. /**
  85703. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85704. * @param center New center of the bounding info
  85705. * @param extend New extend of the bounding info
  85706. * @returns the current bounding info
  85707. */
  85708. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85709. /**
  85710. * Scale the current bounding info by applying a scale factor
  85711. * @param factor defines the scale factor to apply
  85712. * @returns the current bounding info
  85713. */
  85714. scale(factor: number): BoundingInfo;
  85715. /**
  85716. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85717. * @param frustumPlanes defines the frustum to test
  85718. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85719. * @returns true if the bounding info is in the frustum planes
  85720. */
  85721. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85722. /**
  85723. * Gets the world distance between the min and max points of the bounding box
  85724. */
  85725. get diagonalLength(): number;
  85726. /**
  85727. * Checks if a cullable object (mesh...) is in the camera frustum
  85728. * Unlike isInFrustum this cheks the full bounding box
  85729. * @param frustumPlanes Camera near/planes
  85730. * @returns true if the object is in frustum otherwise false
  85731. */
  85732. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85733. /** @hidden */
  85734. _checkCollision(collider: Collider): boolean;
  85735. /**
  85736. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85737. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85738. * @param point the point to check intersection with
  85739. * @returns if the point intersects
  85740. */
  85741. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85742. /**
  85743. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85744. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85745. * @param boundingInfo the bounding info to check intersection with
  85746. * @param precise if the intersection should be done using OBB
  85747. * @returns if the bounding info intersects
  85748. */
  85749. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85750. }
  85751. }
  85752. declare module BABYLON {
  85753. /**
  85754. * Extracts minimum and maximum values from a list of indexed positions
  85755. * @param positions defines the positions to use
  85756. * @param indices defines the indices to the positions
  85757. * @param indexStart defines the start index
  85758. * @param indexCount defines the end index
  85759. * @param bias defines bias value to add to the result
  85760. * @return minimum and maximum values
  85761. */
  85762. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85763. minimum: Vector3;
  85764. maximum: Vector3;
  85765. };
  85766. /**
  85767. * Extracts minimum and maximum values from a list of positions
  85768. * @param positions defines the positions to use
  85769. * @param start defines the start index in the positions array
  85770. * @param count defines the number of positions to handle
  85771. * @param bias defines bias value to add to the result
  85772. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85773. * @return minimum and maximum values
  85774. */
  85775. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85776. minimum: Vector3;
  85777. maximum: Vector3;
  85778. };
  85779. }
  85780. declare module BABYLON {
  85781. /** @hidden */
  85782. export class WebGLDataBuffer extends DataBuffer {
  85783. private _buffer;
  85784. constructor(resource: WebGLBuffer);
  85785. get underlyingResource(): any;
  85786. }
  85787. }
  85788. declare module BABYLON {
  85789. /** @hidden */
  85790. export class WebGLPipelineContext implements IPipelineContext {
  85791. engine: ThinEngine;
  85792. program: Nullable<WebGLProgram>;
  85793. context?: WebGLRenderingContext;
  85794. vertexShader?: WebGLShader;
  85795. fragmentShader?: WebGLShader;
  85796. isParallelCompiled: boolean;
  85797. onCompiled?: () => void;
  85798. transformFeedback?: WebGLTransformFeedback | null;
  85799. vertexCompilationError: Nullable<string>;
  85800. fragmentCompilationError: Nullable<string>;
  85801. programLinkError: Nullable<string>;
  85802. programValidationError: Nullable<string>;
  85803. get isAsync(): boolean;
  85804. get isReady(): boolean;
  85805. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85806. _getVertexShaderCode(): string | null;
  85807. _getFragmentShaderCode(): string | null;
  85808. }
  85809. }
  85810. declare module BABYLON {
  85811. interface ThinEngine {
  85812. /**
  85813. * Create an uniform buffer
  85814. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85815. * @param elements defines the content of the uniform buffer
  85816. * @returns the webGL uniform buffer
  85817. */
  85818. createUniformBuffer(elements: FloatArray): DataBuffer;
  85819. /**
  85820. * Create a dynamic uniform buffer
  85821. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85822. * @param elements defines the content of the uniform buffer
  85823. * @returns the webGL uniform buffer
  85824. */
  85825. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85826. /**
  85827. * Update an existing uniform buffer
  85828. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85829. * @param uniformBuffer defines the target uniform buffer
  85830. * @param elements defines the content to update
  85831. * @param offset defines the offset in the uniform buffer where update should start
  85832. * @param count defines the size of the data to update
  85833. */
  85834. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85835. /**
  85836. * Bind an uniform buffer to the current webGL context
  85837. * @param buffer defines the buffer to bind
  85838. */
  85839. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85840. /**
  85841. * Bind a buffer to the current webGL context at a given location
  85842. * @param buffer defines the buffer to bind
  85843. * @param location defines the index where to bind the buffer
  85844. */
  85845. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85846. /**
  85847. * Bind a specific block at a given index in a specific shader program
  85848. * @param pipelineContext defines the pipeline context to use
  85849. * @param blockName defines the block name
  85850. * @param index defines the index where to bind the block
  85851. */
  85852. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85853. }
  85854. }
  85855. declare module BABYLON {
  85856. /**
  85857. * Uniform buffer objects.
  85858. *
  85859. * Handles blocks of uniform on the GPU.
  85860. *
  85861. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85862. *
  85863. * For more information, please refer to :
  85864. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85865. */
  85866. export class UniformBuffer {
  85867. private _engine;
  85868. private _buffer;
  85869. private _data;
  85870. private _bufferData;
  85871. private _dynamic?;
  85872. private _uniformLocations;
  85873. private _uniformSizes;
  85874. private _uniformLocationPointer;
  85875. private _needSync;
  85876. private _noUBO;
  85877. private _currentEffect;
  85878. /** @hidden */
  85879. _alreadyBound: boolean;
  85880. private static _MAX_UNIFORM_SIZE;
  85881. private static _tempBuffer;
  85882. /**
  85883. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85884. * This is dynamic to allow compat with webgl 1 and 2.
  85885. * You will need to pass the name of the uniform as well as the value.
  85886. */
  85887. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85888. /**
  85889. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85890. * This is dynamic to allow compat with webgl 1 and 2.
  85891. * You will need to pass the name of the uniform as well as the value.
  85892. */
  85893. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85894. /**
  85895. * Lambda to Update a single float in a uniform buffer.
  85896. * This is dynamic to allow compat with webgl 1 and 2.
  85897. * You will need to pass the name of the uniform as well as the value.
  85898. */
  85899. updateFloat: (name: string, x: number) => void;
  85900. /**
  85901. * Lambda to Update a vec2 of float in a uniform buffer.
  85902. * This is dynamic to allow compat with webgl 1 and 2.
  85903. * You will need to pass the name of the uniform as well as the value.
  85904. */
  85905. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85906. /**
  85907. * Lambda to Update a vec3 of float in a uniform buffer.
  85908. * This is dynamic to allow compat with webgl 1 and 2.
  85909. * You will need to pass the name of the uniform as well as the value.
  85910. */
  85911. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85912. /**
  85913. * Lambda to Update a vec4 of float in a uniform buffer.
  85914. * This is dynamic to allow compat with webgl 1 and 2.
  85915. * You will need to pass the name of the uniform as well as the value.
  85916. */
  85917. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85918. /**
  85919. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85920. * This is dynamic to allow compat with webgl 1 and 2.
  85921. * You will need to pass the name of the uniform as well as the value.
  85922. */
  85923. updateMatrix: (name: string, mat: Matrix) => void;
  85924. /**
  85925. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85926. * This is dynamic to allow compat with webgl 1 and 2.
  85927. * You will need to pass the name of the uniform as well as the value.
  85928. */
  85929. updateVector3: (name: string, vector: Vector3) => void;
  85930. /**
  85931. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85932. * This is dynamic to allow compat with webgl 1 and 2.
  85933. * You will need to pass the name of the uniform as well as the value.
  85934. */
  85935. updateVector4: (name: string, vector: Vector4) => void;
  85936. /**
  85937. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85938. * This is dynamic to allow compat with webgl 1 and 2.
  85939. * You will need to pass the name of the uniform as well as the value.
  85940. */
  85941. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85942. /**
  85943. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85944. * This is dynamic to allow compat with webgl 1 and 2.
  85945. * You will need to pass the name of the uniform as well as the value.
  85946. */
  85947. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85948. /**
  85949. * Instantiates a new Uniform buffer objects.
  85950. *
  85951. * Handles blocks of uniform on the GPU.
  85952. *
  85953. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85954. *
  85955. * For more information, please refer to :
  85956. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85957. * @param engine Define the engine the buffer is associated with
  85958. * @param data Define the data contained in the buffer
  85959. * @param dynamic Define if the buffer is updatable
  85960. */
  85961. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85962. /**
  85963. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85964. * or just falling back on setUniformXXX calls.
  85965. */
  85966. get useUbo(): boolean;
  85967. /**
  85968. * Indicates if the WebGL underlying uniform buffer is in sync
  85969. * with the javascript cache data.
  85970. */
  85971. get isSync(): boolean;
  85972. /**
  85973. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85974. * Also, a dynamic UniformBuffer will disable cache verification and always
  85975. * update the underlying WebGL uniform buffer to the GPU.
  85976. * @returns if Dynamic, otherwise false
  85977. */
  85978. isDynamic(): boolean;
  85979. /**
  85980. * The data cache on JS side.
  85981. * @returns the underlying data as a float array
  85982. */
  85983. getData(): Float32Array;
  85984. /**
  85985. * The underlying WebGL Uniform buffer.
  85986. * @returns the webgl buffer
  85987. */
  85988. getBuffer(): Nullable<DataBuffer>;
  85989. /**
  85990. * std140 layout specifies how to align data within an UBO structure.
  85991. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85992. * for specs.
  85993. */
  85994. private _fillAlignment;
  85995. /**
  85996. * Adds an uniform in the buffer.
  85997. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85998. * for the layout to be correct !
  85999. * @param name Name of the uniform, as used in the uniform block in the shader.
  86000. * @param size Data size, or data directly.
  86001. */
  86002. addUniform(name: string, size: number | number[]): void;
  86003. /**
  86004. * Adds a Matrix 4x4 to the uniform buffer.
  86005. * @param name Name of the uniform, as used in the uniform block in the shader.
  86006. * @param mat A 4x4 matrix.
  86007. */
  86008. addMatrix(name: string, mat: Matrix): void;
  86009. /**
  86010. * Adds a vec2 to the uniform buffer.
  86011. * @param name Name of the uniform, as used in the uniform block in the shader.
  86012. * @param x Define the x component value of the vec2
  86013. * @param y Define the y component value of the vec2
  86014. */
  86015. addFloat2(name: string, x: number, y: number): void;
  86016. /**
  86017. * Adds a vec3 to the uniform buffer.
  86018. * @param name Name of the uniform, as used in the uniform block in the shader.
  86019. * @param x Define the x component value of the vec3
  86020. * @param y Define the y component value of the vec3
  86021. * @param z Define the z component value of the vec3
  86022. */
  86023. addFloat3(name: string, x: number, y: number, z: number): void;
  86024. /**
  86025. * Adds a vec3 to the uniform buffer.
  86026. * @param name Name of the uniform, as used in the uniform block in the shader.
  86027. * @param color Define the vec3 from a Color
  86028. */
  86029. addColor3(name: string, color: Color3): void;
  86030. /**
  86031. * Adds a vec4 to the uniform buffer.
  86032. * @param name Name of the uniform, as used in the uniform block in the shader.
  86033. * @param color Define the rgb components from a Color
  86034. * @param alpha Define the a component of the vec4
  86035. */
  86036. addColor4(name: string, color: Color3, alpha: number): void;
  86037. /**
  86038. * Adds a vec3 to the uniform buffer.
  86039. * @param name Name of the uniform, as used in the uniform block in the shader.
  86040. * @param vector Define the vec3 components from a Vector
  86041. */
  86042. addVector3(name: string, vector: Vector3): void;
  86043. /**
  86044. * Adds a Matrix 3x3 to the uniform buffer.
  86045. * @param name Name of the uniform, as used in the uniform block in the shader.
  86046. */
  86047. addMatrix3x3(name: string): void;
  86048. /**
  86049. * Adds a Matrix 2x2 to the uniform buffer.
  86050. * @param name Name of the uniform, as used in the uniform block in the shader.
  86051. */
  86052. addMatrix2x2(name: string): void;
  86053. /**
  86054. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86055. */
  86056. create(): void;
  86057. /** @hidden */
  86058. _rebuild(): void;
  86059. /**
  86060. * Updates the WebGL Uniform Buffer on the GPU.
  86061. * If the `dynamic` flag is set to true, no cache comparison is done.
  86062. * Otherwise, the buffer will be updated only if the cache differs.
  86063. */
  86064. update(): void;
  86065. /**
  86066. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86067. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86068. * @param data Define the flattened data
  86069. * @param size Define the size of the data.
  86070. */
  86071. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86072. private _valueCache;
  86073. private _cacheMatrix;
  86074. private _updateMatrix3x3ForUniform;
  86075. private _updateMatrix3x3ForEffect;
  86076. private _updateMatrix2x2ForEffect;
  86077. private _updateMatrix2x2ForUniform;
  86078. private _updateFloatForEffect;
  86079. private _updateFloatForUniform;
  86080. private _updateFloat2ForEffect;
  86081. private _updateFloat2ForUniform;
  86082. private _updateFloat3ForEffect;
  86083. private _updateFloat3ForUniform;
  86084. private _updateFloat4ForEffect;
  86085. private _updateFloat4ForUniform;
  86086. private _updateMatrixForEffect;
  86087. private _updateMatrixForUniform;
  86088. private _updateVector3ForEffect;
  86089. private _updateVector3ForUniform;
  86090. private _updateVector4ForEffect;
  86091. private _updateVector4ForUniform;
  86092. private _updateColor3ForEffect;
  86093. private _updateColor3ForUniform;
  86094. private _updateColor4ForEffect;
  86095. private _updateColor4ForUniform;
  86096. /**
  86097. * Sets a sampler uniform on the effect.
  86098. * @param name Define the name of the sampler.
  86099. * @param texture Define the texture to set in the sampler
  86100. */
  86101. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86102. /**
  86103. * Directly updates the value of the uniform in the cache AND on the GPU.
  86104. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86105. * @param data Define the flattened data
  86106. */
  86107. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86108. /**
  86109. * Binds this uniform buffer to an effect.
  86110. * @param effect Define the effect to bind the buffer to
  86111. * @param name Name of the uniform block in the shader.
  86112. */
  86113. bindToEffect(effect: Effect, name: string): void;
  86114. /**
  86115. * Disposes the uniform buffer.
  86116. */
  86117. dispose(): void;
  86118. }
  86119. }
  86120. declare module BABYLON {
  86121. /**
  86122. * Enum that determines the text-wrapping mode to use.
  86123. */
  86124. export enum InspectableType {
  86125. /**
  86126. * Checkbox for booleans
  86127. */
  86128. Checkbox = 0,
  86129. /**
  86130. * Sliders for numbers
  86131. */
  86132. Slider = 1,
  86133. /**
  86134. * Vector3
  86135. */
  86136. Vector3 = 2,
  86137. /**
  86138. * Quaternions
  86139. */
  86140. Quaternion = 3,
  86141. /**
  86142. * Color3
  86143. */
  86144. Color3 = 4,
  86145. /**
  86146. * String
  86147. */
  86148. String = 5
  86149. }
  86150. /**
  86151. * Interface used to define custom inspectable properties.
  86152. * This interface is used by the inspector to display custom property grids
  86153. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86154. */
  86155. export interface IInspectable {
  86156. /**
  86157. * Gets the label to display
  86158. */
  86159. label: string;
  86160. /**
  86161. * Gets the name of the property to edit
  86162. */
  86163. propertyName: string;
  86164. /**
  86165. * Gets the type of the editor to use
  86166. */
  86167. type: InspectableType;
  86168. /**
  86169. * Gets the minimum value of the property when using in "slider" mode
  86170. */
  86171. min?: number;
  86172. /**
  86173. * Gets the maximum value of the property when using in "slider" mode
  86174. */
  86175. max?: number;
  86176. /**
  86177. * Gets the setp to use when using in "slider" mode
  86178. */
  86179. step?: number;
  86180. }
  86181. }
  86182. declare module BABYLON {
  86183. /**
  86184. * Class used to provide helper for timing
  86185. */
  86186. export class TimingTools {
  86187. /**
  86188. * Polyfill for setImmediate
  86189. * @param action defines the action to execute after the current execution block
  86190. */
  86191. static SetImmediate(action: () => void): void;
  86192. }
  86193. }
  86194. declare module BABYLON {
  86195. /**
  86196. * Class used to enable instatition of objects by class name
  86197. */
  86198. export class InstantiationTools {
  86199. /**
  86200. * Use this object to register external classes like custom textures or material
  86201. * to allow the laoders to instantiate them
  86202. */
  86203. static RegisteredExternalClasses: {
  86204. [key: string]: Object;
  86205. };
  86206. /**
  86207. * Tries to instantiate a new object from a given class name
  86208. * @param className defines the class name to instantiate
  86209. * @returns the new object or null if the system was not able to do the instantiation
  86210. */
  86211. static Instantiate(className: string): any;
  86212. }
  86213. }
  86214. declare module BABYLON {
  86215. /**
  86216. * Define options used to create a depth texture
  86217. */
  86218. export class DepthTextureCreationOptions {
  86219. /** Specifies whether or not a stencil should be allocated in the texture */
  86220. generateStencil?: boolean;
  86221. /** Specifies whether or not bilinear filtering is enable on the texture */
  86222. bilinearFiltering?: boolean;
  86223. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86224. comparisonFunction?: number;
  86225. /** Specifies if the created texture is a cube texture */
  86226. isCube?: boolean;
  86227. }
  86228. }
  86229. declare module BABYLON {
  86230. interface ThinEngine {
  86231. /**
  86232. * Creates a depth stencil cube texture.
  86233. * This is only available in WebGL 2.
  86234. * @param size The size of face edge in the cube texture.
  86235. * @param options The options defining the cube texture.
  86236. * @returns The cube texture
  86237. */
  86238. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86239. /**
  86240. * Creates a cube texture
  86241. * @param rootUrl defines the url where the files to load is located
  86242. * @param scene defines the current scene
  86243. * @param files defines the list of files to load (1 per face)
  86244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86245. * @param onLoad defines an optional callback raised when the texture is loaded
  86246. * @param onError defines an optional callback raised if there is an issue to load the texture
  86247. * @param format defines the format of the data
  86248. * @param forcedExtension defines the extension to use to pick the right loader
  86249. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86250. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86251. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86252. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86253. * @returns the cube texture as an InternalTexture
  86254. */
  86255. 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>): InternalTexture;
  86256. /**
  86257. * Creates a cube texture
  86258. * @param rootUrl defines the url where the files to load is located
  86259. * @param scene defines the current scene
  86260. * @param files defines the list of files to load (1 per face)
  86261. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86262. * @param onLoad defines an optional callback raised when the texture is loaded
  86263. * @param onError defines an optional callback raised if there is an issue to load the texture
  86264. * @param format defines the format of the data
  86265. * @param forcedExtension defines the extension to use to pick the right loader
  86266. * @returns the cube texture as an InternalTexture
  86267. */
  86268. 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;
  86269. /**
  86270. * Creates a cube texture
  86271. * @param rootUrl defines the url where the files to load is located
  86272. * @param scene defines the current scene
  86273. * @param files defines the list of files to load (1 per face)
  86274. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86275. * @param onLoad defines an optional callback raised when the texture is loaded
  86276. * @param onError defines an optional callback raised if there is an issue to load the texture
  86277. * @param format defines the format of the data
  86278. * @param forcedExtension defines the extension to use to pick the right loader
  86279. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86280. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86281. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86282. * @returns the cube texture as an InternalTexture
  86283. */
  86284. 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;
  86285. /** @hidden */
  86286. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86287. /** @hidden */
  86288. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86289. /** @hidden */
  86290. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86291. /** @hidden */
  86292. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86293. /**
  86294. * @hidden
  86295. */
  86296. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86297. }
  86298. }
  86299. declare module BABYLON {
  86300. /**
  86301. * Class for creating a cube texture
  86302. */
  86303. export class CubeTexture extends BaseTexture {
  86304. private _delayedOnLoad;
  86305. /**
  86306. * Observable triggered once the texture has been loaded.
  86307. */
  86308. onLoadObservable: Observable<CubeTexture>;
  86309. /**
  86310. * The url of the texture
  86311. */
  86312. url: string;
  86313. /**
  86314. * Gets or sets the center of the bounding box associated with the cube texture.
  86315. * It must define where the camera used to render the texture was set
  86316. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86317. */
  86318. boundingBoxPosition: Vector3;
  86319. private _boundingBoxSize;
  86320. /**
  86321. * Gets or sets the size of the bounding box associated with the cube texture
  86322. * When defined, the cubemap will switch to local mode
  86323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86324. * @example https://www.babylonjs-playground.com/#RNASML
  86325. */
  86326. set boundingBoxSize(value: Vector3);
  86327. /**
  86328. * Returns the bounding box size
  86329. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86330. */
  86331. get boundingBoxSize(): Vector3;
  86332. protected _rotationY: number;
  86333. /**
  86334. * Sets texture matrix rotation angle around Y axis in radians.
  86335. */
  86336. set rotationY(value: number);
  86337. /**
  86338. * Gets texture matrix rotation angle around Y axis radians.
  86339. */
  86340. get rotationY(): number;
  86341. /**
  86342. * Are mip maps generated for this texture or not.
  86343. */
  86344. get noMipmap(): boolean;
  86345. private _noMipmap;
  86346. private _files;
  86347. protected _forcedExtension: Nullable<string>;
  86348. private _extensions;
  86349. private _textureMatrix;
  86350. private _format;
  86351. private _createPolynomials;
  86352. /**
  86353. * Creates a cube texture from an array of image urls
  86354. * @param files defines an array of image urls
  86355. * @param scene defines the hosting scene
  86356. * @param noMipmap specifies if mip maps are not used
  86357. * @returns a cube texture
  86358. */
  86359. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86360. /**
  86361. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86362. * @param url defines the url of the prefiltered texture
  86363. * @param scene defines the scene the texture is attached to
  86364. * @param forcedExtension defines the extension of the file if different from the url
  86365. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86366. * @return the prefiltered texture
  86367. */
  86368. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86369. /**
  86370. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86371. * as prefiltered data.
  86372. * @param rootUrl defines the url of the texture or the root name of the six images
  86373. * @param null defines the scene or engine the texture is attached to
  86374. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86375. * @param noMipmap defines if mipmaps should be created or not
  86376. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86377. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86378. * @param onError defines a callback triggered in case of error during load
  86379. * @param format defines the internal format to use for the texture once loaded
  86380. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86381. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86382. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86383. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86384. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86385. * @return the cube texture
  86386. */
  86387. 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);
  86388. /**
  86389. * Get the current class name of the texture useful for serialization or dynamic coding.
  86390. * @returns "CubeTexture"
  86391. */
  86392. getClassName(): string;
  86393. /**
  86394. * Update the url (and optional buffer) of this texture if url was null during construction.
  86395. * @param url the url of the texture
  86396. * @param forcedExtension defines the extension to use
  86397. * @param onLoad callback called when the texture is loaded (defaults to null)
  86398. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86399. */
  86400. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86401. /**
  86402. * Delays loading of the cube texture
  86403. * @param forcedExtension defines the extension to use
  86404. */
  86405. delayLoad(forcedExtension?: string): void;
  86406. /**
  86407. * Returns the reflection texture matrix
  86408. * @returns the reflection texture matrix
  86409. */
  86410. getReflectionTextureMatrix(): Matrix;
  86411. /**
  86412. * Sets the reflection texture matrix
  86413. * @param value Reflection texture matrix
  86414. */
  86415. setReflectionTextureMatrix(value: Matrix): void;
  86416. /**
  86417. * Parses text to create a cube texture
  86418. * @param parsedTexture define the serialized text to read from
  86419. * @param scene defines the hosting scene
  86420. * @param rootUrl defines the root url of the cube texture
  86421. * @returns a cube texture
  86422. */
  86423. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86424. /**
  86425. * Makes a clone, or deep copy, of the cube texture
  86426. * @returns a new cube texture
  86427. */
  86428. clone(): CubeTexture;
  86429. }
  86430. }
  86431. declare module BABYLON {
  86432. /**
  86433. * Manages the defines for the Material
  86434. */
  86435. export class MaterialDefines {
  86436. /** @hidden */
  86437. protected _keys: string[];
  86438. private _isDirty;
  86439. /** @hidden */
  86440. _renderId: number;
  86441. /** @hidden */
  86442. _areLightsDirty: boolean;
  86443. /** @hidden */
  86444. _areLightsDisposed: boolean;
  86445. /** @hidden */
  86446. _areAttributesDirty: boolean;
  86447. /** @hidden */
  86448. _areTexturesDirty: boolean;
  86449. /** @hidden */
  86450. _areFresnelDirty: boolean;
  86451. /** @hidden */
  86452. _areMiscDirty: boolean;
  86453. /** @hidden */
  86454. _areImageProcessingDirty: boolean;
  86455. /** @hidden */
  86456. _normals: boolean;
  86457. /** @hidden */
  86458. _uvs: boolean;
  86459. /** @hidden */
  86460. _needNormals: boolean;
  86461. /** @hidden */
  86462. _needUVs: boolean;
  86463. [id: string]: any;
  86464. /**
  86465. * Specifies if the material needs to be re-calculated
  86466. */
  86467. get isDirty(): boolean;
  86468. /**
  86469. * Marks the material to indicate that it has been re-calculated
  86470. */
  86471. markAsProcessed(): void;
  86472. /**
  86473. * Marks the material to indicate that it needs to be re-calculated
  86474. */
  86475. markAsUnprocessed(): void;
  86476. /**
  86477. * Marks the material to indicate all of its defines need to be re-calculated
  86478. */
  86479. markAllAsDirty(): void;
  86480. /**
  86481. * Marks the material to indicate that image processing needs to be re-calculated
  86482. */
  86483. markAsImageProcessingDirty(): void;
  86484. /**
  86485. * Marks the material to indicate the lights need to be re-calculated
  86486. * @param disposed Defines whether the light is dirty due to dispose or not
  86487. */
  86488. markAsLightDirty(disposed?: boolean): void;
  86489. /**
  86490. * Marks the attribute state as changed
  86491. */
  86492. markAsAttributesDirty(): void;
  86493. /**
  86494. * Marks the texture state as changed
  86495. */
  86496. markAsTexturesDirty(): void;
  86497. /**
  86498. * Marks the fresnel state as changed
  86499. */
  86500. markAsFresnelDirty(): void;
  86501. /**
  86502. * Marks the misc state as changed
  86503. */
  86504. markAsMiscDirty(): void;
  86505. /**
  86506. * Rebuilds the material defines
  86507. */
  86508. rebuild(): void;
  86509. /**
  86510. * Specifies if two material defines are equal
  86511. * @param other - A material define instance to compare to
  86512. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86513. */
  86514. isEqual(other: MaterialDefines): boolean;
  86515. /**
  86516. * Clones this instance's defines to another instance
  86517. * @param other - material defines to clone values to
  86518. */
  86519. cloneTo(other: MaterialDefines): void;
  86520. /**
  86521. * Resets the material define values
  86522. */
  86523. reset(): void;
  86524. /**
  86525. * Converts the material define values to a string
  86526. * @returns - String of material define information
  86527. */
  86528. toString(): string;
  86529. }
  86530. }
  86531. declare module BABYLON {
  86532. /**
  86533. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86534. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86535. * 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;
  86536. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86537. */
  86538. export class ColorCurves {
  86539. private _dirty;
  86540. private _tempColor;
  86541. private _globalCurve;
  86542. private _highlightsCurve;
  86543. private _midtonesCurve;
  86544. private _shadowsCurve;
  86545. private _positiveCurve;
  86546. private _negativeCurve;
  86547. private _globalHue;
  86548. private _globalDensity;
  86549. private _globalSaturation;
  86550. private _globalExposure;
  86551. /**
  86552. * Gets the global Hue value.
  86553. * 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).
  86554. */
  86555. get globalHue(): number;
  86556. /**
  86557. * Sets the global Hue value.
  86558. * 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).
  86559. */
  86560. set globalHue(value: number);
  86561. /**
  86562. * Gets the global Density value.
  86563. * 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.
  86564. * Values less than zero provide a filter of opposite hue.
  86565. */
  86566. get globalDensity(): number;
  86567. /**
  86568. * Sets the global Density value.
  86569. * 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.
  86570. * Values less than zero provide a filter of opposite hue.
  86571. */
  86572. set globalDensity(value: number);
  86573. /**
  86574. * Gets the global Saturation value.
  86575. * 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.
  86576. */
  86577. get globalSaturation(): number;
  86578. /**
  86579. * Sets the global Saturation value.
  86580. * 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.
  86581. */
  86582. set globalSaturation(value: number);
  86583. /**
  86584. * Gets the global Exposure value.
  86585. * 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.
  86586. */
  86587. get globalExposure(): number;
  86588. /**
  86589. * Sets the global Exposure value.
  86590. * 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.
  86591. */
  86592. set globalExposure(value: number);
  86593. private _highlightsHue;
  86594. private _highlightsDensity;
  86595. private _highlightsSaturation;
  86596. private _highlightsExposure;
  86597. /**
  86598. * Gets the highlights Hue value.
  86599. * 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).
  86600. */
  86601. get highlightsHue(): number;
  86602. /**
  86603. * Sets the highlights Hue value.
  86604. * 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).
  86605. */
  86606. set highlightsHue(value: number);
  86607. /**
  86608. * Gets the highlights Density value.
  86609. * 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.
  86610. * Values less than zero provide a filter of opposite hue.
  86611. */
  86612. get highlightsDensity(): number;
  86613. /**
  86614. * Sets the highlights Density value.
  86615. * 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.
  86616. * Values less than zero provide a filter of opposite hue.
  86617. */
  86618. set highlightsDensity(value: number);
  86619. /**
  86620. * Gets the highlights Saturation value.
  86621. * 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.
  86622. */
  86623. get highlightsSaturation(): number;
  86624. /**
  86625. * Sets the highlights Saturation value.
  86626. * 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.
  86627. */
  86628. set highlightsSaturation(value: number);
  86629. /**
  86630. * Gets the highlights Exposure value.
  86631. * 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.
  86632. */
  86633. get highlightsExposure(): number;
  86634. /**
  86635. * Sets the highlights Exposure value.
  86636. * 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.
  86637. */
  86638. set highlightsExposure(value: number);
  86639. private _midtonesHue;
  86640. private _midtonesDensity;
  86641. private _midtonesSaturation;
  86642. private _midtonesExposure;
  86643. /**
  86644. * Gets the midtones Hue value.
  86645. * 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).
  86646. */
  86647. get midtonesHue(): number;
  86648. /**
  86649. * Sets the midtones Hue value.
  86650. * 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).
  86651. */
  86652. set midtonesHue(value: number);
  86653. /**
  86654. * Gets the midtones Density value.
  86655. * 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.
  86656. * Values less than zero provide a filter of opposite hue.
  86657. */
  86658. get midtonesDensity(): number;
  86659. /**
  86660. * Sets the midtones Density value.
  86661. * 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.
  86662. * Values less than zero provide a filter of opposite hue.
  86663. */
  86664. set midtonesDensity(value: number);
  86665. /**
  86666. * Gets the midtones Saturation value.
  86667. * 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.
  86668. */
  86669. get midtonesSaturation(): number;
  86670. /**
  86671. * Sets the midtones Saturation value.
  86672. * 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.
  86673. */
  86674. set midtonesSaturation(value: number);
  86675. /**
  86676. * Gets the midtones Exposure value.
  86677. * 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.
  86678. */
  86679. get midtonesExposure(): number;
  86680. /**
  86681. * Sets the midtones Exposure value.
  86682. * 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.
  86683. */
  86684. set midtonesExposure(value: number);
  86685. private _shadowsHue;
  86686. private _shadowsDensity;
  86687. private _shadowsSaturation;
  86688. private _shadowsExposure;
  86689. /**
  86690. * Gets the shadows Hue value.
  86691. * 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).
  86692. */
  86693. get shadowsHue(): number;
  86694. /**
  86695. * Sets the shadows Hue value.
  86696. * 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).
  86697. */
  86698. set shadowsHue(value: number);
  86699. /**
  86700. * Gets the shadows Density value.
  86701. * 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.
  86702. * Values less than zero provide a filter of opposite hue.
  86703. */
  86704. get shadowsDensity(): number;
  86705. /**
  86706. * Sets the shadows Density value.
  86707. * 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.
  86708. * Values less than zero provide a filter of opposite hue.
  86709. */
  86710. set shadowsDensity(value: number);
  86711. /**
  86712. * Gets the shadows Saturation value.
  86713. * 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.
  86714. */
  86715. get shadowsSaturation(): number;
  86716. /**
  86717. * Sets the shadows Saturation value.
  86718. * 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.
  86719. */
  86720. set shadowsSaturation(value: number);
  86721. /**
  86722. * Gets the shadows Exposure value.
  86723. * 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.
  86724. */
  86725. get shadowsExposure(): number;
  86726. /**
  86727. * Sets the shadows Exposure value.
  86728. * 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.
  86729. */
  86730. set shadowsExposure(value: number);
  86731. /**
  86732. * Returns the class name
  86733. * @returns The class name
  86734. */
  86735. getClassName(): string;
  86736. /**
  86737. * Binds the color curves to the shader.
  86738. * @param colorCurves The color curve to bind
  86739. * @param effect The effect to bind to
  86740. * @param positiveUniform The positive uniform shader parameter
  86741. * @param neutralUniform The neutral uniform shader parameter
  86742. * @param negativeUniform The negative uniform shader parameter
  86743. */
  86744. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86745. /**
  86746. * Prepare the list of uniforms associated with the ColorCurves effects.
  86747. * @param uniformsList The list of uniforms used in the effect
  86748. */
  86749. static PrepareUniforms(uniformsList: string[]): void;
  86750. /**
  86751. * Returns color grading data based on a hue, density, saturation and exposure value.
  86752. * @param filterHue The hue of the color filter.
  86753. * @param filterDensity The density of the color filter.
  86754. * @param saturation The saturation.
  86755. * @param exposure The exposure.
  86756. * @param result The result data container.
  86757. */
  86758. private getColorGradingDataToRef;
  86759. /**
  86760. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86761. * @param value The input slider value in range [-100,100].
  86762. * @returns Adjusted value.
  86763. */
  86764. private static applyColorGradingSliderNonlinear;
  86765. /**
  86766. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86767. * @param hue The hue (H) input.
  86768. * @param saturation The saturation (S) input.
  86769. * @param brightness The brightness (B) input.
  86770. * @result An RGBA color represented as Vector4.
  86771. */
  86772. private static fromHSBToRef;
  86773. /**
  86774. * Returns a value clamped between min and max
  86775. * @param value The value to clamp
  86776. * @param min The minimum of value
  86777. * @param max The maximum of value
  86778. * @returns The clamped value.
  86779. */
  86780. private static clamp;
  86781. /**
  86782. * Clones the current color curve instance.
  86783. * @return The cloned curves
  86784. */
  86785. clone(): ColorCurves;
  86786. /**
  86787. * Serializes the current color curve instance to a json representation.
  86788. * @return a JSON representation
  86789. */
  86790. serialize(): any;
  86791. /**
  86792. * Parses the color curve from a json representation.
  86793. * @param source the JSON source to parse
  86794. * @return The parsed curves
  86795. */
  86796. static Parse(source: any): ColorCurves;
  86797. }
  86798. }
  86799. declare module BABYLON {
  86800. /**
  86801. * Interface to follow in your material defines to integrate easily the
  86802. * Image proccessing functions.
  86803. * @hidden
  86804. */
  86805. export interface IImageProcessingConfigurationDefines {
  86806. IMAGEPROCESSING: boolean;
  86807. VIGNETTE: boolean;
  86808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86809. VIGNETTEBLENDMODEOPAQUE: boolean;
  86810. TONEMAPPING: boolean;
  86811. TONEMAPPING_ACES: boolean;
  86812. CONTRAST: boolean;
  86813. EXPOSURE: boolean;
  86814. COLORCURVES: boolean;
  86815. COLORGRADING: boolean;
  86816. COLORGRADING3D: boolean;
  86817. SAMPLER3DGREENDEPTH: boolean;
  86818. SAMPLER3DBGRMAP: boolean;
  86819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86820. }
  86821. /**
  86822. * @hidden
  86823. */
  86824. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86825. IMAGEPROCESSING: boolean;
  86826. VIGNETTE: boolean;
  86827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86828. VIGNETTEBLENDMODEOPAQUE: boolean;
  86829. TONEMAPPING: boolean;
  86830. TONEMAPPING_ACES: boolean;
  86831. CONTRAST: boolean;
  86832. COLORCURVES: boolean;
  86833. COLORGRADING: boolean;
  86834. COLORGRADING3D: boolean;
  86835. SAMPLER3DGREENDEPTH: boolean;
  86836. SAMPLER3DBGRMAP: boolean;
  86837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86838. EXPOSURE: boolean;
  86839. constructor();
  86840. }
  86841. /**
  86842. * This groups together the common properties used for image processing either in direct forward pass
  86843. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86844. * or not.
  86845. */
  86846. export class ImageProcessingConfiguration {
  86847. /**
  86848. * Default tone mapping applied in BabylonJS.
  86849. */
  86850. static readonly TONEMAPPING_STANDARD: number;
  86851. /**
  86852. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86853. * to other engines rendering to increase portability.
  86854. */
  86855. static readonly TONEMAPPING_ACES: number;
  86856. /**
  86857. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86858. */
  86859. colorCurves: Nullable<ColorCurves>;
  86860. private _colorCurvesEnabled;
  86861. /**
  86862. * Gets wether the color curves effect is enabled.
  86863. */
  86864. get colorCurvesEnabled(): boolean;
  86865. /**
  86866. * Sets wether the color curves effect is enabled.
  86867. */
  86868. set colorCurvesEnabled(value: boolean);
  86869. private _colorGradingTexture;
  86870. /**
  86871. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86872. */
  86873. get colorGradingTexture(): Nullable<BaseTexture>;
  86874. /**
  86875. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86876. */
  86877. set colorGradingTexture(value: Nullable<BaseTexture>);
  86878. private _colorGradingEnabled;
  86879. /**
  86880. * Gets wether the color grading effect is enabled.
  86881. */
  86882. get colorGradingEnabled(): boolean;
  86883. /**
  86884. * Sets wether the color grading effect is enabled.
  86885. */
  86886. set colorGradingEnabled(value: boolean);
  86887. private _colorGradingWithGreenDepth;
  86888. /**
  86889. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86890. */
  86891. get colorGradingWithGreenDepth(): boolean;
  86892. /**
  86893. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86894. */
  86895. set colorGradingWithGreenDepth(value: boolean);
  86896. private _colorGradingBGR;
  86897. /**
  86898. * Gets wether the color grading texture contains BGR values.
  86899. */
  86900. get colorGradingBGR(): boolean;
  86901. /**
  86902. * Sets wether the color grading texture contains BGR values.
  86903. */
  86904. set colorGradingBGR(value: boolean);
  86905. /** @hidden */
  86906. _exposure: number;
  86907. /**
  86908. * Gets the Exposure used in the effect.
  86909. */
  86910. get exposure(): number;
  86911. /**
  86912. * Sets the Exposure used in the effect.
  86913. */
  86914. set exposure(value: number);
  86915. private _toneMappingEnabled;
  86916. /**
  86917. * Gets wether the tone mapping effect is enabled.
  86918. */
  86919. get toneMappingEnabled(): boolean;
  86920. /**
  86921. * Sets wether the tone mapping effect is enabled.
  86922. */
  86923. set toneMappingEnabled(value: boolean);
  86924. private _toneMappingType;
  86925. /**
  86926. * Gets the type of tone mapping effect.
  86927. */
  86928. get toneMappingType(): number;
  86929. /**
  86930. * Sets the type of tone mapping effect used in BabylonJS.
  86931. */
  86932. set toneMappingType(value: number);
  86933. protected _contrast: number;
  86934. /**
  86935. * Gets the contrast used in the effect.
  86936. */
  86937. get contrast(): number;
  86938. /**
  86939. * Sets the contrast used in the effect.
  86940. */
  86941. set contrast(value: number);
  86942. /**
  86943. * Vignette stretch size.
  86944. */
  86945. vignetteStretch: number;
  86946. /**
  86947. * Vignette centre X Offset.
  86948. */
  86949. vignetteCentreX: number;
  86950. /**
  86951. * Vignette centre Y Offset.
  86952. */
  86953. vignetteCentreY: number;
  86954. /**
  86955. * Vignette weight or intensity of the vignette effect.
  86956. */
  86957. vignetteWeight: number;
  86958. /**
  86959. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86960. * if vignetteEnabled is set to true.
  86961. */
  86962. vignetteColor: Color4;
  86963. /**
  86964. * Camera field of view used by the Vignette effect.
  86965. */
  86966. vignetteCameraFov: number;
  86967. private _vignetteBlendMode;
  86968. /**
  86969. * Gets the vignette blend mode allowing different kind of effect.
  86970. */
  86971. get vignetteBlendMode(): number;
  86972. /**
  86973. * Sets the vignette blend mode allowing different kind of effect.
  86974. */
  86975. set vignetteBlendMode(value: number);
  86976. private _vignetteEnabled;
  86977. /**
  86978. * Gets wether the vignette effect is enabled.
  86979. */
  86980. get vignetteEnabled(): boolean;
  86981. /**
  86982. * Sets wether the vignette effect is enabled.
  86983. */
  86984. set vignetteEnabled(value: boolean);
  86985. private _applyByPostProcess;
  86986. /**
  86987. * Gets wether the image processing is applied through a post process or not.
  86988. */
  86989. get applyByPostProcess(): boolean;
  86990. /**
  86991. * Sets wether the image processing is applied through a post process or not.
  86992. */
  86993. set applyByPostProcess(value: boolean);
  86994. private _isEnabled;
  86995. /**
  86996. * Gets wether the image processing is enabled or not.
  86997. */
  86998. get isEnabled(): boolean;
  86999. /**
  87000. * Sets wether the image processing is enabled or not.
  87001. */
  87002. set isEnabled(value: boolean);
  87003. /**
  87004. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87005. */
  87006. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87007. /**
  87008. * Method called each time the image processing information changes requires to recompile the effect.
  87009. */
  87010. protected _updateParameters(): void;
  87011. /**
  87012. * Gets the current class name.
  87013. * @return "ImageProcessingConfiguration"
  87014. */
  87015. getClassName(): string;
  87016. /**
  87017. * Prepare the list of uniforms associated with the Image Processing effects.
  87018. * @param uniforms The list of uniforms used in the effect
  87019. * @param defines the list of defines currently in use
  87020. */
  87021. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87022. /**
  87023. * Prepare the list of samplers associated with the Image Processing effects.
  87024. * @param samplersList The list of uniforms used in the effect
  87025. * @param defines the list of defines currently in use
  87026. */
  87027. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87028. /**
  87029. * Prepare the list of defines associated to the shader.
  87030. * @param defines the list of defines to complete
  87031. * @param forPostProcess Define if we are currently in post process mode or not
  87032. */
  87033. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87034. /**
  87035. * Returns true if all the image processing information are ready.
  87036. * @returns True if ready, otherwise, false
  87037. */
  87038. isReady(): boolean;
  87039. /**
  87040. * Binds the image processing to the shader.
  87041. * @param effect The effect to bind to
  87042. * @param overrideAspectRatio Override the aspect ratio of the effect
  87043. */
  87044. bind(effect: Effect, overrideAspectRatio?: number): void;
  87045. /**
  87046. * Clones the current image processing instance.
  87047. * @return The cloned image processing
  87048. */
  87049. clone(): ImageProcessingConfiguration;
  87050. /**
  87051. * Serializes the current image processing instance to a json representation.
  87052. * @return a JSON representation
  87053. */
  87054. serialize(): any;
  87055. /**
  87056. * Parses the image processing from a json representation.
  87057. * @param source the JSON source to parse
  87058. * @return The parsed image processing
  87059. */
  87060. static Parse(source: any): ImageProcessingConfiguration;
  87061. private static _VIGNETTEMODE_MULTIPLY;
  87062. private static _VIGNETTEMODE_OPAQUE;
  87063. /**
  87064. * Used to apply the vignette as a mix with the pixel color.
  87065. */
  87066. static get VIGNETTEMODE_MULTIPLY(): number;
  87067. /**
  87068. * Used to apply the vignette as a replacement of the pixel color.
  87069. */
  87070. static get VIGNETTEMODE_OPAQUE(): number;
  87071. }
  87072. }
  87073. declare module BABYLON {
  87074. /** @hidden */
  87075. export var postprocessVertexShader: {
  87076. name: string;
  87077. shader: string;
  87078. };
  87079. }
  87080. declare module BABYLON {
  87081. interface ThinEngine {
  87082. /**
  87083. * Creates a new render target texture
  87084. * @param size defines the size of the texture
  87085. * @param options defines the options used to create the texture
  87086. * @returns a new render target texture stored in an InternalTexture
  87087. */
  87088. createRenderTargetTexture(size: number | {
  87089. width: number;
  87090. height: number;
  87091. layers?: number;
  87092. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87093. /**
  87094. * Creates a depth stencil texture.
  87095. * This is only available in WebGL 2 or with the depth texture extension available.
  87096. * @param size The size of face edge in the texture.
  87097. * @param options The options defining the texture.
  87098. * @returns The texture
  87099. */
  87100. createDepthStencilTexture(size: number | {
  87101. width: number;
  87102. height: number;
  87103. layers?: number;
  87104. }, options: DepthTextureCreationOptions): InternalTexture;
  87105. /** @hidden */
  87106. _createDepthStencilTexture(size: number | {
  87107. width: number;
  87108. height: number;
  87109. layers?: number;
  87110. }, options: DepthTextureCreationOptions): InternalTexture;
  87111. }
  87112. }
  87113. declare module BABYLON {
  87114. /**
  87115. * Defines the kind of connection point for node based material
  87116. */
  87117. export enum NodeMaterialBlockConnectionPointTypes {
  87118. /** Float */
  87119. Float = 1,
  87120. /** Int */
  87121. Int = 2,
  87122. /** Vector2 */
  87123. Vector2 = 4,
  87124. /** Vector3 */
  87125. Vector3 = 8,
  87126. /** Vector4 */
  87127. Vector4 = 16,
  87128. /** Color3 */
  87129. Color3 = 32,
  87130. /** Color4 */
  87131. Color4 = 64,
  87132. /** Matrix */
  87133. Matrix = 128,
  87134. /** Custom object */
  87135. Object = 256,
  87136. /** Detect type based on connection */
  87137. AutoDetect = 1024,
  87138. /** Output type that will be defined by input type */
  87139. BasedOnInput = 2048
  87140. }
  87141. }
  87142. declare module BABYLON {
  87143. /**
  87144. * Enum used to define the target of a block
  87145. */
  87146. export enum NodeMaterialBlockTargets {
  87147. /** Vertex shader */
  87148. Vertex = 1,
  87149. /** Fragment shader */
  87150. Fragment = 2,
  87151. /** Neutral */
  87152. Neutral = 4,
  87153. /** Vertex and Fragment */
  87154. VertexAndFragment = 3
  87155. }
  87156. }
  87157. declare module BABYLON {
  87158. /**
  87159. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87160. */
  87161. export enum NodeMaterialBlockConnectionPointMode {
  87162. /** Value is an uniform */
  87163. Uniform = 0,
  87164. /** Value is a mesh attribute */
  87165. Attribute = 1,
  87166. /** Value is a varying between vertex and fragment shaders */
  87167. Varying = 2,
  87168. /** Mode is undefined */
  87169. Undefined = 3
  87170. }
  87171. }
  87172. declare module BABYLON {
  87173. /**
  87174. * Enum used to define system values e.g. values automatically provided by the system
  87175. */
  87176. export enum NodeMaterialSystemValues {
  87177. /** World */
  87178. World = 1,
  87179. /** View */
  87180. View = 2,
  87181. /** Projection */
  87182. Projection = 3,
  87183. /** ViewProjection */
  87184. ViewProjection = 4,
  87185. /** WorldView */
  87186. WorldView = 5,
  87187. /** WorldViewProjection */
  87188. WorldViewProjection = 6,
  87189. /** CameraPosition */
  87190. CameraPosition = 7,
  87191. /** Fog Color */
  87192. FogColor = 8,
  87193. /** Delta time */
  87194. DeltaTime = 9
  87195. }
  87196. }
  87197. declare module BABYLON {
  87198. /** Defines supported spaces */
  87199. export enum Space {
  87200. /** Local (object) space */
  87201. LOCAL = 0,
  87202. /** World space */
  87203. WORLD = 1,
  87204. /** Bone space */
  87205. BONE = 2
  87206. }
  87207. /** Defines the 3 main axes */
  87208. export class Axis {
  87209. /** X axis */
  87210. static X: Vector3;
  87211. /** Y axis */
  87212. static Y: Vector3;
  87213. /** Z axis */
  87214. static Z: Vector3;
  87215. }
  87216. }
  87217. declare module BABYLON {
  87218. /**
  87219. * Represents a camera frustum
  87220. */
  87221. export class Frustum {
  87222. /**
  87223. * Gets the planes representing the frustum
  87224. * @param transform matrix to be applied to the returned planes
  87225. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87226. */
  87227. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87228. /**
  87229. * Gets the near frustum plane transformed by the transform matrix
  87230. * @param transform transformation matrix to be applied to the resulting frustum plane
  87231. * @param frustumPlane the resuling frustum plane
  87232. */
  87233. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87234. /**
  87235. * Gets the far frustum plane transformed by the transform matrix
  87236. * @param transform transformation matrix to be applied to the resulting frustum plane
  87237. * @param frustumPlane the resuling frustum plane
  87238. */
  87239. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87240. /**
  87241. * Gets the left frustum plane transformed by the transform matrix
  87242. * @param transform transformation matrix to be applied to the resulting frustum plane
  87243. * @param frustumPlane the resuling frustum plane
  87244. */
  87245. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87246. /**
  87247. * Gets the right frustum plane transformed by the transform matrix
  87248. * @param transform transformation matrix to be applied to the resulting frustum plane
  87249. * @param frustumPlane the resuling frustum plane
  87250. */
  87251. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87252. /**
  87253. * Gets the top frustum plane transformed by the transform matrix
  87254. * @param transform transformation matrix to be applied to the resulting frustum plane
  87255. * @param frustumPlane the resuling frustum plane
  87256. */
  87257. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87258. /**
  87259. * Gets the bottom frustum plane transformed by the transform matrix
  87260. * @param transform transformation matrix to be applied to the resulting frustum plane
  87261. * @param frustumPlane the resuling frustum plane
  87262. */
  87263. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87264. /**
  87265. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87266. * @param transform transformation matrix to be applied to the resulting frustum planes
  87267. * @param frustumPlanes the resuling frustum planes
  87268. */
  87269. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87270. }
  87271. }
  87272. declare module BABYLON {
  87273. /**
  87274. * Interface for the size containing width and height
  87275. */
  87276. export interface ISize {
  87277. /**
  87278. * Width
  87279. */
  87280. width: number;
  87281. /**
  87282. * Heighht
  87283. */
  87284. height: number;
  87285. }
  87286. /**
  87287. * Size containing widht and height
  87288. */
  87289. export class Size implements ISize {
  87290. /**
  87291. * Width
  87292. */
  87293. width: number;
  87294. /**
  87295. * Height
  87296. */
  87297. height: number;
  87298. /**
  87299. * Creates a Size object from the given width and height (floats).
  87300. * @param width width of the new size
  87301. * @param height height of the new size
  87302. */
  87303. constructor(width: number, height: number);
  87304. /**
  87305. * Returns a string with the Size width and height
  87306. * @returns a string with the Size width and height
  87307. */
  87308. toString(): string;
  87309. /**
  87310. * "Size"
  87311. * @returns the string "Size"
  87312. */
  87313. getClassName(): string;
  87314. /**
  87315. * Returns the Size hash code.
  87316. * @returns a hash code for a unique width and height
  87317. */
  87318. getHashCode(): number;
  87319. /**
  87320. * Updates the current size from the given one.
  87321. * @param src the given size
  87322. */
  87323. copyFrom(src: Size): void;
  87324. /**
  87325. * Updates in place the current Size from the given floats.
  87326. * @param width width of the new size
  87327. * @param height height of the new size
  87328. * @returns the updated Size.
  87329. */
  87330. copyFromFloats(width: number, height: number): Size;
  87331. /**
  87332. * Updates in place the current Size from the given floats.
  87333. * @param width width to set
  87334. * @param height height to set
  87335. * @returns the updated Size.
  87336. */
  87337. set(width: number, height: number): Size;
  87338. /**
  87339. * Multiplies the width and height by numbers
  87340. * @param w factor to multiple the width by
  87341. * @param h factor to multiple the height by
  87342. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87343. */
  87344. multiplyByFloats(w: number, h: number): Size;
  87345. /**
  87346. * Clones the size
  87347. * @returns a new Size copied from the given one.
  87348. */
  87349. clone(): Size;
  87350. /**
  87351. * True if the current Size and the given one width and height are strictly equal.
  87352. * @param other the other size to compare against
  87353. * @returns True if the current Size and the given one width and height are strictly equal.
  87354. */
  87355. equals(other: Size): boolean;
  87356. /**
  87357. * The surface of the Size : width * height (float).
  87358. */
  87359. get surface(): number;
  87360. /**
  87361. * Create a new size of zero
  87362. * @returns a new Size set to (0.0, 0.0)
  87363. */
  87364. static Zero(): Size;
  87365. /**
  87366. * Sums the width and height of two sizes
  87367. * @param otherSize size to add to this size
  87368. * @returns a new Size set as the addition result of the current Size and the given one.
  87369. */
  87370. add(otherSize: Size): Size;
  87371. /**
  87372. * Subtracts the width and height of two
  87373. * @param otherSize size to subtract to this size
  87374. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87375. */
  87376. subtract(otherSize: Size): Size;
  87377. /**
  87378. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87379. * @param start starting size to lerp between
  87380. * @param end end size to lerp between
  87381. * @param amount amount to lerp between the start and end values
  87382. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87383. */
  87384. static Lerp(start: Size, end: Size, amount: number): Size;
  87385. }
  87386. }
  87387. declare module BABYLON {
  87388. /**
  87389. * Contains position and normal vectors for a vertex
  87390. */
  87391. export class PositionNormalVertex {
  87392. /** the position of the vertex (defaut: 0,0,0) */
  87393. position: Vector3;
  87394. /** the normal of the vertex (defaut: 0,1,0) */
  87395. normal: Vector3;
  87396. /**
  87397. * Creates a PositionNormalVertex
  87398. * @param position the position of the vertex (defaut: 0,0,0)
  87399. * @param normal the normal of the vertex (defaut: 0,1,0)
  87400. */
  87401. constructor(
  87402. /** the position of the vertex (defaut: 0,0,0) */
  87403. position?: Vector3,
  87404. /** the normal of the vertex (defaut: 0,1,0) */
  87405. normal?: Vector3);
  87406. /**
  87407. * Clones the PositionNormalVertex
  87408. * @returns the cloned PositionNormalVertex
  87409. */
  87410. clone(): PositionNormalVertex;
  87411. }
  87412. /**
  87413. * Contains position, normal and uv vectors for a vertex
  87414. */
  87415. export class PositionNormalTextureVertex {
  87416. /** the position of the vertex (defaut: 0,0,0) */
  87417. position: Vector3;
  87418. /** the normal of the vertex (defaut: 0,1,0) */
  87419. normal: Vector3;
  87420. /** the uv of the vertex (default: 0,0) */
  87421. uv: Vector2;
  87422. /**
  87423. * Creates a PositionNormalTextureVertex
  87424. * @param position the position of the vertex (defaut: 0,0,0)
  87425. * @param normal the normal of the vertex (defaut: 0,1,0)
  87426. * @param uv the uv of the vertex (default: 0,0)
  87427. */
  87428. constructor(
  87429. /** the position of the vertex (defaut: 0,0,0) */
  87430. position?: Vector3,
  87431. /** the normal of the vertex (defaut: 0,1,0) */
  87432. normal?: Vector3,
  87433. /** the uv of the vertex (default: 0,0) */
  87434. uv?: Vector2);
  87435. /**
  87436. * Clones the PositionNormalTextureVertex
  87437. * @returns the cloned PositionNormalTextureVertex
  87438. */
  87439. clone(): PositionNormalTextureVertex;
  87440. }
  87441. }
  87442. declare module BABYLON {
  87443. /**
  87444. * Enum defining the type of animations supported by InputBlock
  87445. */
  87446. export enum AnimatedInputBlockTypes {
  87447. /** No animation */
  87448. None = 0,
  87449. /** Time based animation. Will only work for floats */
  87450. Time = 1
  87451. }
  87452. }
  87453. declare module BABYLON {
  87454. /**
  87455. * Interface describing all the common properties and methods a shadow light needs to implement.
  87456. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87457. * as well as binding the different shadow properties to the effects.
  87458. */
  87459. export interface IShadowLight extends Light {
  87460. /**
  87461. * The light id in the scene (used in scene.findLighById for instance)
  87462. */
  87463. id: string;
  87464. /**
  87465. * The position the shdow will be casted from.
  87466. */
  87467. position: Vector3;
  87468. /**
  87469. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87470. */
  87471. direction: Vector3;
  87472. /**
  87473. * The transformed position. Position of the light in world space taking parenting in account.
  87474. */
  87475. transformedPosition: Vector3;
  87476. /**
  87477. * The transformed direction. Direction of the light in world space taking parenting in account.
  87478. */
  87479. transformedDirection: Vector3;
  87480. /**
  87481. * The friendly name of the light in the scene.
  87482. */
  87483. name: string;
  87484. /**
  87485. * Defines the shadow projection clipping minimum z value.
  87486. */
  87487. shadowMinZ: number;
  87488. /**
  87489. * Defines the shadow projection clipping maximum z value.
  87490. */
  87491. shadowMaxZ: number;
  87492. /**
  87493. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87494. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87495. */
  87496. computeTransformedInformation(): boolean;
  87497. /**
  87498. * Gets the scene the light belongs to.
  87499. * @returns The scene
  87500. */
  87501. getScene(): Scene;
  87502. /**
  87503. * Callback defining a custom Projection Matrix Builder.
  87504. * This can be used to override the default projection matrix computation.
  87505. */
  87506. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87507. /**
  87508. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87509. * @param matrix The materix to updated with the projection information
  87510. * @param viewMatrix The transform matrix of the light
  87511. * @param renderList The list of mesh to render in the map
  87512. * @returns The current light
  87513. */
  87514. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87515. /**
  87516. * Gets the current depth scale used in ESM.
  87517. * @returns The scale
  87518. */
  87519. getDepthScale(): number;
  87520. /**
  87521. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87522. * @returns true if a cube texture needs to be use
  87523. */
  87524. needCube(): boolean;
  87525. /**
  87526. * Detects if the projection matrix requires to be recomputed this frame.
  87527. * @returns true if it requires to be recomputed otherwise, false.
  87528. */
  87529. needProjectionMatrixCompute(): boolean;
  87530. /**
  87531. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87532. */
  87533. forceProjectionMatrixCompute(): void;
  87534. /**
  87535. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87536. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87537. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87538. */
  87539. getShadowDirection(faceIndex?: number): Vector3;
  87540. /**
  87541. * Gets the minZ used for shadow according to both the scene and the light.
  87542. * @param activeCamera The camera we are returning the min for
  87543. * @returns the depth min z
  87544. */
  87545. getDepthMinZ(activeCamera: Camera): number;
  87546. /**
  87547. * Gets the maxZ used for shadow according to both the scene and the light.
  87548. * @param activeCamera The camera we are returning the max for
  87549. * @returns the depth max z
  87550. */
  87551. getDepthMaxZ(activeCamera: Camera): number;
  87552. }
  87553. /**
  87554. * Base implementation IShadowLight
  87555. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87556. */
  87557. export abstract class ShadowLight extends Light implements IShadowLight {
  87558. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87559. protected _position: Vector3;
  87560. protected _setPosition(value: Vector3): void;
  87561. /**
  87562. * Sets the position the shadow will be casted from. Also use as the light position for both
  87563. * point and spot lights.
  87564. */
  87565. get position(): Vector3;
  87566. /**
  87567. * Sets the position the shadow will be casted from. Also use as the light position for both
  87568. * point and spot lights.
  87569. */
  87570. set position(value: Vector3);
  87571. protected _direction: Vector3;
  87572. protected _setDirection(value: Vector3): void;
  87573. /**
  87574. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87575. * Also use as the light direction on spot and directional lights.
  87576. */
  87577. get direction(): Vector3;
  87578. /**
  87579. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87580. * Also use as the light direction on spot and directional lights.
  87581. */
  87582. set direction(value: Vector3);
  87583. protected _shadowMinZ: number;
  87584. /**
  87585. * Gets the shadow projection clipping minimum z value.
  87586. */
  87587. get shadowMinZ(): number;
  87588. /**
  87589. * Sets the shadow projection clipping minimum z value.
  87590. */
  87591. set shadowMinZ(value: number);
  87592. protected _shadowMaxZ: number;
  87593. /**
  87594. * Sets the shadow projection clipping maximum z value.
  87595. */
  87596. get shadowMaxZ(): number;
  87597. /**
  87598. * Gets the shadow projection clipping maximum z value.
  87599. */
  87600. set shadowMaxZ(value: number);
  87601. /**
  87602. * Callback defining a custom Projection Matrix Builder.
  87603. * This can be used to override the default projection matrix computation.
  87604. */
  87605. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87606. /**
  87607. * The transformed position. Position of the light in world space taking parenting in account.
  87608. */
  87609. transformedPosition: Vector3;
  87610. /**
  87611. * The transformed direction. Direction of the light in world space taking parenting in account.
  87612. */
  87613. transformedDirection: Vector3;
  87614. private _needProjectionMatrixCompute;
  87615. /**
  87616. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87617. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87618. */
  87619. computeTransformedInformation(): boolean;
  87620. /**
  87621. * Return the depth scale used for the shadow map.
  87622. * @returns the depth scale.
  87623. */
  87624. getDepthScale(): number;
  87625. /**
  87626. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87627. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87628. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87629. */
  87630. getShadowDirection(faceIndex?: number): Vector3;
  87631. /**
  87632. * Returns the ShadowLight absolute position in the World.
  87633. * @returns the position vector in world space
  87634. */
  87635. getAbsolutePosition(): Vector3;
  87636. /**
  87637. * Sets the ShadowLight direction toward the passed target.
  87638. * @param target The point to target in local space
  87639. * @returns the updated ShadowLight direction
  87640. */
  87641. setDirectionToTarget(target: Vector3): Vector3;
  87642. /**
  87643. * Returns the light rotation in euler definition.
  87644. * @returns the x y z rotation in local space.
  87645. */
  87646. getRotation(): Vector3;
  87647. /**
  87648. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87649. * @returns true if a cube texture needs to be use
  87650. */
  87651. needCube(): boolean;
  87652. /**
  87653. * Detects if the projection matrix requires to be recomputed this frame.
  87654. * @returns true if it requires to be recomputed otherwise, false.
  87655. */
  87656. needProjectionMatrixCompute(): boolean;
  87657. /**
  87658. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87659. */
  87660. forceProjectionMatrixCompute(): void;
  87661. /** @hidden */
  87662. _initCache(): void;
  87663. /** @hidden */
  87664. _isSynchronized(): boolean;
  87665. /**
  87666. * Computes the world matrix of the node
  87667. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87668. * @returns the world matrix
  87669. */
  87670. computeWorldMatrix(force?: boolean): Matrix;
  87671. /**
  87672. * Gets the minZ used for shadow according to both the scene and the light.
  87673. * @param activeCamera The camera we are returning the min for
  87674. * @returns the depth min z
  87675. */
  87676. getDepthMinZ(activeCamera: Camera): number;
  87677. /**
  87678. * Gets the maxZ used for shadow according to both the scene and the light.
  87679. * @param activeCamera The camera we are returning the max for
  87680. * @returns the depth max z
  87681. */
  87682. getDepthMaxZ(activeCamera: Camera): number;
  87683. /**
  87684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87685. * @param matrix The materix to updated with the projection information
  87686. * @param viewMatrix The transform matrix of the light
  87687. * @param renderList The list of mesh to render in the map
  87688. * @returns The current light
  87689. */
  87690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87691. }
  87692. }
  87693. declare module BABYLON {
  87694. /** @hidden */
  87695. export var packingFunctions: {
  87696. name: string;
  87697. shader: string;
  87698. };
  87699. }
  87700. declare module BABYLON {
  87701. /** @hidden */
  87702. export var bayerDitherFunctions: {
  87703. name: string;
  87704. shader: string;
  87705. };
  87706. }
  87707. declare module BABYLON {
  87708. /** @hidden */
  87709. export var shadowMapFragmentDeclaration: {
  87710. name: string;
  87711. shader: string;
  87712. };
  87713. }
  87714. declare module BABYLON {
  87715. /** @hidden */
  87716. export var clipPlaneFragmentDeclaration: {
  87717. name: string;
  87718. shader: string;
  87719. };
  87720. }
  87721. declare module BABYLON {
  87722. /** @hidden */
  87723. export var clipPlaneFragment: {
  87724. name: string;
  87725. shader: string;
  87726. };
  87727. }
  87728. declare module BABYLON {
  87729. /** @hidden */
  87730. export var shadowMapFragment: {
  87731. name: string;
  87732. shader: string;
  87733. };
  87734. }
  87735. declare module BABYLON {
  87736. /** @hidden */
  87737. export var shadowMapPixelShader: {
  87738. name: string;
  87739. shader: string;
  87740. };
  87741. }
  87742. declare module BABYLON {
  87743. /** @hidden */
  87744. export var bonesDeclaration: {
  87745. name: string;
  87746. shader: string;
  87747. };
  87748. }
  87749. declare module BABYLON {
  87750. /** @hidden */
  87751. export var morphTargetsVertexGlobalDeclaration: {
  87752. name: string;
  87753. shader: string;
  87754. };
  87755. }
  87756. declare module BABYLON {
  87757. /** @hidden */
  87758. export var morphTargetsVertexDeclaration: {
  87759. name: string;
  87760. shader: string;
  87761. };
  87762. }
  87763. declare module BABYLON {
  87764. /** @hidden */
  87765. export var instancesDeclaration: {
  87766. name: string;
  87767. shader: string;
  87768. };
  87769. }
  87770. declare module BABYLON {
  87771. /** @hidden */
  87772. export var helperFunctions: {
  87773. name: string;
  87774. shader: string;
  87775. };
  87776. }
  87777. declare module BABYLON {
  87778. /** @hidden */
  87779. export var shadowMapVertexDeclaration: {
  87780. name: string;
  87781. shader: string;
  87782. };
  87783. }
  87784. declare module BABYLON {
  87785. /** @hidden */
  87786. export var clipPlaneVertexDeclaration: {
  87787. name: string;
  87788. shader: string;
  87789. };
  87790. }
  87791. declare module BABYLON {
  87792. /** @hidden */
  87793. export var morphTargetsVertex: {
  87794. name: string;
  87795. shader: string;
  87796. };
  87797. }
  87798. declare module BABYLON {
  87799. /** @hidden */
  87800. export var instancesVertex: {
  87801. name: string;
  87802. shader: string;
  87803. };
  87804. }
  87805. declare module BABYLON {
  87806. /** @hidden */
  87807. export var bonesVertex: {
  87808. name: string;
  87809. shader: string;
  87810. };
  87811. }
  87812. declare module BABYLON {
  87813. /** @hidden */
  87814. export var shadowMapVertexNormalBias: {
  87815. name: string;
  87816. shader: string;
  87817. };
  87818. }
  87819. declare module BABYLON {
  87820. /** @hidden */
  87821. export var shadowMapVertexMetric: {
  87822. name: string;
  87823. shader: string;
  87824. };
  87825. }
  87826. declare module BABYLON {
  87827. /** @hidden */
  87828. export var clipPlaneVertex: {
  87829. name: string;
  87830. shader: string;
  87831. };
  87832. }
  87833. declare module BABYLON {
  87834. /** @hidden */
  87835. export var shadowMapVertexShader: {
  87836. name: string;
  87837. shader: string;
  87838. };
  87839. }
  87840. declare module BABYLON {
  87841. /** @hidden */
  87842. export var depthBoxBlurPixelShader: {
  87843. name: string;
  87844. shader: string;
  87845. };
  87846. }
  87847. declare module BABYLON {
  87848. /** @hidden */
  87849. export var shadowMapFragmentSoftTransparentShadow: {
  87850. name: string;
  87851. shader: string;
  87852. };
  87853. }
  87854. declare module BABYLON {
  87855. /**
  87856. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87857. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87858. */
  87859. export class EffectFallbacks implements IEffectFallbacks {
  87860. private _defines;
  87861. private _currentRank;
  87862. private _maxRank;
  87863. private _mesh;
  87864. /**
  87865. * Removes the fallback from the bound mesh.
  87866. */
  87867. unBindMesh(): void;
  87868. /**
  87869. * Adds a fallback on the specified property.
  87870. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87871. * @param define The name of the define in the shader
  87872. */
  87873. addFallback(rank: number, define: string): void;
  87874. /**
  87875. * Sets the mesh to use CPU skinning when needing to fallback.
  87876. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87877. * @param mesh The mesh to use the fallbacks.
  87878. */
  87879. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87880. /**
  87881. * Checks to see if more fallbacks are still availible.
  87882. */
  87883. get hasMoreFallbacks(): boolean;
  87884. /**
  87885. * Removes the defines that should be removed when falling back.
  87886. * @param currentDefines defines the current define statements for the shader.
  87887. * @param effect defines the current effect we try to compile
  87888. * @returns The resulting defines with defines of the current rank removed.
  87889. */
  87890. reduce(currentDefines: string, effect: Effect): string;
  87891. }
  87892. }
  87893. declare module BABYLON {
  87894. /**
  87895. * Interface used to define Action
  87896. */
  87897. export interface IAction {
  87898. /**
  87899. * Trigger for the action
  87900. */
  87901. trigger: number;
  87902. /** Options of the trigger */
  87903. triggerOptions: any;
  87904. /**
  87905. * Gets the trigger parameters
  87906. * @returns the trigger parameters
  87907. */
  87908. getTriggerParameter(): any;
  87909. /**
  87910. * Internal only - executes current action event
  87911. * @hidden
  87912. */
  87913. _executeCurrent(evt?: ActionEvent): void;
  87914. /**
  87915. * Serialize placeholder for child classes
  87916. * @param parent of child
  87917. * @returns the serialized object
  87918. */
  87919. serialize(parent: any): any;
  87920. /**
  87921. * Internal only
  87922. * @hidden
  87923. */
  87924. _prepare(): void;
  87925. /**
  87926. * Internal only - manager for action
  87927. * @hidden
  87928. */
  87929. _actionManager: AbstractActionManager;
  87930. /**
  87931. * Adds action to chain of actions, may be a DoNothingAction
  87932. * @param action defines the next action to execute
  87933. * @returns The action passed in
  87934. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87935. */
  87936. then(action: IAction): IAction;
  87937. }
  87938. /**
  87939. * The action to be carried out following a trigger
  87940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87941. */
  87942. export class Action implements IAction {
  87943. /** the trigger, with or without parameters, for the action */
  87944. triggerOptions: any;
  87945. /**
  87946. * Trigger for the action
  87947. */
  87948. trigger: number;
  87949. /**
  87950. * Internal only - manager for action
  87951. * @hidden
  87952. */
  87953. _actionManager: ActionManager;
  87954. private _nextActiveAction;
  87955. private _child;
  87956. private _condition?;
  87957. private _triggerParameter;
  87958. /**
  87959. * An event triggered prior to action being executed.
  87960. */
  87961. onBeforeExecuteObservable: Observable<Action>;
  87962. /**
  87963. * Creates a new Action
  87964. * @param triggerOptions the trigger, with or without parameters, for the action
  87965. * @param condition an optional determinant of action
  87966. */
  87967. constructor(
  87968. /** the trigger, with or without parameters, for the action */
  87969. triggerOptions: any, condition?: Condition);
  87970. /**
  87971. * Internal only
  87972. * @hidden
  87973. */
  87974. _prepare(): void;
  87975. /**
  87976. * Gets the trigger parameters
  87977. * @returns the trigger parameters
  87978. */
  87979. getTriggerParameter(): any;
  87980. /**
  87981. * Internal only - executes current action event
  87982. * @hidden
  87983. */
  87984. _executeCurrent(evt?: ActionEvent): void;
  87985. /**
  87986. * Execute placeholder for child classes
  87987. * @param evt optional action event
  87988. */
  87989. execute(evt?: ActionEvent): void;
  87990. /**
  87991. * Skips to next active action
  87992. */
  87993. skipToNextActiveAction(): void;
  87994. /**
  87995. * Adds action to chain of actions, may be a DoNothingAction
  87996. * @param action defines the next action to execute
  87997. * @returns The action passed in
  87998. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87999. */
  88000. then(action: Action): Action;
  88001. /**
  88002. * Internal only
  88003. * @hidden
  88004. */
  88005. _getProperty(propertyPath: string): string;
  88006. /**
  88007. * Internal only
  88008. * @hidden
  88009. */
  88010. _getEffectiveTarget(target: any, propertyPath: string): any;
  88011. /**
  88012. * Serialize placeholder for child classes
  88013. * @param parent of child
  88014. * @returns the serialized object
  88015. */
  88016. serialize(parent: any): any;
  88017. /**
  88018. * Internal only called by serialize
  88019. * @hidden
  88020. */
  88021. protected _serialize(serializedAction: any, parent?: any): any;
  88022. /**
  88023. * Internal only
  88024. * @hidden
  88025. */
  88026. static _SerializeValueAsString: (value: any) => string;
  88027. /**
  88028. * Internal only
  88029. * @hidden
  88030. */
  88031. static _GetTargetProperty: (target: Scene | Node) => {
  88032. name: string;
  88033. targetType: string;
  88034. value: string;
  88035. };
  88036. }
  88037. }
  88038. declare module BABYLON {
  88039. /**
  88040. * A Condition applied to an Action
  88041. */
  88042. export class Condition {
  88043. /**
  88044. * Internal only - manager for action
  88045. * @hidden
  88046. */
  88047. _actionManager: ActionManager;
  88048. /**
  88049. * Internal only
  88050. * @hidden
  88051. */
  88052. _evaluationId: number;
  88053. /**
  88054. * Internal only
  88055. * @hidden
  88056. */
  88057. _currentResult: boolean;
  88058. /**
  88059. * Creates a new Condition
  88060. * @param actionManager the manager of the action the condition is applied to
  88061. */
  88062. constructor(actionManager: ActionManager);
  88063. /**
  88064. * Check if the current condition is valid
  88065. * @returns a boolean
  88066. */
  88067. isValid(): boolean;
  88068. /**
  88069. * Internal only
  88070. * @hidden
  88071. */
  88072. _getProperty(propertyPath: string): string;
  88073. /**
  88074. * Internal only
  88075. * @hidden
  88076. */
  88077. _getEffectiveTarget(target: any, propertyPath: string): any;
  88078. /**
  88079. * Serialize placeholder for child classes
  88080. * @returns the serialized object
  88081. */
  88082. serialize(): any;
  88083. /**
  88084. * Internal only
  88085. * @hidden
  88086. */
  88087. protected _serialize(serializedCondition: any): any;
  88088. }
  88089. /**
  88090. * Defines specific conditional operators as extensions of Condition
  88091. */
  88092. export class ValueCondition extends Condition {
  88093. /** path to specify the property of the target the conditional operator uses */
  88094. propertyPath: string;
  88095. /** the value compared by the conditional operator against the current value of the property */
  88096. value: any;
  88097. /** the conditional operator, default ValueCondition.IsEqual */
  88098. operator: number;
  88099. /**
  88100. * Internal only
  88101. * @hidden
  88102. */
  88103. private static _IsEqual;
  88104. /**
  88105. * Internal only
  88106. * @hidden
  88107. */
  88108. private static _IsDifferent;
  88109. /**
  88110. * Internal only
  88111. * @hidden
  88112. */
  88113. private static _IsGreater;
  88114. /**
  88115. * Internal only
  88116. * @hidden
  88117. */
  88118. private static _IsLesser;
  88119. /**
  88120. * returns the number for IsEqual
  88121. */
  88122. static get IsEqual(): number;
  88123. /**
  88124. * Returns the number for IsDifferent
  88125. */
  88126. static get IsDifferent(): number;
  88127. /**
  88128. * Returns the number for IsGreater
  88129. */
  88130. static get IsGreater(): number;
  88131. /**
  88132. * Returns the number for IsLesser
  88133. */
  88134. static get IsLesser(): number;
  88135. /**
  88136. * Internal only The action manager for the condition
  88137. * @hidden
  88138. */
  88139. _actionManager: ActionManager;
  88140. /**
  88141. * Internal only
  88142. * @hidden
  88143. */
  88144. private _target;
  88145. /**
  88146. * Internal only
  88147. * @hidden
  88148. */
  88149. private _effectiveTarget;
  88150. /**
  88151. * Internal only
  88152. * @hidden
  88153. */
  88154. private _property;
  88155. /**
  88156. * Creates a new ValueCondition
  88157. * @param actionManager manager for the action the condition applies to
  88158. * @param target for the action
  88159. * @param propertyPath path to specify the property of the target the conditional operator uses
  88160. * @param value the value compared by the conditional operator against the current value of the property
  88161. * @param operator the conditional operator, default ValueCondition.IsEqual
  88162. */
  88163. constructor(actionManager: ActionManager, target: any,
  88164. /** path to specify the property of the target the conditional operator uses */
  88165. propertyPath: string,
  88166. /** the value compared by the conditional operator against the current value of the property */
  88167. value: any,
  88168. /** the conditional operator, default ValueCondition.IsEqual */
  88169. operator?: number);
  88170. /**
  88171. * Compares the given value with the property value for the specified conditional operator
  88172. * @returns the result of the comparison
  88173. */
  88174. isValid(): boolean;
  88175. /**
  88176. * Serialize the ValueCondition into a JSON compatible object
  88177. * @returns serialization object
  88178. */
  88179. serialize(): any;
  88180. /**
  88181. * Gets the name of the conditional operator for the ValueCondition
  88182. * @param operator the conditional operator
  88183. * @returns the name
  88184. */
  88185. static GetOperatorName(operator: number): string;
  88186. }
  88187. /**
  88188. * Defines a predicate condition as an extension of Condition
  88189. */
  88190. export class PredicateCondition extends Condition {
  88191. /** defines the predicate function used to validate the condition */
  88192. predicate: () => boolean;
  88193. /**
  88194. * Internal only - manager for action
  88195. * @hidden
  88196. */
  88197. _actionManager: ActionManager;
  88198. /**
  88199. * Creates a new PredicateCondition
  88200. * @param actionManager manager for the action the condition applies to
  88201. * @param predicate defines the predicate function used to validate the condition
  88202. */
  88203. constructor(actionManager: ActionManager,
  88204. /** defines the predicate function used to validate the condition */
  88205. predicate: () => boolean);
  88206. /**
  88207. * @returns the validity of the predicate condition
  88208. */
  88209. isValid(): boolean;
  88210. }
  88211. /**
  88212. * Defines a state condition as an extension of Condition
  88213. */
  88214. export class StateCondition extends Condition {
  88215. /** Value to compare with target state */
  88216. value: string;
  88217. /**
  88218. * Internal only - manager for action
  88219. * @hidden
  88220. */
  88221. _actionManager: ActionManager;
  88222. /**
  88223. * Internal only
  88224. * @hidden
  88225. */
  88226. private _target;
  88227. /**
  88228. * Creates a new StateCondition
  88229. * @param actionManager manager for the action the condition applies to
  88230. * @param target of the condition
  88231. * @param value to compare with target state
  88232. */
  88233. constructor(actionManager: ActionManager, target: any,
  88234. /** Value to compare with target state */
  88235. value: string);
  88236. /**
  88237. * Gets a boolean indicating if the current condition is met
  88238. * @returns the validity of the state
  88239. */
  88240. isValid(): boolean;
  88241. /**
  88242. * Serialize the StateCondition into a JSON compatible object
  88243. * @returns serialization object
  88244. */
  88245. serialize(): any;
  88246. }
  88247. }
  88248. declare module BABYLON {
  88249. /**
  88250. * This defines an action responsible to toggle a boolean once triggered.
  88251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88252. */
  88253. export class SwitchBooleanAction extends Action {
  88254. /**
  88255. * The path to the boolean property in the target object
  88256. */
  88257. propertyPath: string;
  88258. private _target;
  88259. private _effectiveTarget;
  88260. private _property;
  88261. /**
  88262. * Instantiate the action
  88263. * @param triggerOptions defines the trigger options
  88264. * @param target defines the object containing the boolean
  88265. * @param propertyPath defines the path to the boolean property in the target object
  88266. * @param condition defines the trigger related conditions
  88267. */
  88268. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88269. /** @hidden */
  88270. _prepare(): void;
  88271. /**
  88272. * Execute the action toggle the boolean value.
  88273. */
  88274. execute(): void;
  88275. /**
  88276. * Serializes the actions and its related information.
  88277. * @param parent defines the object to serialize in
  88278. * @returns the serialized object
  88279. */
  88280. serialize(parent: any): any;
  88281. }
  88282. /**
  88283. * This defines an action responsible to set a the state field of the target
  88284. * to a desired value once triggered.
  88285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88286. */
  88287. export class SetStateAction extends Action {
  88288. /**
  88289. * The value to store in the state field.
  88290. */
  88291. value: string;
  88292. private _target;
  88293. /**
  88294. * Instantiate the action
  88295. * @param triggerOptions defines the trigger options
  88296. * @param target defines the object containing the state property
  88297. * @param value defines the value to store in the state field
  88298. * @param condition defines the trigger related conditions
  88299. */
  88300. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88301. /**
  88302. * Execute the action and store the value on the target state property.
  88303. */
  88304. execute(): void;
  88305. /**
  88306. * Serializes the actions and its related information.
  88307. * @param parent defines the object to serialize in
  88308. * @returns the serialized object
  88309. */
  88310. serialize(parent: any): any;
  88311. }
  88312. /**
  88313. * This defines an action responsible to set a property of the target
  88314. * to a desired value once triggered.
  88315. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88316. */
  88317. export class SetValueAction extends Action {
  88318. /**
  88319. * The path of the property to set in the target.
  88320. */
  88321. propertyPath: string;
  88322. /**
  88323. * The value to set in the property
  88324. */
  88325. value: any;
  88326. private _target;
  88327. private _effectiveTarget;
  88328. private _property;
  88329. /**
  88330. * Instantiate the action
  88331. * @param triggerOptions defines the trigger options
  88332. * @param target defines the object containing the property
  88333. * @param propertyPath defines the path of the property to set in the target
  88334. * @param value defines the value to set in the property
  88335. * @param condition defines the trigger related conditions
  88336. */
  88337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88338. /** @hidden */
  88339. _prepare(): void;
  88340. /**
  88341. * Execute the action and set the targetted property to the desired value.
  88342. */
  88343. execute(): void;
  88344. /**
  88345. * Serializes the actions and its related information.
  88346. * @param parent defines the object to serialize in
  88347. * @returns the serialized object
  88348. */
  88349. serialize(parent: any): any;
  88350. }
  88351. /**
  88352. * This defines an action responsible to increment the target value
  88353. * to a desired value once triggered.
  88354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88355. */
  88356. export class IncrementValueAction extends Action {
  88357. /**
  88358. * The path of the property to increment in the target.
  88359. */
  88360. propertyPath: string;
  88361. /**
  88362. * The value we should increment the property by.
  88363. */
  88364. value: any;
  88365. private _target;
  88366. private _effectiveTarget;
  88367. private _property;
  88368. /**
  88369. * Instantiate the action
  88370. * @param triggerOptions defines the trigger options
  88371. * @param target defines the object containing the property
  88372. * @param propertyPath defines the path of the property to increment in the target
  88373. * @param value defines the value value we should increment the property by
  88374. * @param condition defines the trigger related conditions
  88375. */
  88376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88377. /** @hidden */
  88378. _prepare(): void;
  88379. /**
  88380. * Execute the action and increment the target of the value amount.
  88381. */
  88382. execute(): void;
  88383. /**
  88384. * Serializes the actions and its related information.
  88385. * @param parent defines the object to serialize in
  88386. * @returns the serialized object
  88387. */
  88388. serialize(parent: any): any;
  88389. }
  88390. /**
  88391. * This defines an action responsible to start an animation once triggered.
  88392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88393. */
  88394. export class PlayAnimationAction extends Action {
  88395. /**
  88396. * Where the animation should start (animation frame)
  88397. */
  88398. from: number;
  88399. /**
  88400. * Where the animation should stop (animation frame)
  88401. */
  88402. to: number;
  88403. /**
  88404. * Define if the animation should loop or stop after the first play.
  88405. */
  88406. loop?: boolean;
  88407. private _target;
  88408. /**
  88409. * Instantiate the action
  88410. * @param triggerOptions defines the trigger options
  88411. * @param target defines the target animation or animation name
  88412. * @param from defines from where the animation should start (animation frame)
  88413. * @param end defines where the animation should stop (animation frame)
  88414. * @param loop defines if the animation should loop or stop after the first play
  88415. * @param condition defines the trigger related conditions
  88416. */
  88417. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88418. /** @hidden */
  88419. _prepare(): void;
  88420. /**
  88421. * Execute the action and play the animation.
  88422. */
  88423. execute(): void;
  88424. /**
  88425. * Serializes the actions and its related information.
  88426. * @param parent defines the object to serialize in
  88427. * @returns the serialized object
  88428. */
  88429. serialize(parent: any): any;
  88430. }
  88431. /**
  88432. * This defines an action responsible to stop an animation once triggered.
  88433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88434. */
  88435. export class StopAnimationAction extends Action {
  88436. private _target;
  88437. /**
  88438. * Instantiate the action
  88439. * @param triggerOptions defines the trigger options
  88440. * @param target defines the target animation or animation name
  88441. * @param condition defines the trigger related conditions
  88442. */
  88443. constructor(triggerOptions: any, target: any, condition?: Condition);
  88444. /** @hidden */
  88445. _prepare(): void;
  88446. /**
  88447. * Execute the action and stop the animation.
  88448. */
  88449. execute(): void;
  88450. /**
  88451. * Serializes the actions and its related information.
  88452. * @param parent defines the object to serialize in
  88453. * @returns the serialized object
  88454. */
  88455. serialize(parent: any): any;
  88456. }
  88457. /**
  88458. * This defines an action responsible that does nothing once triggered.
  88459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88460. */
  88461. export class DoNothingAction extends Action {
  88462. /**
  88463. * Instantiate the action
  88464. * @param triggerOptions defines the trigger options
  88465. * @param condition defines the trigger related conditions
  88466. */
  88467. constructor(triggerOptions?: any, condition?: Condition);
  88468. /**
  88469. * Execute the action and do nothing.
  88470. */
  88471. execute(): void;
  88472. /**
  88473. * Serializes the actions and its related information.
  88474. * @param parent defines the object to serialize in
  88475. * @returns the serialized object
  88476. */
  88477. serialize(parent: any): any;
  88478. }
  88479. /**
  88480. * This defines an action responsible to trigger several actions once triggered.
  88481. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88482. */
  88483. export class CombineAction extends Action {
  88484. /**
  88485. * The list of aggregated animations to run.
  88486. */
  88487. children: Action[];
  88488. /**
  88489. * Instantiate the action
  88490. * @param triggerOptions defines the trigger options
  88491. * @param children defines the list of aggregated animations to run
  88492. * @param condition defines the trigger related conditions
  88493. */
  88494. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88495. /** @hidden */
  88496. _prepare(): void;
  88497. /**
  88498. * Execute the action and executes all the aggregated actions.
  88499. */
  88500. execute(evt: ActionEvent): void;
  88501. /**
  88502. * Serializes the actions and its related information.
  88503. * @param parent defines the object to serialize in
  88504. * @returns the serialized object
  88505. */
  88506. serialize(parent: any): any;
  88507. }
  88508. /**
  88509. * This defines an action responsible to run code (external event) once triggered.
  88510. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88511. */
  88512. export class ExecuteCodeAction extends Action {
  88513. /**
  88514. * The callback function to run.
  88515. */
  88516. func: (evt: ActionEvent) => void;
  88517. /**
  88518. * Instantiate the action
  88519. * @param triggerOptions defines the trigger options
  88520. * @param func defines the callback function to run
  88521. * @param condition defines the trigger related conditions
  88522. */
  88523. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88524. /**
  88525. * Execute the action and run the attached code.
  88526. */
  88527. execute(evt: ActionEvent): void;
  88528. }
  88529. /**
  88530. * This defines an action responsible to set the parent property of the target once triggered.
  88531. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88532. */
  88533. export class SetParentAction extends Action {
  88534. private _parent;
  88535. private _target;
  88536. /**
  88537. * Instantiate the action
  88538. * @param triggerOptions defines the trigger options
  88539. * @param target defines the target containing the parent property
  88540. * @param parent defines from where the animation should start (animation frame)
  88541. * @param condition defines the trigger related conditions
  88542. */
  88543. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88544. /** @hidden */
  88545. _prepare(): void;
  88546. /**
  88547. * Execute the action and set the parent property.
  88548. */
  88549. execute(): void;
  88550. /**
  88551. * Serializes the actions and its related information.
  88552. * @param parent defines the object to serialize in
  88553. * @returns the serialized object
  88554. */
  88555. serialize(parent: any): any;
  88556. }
  88557. }
  88558. declare module BABYLON {
  88559. /**
  88560. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88561. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88562. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88563. */
  88564. export class ActionManager extends AbstractActionManager {
  88565. /**
  88566. * Nothing
  88567. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88568. */
  88569. static readonly NothingTrigger: number;
  88570. /**
  88571. * On pick
  88572. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88573. */
  88574. static readonly OnPickTrigger: number;
  88575. /**
  88576. * On left pick
  88577. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88578. */
  88579. static readonly OnLeftPickTrigger: number;
  88580. /**
  88581. * On right pick
  88582. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88583. */
  88584. static readonly OnRightPickTrigger: number;
  88585. /**
  88586. * On center pick
  88587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88588. */
  88589. static readonly OnCenterPickTrigger: number;
  88590. /**
  88591. * On pick down
  88592. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88593. */
  88594. static readonly OnPickDownTrigger: number;
  88595. /**
  88596. * On double pick
  88597. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88598. */
  88599. static readonly OnDoublePickTrigger: number;
  88600. /**
  88601. * On pick up
  88602. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88603. */
  88604. static readonly OnPickUpTrigger: number;
  88605. /**
  88606. * On pick out.
  88607. * This trigger will only be raised if you also declared a OnPickDown
  88608. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88609. */
  88610. static readonly OnPickOutTrigger: number;
  88611. /**
  88612. * On long press
  88613. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88614. */
  88615. static readonly OnLongPressTrigger: number;
  88616. /**
  88617. * On pointer over
  88618. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88619. */
  88620. static readonly OnPointerOverTrigger: number;
  88621. /**
  88622. * On pointer out
  88623. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88624. */
  88625. static readonly OnPointerOutTrigger: number;
  88626. /**
  88627. * On every frame
  88628. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88629. */
  88630. static readonly OnEveryFrameTrigger: number;
  88631. /**
  88632. * On intersection enter
  88633. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88634. */
  88635. static readonly OnIntersectionEnterTrigger: number;
  88636. /**
  88637. * On intersection exit
  88638. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88639. */
  88640. static readonly OnIntersectionExitTrigger: number;
  88641. /**
  88642. * On key down
  88643. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88644. */
  88645. static readonly OnKeyDownTrigger: number;
  88646. /**
  88647. * On key up
  88648. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88649. */
  88650. static readonly OnKeyUpTrigger: number;
  88651. private _scene;
  88652. /**
  88653. * Creates a new action manager
  88654. * @param scene defines the hosting scene
  88655. */
  88656. constructor(scene: Scene);
  88657. /**
  88658. * Releases all associated resources
  88659. */
  88660. dispose(): void;
  88661. /**
  88662. * Gets hosting scene
  88663. * @returns the hosting scene
  88664. */
  88665. getScene(): Scene;
  88666. /**
  88667. * Does this action manager handles actions of any of the given triggers
  88668. * @param triggers defines the triggers to be tested
  88669. * @return a boolean indicating whether one (or more) of the triggers is handled
  88670. */
  88671. hasSpecificTriggers(triggers: number[]): boolean;
  88672. /**
  88673. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88674. * speed.
  88675. * @param triggerA defines the trigger to be tested
  88676. * @param triggerB defines the trigger to be tested
  88677. * @return a boolean indicating whether one (or more) of the triggers is handled
  88678. */
  88679. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88680. /**
  88681. * Does this action manager handles actions of a given trigger
  88682. * @param trigger defines the trigger to be tested
  88683. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88684. * @return whether the trigger is handled
  88685. */
  88686. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88687. /**
  88688. * Does this action manager has pointer triggers
  88689. */
  88690. get hasPointerTriggers(): boolean;
  88691. /**
  88692. * Does this action manager has pick triggers
  88693. */
  88694. get hasPickTriggers(): boolean;
  88695. /**
  88696. * Registers an action to this action manager
  88697. * @param action defines the action to be registered
  88698. * @return the action amended (prepared) after registration
  88699. */
  88700. registerAction(action: IAction): Nullable<IAction>;
  88701. /**
  88702. * Unregisters an action to this action manager
  88703. * @param action defines the action to be unregistered
  88704. * @return a boolean indicating whether the action has been unregistered
  88705. */
  88706. unregisterAction(action: IAction): Boolean;
  88707. /**
  88708. * Process a specific trigger
  88709. * @param trigger defines the trigger to process
  88710. * @param evt defines the event details to be processed
  88711. */
  88712. processTrigger(trigger: number, evt?: IActionEvent): void;
  88713. /** @hidden */
  88714. _getEffectiveTarget(target: any, propertyPath: string): any;
  88715. /** @hidden */
  88716. _getProperty(propertyPath: string): string;
  88717. /**
  88718. * Serialize this manager to a JSON object
  88719. * @param name defines the property name to store this manager
  88720. * @returns a JSON representation of this manager
  88721. */
  88722. serialize(name: string): any;
  88723. /**
  88724. * Creates a new ActionManager from a JSON data
  88725. * @param parsedActions defines the JSON data to read from
  88726. * @param object defines the hosting mesh
  88727. * @param scene defines the hosting scene
  88728. */
  88729. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88730. /**
  88731. * Get a trigger name by index
  88732. * @param trigger defines the trigger index
  88733. * @returns a trigger name
  88734. */
  88735. static GetTriggerName(trigger: number): string;
  88736. }
  88737. }
  88738. declare module BABYLON {
  88739. /**
  88740. * Class used to represent a sprite
  88741. * @see https://doc.babylonjs.com/babylon101/sprites
  88742. */
  88743. export class Sprite implements IAnimatable {
  88744. /** defines the name */
  88745. name: string;
  88746. /** Gets or sets the current world position */
  88747. position: Vector3;
  88748. /** Gets or sets the main color */
  88749. color: Color4;
  88750. /** Gets or sets the width */
  88751. width: number;
  88752. /** Gets or sets the height */
  88753. height: number;
  88754. /** Gets or sets rotation angle */
  88755. angle: number;
  88756. /** Gets or sets the cell index in the sprite sheet */
  88757. cellIndex: number;
  88758. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88759. cellRef: string;
  88760. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88761. invertU: boolean;
  88762. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88763. invertV: boolean;
  88764. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88765. disposeWhenFinishedAnimating: boolean;
  88766. /** Gets the list of attached animations */
  88767. animations: Nullable<Array<Animation>>;
  88768. /** Gets or sets a boolean indicating if the sprite can be picked */
  88769. isPickable: boolean;
  88770. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88771. useAlphaForPicking: boolean;
  88772. /** @hidden */
  88773. _xOffset: number;
  88774. /** @hidden */
  88775. _yOffset: number;
  88776. /** @hidden */
  88777. _xSize: number;
  88778. /** @hidden */
  88779. _ySize: number;
  88780. /**
  88781. * Gets or sets the associated action manager
  88782. */
  88783. actionManager: Nullable<ActionManager>;
  88784. /**
  88785. * An event triggered when the control has been disposed
  88786. */
  88787. onDisposeObservable: Observable<Sprite>;
  88788. private _animationStarted;
  88789. private _loopAnimation;
  88790. private _fromIndex;
  88791. private _toIndex;
  88792. private _delay;
  88793. private _direction;
  88794. private _manager;
  88795. private _time;
  88796. private _onAnimationEnd;
  88797. /**
  88798. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88799. */
  88800. isVisible: boolean;
  88801. /**
  88802. * Gets or sets the sprite size
  88803. */
  88804. get size(): number;
  88805. set size(value: number);
  88806. /**
  88807. * Returns a boolean indicating if the animation is started
  88808. */
  88809. get animationStarted(): boolean;
  88810. /**
  88811. * Gets or sets the unique id of the sprite
  88812. */
  88813. uniqueId: number;
  88814. /**
  88815. * Gets the manager of this sprite
  88816. */
  88817. get manager(): ISpriteManager;
  88818. /**
  88819. * Creates a new Sprite
  88820. * @param name defines the name
  88821. * @param manager defines the manager
  88822. */
  88823. constructor(
  88824. /** defines the name */
  88825. name: string, manager: ISpriteManager);
  88826. /**
  88827. * Returns the string "Sprite"
  88828. * @returns "Sprite"
  88829. */
  88830. getClassName(): string;
  88831. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88832. get fromIndex(): number;
  88833. set fromIndex(value: number);
  88834. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88835. get toIndex(): number;
  88836. set toIndex(value: number);
  88837. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88838. get loopAnimation(): boolean;
  88839. set loopAnimation(value: boolean);
  88840. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88841. get delay(): number;
  88842. set delay(value: number);
  88843. /**
  88844. * Starts an animation
  88845. * @param from defines the initial key
  88846. * @param to defines the end key
  88847. * @param loop defines if the animation must loop
  88848. * @param delay defines the start delay (in ms)
  88849. * @param onAnimationEnd defines a callback to call when animation ends
  88850. */
  88851. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88852. /** Stops current animation (if any) */
  88853. stopAnimation(): void;
  88854. /** @hidden */
  88855. _animate(deltaTime: number): void;
  88856. /** Release associated resources */
  88857. dispose(): void;
  88858. /**
  88859. * Serializes the sprite to a JSON object
  88860. * @returns the JSON object
  88861. */
  88862. serialize(): any;
  88863. /**
  88864. * Parses a JSON object to create a new sprite
  88865. * @param parsedSprite The JSON object to parse
  88866. * @param manager defines the hosting manager
  88867. * @returns the new sprite
  88868. */
  88869. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88870. }
  88871. }
  88872. declare module BABYLON {
  88873. /**
  88874. * Information about the result of picking within a scene
  88875. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88876. */
  88877. export class PickingInfo {
  88878. /** @hidden */
  88879. _pickingUnavailable: boolean;
  88880. /**
  88881. * If the pick collided with an object
  88882. */
  88883. hit: boolean;
  88884. /**
  88885. * Distance away where the pick collided
  88886. */
  88887. distance: number;
  88888. /**
  88889. * The location of pick collision
  88890. */
  88891. pickedPoint: Nullable<Vector3>;
  88892. /**
  88893. * The mesh corresponding the the pick collision
  88894. */
  88895. pickedMesh: Nullable<AbstractMesh>;
  88896. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88897. bu: number;
  88898. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88899. bv: number;
  88900. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88901. faceId: number;
  88902. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88903. subMeshFaceId: number;
  88904. /** Id of the the submesh that was picked */
  88905. subMeshId: number;
  88906. /** If a sprite was picked, this will be the sprite the pick collided with */
  88907. pickedSprite: Nullable<Sprite>;
  88908. /**
  88909. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88910. */
  88911. originMesh: Nullable<AbstractMesh>;
  88912. /**
  88913. * The ray that was used to perform the picking.
  88914. */
  88915. ray: Nullable<Ray>;
  88916. /**
  88917. * Gets the normal correspodning to the face the pick collided with
  88918. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88919. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88920. * @returns The normal correspodning to the face the pick collided with
  88921. */
  88922. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88923. /**
  88924. * Gets the texture coordinates of where the pick occured
  88925. * @returns the vector containing the coordnates of the texture
  88926. */
  88927. getTextureCoordinates(): Nullable<Vector2>;
  88928. }
  88929. }
  88930. declare module BABYLON {
  88931. /**
  88932. * Class representing a ray with position and direction
  88933. */
  88934. export class Ray {
  88935. /** origin point */
  88936. origin: Vector3;
  88937. /** direction */
  88938. direction: Vector3;
  88939. /** length of the ray */
  88940. length: number;
  88941. private static readonly TmpVector3;
  88942. private _tmpRay;
  88943. /**
  88944. * Creates a new ray
  88945. * @param origin origin point
  88946. * @param direction direction
  88947. * @param length length of the ray
  88948. */
  88949. constructor(
  88950. /** origin point */
  88951. origin: Vector3,
  88952. /** direction */
  88953. direction: Vector3,
  88954. /** length of the ray */
  88955. length?: number);
  88956. /**
  88957. * Checks if the ray intersects a box
  88958. * This does not account for the ray lenght by design to improve perfs.
  88959. * @param minimum bound of the box
  88960. * @param maximum bound of the box
  88961. * @param intersectionTreshold extra extend to be added to the box in all direction
  88962. * @returns if the box was hit
  88963. */
  88964. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88965. /**
  88966. * Checks if the ray intersects a box
  88967. * This does not account for the ray lenght by design to improve perfs.
  88968. * @param box the bounding box to check
  88969. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88970. * @returns if the box was hit
  88971. */
  88972. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88973. /**
  88974. * If the ray hits a sphere
  88975. * @param sphere the bounding sphere to check
  88976. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88977. * @returns true if it hits the sphere
  88978. */
  88979. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88980. /**
  88981. * If the ray hits a triange
  88982. * @param vertex0 triangle vertex
  88983. * @param vertex1 triangle vertex
  88984. * @param vertex2 triangle vertex
  88985. * @returns intersection information if hit
  88986. */
  88987. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88988. /**
  88989. * Checks if ray intersects a plane
  88990. * @param plane the plane to check
  88991. * @returns the distance away it was hit
  88992. */
  88993. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88994. /**
  88995. * Calculate the intercept of a ray on a given axis
  88996. * @param axis to check 'x' | 'y' | 'z'
  88997. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88998. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88999. */
  89000. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89001. /**
  89002. * Checks if ray intersects a mesh
  89003. * @param mesh the mesh to check
  89004. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89005. * @returns picking info of the intersecton
  89006. */
  89007. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89008. /**
  89009. * Checks if ray intersects a mesh
  89010. * @param meshes the meshes to check
  89011. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89012. * @param results array to store result in
  89013. * @returns Array of picking infos
  89014. */
  89015. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89016. private _comparePickingInfo;
  89017. private static smallnum;
  89018. private static rayl;
  89019. /**
  89020. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89021. * @param sega the first point of the segment to test the intersection against
  89022. * @param segb the second point of the segment to test the intersection against
  89023. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89024. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89025. */
  89026. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89027. /**
  89028. * Update the ray from viewport position
  89029. * @param x position
  89030. * @param y y position
  89031. * @param viewportWidth viewport width
  89032. * @param viewportHeight viewport height
  89033. * @param world world matrix
  89034. * @param view view matrix
  89035. * @param projection projection matrix
  89036. * @returns this ray updated
  89037. */
  89038. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89039. /**
  89040. * Creates a ray with origin and direction of 0,0,0
  89041. * @returns the new ray
  89042. */
  89043. static Zero(): Ray;
  89044. /**
  89045. * Creates a new ray from screen space and viewport
  89046. * @param x position
  89047. * @param y y position
  89048. * @param viewportWidth viewport width
  89049. * @param viewportHeight viewport height
  89050. * @param world world matrix
  89051. * @param view view matrix
  89052. * @param projection projection matrix
  89053. * @returns new ray
  89054. */
  89055. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89056. /**
  89057. * 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
  89058. * transformed to the given world matrix.
  89059. * @param origin The origin point
  89060. * @param end The end point
  89061. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89062. * @returns the new ray
  89063. */
  89064. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89065. /**
  89066. * Transforms a ray by a matrix
  89067. * @param ray ray to transform
  89068. * @param matrix matrix to apply
  89069. * @returns the resulting new ray
  89070. */
  89071. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89072. /**
  89073. * Transforms a ray by a matrix
  89074. * @param ray ray to transform
  89075. * @param matrix matrix to apply
  89076. * @param result ray to store result in
  89077. */
  89078. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89079. /**
  89080. * Unproject a ray from screen space to object space
  89081. * @param sourceX defines the screen space x coordinate to use
  89082. * @param sourceY defines the screen space y coordinate to use
  89083. * @param viewportWidth defines the current width of the viewport
  89084. * @param viewportHeight defines the current height of the viewport
  89085. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89086. * @param view defines the view matrix to use
  89087. * @param projection defines the projection matrix to use
  89088. */
  89089. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89090. }
  89091. /**
  89092. * Type used to define predicate used to select faces when a mesh intersection is detected
  89093. */
  89094. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89095. interface Scene {
  89096. /** @hidden */
  89097. _tempPickingRay: Nullable<Ray>;
  89098. /** @hidden */
  89099. _cachedRayForTransform: Ray;
  89100. /** @hidden */
  89101. _pickWithRayInverseMatrix: Matrix;
  89102. /** @hidden */
  89103. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89104. /** @hidden */
  89105. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89106. }
  89107. }
  89108. declare module BABYLON {
  89109. /**
  89110. * Groups all the scene component constants in one place to ease maintenance.
  89111. * @hidden
  89112. */
  89113. export class SceneComponentConstants {
  89114. static readonly NAME_EFFECTLAYER: string;
  89115. static readonly NAME_LAYER: string;
  89116. static readonly NAME_LENSFLARESYSTEM: string;
  89117. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89118. static readonly NAME_PARTICLESYSTEM: string;
  89119. static readonly NAME_GAMEPAD: string;
  89120. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89121. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89122. static readonly NAME_PREPASSRENDERER: string;
  89123. static readonly NAME_DEPTHRENDERER: string;
  89124. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89125. static readonly NAME_SPRITE: string;
  89126. static readonly NAME_OUTLINERENDERER: string;
  89127. static readonly NAME_PROCEDURALTEXTURE: string;
  89128. static readonly NAME_SHADOWGENERATOR: string;
  89129. static readonly NAME_OCTREE: string;
  89130. static readonly NAME_PHYSICSENGINE: string;
  89131. static readonly NAME_AUDIO: string;
  89132. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89133. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89134. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89135. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89136. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89137. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89138. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89139. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89140. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89141. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89142. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89143. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89144. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89145. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89146. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89147. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89148. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89149. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89150. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89151. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89152. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89153. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89154. static readonly STEP_AFTERRENDER_AUDIO: number;
  89155. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89156. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89157. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89158. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89159. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89160. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89161. static readonly STEP_POINTERMOVE_SPRITE: number;
  89162. static readonly STEP_POINTERDOWN_SPRITE: number;
  89163. static readonly STEP_POINTERUP_SPRITE: number;
  89164. }
  89165. /**
  89166. * This represents a scene component.
  89167. *
  89168. * This is used to decouple the dependency the scene is having on the different workloads like
  89169. * layers, post processes...
  89170. */
  89171. export interface ISceneComponent {
  89172. /**
  89173. * The name of the component. Each component must have a unique name.
  89174. */
  89175. name: string;
  89176. /**
  89177. * The scene the component belongs to.
  89178. */
  89179. scene: Scene;
  89180. /**
  89181. * Register the component to one instance of a scene.
  89182. */
  89183. register(): void;
  89184. /**
  89185. * Rebuilds the elements related to this component in case of
  89186. * context lost for instance.
  89187. */
  89188. rebuild(): void;
  89189. /**
  89190. * Disposes the component and the associated ressources.
  89191. */
  89192. dispose(): void;
  89193. }
  89194. /**
  89195. * This represents a SERIALIZABLE scene component.
  89196. *
  89197. * This extends Scene Component to add Serialization methods on top.
  89198. */
  89199. export interface ISceneSerializableComponent extends ISceneComponent {
  89200. /**
  89201. * Adds all the elements from the container to the scene
  89202. * @param container the container holding the elements
  89203. */
  89204. addFromContainer(container: AbstractScene): void;
  89205. /**
  89206. * Removes all the elements in the container from the scene
  89207. * @param container contains the elements to remove
  89208. * @param dispose if the removed element should be disposed (default: false)
  89209. */
  89210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89211. /**
  89212. * Serializes the component data to the specified json object
  89213. * @param serializationObject The object to serialize to
  89214. */
  89215. serialize(serializationObject: any): void;
  89216. }
  89217. /**
  89218. * Strong typing of a Mesh related stage step action
  89219. */
  89220. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89221. /**
  89222. * Strong typing of a Evaluate Sub Mesh related stage step action
  89223. */
  89224. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89225. /**
  89226. * Strong typing of a Active Mesh related stage step action
  89227. */
  89228. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89229. /**
  89230. * Strong typing of a Camera related stage step action
  89231. */
  89232. export type CameraStageAction = (camera: Camera) => void;
  89233. /**
  89234. * Strong typing of a Camera Frame buffer related stage step action
  89235. */
  89236. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89237. /**
  89238. * Strong typing of a Render Target related stage step action
  89239. */
  89240. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89241. /**
  89242. * Strong typing of a RenderingGroup related stage step action
  89243. */
  89244. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89245. /**
  89246. * Strong typing of a Mesh Render related stage step action
  89247. */
  89248. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89249. /**
  89250. * Strong typing of a simple stage step action
  89251. */
  89252. export type SimpleStageAction = () => void;
  89253. /**
  89254. * Strong typing of a render target action.
  89255. */
  89256. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89257. /**
  89258. * Strong typing of a pointer move action.
  89259. */
  89260. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89261. /**
  89262. * Strong typing of a pointer up/down action.
  89263. */
  89264. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89265. /**
  89266. * Representation of a stage in the scene (Basically a list of ordered steps)
  89267. * @hidden
  89268. */
  89269. export class Stage<T extends Function> extends Array<{
  89270. index: number;
  89271. component: ISceneComponent;
  89272. action: T;
  89273. }> {
  89274. /**
  89275. * Hide ctor from the rest of the world.
  89276. * @param items The items to add.
  89277. */
  89278. private constructor();
  89279. /**
  89280. * Creates a new Stage.
  89281. * @returns A new instance of a Stage
  89282. */
  89283. static Create<T extends Function>(): Stage<T>;
  89284. /**
  89285. * Registers a step in an ordered way in the targeted stage.
  89286. * @param index Defines the position to register the step in
  89287. * @param component Defines the component attached to the step
  89288. * @param action Defines the action to launch during the step
  89289. */
  89290. registerStep(index: number, component: ISceneComponent, action: T): void;
  89291. /**
  89292. * Clears all the steps from the stage.
  89293. */
  89294. clear(): void;
  89295. }
  89296. }
  89297. declare module BABYLON {
  89298. interface Scene {
  89299. /** @hidden */
  89300. _pointerOverSprite: Nullable<Sprite>;
  89301. /** @hidden */
  89302. _pickedDownSprite: Nullable<Sprite>;
  89303. /** @hidden */
  89304. _tempSpritePickingRay: Nullable<Ray>;
  89305. /**
  89306. * All of the sprite managers added to this scene
  89307. * @see https://doc.babylonjs.com/babylon101/sprites
  89308. */
  89309. spriteManagers: Array<ISpriteManager>;
  89310. /**
  89311. * An event triggered when sprites rendering is about to start
  89312. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89313. */
  89314. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89315. /**
  89316. * An event triggered when sprites rendering is done
  89317. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89318. */
  89319. onAfterSpritesRenderingObservable: Observable<Scene>;
  89320. /** @hidden */
  89321. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89322. /** Launch a ray to try to pick a sprite in the scene
  89323. * @param x position on screen
  89324. * @param y position on screen
  89325. * @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
  89326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89327. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89328. * @returns a PickingInfo
  89329. */
  89330. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89331. /** Use the given ray to pick a sprite in the scene
  89332. * @param ray The ray (in world space) to use to pick meshes
  89333. * @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
  89334. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89335. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89336. * @returns a PickingInfo
  89337. */
  89338. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89339. /** @hidden */
  89340. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89341. /** Launch a ray to try to pick sprites in the scene
  89342. * @param x position on screen
  89343. * @param y position on screen
  89344. * @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
  89345. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89346. * @returns a PickingInfo array
  89347. */
  89348. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89349. /** Use the given ray to pick sprites in the scene
  89350. * @param ray The ray (in world space) to use to pick meshes
  89351. * @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
  89352. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89353. * @returns a PickingInfo array
  89354. */
  89355. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89356. /**
  89357. * Force the sprite under the pointer
  89358. * @param sprite defines the sprite to use
  89359. */
  89360. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89361. /**
  89362. * Gets the sprite under the pointer
  89363. * @returns a Sprite or null if no sprite is under the pointer
  89364. */
  89365. getPointerOverSprite(): Nullable<Sprite>;
  89366. }
  89367. /**
  89368. * Defines the sprite scene component responsible to manage sprites
  89369. * in a given scene.
  89370. */
  89371. export class SpriteSceneComponent implements ISceneComponent {
  89372. /**
  89373. * The component name helpfull to identify the component in the list of scene components.
  89374. */
  89375. readonly name: string;
  89376. /**
  89377. * The scene the component belongs to.
  89378. */
  89379. scene: Scene;
  89380. /** @hidden */
  89381. private _spritePredicate;
  89382. /**
  89383. * Creates a new instance of the component for the given scene
  89384. * @param scene Defines the scene to register the component in
  89385. */
  89386. constructor(scene: Scene);
  89387. /**
  89388. * Registers the component in a given scene
  89389. */
  89390. register(): void;
  89391. /**
  89392. * Rebuilds the elements related to this component in case of
  89393. * context lost for instance.
  89394. */
  89395. rebuild(): void;
  89396. /**
  89397. * Disposes the component and the associated ressources.
  89398. */
  89399. dispose(): void;
  89400. private _pickSpriteButKeepRay;
  89401. private _pointerMove;
  89402. private _pointerDown;
  89403. private _pointerUp;
  89404. }
  89405. }
  89406. declare module BABYLON {
  89407. /** @hidden */
  89408. export var fogFragmentDeclaration: {
  89409. name: string;
  89410. shader: string;
  89411. };
  89412. }
  89413. declare module BABYLON {
  89414. /** @hidden */
  89415. export var fogFragment: {
  89416. name: string;
  89417. shader: string;
  89418. };
  89419. }
  89420. declare module BABYLON {
  89421. /** @hidden */
  89422. export var spritesPixelShader: {
  89423. name: string;
  89424. shader: string;
  89425. };
  89426. }
  89427. declare module BABYLON {
  89428. /** @hidden */
  89429. export var fogVertexDeclaration: {
  89430. name: string;
  89431. shader: string;
  89432. };
  89433. }
  89434. declare module BABYLON {
  89435. /** @hidden */
  89436. export var spritesVertexShader: {
  89437. name: string;
  89438. shader: string;
  89439. };
  89440. }
  89441. declare module BABYLON {
  89442. /**
  89443. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89444. */
  89445. export interface ISpriteManager extends IDisposable {
  89446. /**
  89447. * Gets manager's name
  89448. */
  89449. name: string;
  89450. /**
  89451. * Restricts the camera to viewing objects with the same layerMask.
  89452. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89453. */
  89454. layerMask: number;
  89455. /**
  89456. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89457. */
  89458. isPickable: boolean;
  89459. /**
  89460. * Gets the hosting scene
  89461. */
  89462. scene: Scene;
  89463. /**
  89464. * Specifies the rendering group id for this mesh (0 by default)
  89465. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89466. */
  89467. renderingGroupId: number;
  89468. /**
  89469. * Defines the list of sprites managed by the manager.
  89470. */
  89471. sprites: Array<Sprite>;
  89472. /**
  89473. * Gets or sets the spritesheet texture
  89474. */
  89475. texture: Texture;
  89476. /** Defines the default width of a cell in the spritesheet */
  89477. cellWidth: number;
  89478. /** Defines the default height of a cell in the spritesheet */
  89479. cellHeight: number;
  89480. /**
  89481. * Tests the intersection of a sprite with a specific ray.
  89482. * @param ray The ray we are sending to test the collision
  89483. * @param camera The camera space we are sending rays in
  89484. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89485. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89486. * @returns picking info or null.
  89487. */
  89488. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89489. /**
  89490. * Intersects the sprites with a ray
  89491. * @param ray defines the ray to intersect with
  89492. * @param camera defines the current active camera
  89493. * @param predicate defines a predicate used to select candidate sprites
  89494. * @returns null if no hit or a PickingInfo array
  89495. */
  89496. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89497. /**
  89498. * Renders the list of sprites on screen.
  89499. */
  89500. render(): void;
  89501. }
  89502. /**
  89503. * Class used to manage multiple sprites on the same spritesheet
  89504. * @see https://doc.babylonjs.com/babylon101/sprites
  89505. */
  89506. export class SpriteManager implements ISpriteManager {
  89507. /** defines the manager's name */
  89508. name: string;
  89509. /** Define the Url to load snippets */
  89510. static SnippetUrl: string;
  89511. /** Snippet ID if the manager was created from the snippet server */
  89512. snippetId: string;
  89513. /** Gets the list of sprites */
  89514. sprites: Sprite[];
  89515. /** Gets or sets the rendering group id (0 by default) */
  89516. renderingGroupId: number;
  89517. /** Gets or sets camera layer mask */
  89518. layerMask: number;
  89519. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89520. fogEnabled: boolean;
  89521. /** Gets or sets a boolean indicating if the sprites are pickable */
  89522. isPickable: boolean;
  89523. /** Defines the default width of a cell in the spritesheet */
  89524. cellWidth: number;
  89525. /** Defines the default height of a cell in the spritesheet */
  89526. cellHeight: number;
  89527. /** Associative array from JSON sprite data file */
  89528. private _cellData;
  89529. /** Array of sprite names from JSON sprite data file */
  89530. private _spriteMap;
  89531. /** True when packed cell data from JSON file is ready*/
  89532. private _packedAndReady;
  89533. private _textureContent;
  89534. /**
  89535. * An event triggered when the manager is disposed.
  89536. */
  89537. onDisposeObservable: Observable<SpriteManager>;
  89538. private _onDisposeObserver;
  89539. /**
  89540. * Callback called when the manager is disposed
  89541. */
  89542. set onDispose(callback: () => void);
  89543. private _capacity;
  89544. private _fromPacked;
  89545. private _spriteTexture;
  89546. private _epsilon;
  89547. private _scene;
  89548. private _vertexData;
  89549. private _buffer;
  89550. private _vertexBuffers;
  89551. private _indexBuffer;
  89552. private _effectBase;
  89553. private _effectFog;
  89554. /**
  89555. * Gets or sets the unique id of the sprite
  89556. */
  89557. uniqueId: number;
  89558. /**
  89559. * Gets the array of sprites
  89560. */
  89561. get children(): Sprite[];
  89562. /**
  89563. * Gets the hosting scene
  89564. */
  89565. get scene(): Scene;
  89566. /**
  89567. * Gets the capacity of the manager
  89568. */
  89569. get capacity(): number;
  89570. /**
  89571. * Gets or sets the spritesheet texture
  89572. */
  89573. get texture(): Texture;
  89574. set texture(value: Texture);
  89575. private _blendMode;
  89576. /**
  89577. * Blend mode use to render the particle, it can be any of
  89578. * the static Constants.ALPHA_x properties provided in this class.
  89579. * Default value is Constants.ALPHA_COMBINE
  89580. */
  89581. get blendMode(): number;
  89582. set blendMode(blendMode: number);
  89583. /** Disables writing to the depth buffer when rendering the sprites.
  89584. * It can be handy to disable depth writing when using textures without alpha channel
  89585. * and setting some specific blend modes.
  89586. */
  89587. disableDepthWrite: boolean;
  89588. /**
  89589. * Creates a new sprite manager
  89590. * @param name defines the manager's name
  89591. * @param imgUrl defines the sprite sheet url
  89592. * @param capacity defines the maximum allowed number of sprites
  89593. * @param cellSize defines the size of a sprite cell
  89594. * @param scene defines the hosting scene
  89595. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89596. * @param samplingMode defines the smapling mode to use with spritesheet
  89597. * @param fromPacked set to false; do not alter
  89598. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89599. */
  89600. constructor(
  89601. /** defines the manager's name */
  89602. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89603. /**
  89604. * Returns the string "SpriteManager"
  89605. * @returns "SpriteManager"
  89606. */
  89607. getClassName(): string;
  89608. private _makePacked;
  89609. private _appendSpriteVertex;
  89610. private _checkTextureAlpha;
  89611. /**
  89612. * Intersects the sprites with a ray
  89613. * @param ray defines the ray to intersect with
  89614. * @param camera defines the current active camera
  89615. * @param predicate defines a predicate used to select candidate sprites
  89616. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89617. * @returns null if no hit or a PickingInfo
  89618. */
  89619. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89620. /**
  89621. * Intersects the sprites with a ray
  89622. * @param ray defines the ray to intersect with
  89623. * @param camera defines the current active camera
  89624. * @param predicate defines a predicate used to select candidate sprites
  89625. * @returns null if no hit or a PickingInfo array
  89626. */
  89627. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89628. /**
  89629. * Render all child sprites
  89630. */
  89631. render(): void;
  89632. /**
  89633. * Release associated resources
  89634. */
  89635. dispose(): void;
  89636. /**
  89637. * Serializes the sprite manager to a JSON object
  89638. * @param serializeTexture defines if the texture must be serialized as well
  89639. * @returns the JSON object
  89640. */
  89641. serialize(serializeTexture?: boolean): any;
  89642. /**
  89643. * Parses a JSON object to create a new sprite manager.
  89644. * @param parsedManager The JSON object to parse
  89645. * @param scene The scene to create the sprite managerin
  89646. * @param rootUrl The root url to use to load external dependencies like texture
  89647. * @returns the new sprite manager
  89648. */
  89649. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89650. /**
  89651. * Creates a sprite manager from a snippet saved in a remote file
  89652. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89653. * @param url defines the url to load from
  89654. * @param scene defines the hosting scene
  89655. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89656. * @returns a promise that will resolve to the new sprite manager
  89657. */
  89658. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89659. /**
  89660. * Creates a sprite manager from a snippet saved by the sprite editor
  89661. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  89662. * @param scene defines the hosting scene
  89663. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89664. * @returns a promise that will resolve to the new sprite manager
  89665. */
  89666. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89667. }
  89668. }
  89669. declare module BABYLON {
  89670. /** Interface used by value gradients (color, factor, ...) */
  89671. export interface IValueGradient {
  89672. /**
  89673. * Gets or sets the gradient value (between 0 and 1)
  89674. */
  89675. gradient: number;
  89676. }
  89677. /** Class used to store color4 gradient */
  89678. export class ColorGradient implements IValueGradient {
  89679. /**
  89680. * Gets or sets the gradient value (between 0 and 1)
  89681. */
  89682. gradient: number;
  89683. /**
  89684. * Gets or sets first associated color
  89685. */
  89686. color1: Color4;
  89687. /**
  89688. * Gets or sets second associated color
  89689. */
  89690. color2?: Color4 | undefined;
  89691. /**
  89692. * Creates a new color4 gradient
  89693. * @param gradient gets or sets the gradient value (between 0 and 1)
  89694. * @param color1 gets or sets first associated color
  89695. * @param color2 gets or sets first second color
  89696. */
  89697. constructor(
  89698. /**
  89699. * Gets or sets the gradient value (between 0 and 1)
  89700. */
  89701. gradient: number,
  89702. /**
  89703. * Gets or sets first associated color
  89704. */
  89705. color1: Color4,
  89706. /**
  89707. * Gets or sets second associated color
  89708. */
  89709. color2?: Color4 | undefined);
  89710. /**
  89711. * Will get a color picked randomly between color1 and color2.
  89712. * If color2 is undefined then color1 will be used
  89713. * @param result defines the target Color4 to store the result in
  89714. */
  89715. getColorToRef(result: Color4): void;
  89716. }
  89717. /** Class used to store color 3 gradient */
  89718. export class Color3Gradient implements IValueGradient {
  89719. /**
  89720. * Gets or sets the gradient value (between 0 and 1)
  89721. */
  89722. gradient: number;
  89723. /**
  89724. * Gets or sets the associated color
  89725. */
  89726. color: Color3;
  89727. /**
  89728. * Creates a new color3 gradient
  89729. * @param gradient gets or sets the gradient value (between 0 and 1)
  89730. * @param color gets or sets associated color
  89731. */
  89732. constructor(
  89733. /**
  89734. * Gets or sets the gradient value (between 0 and 1)
  89735. */
  89736. gradient: number,
  89737. /**
  89738. * Gets or sets the associated color
  89739. */
  89740. color: Color3);
  89741. }
  89742. /** Class used to store factor gradient */
  89743. export class FactorGradient implements IValueGradient {
  89744. /**
  89745. * Gets or sets the gradient value (between 0 and 1)
  89746. */
  89747. gradient: number;
  89748. /**
  89749. * Gets or sets first associated factor
  89750. */
  89751. factor1: number;
  89752. /**
  89753. * Gets or sets second associated factor
  89754. */
  89755. factor2?: number | undefined;
  89756. /**
  89757. * Creates a new factor gradient
  89758. * @param gradient gets or sets the gradient value (between 0 and 1)
  89759. * @param factor1 gets or sets first associated factor
  89760. * @param factor2 gets or sets second associated factor
  89761. */
  89762. constructor(
  89763. /**
  89764. * Gets or sets the gradient value (between 0 and 1)
  89765. */
  89766. gradient: number,
  89767. /**
  89768. * Gets or sets first associated factor
  89769. */
  89770. factor1: number,
  89771. /**
  89772. * Gets or sets second associated factor
  89773. */
  89774. factor2?: number | undefined);
  89775. /**
  89776. * Will get a number picked randomly between factor1 and factor2.
  89777. * If factor2 is undefined then factor1 will be used
  89778. * @returns the picked number
  89779. */
  89780. getFactor(): number;
  89781. }
  89782. /**
  89783. * Helper used to simplify some generic gradient tasks
  89784. */
  89785. export class GradientHelper {
  89786. /**
  89787. * Gets the current gradient from an array of IValueGradient
  89788. * @param ratio defines the current ratio to get
  89789. * @param gradients defines the array of IValueGradient
  89790. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89791. */
  89792. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89793. }
  89794. }
  89795. declare module BABYLON {
  89796. interface ThinEngine {
  89797. /**
  89798. * Creates a raw texture
  89799. * @param data defines the data to store in the texture
  89800. * @param width defines the width of the texture
  89801. * @param height defines the height of the texture
  89802. * @param format defines the format of the data
  89803. * @param generateMipMaps defines if the engine should generate the mip levels
  89804. * @param invertY defines if data must be stored with Y axis inverted
  89805. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89806. * @param compression defines the compression used (null by default)
  89807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89808. * @returns the raw texture inside an InternalTexture
  89809. */
  89810. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89811. /**
  89812. * Update a raw texture
  89813. * @param texture defines the texture to update
  89814. * @param data defines the data to store in the texture
  89815. * @param format defines the format of the data
  89816. * @param invertY defines if data must be stored with Y axis inverted
  89817. */
  89818. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89819. /**
  89820. * Update a raw texture
  89821. * @param texture defines the texture to update
  89822. * @param data defines the data to store in the texture
  89823. * @param format defines the format of the data
  89824. * @param invertY defines if data must be stored with Y axis inverted
  89825. * @param compression defines the compression used (null by default)
  89826. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89827. */
  89828. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89829. /**
  89830. * Creates a new raw cube texture
  89831. * @param data defines the array of data to use to create each face
  89832. * @param size defines the size of the textures
  89833. * @param format defines the format of the data
  89834. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89835. * @param generateMipMaps defines if the engine should generate the mip levels
  89836. * @param invertY defines if data must be stored with Y axis inverted
  89837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89838. * @param compression defines the compression used (null by default)
  89839. * @returns the cube texture as an InternalTexture
  89840. */
  89841. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89842. /**
  89843. * Update a raw cube texture
  89844. * @param texture defines the texture to udpdate
  89845. * @param data defines the data to store
  89846. * @param format defines the data format
  89847. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89848. * @param invertY defines if data must be stored with Y axis inverted
  89849. */
  89850. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89851. /**
  89852. * Update a raw cube texture
  89853. * @param texture defines the texture to udpdate
  89854. * @param data defines the data to store
  89855. * @param format defines the data format
  89856. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89857. * @param invertY defines if data must be stored with Y axis inverted
  89858. * @param compression defines the compression used (null by default)
  89859. */
  89860. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89861. /**
  89862. * Update a raw cube texture
  89863. * @param texture defines the texture to udpdate
  89864. * @param data defines the data to store
  89865. * @param format defines the data format
  89866. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89867. * @param invertY defines if data must be stored with Y axis inverted
  89868. * @param compression defines the compression used (null by default)
  89869. * @param level defines which level of the texture to update
  89870. */
  89871. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89872. /**
  89873. * Creates a new raw cube texture from a specified url
  89874. * @param url defines the url where the data is located
  89875. * @param scene defines the current scene
  89876. * @param size defines the size of the textures
  89877. * @param format defines the format of the data
  89878. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89879. * @param noMipmap defines if the engine should avoid generating the mip levels
  89880. * @param callback defines a callback used to extract texture data from loaded data
  89881. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89882. * @param onLoad defines a callback called when texture is loaded
  89883. * @param onError defines a callback called if there is an error
  89884. * @returns the cube texture as an InternalTexture
  89885. */
  89886. 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;
  89887. /**
  89888. * Creates a new raw cube texture from a specified url
  89889. * @param url defines the url where the data is located
  89890. * @param scene defines the current scene
  89891. * @param size defines the size of the textures
  89892. * @param format defines the format of the data
  89893. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89894. * @param noMipmap defines if the engine should avoid generating the mip levels
  89895. * @param callback defines a callback used to extract texture data from loaded data
  89896. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89897. * @param onLoad defines a callback called when texture is loaded
  89898. * @param onError defines a callback called if there is an error
  89899. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89900. * @param invertY defines if data must be stored with Y axis inverted
  89901. * @returns the cube texture as an InternalTexture
  89902. */
  89903. 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;
  89904. /**
  89905. * Creates a new raw 3D texture
  89906. * @param data defines the data used to create the texture
  89907. * @param width defines the width of the texture
  89908. * @param height defines the height of the texture
  89909. * @param depth defines the depth of the texture
  89910. * @param format defines the format of the texture
  89911. * @param generateMipMaps defines if the engine must generate mip levels
  89912. * @param invertY defines if data must be stored with Y axis inverted
  89913. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89914. * @param compression defines the compressed used (can be null)
  89915. * @param textureType defines the compressed used (can be null)
  89916. * @returns a new raw 3D texture (stored in an InternalTexture)
  89917. */
  89918. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89919. /**
  89920. * Update a raw 3D texture
  89921. * @param texture defines the texture to update
  89922. * @param data defines the data to store
  89923. * @param format defines the data format
  89924. * @param invertY defines if data must be stored with Y axis inverted
  89925. */
  89926. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89927. /**
  89928. * Update a raw 3D texture
  89929. * @param texture defines the texture to update
  89930. * @param data defines the data to store
  89931. * @param format defines the data format
  89932. * @param invertY defines if data must be stored with Y axis inverted
  89933. * @param compression defines the used compression (can be null)
  89934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89935. */
  89936. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89937. /**
  89938. * Creates a new raw 2D array texture
  89939. * @param data defines the data used to create the texture
  89940. * @param width defines the width of the texture
  89941. * @param height defines the height of the texture
  89942. * @param depth defines the number of layers of the texture
  89943. * @param format defines the format of the texture
  89944. * @param generateMipMaps defines if the engine must generate mip levels
  89945. * @param invertY defines if data must be stored with Y axis inverted
  89946. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89947. * @param compression defines the compressed used (can be null)
  89948. * @param textureType defines the compressed used (can be null)
  89949. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89950. */
  89951. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89952. /**
  89953. * Update a raw 2D array texture
  89954. * @param texture defines the texture to update
  89955. * @param data defines the data to store
  89956. * @param format defines the data format
  89957. * @param invertY defines if data must be stored with Y axis inverted
  89958. */
  89959. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89960. /**
  89961. * Update a raw 2D array texture
  89962. * @param texture defines the texture to update
  89963. * @param data defines the data to store
  89964. * @param format defines the data format
  89965. * @param invertY defines if data must be stored with Y axis inverted
  89966. * @param compression defines the used compression (can be null)
  89967. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89968. */
  89969. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89970. }
  89971. }
  89972. declare module BABYLON {
  89973. /**
  89974. * Raw texture can help creating a texture directly from an array of data.
  89975. * This can be super useful if you either get the data from an uncompressed source or
  89976. * if you wish to create your texture pixel by pixel.
  89977. */
  89978. export class RawTexture extends Texture {
  89979. /**
  89980. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89981. */
  89982. format: number;
  89983. /**
  89984. * Instantiates a new RawTexture.
  89985. * Raw texture can help creating a texture directly from an array of data.
  89986. * This can be super useful if you either get the data from an uncompressed source or
  89987. * if you wish to create your texture pixel by pixel.
  89988. * @param data define the array of data to use to create the texture
  89989. * @param width define the width of the texture
  89990. * @param height define the height of the texture
  89991. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89992. * @param scene define the scene the texture belongs to
  89993. * @param generateMipMaps define whether mip maps should be generated or not
  89994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89997. */
  89998. constructor(data: ArrayBufferView, width: number, height: number,
  89999. /**
  90000. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90001. */
  90002. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90003. /**
  90004. * Updates the texture underlying data.
  90005. * @param data Define the new data of the texture
  90006. */
  90007. update(data: ArrayBufferView): void;
  90008. /**
  90009. * Creates a luminance texture from some data.
  90010. * @param data Define the texture data
  90011. * @param width Define the width of the texture
  90012. * @param height Define the height of the texture
  90013. * @param scene Define the scene the texture belongs to
  90014. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90015. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90016. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90017. * @returns the luminance texture
  90018. */
  90019. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90020. /**
  90021. * Creates a luminance alpha texture from some data.
  90022. * @param data Define the texture data
  90023. * @param width Define the width of the texture
  90024. * @param height Define the height of the texture
  90025. * @param scene Define the scene the texture belongs to
  90026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90029. * @returns the luminance alpha texture
  90030. */
  90031. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90032. /**
  90033. * Creates an alpha texture from some data.
  90034. * @param data Define the texture data
  90035. * @param width Define the width of the texture
  90036. * @param height Define the height of the texture
  90037. * @param scene Define the scene the texture belongs to
  90038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90041. * @returns the alpha texture
  90042. */
  90043. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90044. /**
  90045. * Creates a RGB texture from some data.
  90046. * @param data Define the texture data
  90047. * @param width Define the width of the texture
  90048. * @param height Define the height of the texture
  90049. * @param scene Define the scene the texture belongs to
  90050. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90053. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90054. * @returns the RGB alpha texture
  90055. */
  90056. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90057. /**
  90058. * Creates a RGBA texture from some data.
  90059. * @param data Define the texture data
  90060. * @param width Define the width of the texture
  90061. * @param height Define the height of the texture
  90062. * @param scene Define the scene the texture belongs to
  90063. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90064. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90065. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90066. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90067. * @returns the RGBA texture
  90068. */
  90069. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90070. /**
  90071. * Creates a R texture from some data.
  90072. * @param data Define the texture data
  90073. * @param width Define the width of the texture
  90074. * @param height Define the height of the texture
  90075. * @param scene Define the scene the texture belongs to
  90076. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90077. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90078. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90079. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90080. * @returns the R texture
  90081. */
  90082. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90083. }
  90084. }
  90085. declare module BABYLON {
  90086. interface AbstractScene {
  90087. /**
  90088. * The list of procedural textures added to the scene
  90089. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90090. */
  90091. proceduralTextures: Array<ProceduralTexture>;
  90092. }
  90093. /**
  90094. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90095. * in a given scene.
  90096. */
  90097. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90098. /**
  90099. * The component name helpfull to identify the component in the list of scene components.
  90100. */
  90101. readonly name: string;
  90102. /**
  90103. * The scene the component belongs to.
  90104. */
  90105. scene: Scene;
  90106. /**
  90107. * Creates a new instance of the component for the given scene
  90108. * @param scene Defines the scene to register the component in
  90109. */
  90110. constructor(scene: Scene);
  90111. /**
  90112. * Registers the component in a given scene
  90113. */
  90114. register(): void;
  90115. /**
  90116. * Rebuilds the elements related to this component in case of
  90117. * context lost for instance.
  90118. */
  90119. rebuild(): void;
  90120. /**
  90121. * Disposes the component and the associated ressources.
  90122. */
  90123. dispose(): void;
  90124. private _beforeClear;
  90125. }
  90126. }
  90127. declare module BABYLON {
  90128. interface ThinEngine {
  90129. /**
  90130. * Creates a new render target cube texture
  90131. * @param size defines the size of the texture
  90132. * @param options defines the options used to create the texture
  90133. * @returns a new render target cube texture stored in an InternalTexture
  90134. */
  90135. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90136. }
  90137. }
  90138. declare module BABYLON {
  90139. /** @hidden */
  90140. export var proceduralVertexShader: {
  90141. name: string;
  90142. shader: string;
  90143. };
  90144. }
  90145. declare module BABYLON {
  90146. /**
  90147. * 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.
  90148. * This is the base class of any Procedural texture and contains most of the shareable code.
  90149. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90150. */
  90151. export class ProceduralTexture extends Texture {
  90152. isCube: boolean;
  90153. /**
  90154. * Define if the texture is enabled or not (disabled texture will not render)
  90155. */
  90156. isEnabled: boolean;
  90157. /**
  90158. * Define if the texture must be cleared before rendering (default is true)
  90159. */
  90160. autoClear: boolean;
  90161. /**
  90162. * Callback called when the texture is generated
  90163. */
  90164. onGenerated: () => void;
  90165. /**
  90166. * Event raised when the texture is generated
  90167. */
  90168. onGeneratedObservable: Observable<ProceduralTexture>;
  90169. /** @hidden */
  90170. _generateMipMaps: boolean;
  90171. /** @hidden **/
  90172. _effect: Effect;
  90173. /** @hidden */
  90174. _textures: {
  90175. [key: string]: Texture;
  90176. };
  90177. /** @hidden */
  90178. protected _fallbackTexture: Nullable<Texture>;
  90179. private _size;
  90180. private _currentRefreshId;
  90181. private _frameId;
  90182. private _refreshRate;
  90183. private _vertexBuffers;
  90184. private _indexBuffer;
  90185. private _uniforms;
  90186. private _samplers;
  90187. private _fragment;
  90188. private _floats;
  90189. private _ints;
  90190. private _floatsArrays;
  90191. private _colors3;
  90192. private _colors4;
  90193. private _vectors2;
  90194. private _vectors3;
  90195. private _matrices;
  90196. private _fallbackTextureUsed;
  90197. private _fullEngine;
  90198. private _cachedDefines;
  90199. private _contentUpdateId;
  90200. private _contentData;
  90201. /**
  90202. * Instantiates a new procedural texture.
  90203. * 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.
  90204. * This is the base class of any Procedural texture and contains most of the shareable code.
  90205. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90206. * @param name Define the name of the texture
  90207. * @param size Define the size of the texture to create
  90208. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90209. * @param scene Define the scene the texture belongs to
  90210. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90211. * @param generateMipMaps Define if the texture should creates mip maps or not
  90212. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90213. */
  90214. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90215. /**
  90216. * The effect that is created when initializing the post process.
  90217. * @returns The created effect corresponding the the postprocess.
  90218. */
  90219. getEffect(): Effect;
  90220. /**
  90221. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90222. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90223. */
  90224. getContent(): Nullable<ArrayBufferView>;
  90225. private _createIndexBuffer;
  90226. /** @hidden */
  90227. _rebuild(): void;
  90228. /**
  90229. * Resets the texture in order to recreate its associated resources.
  90230. * This can be called in case of context loss
  90231. */
  90232. reset(): void;
  90233. protected _getDefines(): string;
  90234. /**
  90235. * Is the texture ready to be used ? (rendered at least once)
  90236. * @returns true if ready, otherwise, false.
  90237. */
  90238. isReady(): boolean;
  90239. /**
  90240. * Resets the refresh counter of the texture and start bak from scratch.
  90241. * Could be useful to regenerate the texture if it is setup to render only once.
  90242. */
  90243. resetRefreshCounter(): void;
  90244. /**
  90245. * Set the fragment shader to use in order to render the texture.
  90246. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90247. */
  90248. setFragment(fragment: any): void;
  90249. /**
  90250. * Define the refresh rate of the texture or the rendering frequency.
  90251. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90252. */
  90253. get refreshRate(): number;
  90254. set refreshRate(value: number);
  90255. /** @hidden */
  90256. _shouldRender(): boolean;
  90257. /**
  90258. * Get the size the texture is rendering at.
  90259. * @returns the size (texture is always squared)
  90260. */
  90261. getRenderSize(): number;
  90262. /**
  90263. * Resize the texture to new value.
  90264. * @param size Define the new size the texture should have
  90265. * @param generateMipMaps Define whether the new texture should create mip maps
  90266. */
  90267. resize(size: number, generateMipMaps: boolean): void;
  90268. private _checkUniform;
  90269. /**
  90270. * Set a texture in the shader program used to render.
  90271. * @param name Define the name of the uniform samplers as defined in the shader
  90272. * @param texture Define the texture to bind to this sampler
  90273. * @return the texture itself allowing "fluent" like uniform updates
  90274. */
  90275. setTexture(name: string, texture: Texture): ProceduralTexture;
  90276. /**
  90277. * Set a float in the shader.
  90278. * @param name Define the name of the uniform as defined in the shader
  90279. * @param value Define the value to give to the uniform
  90280. * @return the texture itself allowing "fluent" like uniform updates
  90281. */
  90282. setFloat(name: string, value: number): ProceduralTexture;
  90283. /**
  90284. * Set a int in the shader.
  90285. * @param name Define the name of the uniform as defined in the shader
  90286. * @param value Define the value to give to the uniform
  90287. * @return the texture itself allowing "fluent" like uniform updates
  90288. */
  90289. setInt(name: string, value: number): ProceduralTexture;
  90290. /**
  90291. * Set an array of floats in the shader.
  90292. * @param name Define the name of the uniform as defined in the shader
  90293. * @param value Define the value to give to the uniform
  90294. * @return the texture itself allowing "fluent" like uniform updates
  90295. */
  90296. setFloats(name: string, value: number[]): ProceduralTexture;
  90297. /**
  90298. * Set a vec3 in the shader from a Color3.
  90299. * @param name Define the name of the uniform as defined in the shader
  90300. * @param value Define the value to give to the uniform
  90301. * @return the texture itself allowing "fluent" like uniform updates
  90302. */
  90303. setColor3(name: string, value: Color3): ProceduralTexture;
  90304. /**
  90305. * Set a vec4 in the shader from a Color4.
  90306. * @param name Define the name of the uniform as defined in the shader
  90307. * @param value Define the value to give to the uniform
  90308. * @return the texture itself allowing "fluent" like uniform updates
  90309. */
  90310. setColor4(name: string, value: Color4): ProceduralTexture;
  90311. /**
  90312. * Set a vec2 in the shader from a Vector2.
  90313. * @param name Define the name of the uniform as defined in the shader
  90314. * @param value Define the value to give to the uniform
  90315. * @return the texture itself allowing "fluent" like uniform updates
  90316. */
  90317. setVector2(name: string, value: Vector2): ProceduralTexture;
  90318. /**
  90319. * Set a vec3 in the shader from a Vector3.
  90320. * @param name Define the name of the uniform as defined in the shader
  90321. * @param value Define the value to give to the uniform
  90322. * @return the texture itself allowing "fluent" like uniform updates
  90323. */
  90324. setVector3(name: string, value: Vector3): ProceduralTexture;
  90325. /**
  90326. * Set a mat4 in the shader from a MAtrix.
  90327. * @param name Define the name of the uniform as defined in the shader
  90328. * @param value Define the value to give to the uniform
  90329. * @return the texture itself allowing "fluent" like uniform updates
  90330. */
  90331. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90332. /**
  90333. * Render the texture to its associated render target.
  90334. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90335. */
  90336. render(useCameraPostProcess?: boolean): void;
  90337. /**
  90338. * Clone the texture.
  90339. * @returns the cloned texture
  90340. */
  90341. clone(): ProceduralTexture;
  90342. /**
  90343. * Dispose the texture and release its asoociated resources.
  90344. */
  90345. dispose(): void;
  90346. }
  90347. }
  90348. declare module BABYLON {
  90349. /**
  90350. * This represents the base class for particle system in Babylon.
  90351. * 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.
  90352. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90353. * @example https://doc.babylonjs.com/babylon101/particles
  90354. */
  90355. export class BaseParticleSystem {
  90356. /**
  90357. * Source color is added to the destination color without alpha affecting the result
  90358. */
  90359. static BLENDMODE_ONEONE: number;
  90360. /**
  90361. * Blend current color and particle color using particle’s alpha
  90362. */
  90363. static BLENDMODE_STANDARD: number;
  90364. /**
  90365. * Add current color and particle color multiplied by particle’s alpha
  90366. */
  90367. static BLENDMODE_ADD: number;
  90368. /**
  90369. * Multiply current color with particle color
  90370. */
  90371. static BLENDMODE_MULTIPLY: number;
  90372. /**
  90373. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90374. */
  90375. static BLENDMODE_MULTIPLYADD: number;
  90376. /**
  90377. * List of animations used by the particle system.
  90378. */
  90379. animations: Animation[];
  90380. /**
  90381. * Gets or sets the unique id of the particle system
  90382. */
  90383. uniqueId: number;
  90384. /**
  90385. * The id of the Particle system.
  90386. */
  90387. id: string;
  90388. /**
  90389. * The friendly name of the Particle system.
  90390. */
  90391. name: string;
  90392. /**
  90393. * Snippet ID if the particle system was created from the snippet server
  90394. */
  90395. snippetId: string;
  90396. /**
  90397. * The rendering group used by the Particle system to chose when to render.
  90398. */
  90399. renderingGroupId: number;
  90400. /**
  90401. * The emitter represents the Mesh or position we are attaching the particle system to.
  90402. */
  90403. emitter: Nullable<AbstractMesh | Vector3>;
  90404. /**
  90405. * The maximum number of particles to emit per frame
  90406. */
  90407. emitRate: number;
  90408. /**
  90409. * If you want to launch only a few particles at once, that can be done, as well.
  90410. */
  90411. manualEmitCount: number;
  90412. /**
  90413. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90414. */
  90415. updateSpeed: number;
  90416. /**
  90417. * The amount of time the particle system is running (depends of the overall update speed).
  90418. */
  90419. targetStopDuration: number;
  90420. /**
  90421. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90422. */
  90423. disposeOnStop: boolean;
  90424. /**
  90425. * Minimum power of emitting particles.
  90426. */
  90427. minEmitPower: number;
  90428. /**
  90429. * Maximum power of emitting particles.
  90430. */
  90431. maxEmitPower: number;
  90432. /**
  90433. * Minimum life time of emitting particles.
  90434. */
  90435. minLifeTime: number;
  90436. /**
  90437. * Maximum life time of emitting particles.
  90438. */
  90439. maxLifeTime: number;
  90440. /**
  90441. * Minimum Size of emitting particles.
  90442. */
  90443. minSize: number;
  90444. /**
  90445. * Maximum Size of emitting particles.
  90446. */
  90447. maxSize: number;
  90448. /**
  90449. * Minimum scale of emitting particles on X axis.
  90450. */
  90451. minScaleX: number;
  90452. /**
  90453. * Maximum scale of emitting particles on X axis.
  90454. */
  90455. maxScaleX: number;
  90456. /**
  90457. * Minimum scale of emitting particles on Y axis.
  90458. */
  90459. minScaleY: number;
  90460. /**
  90461. * Maximum scale of emitting particles on Y axis.
  90462. */
  90463. maxScaleY: number;
  90464. /**
  90465. * Gets or sets the minimal initial rotation in radians.
  90466. */
  90467. minInitialRotation: number;
  90468. /**
  90469. * Gets or sets the maximal initial rotation in radians.
  90470. */
  90471. maxInitialRotation: number;
  90472. /**
  90473. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90474. */
  90475. minAngularSpeed: number;
  90476. /**
  90477. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90478. */
  90479. maxAngularSpeed: number;
  90480. /**
  90481. * The texture used to render each particle. (this can be a spritesheet)
  90482. */
  90483. particleTexture: Nullable<Texture>;
  90484. /**
  90485. * The layer mask we are rendering the particles through.
  90486. */
  90487. layerMask: number;
  90488. /**
  90489. * This can help using your own shader to render the particle system.
  90490. * The according effect will be created
  90491. */
  90492. customShader: any;
  90493. /**
  90494. * By default particle system starts as soon as they are created. This prevents the
  90495. * automatic start to happen and let you decide when to start emitting particles.
  90496. */
  90497. preventAutoStart: boolean;
  90498. private _noiseTexture;
  90499. /**
  90500. * Gets or sets a texture used to add random noise to particle positions
  90501. */
  90502. get noiseTexture(): Nullable<ProceduralTexture>;
  90503. set noiseTexture(value: Nullable<ProceduralTexture>);
  90504. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90505. noiseStrength: Vector3;
  90506. /**
  90507. * Callback triggered when the particle animation is ending.
  90508. */
  90509. onAnimationEnd: Nullable<() => void>;
  90510. /**
  90511. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90512. */
  90513. blendMode: number;
  90514. /**
  90515. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90516. * to override the particles.
  90517. */
  90518. forceDepthWrite: boolean;
  90519. /** 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 */
  90520. preWarmCycles: number;
  90521. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90522. preWarmStepOffset: number;
  90523. /**
  90524. * 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)
  90525. */
  90526. spriteCellChangeSpeed: number;
  90527. /**
  90528. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90529. */
  90530. startSpriteCellID: number;
  90531. /**
  90532. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90533. */
  90534. endSpriteCellID: number;
  90535. /**
  90536. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90537. */
  90538. spriteCellWidth: number;
  90539. /**
  90540. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90541. */
  90542. spriteCellHeight: number;
  90543. /**
  90544. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90545. */
  90546. spriteRandomStartCell: boolean;
  90547. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90548. translationPivot: Vector2;
  90549. /** @hidden */
  90550. protected _isAnimationSheetEnabled: boolean;
  90551. /**
  90552. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90553. */
  90554. beginAnimationOnStart: boolean;
  90555. /**
  90556. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90557. */
  90558. beginAnimationFrom: number;
  90559. /**
  90560. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90561. */
  90562. beginAnimationTo: number;
  90563. /**
  90564. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90565. */
  90566. beginAnimationLoop: boolean;
  90567. /**
  90568. * Gets or sets a world offset applied to all particles
  90569. */
  90570. worldOffset: Vector3;
  90571. /**
  90572. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90573. */
  90574. get isAnimationSheetEnabled(): boolean;
  90575. set isAnimationSheetEnabled(value: boolean);
  90576. /**
  90577. * Get hosting scene
  90578. * @returns the scene
  90579. */
  90580. getScene(): Scene;
  90581. /**
  90582. * You can use gravity if you want to give an orientation to your particles.
  90583. */
  90584. gravity: Vector3;
  90585. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90586. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90587. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90588. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90589. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90590. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90591. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90592. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90593. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90594. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90595. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90596. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90597. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90598. /**
  90599. * Defines the delay in milliseconds before starting the system (0 by default)
  90600. */
  90601. startDelay: number;
  90602. /**
  90603. * Gets the current list of drag gradients.
  90604. * You must use addDragGradient and removeDragGradient to udpate this list
  90605. * @returns the list of drag gradients
  90606. */
  90607. getDragGradients(): Nullable<Array<FactorGradient>>;
  90608. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90609. limitVelocityDamping: number;
  90610. /**
  90611. * Gets the current list of limit velocity gradients.
  90612. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90613. * @returns the list of limit velocity gradients
  90614. */
  90615. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90616. /**
  90617. * Gets the current list of color gradients.
  90618. * You must use addColorGradient and removeColorGradient to udpate this list
  90619. * @returns the list of color gradients
  90620. */
  90621. getColorGradients(): Nullable<Array<ColorGradient>>;
  90622. /**
  90623. * Gets the current list of size gradients.
  90624. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90625. * @returns the list of size gradients
  90626. */
  90627. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90628. /**
  90629. * Gets the current list of color remap gradients.
  90630. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90631. * @returns the list of color remap gradients
  90632. */
  90633. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90634. /**
  90635. * Gets the current list of alpha remap gradients.
  90636. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90637. * @returns the list of alpha remap gradients
  90638. */
  90639. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90640. /**
  90641. * Gets the current list of life time gradients.
  90642. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90643. * @returns the list of life time gradients
  90644. */
  90645. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90646. /**
  90647. * Gets the current list of angular speed gradients.
  90648. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90649. * @returns the list of angular speed gradients
  90650. */
  90651. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90652. /**
  90653. * Gets the current list of velocity gradients.
  90654. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90655. * @returns the list of velocity gradients
  90656. */
  90657. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90658. /**
  90659. * Gets the current list of start size gradients.
  90660. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90661. * @returns the list of start size gradients
  90662. */
  90663. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90664. /**
  90665. * Gets the current list of emit rate gradients.
  90666. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90667. * @returns the list of emit rate gradients
  90668. */
  90669. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90670. /**
  90671. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90672. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90673. */
  90674. get direction1(): Vector3;
  90675. set direction1(value: Vector3);
  90676. /**
  90677. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90678. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90679. */
  90680. get direction2(): Vector3;
  90681. set direction2(value: Vector3);
  90682. /**
  90683. * 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.
  90684. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90685. */
  90686. get minEmitBox(): Vector3;
  90687. set minEmitBox(value: Vector3);
  90688. /**
  90689. * 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.
  90690. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90691. */
  90692. get maxEmitBox(): Vector3;
  90693. set maxEmitBox(value: Vector3);
  90694. /**
  90695. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90696. */
  90697. color1: Color4;
  90698. /**
  90699. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90700. */
  90701. color2: Color4;
  90702. /**
  90703. * Color the particle will have at the end of its lifetime
  90704. */
  90705. colorDead: Color4;
  90706. /**
  90707. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90708. */
  90709. textureMask: Color4;
  90710. /**
  90711. * The particle emitter type defines the emitter used by the particle system.
  90712. * It can be for example box, sphere, or cone...
  90713. */
  90714. particleEmitterType: IParticleEmitterType;
  90715. /** @hidden */
  90716. _isSubEmitter: boolean;
  90717. /**
  90718. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90719. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90720. */
  90721. billboardMode: number;
  90722. protected _isBillboardBased: boolean;
  90723. /**
  90724. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90725. */
  90726. get isBillboardBased(): boolean;
  90727. set isBillboardBased(value: boolean);
  90728. /**
  90729. * The scene the particle system belongs to.
  90730. */
  90731. protected _scene: Scene;
  90732. /**
  90733. * Local cache of defines for image processing.
  90734. */
  90735. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90736. /**
  90737. * Default configuration related to image processing available in the standard Material.
  90738. */
  90739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90740. /**
  90741. * Gets the image processing configuration used either in this material.
  90742. */
  90743. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90744. /**
  90745. * Sets the Default image processing configuration used either in the this material.
  90746. *
  90747. * If sets to null, the scene one is in use.
  90748. */
  90749. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90750. /**
  90751. * Attaches a new image processing configuration to the Standard Material.
  90752. * @param configuration
  90753. */
  90754. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90755. /** @hidden */
  90756. protected _reset(): void;
  90757. /** @hidden */
  90758. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90759. /**
  90760. * Instantiates a particle system.
  90761. * 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.
  90762. * @param name The name of the particle system
  90763. */
  90764. constructor(name: string);
  90765. /**
  90766. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90769. * @returns the emitter
  90770. */
  90771. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90772. /**
  90773. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90774. * @param radius The radius of the hemisphere to emit from
  90775. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90776. * @returns the emitter
  90777. */
  90778. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90779. /**
  90780. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90781. * @param radius The radius of the sphere to emit from
  90782. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90783. * @returns the emitter
  90784. */
  90785. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90786. /**
  90787. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90788. * @param radius The radius of the sphere to emit from
  90789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90791. * @returns the emitter
  90792. */
  90793. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90794. /**
  90795. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90796. * @param radius The radius of the emission cylinder
  90797. * @param height The height of the emission cylinder
  90798. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90799. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90800. * @returns the emitter
  90801. */
  90802. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90803. /**
  90804. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90805. * @param radius The radius of the cylinder to emit from
  90806. * @param height The height of the emission cylinder
  90807. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90810. * @returns the emitter
  90811. */
  90812. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90813. /**
  90814. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90815. * @param radius The radius of the cone to emit from
  90816. * @param angle The base angle of the cone
  90817. * @returns the emitter
  90818. */
  90819. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90820. /**
  90821. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90824. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90825. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90826. * @returns the emitter
  90827. */
  90828. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90829. }
  90830. }
  90831. declare module BABYLON {
  90832. /**
  90833. * Type of sub emitter
  90834. */
  90835. export enum SubEmitterType {
  90836. /**
  90837. * Attached to the particle over it's lifetime
  90838. */
  90839. ATTACHED = 0,
  90840. /**
  90841. * Created when the particle dies
  90842. */
  90843. END = 1
  90844. }
  90845. /**
  90846. * Sub emitter class used to emit particles from an existing particle
  90847. */
  90848. export class SubEmitter {
  90849. /**
  90850. * the particle system to be used by the sub emitter
  90851. */
  90852. particleSystem: ParticleSystem;
  90853. /**
  90854. * Type of the submitter (Default: END)
  90855. */
  90856. type: SubEmitterType;
  90857. /**
  90858. * 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)
  90859. * Note: This only is supported when using an emitter of type Mesh
  90860. */
  90861. inheritDirection: boolean;
  90862. /**
  90863. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90864. */
  90865. inheritedVelocityAmount: number;
  90866. /**
  90867. * Creates a sub emitter
  90868. * @param particleSystem the particle system to be used by the sub emitter
  90869. */
  90870. constructor(
  90871. /**
  90872. * the particle system to be used by the sub emitter
  90873. */
  90874. particleSystem: ParticleSystem);
  90875. /**
  90876. * Clones the sub emitter
  90877. * @returns the cloned sub emitter
  90878. */
  90879. clone(): SubEmitter;
  90880. /**
  90881. * Serialize current object to a JSON object
  90882. * @returns the serialized object
  90883. */
  90884. serialize(): any;
  90885. /** @hidden */
  90886. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90887. /**
  90888. * Creates a new SubEmitter from a serialized JSON version
  90889. * @param serializationObject defines the JSON object to read from
  90890. * @param scene defines the hosting scene
  90891. * @param rootUrl defines the rootUrl for data loading
  90892. * @returns a new SubEmitter
  90893. */
  90894. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90895. /** Release associated resources */
  90896. dispose(): void;
  90897. }
  90898. }
  90899. declare module BABYLON {
  90900. /** @hidden */
  90901. export var imageProcessingDeclaration: {
  90902. name: string;
  90903. shader: string;
  90904. };
  90905. }
  90906. declare module BABYLON {
  90907. /** @hidden */
  90908. export var imageProcessingFunctions: {
  90909. name: string;
  90910. shader: string;
  90911. };
  90912. }
  90913. declare module BABYLON {
  90914. /** @hidden */
  90915. export var particlesPixelShader: {
  90916. name: string;
  90917. shader: string;
  90918. };
  90919. }
  90920. declare module BABYLON {
  90921. /** @hidden */
  90922. export var particlesVertexShader: {
  90923. name: string;
  90924. shader: string;
  90925. };
  90926. }
  90927. declare module BABYLON {
  90928. /**
  90929. * This represents a particle system in Babylon.
  90930. * 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.
  90931. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90932. * @example https://doc.babylonjs.com/babylon101/particles
  90933. */
  90934. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90935. /**
  90936. * Billboard mode will only apply to Y axis
  90937. */
  90938. static readonly BILLBOARDMODE_Y: number;
  90939. /**
  90940. * Billboard mode will apply to all axes
  90941. */
  90942. static readonly BILLBOARDMODE_ALL: number;
  90943. /**
  90944. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90945. */
  90946. static readonly BILLBOARDMODE_STRETCHED: number;
  90947. /**
  90948. * This function can be defined to provide custom update for active particles.
  90949. * This function will be called instead of regular update (age, position, color, etc.).
  90950. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90951. */
  90952. updateFunction: (particles: Particle[]) => void;
  90953. private _emitterWorldMatrix;
  90954. /**
  90955. * This function can be defined to specify initial direction for every new particle.
  90956. * It by default use the emitterType defined function
  90957. */
  90958. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90959. /**
  90960. * This function can be defined to specify initial position for every new particle.
  90961. * It by default use the emitterType defined function
  90962. */
  90963. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90964. /**
  90965. * @hidden
  90966. */
  90967. _inheritedVelocityOffset: Vector3;
  90968. /**
  90969. * An event triggered when the system is disposed
  90970. */
  90971. onDisposeObservable: Observable<IParticleSystem>;
  90972. private _onDisposeObserver;
  90973. /**
  90974. * Sets a callback that will be triggered when the system is disposed
  90975. */
  90976. set onDispose(callback: () => void);
  90977. private _particles;
  90978. private _epsilon;
  90979. private _capacity;
  90980. private _stockParticles;
  90981. private _newPartsExcess;
  90982. private _vertexData;
  90983. private _vertexBuffer;
  90984. private _vertexBuffers;
  90985. private _spriteBuffer;
  90986. private _indexBuffer;
  90987. private _effect;
  90988. private _customEffect;
  90989. private _cachedDefines;
  90990. private _scaledColorStep;
  90991. private _colorDiff;
  90992. private _scaledDirection;
  90993. private _scaledGravity;
  90994. private _currentRenderId;
  90995. private _alive;
  90996. private _useInstancing;
  90997. private _started;
  90998. private _stopped;
  90999. private _actualFrame;
  91000. private _scaledUpdateSpeed;
  91001. private _vertexBufferSize;
  91002. /** @hidden */
  91003. _currentEmitRateGradient: Nullable<FactorGradient>;
  91004. /** @hidden */
  91005. _currentEmitRate1: number;
  91006. /** @hidden */
  91007. _currentEmitRate2: number;
  91008. /** @hidden */
  91009. _currentStartSizeGradient: Nullable<FactorGradient>;
  91010. /** @hidden */
  91011. _currentStartSize1: number;
  91012. /** @hidden */
  91013. _currentStartSize2: number;
  91014. private readonly _rawTextureWidth;
  91015. private _rampGradientsTexture;
  91016. private _useRampGradients;
  91017. /** Gets or sets a boolean indicating that ramp gradients must be used
  91018. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91019. */
  91020. get useRampGradients(): boolean;
  91021. set useRampGradients(value: boolean);
  91022. /**
  91023. * 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.
  91024. * 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: [])
  91025. */
  91026. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91027. private _subEmitters;
  91028. /**
  91029. * @hidden
  91030. * If the particle systems emitter should be disposed when the particle system is disposed
  91031. */
  91032. _disposeEmitterOnDispose: boolean;
  91033. /**
  91034. * The current active Sub-systems, this property is used by the root particle system only.
  91035. */
  91036. activeSubSystems: Array<ParticleSystem>;
  91037. /**
  91038. * Specifies if the particles are updated in emitter local space or world space
  91039. */
  91040. isLocal: boolean;
  91041. private _rootParticleSystem;
  91042. /**
  91043. * Gets the current list of active particles
  91044. */
  91045. get particles(): Particle[];
  91046. /**
  91047. * Gets the number of particles active at the same time.
  91048. * @returns The number of active particles.
  91049. */
  91050. getActiveCount(): number;
  91051. /**
  91052. * Returns the string "ParticleSystem"
  91053. * @returns a string containing the class name
  91054. */
  91055. getClassName(): string;
  91056. /**
  91057. * Gets a boolean indicating that the system is stopping
  91058. * @returns true if the system is currently stopping
  91059. */
  91060. isStopping(): boolean;
  91061. /**
  91062. * Gets the custom effect used to render the particles
  91063. * @param blendMode Blend mode for which the effect should be retrieved
  91064. * @returns The effect
  91065. */
  91066. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91067. /**
  91068. * Sets the custom effect used to render the particles
  91069. * @param effect The effect to set
  91070. * @param blendMode Blend mode for which the effect should be set
  91071. */
  91072. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91073. /** @hidden */
  91074. private _onBeforeDrawParticlesObservable;
  91075. /**
  91076. * Observable that will be called just before the particles are drawn
  91077. */
  91078. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91079. /**
  91080. * Gets the name of the particle vertex shader
  91081. */
  91082. get vertexShaderName(): string;
  91083. /**
  91084. * Instantiates a particle system.
  91085. * 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.
  91086. * @param name The name of the particle system
  91087. * @param capacity The max number of particles alive at the same time
  91088. * @param scene The scene the particle system belongs to
  91089. * @param customEffect a custom effect used to change the way particles are rendered by default
  91090. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91091. * @param epsilon Offset used to render the particles
  91092. */
  91093. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91094. private _addFactorGradient;
  91095. private _removeFactorGradient;
  91096. /**
  91097. * Adds a new life time gradient
  91098. * @param gradient defines the gradient to use (between 0 and 1)
  91099. * @param factor defines the life time factor to affect to the specified gradient
  91100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91101. * @returns the current particle system
  91102. */
  91103. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91104. /**
  91105. * Remove a specific life time gradient
  91106. * @param gradient defines the gradient to remove
  91107. * @returns the current particle system
  91108. */
  91109. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91110. /**
  91111. * Adds a new size gradient
  91112. * @param gradient defines the gradient to use (between 0 and 1)
  91113. * @param factor defines the size factor to affect to the specified gradient
  91114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91115. * @returns the current particle system
  91116. */
  91117. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91118. /**
  91119. * Remove a specific size gradient
  91120. * @param gradient defines the gradient to remove
  91121. * @returns the current particle system
  91122. */
  91123. removeSizeGradient(gradient: number): IParticleSystem;
  91124. /**
  91125. * Adds a new color remap gradient
  91126. * @param gradient defines the gradient to use (between 0 and 1)
  91127. * @param min defines the color remap minimal range
  91128. * @param max defines the color remap maximal range
  91129. * @returns the current particle system
  91130. */
  91131. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91132. /**
  91133. * Remove a specific color remap gradient
  91134. * @param gradient defines the gradient to remove
  91135. * @returns the current particle system
  91136. */
  91137. removeColorRemapGradient(gradient: number): IParticleSystem;
  91138. /**
  91139. * Adds a new alpha remap gradient
  91140. * @param gradient defines the gradient to use (between 0 and 1)
  91141. * @param min defines the alpha remap minimal range
  91142. * @param max defines the alpha remap maximal range
  91143. * @returns the current particle system
  91144. */
  91145. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91146. /**
  91147. * Remove a specific alpha remap gradient
  91148. * @param gradient defines the gradient to remove
  91149. * @returns the current particle system
  91150. */
  91151. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91152. /**
  91153. * Adds a new angular speed gradient
  91154. * @param gradient defines the gradient to use (between 0 and 1)
  91155. * @param factor defines the angular speed to affect to the specified gradient
  91156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91157. * @returns the current particle system
  91158. */
  91159. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91160. /**
  91161. * Remove a specific angular speed gradient
  91162. * @param gradient defines the gradient to remove
  91163. * @returns the current particle system
  91164. */
  91165. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91166. /**
  91167. * Adds a new velocity gradient
  91168. * @param gradient defines the gradient to use (between 0 and 1)
  91169. * @param factor defines the velocity to affect to the specified gradient
  91170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91171. * @returns the current particle system
  91172. */
  91173. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91174. /**
  91175. * Remove a specific velocity gradient
  91176. * @param gradient defines the gradient to remove
  91177. * @returns the current particle system
  91178. */
  91179. removeVelocityGradient(gradient: number): IParticleSystem;
  91180. /**
  91181. * Adds a new limit velocity gradient
  91182. * @param gradient defines the gradient to use (between 0 and 1)
  91183. * @param factor defines the limit velocity value to affect to the specified gradient
  91184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91185. * @returns the current particle system
  91186. */
  91187. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91188. /**
  91189. * Remove a specific limit velocity gradient
  91190. * @param gradient defines the gradient to remove
  91191. * @returns the current particle system
  91192. */
  91193. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91194. /**
  91195. * Adds a new drag gradient
  91196. * @param gradient defines the gradient to use (between 0 and 1)
  91197. * @param factor defines the drag value to affect to the specified gradient
  91198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91199. * @returns the current particle system
  91200. */
  91201. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91202. /**
  91203. * Remove a specific drag gradient
  91204. * @param gradient defines the gradient to remove
  91205. * @returns the current particle system
  91206. */
  91207. removeDragGradient(gradient: number): IParticleSystem;
  91208. /**
  91209. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91210. * @param gradient defines the gradient to use (between 0 and 1)
  91211. * @param factor defines the emit rate value to affect to the specified gradient
  91212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91213. * @returns the current particle system
  91214. */
  91215. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91216. /**
  91217. * Remove a specific emit rate gradient
  91218. * @param gradient defines the gradient to remove
  91219. * @returns the current particle system
  91220. */
  91221. removeEmitRateGradient(gradient: number): IParticleSystem;
  91222. /**
  91223. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91224. * @param gradient defines the gradient to use (between 0 and 1)
  91225. * @param factor defines the start size value to affect to the specified gradient
  91226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91227. * @returns the current particle system
  91228. */
  91229. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91230. /**
  91231. * Remove a specific start size gradient
  91232. * @param gradient defines the gradient to remove
  91233. * @returns the current particle system
  91234. */
  91235. removeStartSizeGradient(gradient: number): IParticleSystem;
  91236. private _createRampGradientTexture;
  91237. /**
  91238. * Gets the current list of ramp gradients.
  91239. * You must use addRampGradient and removeRampGradient to udpate this list
  91240. * @returns the list of ramp gradients
  91241. */
  91242. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91243. /** Force the system to rebuild all gradients that need to be resync */
  91244. forceRefreshGradients(): void;
  91245. private _syncRampGradientTexture;
  91246. /**
  91247. * Adds a new ramp gradient used to remap particle colors
  91248. * @param gradient defines the gradient to use (between 0 and 1)
  91249. * @param color defines the color to affect to the specified gradient
  91250. * @returns the current particle system
  91251. */
  91252. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91253. /**
  91254. * Remove a specific ramp gradient
  91255. * @param gradient defines the gradient to remove
  91256. * @returns the current particle system
  91257. */
  91258. removeRampGradient(gradient: number): ParticleSystem;
  91259. /**
  91260. * Adds a new color gradient
  91261. * @param gradient defines the gradient to use (between 0 and 1)
  91262. * @param color1 defines the color to affect to the specified gradient
  91263. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91264. * @returns this particle system
  91265. */
  91266. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91267. /**
  91268. * Remove a specific color gradient
  91269. * @param gradient defines the gradient to remove
  91270. * @returns this particle system
  91271. */
  91272. removeColorGradient(gradient: number): IParticleSystem;
  91273. private _fetchR;
  91274. protected _reset(): void;
  91275. private _resetEffect;
  91276. private _createVertexBuffers;
  91277. private _createIndexBuffer;
  91278. /**
  91279. * Gets the maximum number of particles active at the same time.
  91280. * @returns The max number of active particles.
  91281. */
  91282. getCapacity(): number;
  91283. /**
  91284. * Gets whether there are still active particles in the system.
  91285. * @returns True if it is alive, otherwise false.
  91286. */
  91287. isAlive(): boolean;
  91288. /**
  91289. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91290. * @returns True if it has been started, otherwise false.
  91291. */
  91292. isStarted(): boolean;
  91293. private _prepareSubEmitterInternalArray;
  91294. /**
  91295. * Starts the particle system and begins to emit
  91296. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91297. */
  91298. start(delay?: number): void;
  91299. /**
  91300. * Stops the particle system.
  91301. * @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.
  91302. */
  91303. stop(stopSubEmitters?: boolean): void;
  91304. /**
  91305. * Remove all active particles
  91306. */
  91307. reset(): void;
  91308. /**
  91309. * @hidden (for internal use only)
  91310. */
  91311. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91312. /**
  91313. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91314. * Its lifetime will start back at 0.
  91315. */
  91316. recycleParticle: (particle: Particle) => void;
  91317. private _stopSubEmitters;
  91318. private _createParticle;
  91319. private _removeFromRoot;
  91320. private _emitFromParticle;
  91321. private _update;
  91322. /** @hidden */
  91323. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91324. /** @hidden */
  91325. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91326. /**
  91327. * Fill the defines array according to the current settings of the particle system
  91328. * @param defines Array to be updated
  91329. * @param blendMode blend mode to take into account when updating the array
  91330. */
  91331. fillDefines(defines: Array<string>, blendMode: number): void;
  91332. /**
  91333. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91334. * @param uniforms Uniforms array to fill
  91335. * @param attributes Attributes array to fill
  91336. * @param samplers Samplers array to fill
  91337. */
  91338. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91339. /** @hidden */
  91340. private _getEffect;
  91341. /**
  91342. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91343. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91344. */
  91345. animate(preWarmOnly?: boolean): void;
  91346. private _appendParticleVertices;
  91347. /**
  91348. * Rebuilds the particle system.
  91349. */
  91350. rebuild(): void;
  91351. /**
  91352. * Is this system ready to be used/rendered
  91353. * @return true if the system is ready
  91354. */
  91355. isReady(): boolean;
  91356. private _render;
  91357. /**
  91358. * Renders the particle system in its current state.
  91359. * @returns the current number of particles
  91360. */
  91361. render(): number;
  91362. /**
  91363. * Disposes the particle system and free the associated resources
  91364. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91365. */
  91366. dispose(disposeTexture?: boolean): void;
  91367. /**
  91368. * Clones the particle system.
  91369. * @param name The name of the cloned object
  91370. * @param newEmitter The new emitter to use
  91371. * @returns the cloned particle system
  91372. */
  91373. clone(name: string, newEmitter: any): ParticleSystem;
  91374. /**
  91375. * Serializes the particle system to a JSON object
  91376. * @param serializeTexture defines if the texture must be serialized as well
  91377. * @returns the JSON object
  91378. */
  91379. serialize(serializeTexture?: boolean): any;
  91380. /** @hidden */
  91381. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91382. /** @hidden */
  91383. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91384. /**
  91385. * Parses a JSON object to create a particle system.
  91386. * @param parsedParticleSystem The JSON object to parse
  91387. * @param scene The scene to create the particle system in
  91388. * @param rootUrl The root url to use to load external dependencies like texture
  91389. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91390. * @returns the Parsed particle system
  91391. */
  91392. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91393. }
  91394. }
  91395. declare module BABYLON {
  91396. /**
  91397. * A particle represents one of the element emitted by a particle system.
  91398. * This is mainly define by its coordinates, direction, velocity and age.
  91399. */
  91400. export class Particle {
  91401. /**
  91402. * The particle system the particle belongs to.
  91403. */
  91404. particleSystem: ParticleSystem;
  91405. private static _Count;
  91406. /**
  91407. * Unique ID of the particle
  91408. */
  91409. id: number;
  91410. /**
  91411. * The world position of the particle in the scene.
  91412. */
  91413. position: Vector3;
  91414. /**
  91415. * The world direction of the particle in the scene.
  91416. */
  91417. direction: Vector3;
  91418. /**
  91419. * The color of the particle.
  91420. */
  91421. color: Color4;
  91422. /**
  91423. * The color change of the particle per step.
  91424. */
  91425. colorStep: Color4;
  91426. /**
  91427. * Defines how long will the life of the particle be.
  91428. */
  91429. lifeTime: number;
  91430. /**
  91431. * The current age of the particle.
  91432. */
  91433. age: number;
  91434. /**
  91435. * The current size of the particle.
  91436. */
  91437. size: number;
  91438. /**
  91439. * The current scale of the particle.
  91440. */
  91441. scale: Vector2;
  91442. /**
  91443. * The current angle of the particle.
  91444. */
  91445. angle: number;
  91446. /**
  91447. * Defines how fast is the angle changing.
  91448. */
  91449. angularSpeed: number;
  91450. /**
  91451. * Defines the cell index used by the particle to be rendered from a sprite.
  91452. */
  91453. cellIndex: number;
  91454. /**
  91455. * The information required to support color remapping
  91456. */
  91457. remapData: Vector4;
  91458. /** @hidden */
  91459. _randomCellOffset?: number;
  91460. /** @hidden */
  91461. _initialDirection: Nullable<Vector3>;
  91462. /** @hidden */
  91463. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91464. /** @hidden */
  91465. _initialStartSpriteCellID: number;
  91466. /** @hidden */
  91467. _initialEndSpriteCellID: number;
  91468. /** @hidden */
  91469. _currentColorGradient: Nullable<ColorGradient>;
  91470. /** @hidden */
  91471. _currentColor1: Color4;
  91472. /** @hidden */
  91473. _currentColor2: Color4;
  91474. /** @hidden */
  91475. _currentSizeGradient: Nullable<FactorGradient>;
  91476. /** @hidden */
  91477. _currentSize1: number;
  91478. /** @hidden */
  91479. _currentSize2: number;
  91480. /** @hidden */
  91481. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91482. /** @hidden */
  91483. _currentAngularSpeed1: number;
  91484. /** @hidden */
  91485. _currentAngularSpeed2: number;
  91486. /** @hidden */
  91487. _currentVelocityGradient: Nullable<FactorGradient>;
  91488. /** @hidden */
  91489. _currentVelocity1: number;
  91490. /** @hidden */
  91491. _currentVelocity2: number;
  91492. /** @hidden */
  91493. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91494. /** @hidden */
  91495. _currentLimitVelocity1: number;
  91496. /** @hidden */
  91497. _currentLimitVelocity2: number;
  91498. /** @hidden */
  91499. _currentDragGradient: Nullable<FactorGradient>;
  91500. /** @hidden */
  91501. _currentDrag1: number;
  91502. /** @hidden */
  91503. _currentDrag2: number;
  91504. /** @hidden */
  91505. _randomNoiseCoordinates1: Vector3;
  91506. /** @hidden */
  91507. _randomNoiseCoordinates2: Vector3;
  91508. /** @hidden */
  91509. _localPosition?: Vector3;
  91510. /**
  91511. * Creates a new instance Particle
  91512. * @param particleSystem the particle system the particle belongs to
  91513. */
  91514. constructor(
  91515. /**
  91516. * The particle system the particle belongs to.
  91517. */
  91518. particleSystem: ParticleSystem);
  91519. private updateCellInfoFromSystem;
  91520. /**
  91521. * Defines how the sprite cell index is updated for the particle
  91522. */
  91523. updateCellIndex(): void;
  91524. /** @hidden */
  91525. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91526. /** @hidden */
  91527. _inheritParticleInfoToSubEmitters(): void;
  91528. /** @hidden */
  91529. _reset(): void;
  91530. /**
  91531. * Copy the properties of particle to another one.
  91532. * @param other the particle to copy the information to.
  91533. */
  91534. copyTo(other: Particle): void;
  91535. }
  91536. }
  91537. declare module BABYLON {
  91538. /**
  91539. * Particle emitter represents a volume emitting particles.
  91540. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91541. */
  91542. export interface IParticleEmitterType {
  91543. /**
  91544. * Called by the particle System when the direction is computed for the created particle.
  91545. * @param worldMatrix is the world matrix of the particle system
  91546. * @param directionToUpdate is the direction vector to update with the result
  91547. * @param particle is the particle we are computed the direction for
  91548. * @param isLocal defines if the direction should be set in local space
  91549. */
  91550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91551. /**
  91552. * Called by the particle System when the position is computed for the created particle.
  91553. * @param worldMatrix is the world matrix of the particle system
  91554. * @param positionToUpdate is the position vector to update with the result
  91555. * @param particle is the particle we are computed the position for
  91556. * @param isLocal defines if the position should be set in local space
  91557. */
  91558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91559. /**
  91560. * Clones the current emitter and returns a copy of it
  91561. * @returns the new emitter
  91562. */
  91563. clone(): IParticleEmitterType;
  91564. /**
  91565. * Called by the GPUParticleSystem to setup the update shader
  91566. * @param effect defines the update shader
  91567. */
  91568. applyToShader(effect: Effect): void;
  91569. /**
  91570. * Returns a string to use to update the GPU particles update shader
  91571. * @returns the effect defines string
  91572. */
  91573. getEffectDefines(): string;
  91574. /**
  91575. * Returns a string representing the class name
  91576. * @returns a string containing the class name
  91577. */
  91578. getClassName(): string;
  91579. /**
  91580. * Serializes the particle system to a JSON object.
  91581. * @returns the JSON object
  91582. */
  91583. serialize(): any;
  91584. /**
  91585. * Parse properties from a JSON object
  91586. * @param serializationObject defines the JSON object
  91587. * @param scene defines the hosting scene
  91588. */
  91589. parse(serializationObject: any, scene: Scene): void;
  91590. }
  91591. }
  91592. declare module BABYLON {
  91593. /**
  91594. * Particle emitter emitting particles from the inside of a box.
  91595. * It emits the particles randomly between 2 given directions.
  91596. */
  91597. export class BoxParticleEmitter implements IParticleEmitterType {
  91598. /**
  91599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91600. */
  91601. direction1: Vector3;
  91602. /**
  91603. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91604. */
  91605. direction2: Vector3;
  91606. /**
  91607. * 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.
  91608. */
  91609. minEmitBox: Vector3;
  91610. /**
  91611. * 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.
  91612. */
  91613. maxEmitBox: Vector3;
  91614. /**
  91615. * Creates a new instance BoxParticleEmitter
  91616. */
  91617. constructor();
  91618. /**
  91619. * Called by the particle System when the direction is computed for the created particle.
  91620. * @param worldMatrix is the world matrix of the particle system
  91621. * @param directionToUpdate is the direction vector to update with the result
  91622. * @param particle is the particle we are computed the direction for
  91623. * @param isLocal defines if the direction should be set in local space
  91624. */
  91625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91626. /**
  91627. * Called by the particle System when the position is computed for the created particle.
  91628. * @param worldMatrix is the world matrix of the particle system
  91629. * @param positionToUpdate is the position vector to update with the result
  91630. * @param particle is the particle we are computed the position for
  91631. * @param isLocal defines if the position should be set in local space
  91632. */
  91633. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91634. /**
  91635. * Clones the current emitter and returns a copy of it
  91636. * @returns the new emitter
  91637. */
  91638. clone(): BoxParticleEmitter;
  91639. /**
  91640. * Called by the GPUParticleSystem to setup the update shader
  91641. * @param effect defines the update shader
  91642. */
  91643. applyToShader(effect: Effect): void;
  91644. /**
  91645. * Returns a string to use to update the GPU particles update shader
  91646. * @returns a string containng the defines string
  91647. */
  91648. getEffectDefines(): string;
  91649. /**
  91650. * Returns the string "BoxParticleEmitter"
  91651. * @returns a string containing the class name
  91652. */
  91653. getClassName(): string;
  91654. /**
  91655. * Serializes the particle system to a JSON object.
  91656. * @returns the JSON object
  91657. */
  91658. serialize(): any;
  91659. /**
  91660. * Parse properties from a JSON object
  91661. * @param serializationObject defines the JSON object
  91662. */
  91663. parse(serializationObject: any): void;
  91664. }
  91665. }
  91666. declare module BABYLON {
  91667. /**
  91668. * Particle emitter emitting particles from the inside of a cone.
  91669. * It emits the particles alongside the cone volume from the base to the particle.
  91670. * The emission direction might be randomized.
  91671. */
  91672. export class ConeParticleEmitter implements IParticleEmitterType {
  91673. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91674. directionRandomizer: number;
  91675. private _radius;
  91676. private _angle;
  91677. private _height;
  91678. /**
  91679. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91680. */
  91681. radiusRange: number;
  91682. /**
  91683. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91684. */
  91685. heightRange: number;
  91686. /**
  91687. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91688. */
  91689. emitFromSpawnPointOnly: boolean;
  91690. /**
  91691. * Gets or sets the radius of the emission cone
  91692. */
  91693. get radius(): number;
  91694. set radius(value: number);
  91695. /**
  91696. * Gets or sets the angle of the emission cone
  91697. */
  91698. get angle(): number;
  91699. set angle(value: number);
  91700. private _buildHeight;
  91701. /**
  91702. * Creates a new instance ConeParticleEmitter
  91703. * @param radius the radius of the emission cone (1 by default)
  91704. * @param angle the cone base angle (PI by default)
  91705. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91706. */
  91707. constructor(radius?: number, angle?: number,
  91708. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91709. directionRandomizer?: number);
  91710. /**
  91711. * Called by the particle System when the direction is computed for the created particle.
  91712. * @param worldMatrix is the world matrix of the particle system
  91713. * @param directionToUpdate is the direction vector to update with the result
  91714. * @param particle is the particle we are computed the direction for
  91715. * @param isLocal defines if the direction should be set in local space
  91716. */
  91717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91718. /**
  91719. * Called by the particle System when the position is computed for the created particle.
  91720. * @param worldMatrix is the world matrix of the particle system
  91721. * @param positionToUpdate is the position vector to update with the result
  91722. * @param particle is the particle we are computed the position for
  91723. * @param isLocal defines if the position should be set in local space
  91724. */
  91725. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91726. /**
  91727. * Clones the current emitter and returns a copy of it
  91728. * @returns the new emitter
  91729. */
  91730. clone(): ConeParticleEmitter;
  91731. /**
  91732. * Called by the GPUParticleSystem to setup the update shader
  91733. * @param effect defines the update shader
  91734. */
  91735. applyToShader(effect: Effect): void;
  91736. /**
  91737. * Returns a string to use to update the GPU particles update shader
  91738. * @returns a string containng the defines string
  91739. */
  91740. getEffectDefines(): string;
  91741. /**
  91742. * Returns the string "ConeParticleEmitter"
  91743. * @returns a string containing the class name
  91744. */
  91745. getClassName(): string;
  91746. /**
  91747. * Serializes the particle system to a JSON object.
  91748. * @returns the JSON object
  91749. */
  91750. serialize(): any;
  91751. /**
  91752. * Parse properties from a JSON object
  91753. * @param serializationObject defines the JSON object
  91754. */
  91755. parse(serializationObject: any): void;
  91756. }
  91757. }
  91758. declare module BABYLON {
  91759. /**
  91760. * Particle emitter emitting particles from the inside of a cylinder.
  91761. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91762. */
  91763. export class CylinderParticleEmitter implements IParticleEmitterType {
  91764. /**
  91765. * The radius of the emission cylinder.
  91766. */
  91767. radius: number;
  91768. /**
  91769. * The height of the emission cylinder.
  91770. */
  91771. height: number;
  91772. /**
  91773. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91774. */
  91775. radiusRange: number;
  91776. /**
  91777. * How much to randomize the particle direction [0-1].
  91778. */
  91779. directionRandomizer: number;
  91780. /**
  91781. * Creates a new instance CylinderParticleEmitter
  91782. * @param radius the radius of the emission cylinder (1 by default)
  91783. * @param height the height of the emission cylinder (1 by default)
  91784. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91785. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91786. */
  91787. constructor(
  91788. /**
  91789. * The radius of the emission cylinder.
  91790. */
  91791. radius?: number,
  91792. /**
  91793. * The height of the emission cylinder.
  91794. */
  91795. height?: number,
  91796. /**
  91797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91798. */
  91799. radiusRange?: number,
  91800. /**
  91801. * How much to randomize the particle direction [0-1].
  91802. */
  91803. directionRandomizer?: number);
  91804. /**
  91805. * Called by the particle System when the direction is computed for the created particle.
  91806. * @param worldMatrix is the world matrix of the particle system
  91807. * @param directionToUpdate is the direction vector to update with the result
  91808. * @param particle is the particle we are computed the direction for
  91809. * @param isLocal defines if the direction should be set in local space
  91810. */
  91811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91812. /**
  91813. * Called by the particle System when the position is computed for the created particle.
  91814. * @param worldMatrix is the world matrix of the particle system
  91815. * @param positionToUpdate is the position vector to update with the result
  91816. * @param particle is the particle we are computed the position for
  91817. * @param isLocal defines if the position should be set in local space
  91818. */
  91819. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91820. /**
  91821. * Clones the current emitter and returns a copy of it
  91822. * @returns the new emitter
  91823. */
  91824. clone(): CylinderParticleEmitter;
  91825. /**
  91826. * Called by the GPUParticleSystem to setup the update shader
  91827. * @param effect defines the update shader
  91828. */
  91829. applyToShader(effect: Effect): void;
  91830. /**
  91831. * Returns a string to use to update the GPU particles update shader
  91832. * @returns a string containng the defines string
  91833. */
  91834. getEffectDefines(): string;
  91835. /**
  91836. * Returns the string "CylinderParticleEmitter"
  91837. * @returns a string containing the class name
  91838. */
  91839. getClassName(): string;
  91840. /**
  91841. * Serializes the particle system to a JSON object.
  91842. * @returns the JSON object
  91843. */
  91844. serialize(): any;
  91845. /**
  91846. * Parse properties from a JSON object
  91847. * @param serializationObject defines the JSON object
  91848. */
  91849. parse(serializationObject: any): void;
  91850. }
  91851. /**
  91852. * Particle emitter emitting particles from the inside of a cylinder.
  91853. * It emits the particles randomly between two vectors.
  91854. */
  91855. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91856. /**
  91857. * The min limit of the emission direction.
  91858. */
  91859. direction1: Vector3;
  91860. /**
  91861. * The max limit of the emission direction.
  91862. */
  91863. direction2: Vector3;
  91864. /**
  91865. * Creates a new instance CylinderDirectedParticleEmitter
  91866. * @param radius the radius of the emission cylinder (1 by default)
  91867. * @param height the height of the emission cylinder (1 by default)
  91868. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91869. * @param direction1 the min limit of the emission direction (up vector by default)
  91870. * @param direction2 the max limit of the emission direction (up vector by default)
  91871. */
  91872. constructor(radius?: number, height?: number, radiusRange?: number,
  91873. /**
  91874. * The min limit of the emission direction.
  91875. */
  91876. direction1?: Vector3,
  91877. /**
  91878. * The max limit of the emission direction.
  91879. */
  91880. direction2?: Vector3);
  91881. /**
  91882. * Called by the particle System when the direction is computed for the created particle.
  91883. * @param worldMatrix is the world matrix of the particle system
  91884. * @param directionToUpdate is the direction vector to update with the result
  91885. * @param particle is the particle we are computed the direction for
  91886. */
  91887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91888. /**
  91889. * Clones the current emitter and returns a copy of it
  91890. * @returns the new emitter
  91891. */
  91892. clone(): CylinderDirectedParticleEmitter;
  91893. /**
  91894. * Called by the GPUParticleSystem to setup the update shader
  91895. * @param effect defines the update shader
  91896. */
  91897. applyToShader(effect: Effect): void;
  91898. /**
  91899. * Returns a string to use to update the GPU particles update shader
  91900. * @returns a string containng the defines string
  91901. */
  91902. getEffectDefines(): string;
  91903. /**
  91904. * Returns the string "CylinderDirectedParticleEmitter"
  91905. * @returns a string containing the class name
  91906. */
  91907. getClassName(): string;
  91908. /**
  91909. * Serializes the particle system to a JSON object.
  91910. * @returns the JSON object
  91911. */
  91912. serialize(): any;
  91913. /**
  91914. * Parse properties from a JSON object
  91915. * @param serializationObject defines the JSON object
  91916. */
  91917. parse(serializationObject: any): void;
  91918. }
  91919. }
  91920. declare module BABYLON {
  91921. /**
  91922. * Particle emitter emitting particles from the inside of a hemisphere.
  91923. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91924. */
  91925. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91926. /**
  91927. * The radius of the emission hemisphere.
  91928. */
  91929. radius: number;
  91930. /**
  91931. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91932. */
  91933. radiusRange: number;
  91934. /**
  91935. * How much to randomize the particle direction [0-1].
  91936. */
  91937. directionRandomizer: number;
  91938. /**
  91939. * Creates a new instance HemisphericParticleEmitter
  91940. * @param radius the radius of the emission hemisphere (1 by default)
  91941. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91943. */
  91944. constructor(
  91945. /**
  91946. * The radius of the emission hemisphere.
  91947. */
  91948. radius?: number,
  91949. /**
  91950. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91951. */
  91952. radiusRange?: number,
  91953. /**
  91954. * How much to randomize the particle direction [0-1].
  91955. */
  91956. directionRandomizer?: number);
  91957. /**
  91958. * Called by the particle System when the direction is computed for the created particle.
  91959. * @param worldMatrix is the world matrix of the particle system
  91960. * @param directionToUpdate is the direction vector to update with the result
  91961. * @param particle is the particle we are computed the direction for
  91962. * @param isLocal defines if the direction should be set in local space
  91963. */
  91964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91965. /**
  91966. * Called by the particle System when the position is computed for the created particle.
  91967. * @param worldMatrix is the world matrix of the particle system
  91968. * @param positionToUpdate is the position vector to update with the result
  91969. * @param particle is the particle we are computed the position for
  91970. * @param isLocal defines if the position should be set in local space
  91971. */
  91972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91973. /**
  91974. * Clones the current emitter and returns a copy of it
  91975. * @returns the new emitter
  91976. */
  91977. clone(): HemisphericParticleEmitter;
  91978. /**
  91979. * Called by the GPUParticleSystem to setup the update shader
  91980. * @param effect defines the update shader
  91981. */
  91982. applyToShader(effect: Effect): void;
  91983. /**
  91984. * Returns a string to use to update the GPU particles update shader
  91985. * @returns a string containng the defines string
  91986. */
  91987. getEffectDefines(): string;
  91988. /**
  91989. * Returns the string "HemisphericParticleEmitter"
  91990. * @returns a string containing the class name
  91991. */
  91992. getClassName(): string;
  91993. /**
  91994. * Serializes the particle system to a JSON object.
  91995. * @returns the JSON object
  91996. */
  91997. serialize(): any;
  91998. /**
  91999. * Parse properties from a JSON object
  92000. * @param serializationObject defines the JSON object
  92001. */
  92002. parse(serializationObject: any): void;
  92003. }
  92004. }
  92005. declare module BABYLON {
  92006. /**
  92007. * Particle emitter emitting particles from a point.
  92008. * It emits the particles randomly between 2 given directions.
  92009. */
  92010. export class PointParticleEmitter implements IParticleEmitterType {
  92011. /**
  92012. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92013. */
  92014. direction1: Vector3;
  92015. /**
  92016. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92017. */
  92018. direction2: Vector3;
  92019. /**
  92020. * Creates a new instance PointParticleEmitter
  92021. */
  92022. constructor();
  92023. /**
  92024. * Called by the particle System when the direction is computed for the created particle.
  92025. * @param worldMatrix is the world matrix of the particle system
  92026. * @param directionToUpdate is the direction vector to update with the result
  92027. * @param particle is the particle we are computed the direction for
  92028. * @param isLocal defines if the direction should be set in local space
  92029. */
  92030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92031. /**
  92032. * Called by the particle System when the position is computed for the created particle.
  92033. * @param worldMatrix is the world matrix of the particle system
  92034. * @param positionToUpdate is the position vector to update with the result
  92035. * @param particle is the particle we are computed the position for
  92036. * @param isLocal defines if the position should be set in local space
  92037. */
  92038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92039. /**
  92040. * Clones the current emitter and returns a copy of it
  92041. * @returns the new emitter
  92042. */
  92043. clone(): PointParticleEmitter;
  92044. /**
  92045. * Called by the GPUParticleSystem to setup the update shader
  92046. * @param effect defines the update shader
  92047. */
  92048. applyToShader(effect: Effect): void;
  92049. /**
  92050. * Returns a string to use to update the GPU particles update shader
  92051. * @returns a string containng the defines string
  92052. */
  92053. getEffectDefines(): string;
  92054. /**
  92055. * Returns the string "PointParticleEmitter"
  92056. * @returns a string containing the class name
  92057. */
  92058. getClassName(): string;
  92059. /**
  92060. * Serializes the particle system to a JSON object.
  92061. * @returns the JSON object
  92062. */
  92063. serialize(): any;
  92064. /**
  92065. * Parse properties from a JSON object
  92066. * @param serializationObject defines the JSON object
  92067. */
  92068. parse(serializationObject: any): void;
  92069. }
  92070. }
  92071. declare module BABYLON {
  92072. /**
  92073. * Particle emitter emitting particles from the inside of a sphere.
  92074. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92075. */
  92076. export class SphereParticleEmitter implements IParticleEmitterType {
  92077. /**
  92078. * The radius of the emission sphere.
  92079. */
  92080. radius: number;
  92081. /**
  92082. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92083. */
  92084. radiusRange: number;
  92085. /**
  92086. * How much to randomize the particle direction [0-1].
  92087. */
  92088. directionRandomizer: number;
  92089. /**
  92090. * Creates a new instance SphereParticleEmitter
  92091. * @param radius the radius of the emission sphere (1 by default)
  92092. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92093. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92094. */
  92095. constructor(
  92096. /**
  92097. * The radius of the emission sphere.
  92098. */
  92099. radius?: number,
  92100. /**
  92101. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92102. */
  92103. radiusRange?: number,
  92104. /**
  92105. * How much to randomize the particle direction [0-1].
  92106. */
  92107. directionRandomizer?: number);
  92108. /**
  92109. * Called by the particle System when the direction is computed for the created particle.
  92110. * @param worldMatrix is the world matrix of the particle system
  92111. * @param directionToUpdate is the direction vector to update with the result
  92112. * @param particle is the particle we are computed the direction for
  92113. * @param isLocal defines if the direction should be set in local space
  92114. */
  92115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92116. /**
  92117. * Called by the particle System when the position is computed for the created particle.
  92118. * @param worldMatrix is the world matrix of the particle system
  92119. * @param positionToUpdate is the position vector to update with the result
  92120. * @param particle is the particle we are computed the position for
  92121. * @param isLocal defines if the position should be set in local space
  92122. */
  92123. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92124. /**
  92125. * Clones the current emitter and returns a copy of it
  92126. * @returns the new emitter
  92127. */
  92128. clone(): SphereParticleEmitter;
  92129. /**
  92130. * Called by the GPUParticleSystem to setup the update shader
  92131. * @param effect defines the update shader
  92132. */
  92133. applyToShader(effect: Effect): void;
  92134. /**
  92135. * Returns a string to use to update the GPU particles update shader
  92136. * @returns a string containng the defines string
  92137. */
  92138. getEffectDefines(): string;
  92139. /**
  92140. * Returns the string "SphereParticleEmitter"
  92141. * @returns a string containing the class name
  92142. */
  92143. getClassName(): string;
  92144. /**
  92145. * Serializes the particle system to a JSON object.
  92146. * @returns the JSON object
  92147. */
  92148. serialize(): any;
  92149. /**
  92150. * Parse properties from a JSON object
  92151. * @param serializationObject defines the JSON object
  92152. */
  92153. parse(serializationObject: any): void;
  92154. }
  92155. /**
  92156. * Particle emitter emitting particles from the inside of a sphere.
  92157. * It emits the particles randomly between two vectors.
  92158. */
  92159. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92160. /**
  92161. * The min limit of the emission direction.
  92162. */
  92163. direction1: Vector3;
  92164. /**
  92165. * The max limit of the emission direction.
  92166. */
  92167. direction2: Vector3;
  92168. /**
  92169. * Creates a new instance SphereDirectedParticleEmitter
  92170. * @param radius the radius of the emission sphere (1 by default)
  92171. * @param direction1 the min limit of the emission direction (up vector by default)
  92172. * @param direction2 the max limit of the emission direction (up vector by default)
  92173. */
  92174. constructor(radius?: number,
  92175. /**
  92176. * The min limit of the emission direction.
  92177. */
  92178. direction1?: Vector3,
  92179. /**
  92180. * The max limit of the emission direction.
  92181. */
  92182. direction2?: Vector3);
  92183. /**
  92184. * Called by the particle System when the direction is computed for the created particle.
  92185. * @param worldMatrix is the world matrix of the particle system
  92186. * @param directionToUpdate is the direction vector to update with the result
  92187. * @param particle is the particle we are computed the direction for
  92188. */
  92189. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92190. /**
  92191. * Clones the current emitter and returns a copy of it
  92192. * @returns the new emitter
  92193. */
  92194. clone(): SphereDirectedParticleEmitter;
  92195. /**
  92196. * Called by the GPUParticleSystem to setup the update shader
  92197. * @param effect defines the update shader
  92198. */
  92199. applyToShader(effect: Effect): void;
  92200. /**
  92201. * Returns a string to use to update the GPU particles update shader
  92202. * @returns a string containng the defines string
  92203. */
  92204. getEffectDefines(): string;
  92205. /**
  92206. * Returns the string "SphereDirectedParticleEmitter"
  92207. * @returns a string containing the class name
  92208. */
  92209. getClassName(): string;
  92210. /**
  92211. * Serializes the particle system to a JSON object.
  92212. * @returns the JSON object
  92213. */
  92214. serialize(): any;
  92215. /**
  92216. * Parse properties from a JSON object
  92217. * @param serializationObject defines the JSON object
  92218. */
  92219. parse(serializationObject: any): void;
  92220. }
  92221. }
  92222. declare module BABYLON {
  92223. /**
  92224. * Particle emitter emitting particles from a custom list of positions.
  92225. */
  92226. export class CustomParticleEmitter implements IParticleEmitterType {
  92227. /**
  92228. * Gets or sets the position generator that will create the inital position of each particle.
  92229. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92230. */
  92231. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92232. /**
  92233. * Gets or sets the destination generator that will create the final destination of each particle.
  92234. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92235. */
  92236. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92237. /**
  92238. * Creates a new instance CustomParticleEmitter
  92239. */
  92240. constructor();
  92241. /**
  92242. * Called by the particle System when the direction is computed for the created particle.
  92243. * @param worldMatrix is the world matrix of the particle system
  92244. * @param directionToUpdate is the direction vector to update with the result
  92245. * @param particle is the particle we are computed the direction for
  92246. * @param isLocal defines if the direction should be set in local space
  92247. */
  92248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92249. /**
  92250. * Called by the particle System when the position is computed for the created particle.
  92251. * @param worldMatrix is the world matrix of the particle system
  92252. * @param positionToUpdate is the position vector to update with the result
  92253. * @param particle is the particle we are computed the position for
  92254. * @param isLocal defines if the position should be set in local space
  92255. */
  92256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92257. /**
  92258. * Clones the current emitter and returns a copy of it
  92259. * @returns the new emitter
  92260. */
  92261. clone(): CustomParticleEmitter;
  92262. /**
  92263. * Called by the GPUParticleSystem to setup the update shader
  92264. * @param effect defines the update shader
  92265. */
  92266. applyToShader(effect: Effect): void;
  92267. /**
  92268. * Returns a string to use to update the GPU particles update shader
  92269. * @returns a string containng the defines string
  92270. */
  92271. getEffectDefines(): string;
  92272. /**
  92273. * Returns the string "PointParticleEmitter"
  92274. * @returns a string containing the class name
  92275. */
  92276. getClassName(): string;
  92277. /**
  92278. * Serializes the particle system to a JSON object.
  92279. * @returns the JSON object
  92280. */
  92281. serialize(): any;
  92282. /**
  92283. * Parse properties from a JSON object
  92284. * @param serializationObject defines the JSON object
  92285. */
  92286. parse(serializationObject: any): void;
  92287. }
  92288. }
  92289. declare module BABYLON {
  92290. /**
  92291. * Particle emitter emitting particles from the inside of a box.
  92292. * It emits the particles randomly between 2 given directions.
  92293. */
  92294. export class MeshParticleEmitter implements IParticleEmitterType {
  92295. private _indices;
  92296. private _positions;
  92297. private _normals;
  92298. private _storedNormal;
  92299. private _mesh;
  92300. /**
  92301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92302. */
  92303. direction1: Vector3;
  92304. /**
  92305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92306. */
  92307. direction2: Vector3;
  92308. /**
  92309. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92310. */
  92311. useMeshNormalsForDirection: boolean;
  92312. /** Defines the mesh to use as source */
  92313. get mesh(): Nullable<AbstractMesh>;
  92314. set mesh(value: Nullable<AbstractMesh>);
  92315. /**
  92316. * Creates a new instance MeshParticleEmitter
  92317. * @param mesh defines the mesh to use as source
  92318. */
  92319. constructor(mesh?: Nullable<AbstractMesh>);
  92320. /**
  92321. * Called by the particle System when the direction is computed for the created particle.
  92322. * @param worldMatrix is the world matrix of the particle system
  92323. * @param directionToUpdate is the direction vector to update with the result
  92324. * @param particle is the particle we are computed the direction for
  92325. * @param isLocal defines if the direction should be set in local space
  92326. */
  92327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92328. /**
  92329. * Called by the particle System when the position is computed for the created particle.
  92330. * @param worldMatrix is the world matrix of the particle system
  92331. * @param positionToUpdate is the position vector to update with the result
  92332. * @param particle is the particle we are computed the position for
  92333. * @param isLocal defines if the position should be set in local space
  92334. */
  92335. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92336. /**
  92337. * Clones the current emitter and returns a copy of it
  92338. * @returns the new emitter
  92339. */
  92340. clone(): MeshParticleEmitter;
  92341. /**
  92342. * Called by the GPUParticleSystem to setup the update shader
  92343. * @param effect defines the update shader
  92344. */
  92345. applyToShader(effect: Effect): void;
  92346. /**
  92347. * Returns a string to use to update the GPU particles update shader
  92348. * @returns a string containng the defines string
  92349. */
  92350. getEffectDefines(): string;
  92351. /**
  92352. * Returns the string "BoxParticleEmitter"
  92353. * @returns a string containing the class name
  92354. */
  92355. getClassName(): string;
  92356. /**
  92357. * Serializes the particle system to a JSON object.
  92358. * @returns the JSON object
  92359. */
  92360. serialize(): any;
  92361. /**
  92362. * Parse properties from a JSON object
  92363. * @param serializationObject defines the JSON object
  92364. * @param scene defines the hosting scene
  92365. */
  92366. parse(serializationObject: any, scene: Scene): void;
  92367. }
  92368. }
  92369. declare module BABYLON {
  92370. /**
  92371. * Interface representing a particle system in Babylon.js.
  92372. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92373. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92374. */
  92375. export interface IParticleSystem {
  92376. /**
  92377. * List of animations used by the particle system.
  92378. */
  92379. animations: Animation[];
  92380. /**
  92381. * The id of the Particle system.
  92382. */
  92383. id: string;
  92384. /**
  92385. * The name of the Particle system.
  92386. */
  92387. name: string;
  92388. /**
  92389. * The emitter represents the Mesh or position we are attaching the particle system to.
  92390. */
  92391. emitter: Nullable<AbstractMesh | Vector3>;
  92392. /**
  92393. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92394. */
  92395. isBillboardBased: boolean;
  92396. /**
  92397. * The rendering group used by the Particle system to chose when to render.
  92398. */
  92399. renderingGroupId: number;
  92400. /**
  92401. * The layer mask we are rendering the particles through.
  92402. */
  92403. layerMask: number;
  92404. /**
  92405. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92406. */
  92407. updateSpeed: number;
  92408. /**
  92409. * The amount of time the particle system is running (depends of the overall update speed).
  92410. */
  92411. targetStopDuration: number;
  92412. /**
  92413. * The texture used to render each particle. (this can be a spritesheet)
  92414. */
  92415. particleTexture: Nullable<Texture>;
  92416. /**
  92417. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92418. */
  92419. blendMode: number;
  92420. /**
  92421. * Minimum life time of emitting particles.
  92422. */
  92423. minLifeTime: number;
  92424. /**
  92425. * Maximum life time of emitting particles.
  92426. */
  92427. maxLifeTime: number;
  92428. /**
  92429. * Minimum Size of emitting particles.
  92430. */
  92431. minSize: number;
  92432. /**
  92433. * Maximum Size of emitting particles.
  92434. */
  92435. maxSize: number;
  92436. /**
  92437. * Minimum scale of emitting particles on X axis.
  92438. */
  92439. minScaleX: number;
  92440. /**
  92441. * Maximum scale of emitting particles on X axis.
  92442. */
  92443. maxScaleX: number;
  92444. /**
  92445. * Minimum scale of emitting particles on Y axis.
  92446. */
  92447. minScaleY: number;
  92448. /**
  92449. * Maximum scale of emitting particles on Y axis.
  92450. */
  92451. maxScaleY: number;
  92452. /**
  92453. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92454. */
  92455. color1: Color4;
  92456. /**
  92457. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92458. */
  92459. color2: Color4;
  92460. /**
  92461. * Color the particle will have at the end of its lifetime.
  92462. */
  92463. colorDead: Color4;
  92464. /**
  92465. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92466. */
  92467. emitRate: number;
  92468. /**
  92469. * You can use gravity if you want to give an orientation to your particles.
  92470. */
  92471. gravity: Vector3;
  92472. /**
  92473. * Minimum power of emitting particles.
  92474. */
  92475. minEmitPower: number;
  92476. /**
  92477. * Maximum power of emitting particles.
  92478. */
  92479. maxEmitPower: number;
  92480. /**
  92481. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92482. */
  92483. minAngularSpeed: number;
  92484. /**
  92485. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92486. */
  92487. maxAngularSpeed: number;
  92488. /**
  92489. * Gets or sets the minimal initial rotation in radians.
  92490. */
  92491. minInitialRotation: number;
  92492. /**
  92493. * Gets or sets the maximal initial rotation in radians.
  92494. */
  92495. maxInitialRotation: number;
  92496. /**
  92497. * The particle emitter type defines the emitter used by the particle system.
  92498. * It can be for example box, sphere, or cone...
  92499. */
  92500. particleEmitterType: Nullable<IParticleEmitterType>;
  92501. /**
  92502. * Defines the delay in milliseconds before starting the system (0 by default)
  92503. */
  92504. startDelay: number;
  92505. /**
  92506. * 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
  92507. */
  92508. preWarmCycles: number;
  92509. /**
  92510. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92511. */
  92512. preWarmStepOffset: number;
  92513. /**
  92514. * 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)
  92515. */
  92516. spriteCellChangeSpeed: number;
  92517. /**
  92518. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92519. */
  92520. startSpriteCellID: number;
  92521. /**
  92522. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92523. */
  92524. endSpriteCellID: number;
  92525. /**
  92526. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92527. */
  92528. spriteCellWidth: number;
  92529. /**
  92530. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92531. */
  92532. spriteCellHeight: number;
  92533. /**
  92534. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92535. */
  92536. spriteRandomStartCell: boolean;
  92537. /**
  92538. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92539. */
  92540. isAnimationSheetEnabled: boolean;
  92541. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92542. translationPivot: Vector2;
  92543. /**
  92544. * Gets or sets a texture used to add random noise to particle positions
  92545. */
  92546. noiseTexture: Nullable<BaseTexture>;
  92547. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92548. noiseStrength: Vector3;
  92549. /**
  92550. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92551. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92552. */
  92553. billboardMode: number;
  92554. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92555. limitVelocityDamping: number;
  92556. /**
  92557. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92558. */
  92559. beginAnimationOnStart: boolean;
  92560. /**
  92561. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92562. */
  92563. beginAnimationFrom: number;
  92564. /**
  92565. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92566. */
  92567. beginAnimationTo: number;
  92568. /**
  92569. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92570. */
  92571. beginAnimationLoop: boolean;
  92572. /**
  92573. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92574. */
  92575. disposeOnStop: boolean;
  92576. /**
  92577. * Specifies if the particles are updated in emitter local space or world space
  92578. */
  92579. isLocal: boolean;
  92580. /** Snippet ID if the particle system was created from the snippet server */
  92581. snippetId: string;
  92582. /**
  92583. * Gets the maximum number of particles active at the same time.
  92584. * @returns The max number of active particles.
  92585. */
  92586. getCapacity(): number;
  92587. /**
  92588. * Gets the number of particles active at the same time.
  92589. * @returns The number of active particles.
  92590. */
  92591. getActiveCount(): number;
  92592. /**
  92593. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92594. * @returns True if it has been started, otherwise false.
  92595. */
  92596. isStarted(): boolean;
  92597. /**
  92598. * Animates the particle system for this frame.
  92599. */
  92600. animate(): void;
  92601. /**
  92602. * Renders the particle system in its current state.
  92603. * @returns the current number of particles
  92604. */
  92605. render(): number;
  92606. /**
  92607. * Dispose the particle system and frees its associated resources.
  92608. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92609. */
  92610. dispose(disposeTexture?: boolean): void;
  92611. /**
  92612. * An event triggered when the system is disposed
  92613. */
  92614. onDisposeObservable: Observable<IParticleSystem>;
  92615. /**
  92616. * Clones the particle system.
  92617. * @param name The name of the cloned object
  92618. * @param newEmitter The new emitter to use
  92619. * @returns the cloned particle system
  92620. */
  92621. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92622. /**
  92623. * Serializes the particle system to a JSON object
  92624. * @param serializeTexture defines if the texture must be serialized as well
  92625. * @returns the JSON object
  92626. */
  92627. serialize(serializeTexture: boolean): any;
  92628. /**
  92629. * Rebuild the particle system
  92630. */
  92631. rebuild(): void;
  92632. /** Force the system to rebuild all gradients that need to be resync */
  92633. forceRefreshGradients(): void;
  92634. /**
  92635. * Starts the particle system and begins to emit
  92636. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92637. */
  92638. start(delay?: number): void;
  92639. /**
  92640. * Stops the particle system.
  92641. */
  92642. stop(): void;
  92643. /**
  92644. * Remove all active particles
  92645. */
  92646. reset(): void;
  92647. /**
  92648. * Gets a boolean indicating that the system is stopping
  92649. * @returns true if the system is currently stopping
  92650. */
  92651. isStopping(): boolean;
  92652. /**
  92653. * Is this system ready to be used/rendered
  92654. * @return true if the system is ready
  92655. */
  92656. isReady(): boolean;
  92657. /**
  92658. * Returns the string "ParticleSystem"
  92659. * @returns a string containing the class name
  92660. */
  92661. getClassName(): string;
  92662. /**
  92663. * Gets the custom effect used to render the particles
  92664. * @param blendMode Blend mode for which the effect should be retrieved
  92665. * @returns The effect
  92666. */
  92667. getCustomEffect(blendMode: number): Nullable<Effect>;
  92668. /**
  92669. * Sets the custom effect used to render the particles
  92670. * @param effect The effect to set
  92671. * @param blendMode Blend mode for which the effect should be set
  92672. */
  92673. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92674. /**
  92675. * Fill the defines array according to the current settings of the particle system
  92676. * @param defines Array to be updated
  92677. * @param blendMode blend mode to take into account when updating the array
  92678. */
  92679. fillDefines(defines: Array<string>, blendMode: number): void;
  92680. /**
  92681. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92682. * @param uniforms Uniforms array to fill
  92683. * @param attributes Attributes array to fill
  92684. * @param samplers Samplers array to fill
  92685. */
  92686. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92687. /**
  92688. * Observable that will be called just before the particles are drawn
  92689. */
  92690. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92691. /**
  92692. * Gets the name of the particle vertex shader
  92693. */
  92694. vertexShaderName: string;
  92695. /**
  92696. * Adds a new color gradient
  92697. * @param gradient defines the gradient to use (between 0 and 1)
  92698. * @param color1 defines the color to affect to the specified gradient
  92699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92700. * @returns the current particle system
  92701. */
  92702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92703. /**
  92704. * Remove a specific color gradient
  92705. * @param gradient defines the gradient to remove
  92706. * @returns the current particle system
  92707. */
  92708. removeColorGradient(gradient: number): IParticleSystem;
  92709. /**
  92710. * Adds a new size gradient
  92711. * @param gradient defines the gradient to use (between 0 and 1)
  92712. * @param factor defines the size factor to affect to the specified gradient
  92713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92714. * @returns the current particle system
  92715. */
  92716. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92717. /**
  92718. * Remove a specific size gradient
  92719. * @param gradient defines the gradient to remove
  92720. * @returns the current particle system
  92721. */
  92722. removeSizeGradient(gradient: number): IParticleSystem;
  92723. /**
  92724. * Gets the current list of color gradients.
  92725. * You must use addColorGradient and removeColorGradient to udpate this list
  92726. * @returns the list of color gradients
  92727. */
  92728. getColorGradients(): Nullable<Array<ColorGradient>>;
  92729. /**
  92730. * Gets the current list of size gradients.
  92731. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92732. * @returns the list of size gradients
  92733. */
  92734. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92735. /**
  92736. * Gets the current list of angular speed gradients.
  92737. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92738. * @returns the list of angular speed gradients
  92739. */
  92740. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92741. /**
  92742. * Adds a new angular speed gradient
  92743. * @param gradient defines the gradient to use (between 0 and 1)
  92744. * @param factor defines the angular speed to affect to the specified gradient
  92745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92746. * @returns the current particle system
  92747. */
  92748. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92749. /**
  92750. * Remove a specific angular speed gradient
  92751. * @param gradient defines the gradient to remove
  92752. * @returns the current particle system
  92753. */
  92754. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92755. /**
  92756. * Gets the current list of velocity gradients.
  92757. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92758. * @returns the list of velocity gradients
  92759. */
  92760. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92761. /**
  92762. * Adds a new velocity gradient
  92763. * @param gradient defines the gradient to use (between 0 and 1)
  92764. * @param factor defines the velocity to affect to the specified gradient
  92765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92766. * @returns the current particle system
  92767. */
  92768. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92769. /**
  92770. * Remove a specific velocity gradient
  92771. * @param gradient defines the gradient to remove
  92772. * @returns the current particle system
  92773. */
  92774. removeVelocityGradient(gradient: number): IParticleSystem;
  92775. /**
  92776. * Gets the current list of limit velocity gradients.
  92777. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92778. * @returns the list of limit velocity gradients
  92779. */
  92780. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92781. /**
  92782. * Adds a new limit velocity gradient
  92783. * @param gradient defines the gradient to use (between 0 and 1)
  92784. * @param factor defines the limit velocity to affect to the specified gradient
  92785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92786. * @returns the current particle system
  92787. */
  92788. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92789. /**
  92790. * Remove a specific limit velocity gradient
  92791. * @param gradient defines the gradient to remove
  92792. * @returns the current particle system
  92793. */
  92794. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92795. /**
  92796. * Adds a new drag gradient
  92797. * @param gradient defines the gradient to use (between 0 and 1)
  92798. * @param factor defines the drag to affect to the specified gradient
  92799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92800. * @returns the current particle system
  92801. */
  92802. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92803. /**
  92804. * Remove a specific drag gradient
  92805. * @param gradient defines the gradient to remove
  92806. * @returns the current particle system
  92807. */
  92808. removeDragGradient(gradient: number): IParticleSystem;
  92809. /**
  92810. * Gets the current list of drag gradients.
  92811. * You must use addDragGradient and removeDragGradient to udpate this list
  92812. * @returns the list of drag gradients
  92813. */
  92814. getDragGradients(): Nullable<Array<FactorGradient>>;
  92815. /**
  92816. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92817. * @param gradient defines the gradient to use (between 0 and 1)
  92818. * @param factor defines the emit rate to affect to the specified gradient
  92819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92820. * @returns the current particle system
  92821. */
  92822. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92823. /**
  92824. * Remove a specific emit rate gradient
  92825. * @param gradient defines the gradient to remove
  92826. * @returns the current particle system
  92827. */
  92828. removeEmitRateGradient(gradient: number): IParticleSystem;
  92829. /**
  92830. * Gets the current list of emit rate gradients.
  92831. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92832. * @returns the list of emit rate gradients
  92833. */
  92834. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92835. /**
  92836. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92837. * @param gradient defines the gradient to use (between 0 and 1)
  92838. * @param factor defines the start size to affect to the specified gradient
  92839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92840. * @returns the current particle system
  92841. */
  92842. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92843. /**
  92844. * Remove a specific start size gradient
  92845. * @param gradient defines the gradient to remove
  92846. * @returns the current particle system
  92847. */
  92848. removeStartSizeGradient(gradient: number): IParticleSystem;
  92849. /**
  92850. * Gets the current list of start size gradients.
  92851. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92852. * @returns the list of start size gradients
  92853. */
  92854. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92855. /**
  92856. * Adds a new life time gradient
  92857. * @param gradient defines the gradient to use (between 0 and 1)
  92858. * @param factor defines the life time factor to affect to the specified gradient
  92859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92860. * @returns the current particle system
  92861. */
  92862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92863. /**
  92864. * Remove a specific life time gradient
  92865. * @param gradient defines the gradient to remove
  92866. * @returns the current particle system
  92867. */
  92868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92869. /**
  92870. * Gets the current list of life time gradients.
  92871. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92872. * @returns the list of life time gradients
  92873. */
  92874. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92875. /**
  92876. * Gets the current list of color gradients.
  92877. * You must use addColorGradient and removeColorGradient to udpate this list
  92878. * @returns the list of color gradients
  92879. */
  92880. getColorGradients(): Nullable<Array<ColorGradient>>;
  92881. /**
  92882. * Adds a new ramp gradient used to remap particle colors
  92883. * @param gradient defines the gradient to use (between 0 and 1)
  92884. * @param color defines the color to affect to the specified gradient
  92885. * @returns the current particle system
  92886. */
  92887. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92888. /**
  92889. * Gets the current list of ramp gradients.
  92890. * You must use addRampGradient and removeRampGradient to udpate this list
  92891. * @returns the list of ramp gradients
  92892. */
  92893. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92894. /** Gets or sets a boolean indicating that ramp gradients must be used
  92895. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92896. */
  92897. useRampGradients: boolean;
  92898. /**
  92899. * Adds a new color remap gradient
  92900. * @param gradient defines the gradient to use (between 0 and 1)
  92901. * @param min defines the color remap minimal range
  92902. * @param max defines the color remap maximal range
  92903. * @returns the current particle system
  92904. */
  92905. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92906. /**
  92907. * Gets the current list of color remap gradients.
  92908. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92909. * @returns the list of color remap gradients
  92910. */
  92911. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92912. /**
  92913. * Adds a new alpha remap gradient
  92914. * @param gradient defines the gradient to use (between 0 and 1)
  92915. * @param min defines the alpha remap minimal range
  92916. * @param max defines the alpha remap maximal range
  92917. * @returns the current particle system
  92918. */
  92919. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92920. /**
  92921. * Gets the current list of alpha remap gradients.
  92922. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92923. * @returns the list of alpha remap gradients
  92924. */
  92925. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92926. /**
  92927. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92928. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92929. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92930. * @returns the emitter
  92931. */
  92932. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92933. /**
  92934. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92935. * @param radius The radius of the hemisphere to emit from
  92936. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92937. * @returns the emitter
  92938. */
  92939. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92940. /**
  92941. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92942. * @param radius The radius of the sphere to emit from
  92943. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92944. * @returns the emitter
  92945. */
  92946. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92947. /**
  92948. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92949. * @param radius The radius of the sphere to emit from
  92950. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92951. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92952. * @returns the emitter
  92953. */
  92954. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92955. /**
  92956. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92957. * @param radius The radius of the emission cylinder
  92958. * @param height The height of the emission cylinder
  92959. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92960. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92961. * @returns the emitter
  92962. */
  92963. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92964. /**
  92965. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92966. * @param radius The radius of the cylinder to emit from
  92967. * @param height The height of the emission cylinder
  92968. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92971. * @returns the emitter
  92972. */
  92973. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92974. /**
  92975. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92976. * @param radius The radius of the cone to emit from
  92977. * @param angle The base angle of the cone
  92978. * @returns the emitter
  92979. */
  92980. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92981. /**
  92982. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92983. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92984. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92985. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92986. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92987. * @returns the emitter
  92988. */
  92989. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92990. /**
  92991. * Get hosting scene
  92992. * @returns the scene
  92993. */
  92994. getScene(): Scene;
  92995. }
  92996. }
  92997. declare module BABYLON {
  92998. /**
  92999. * 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.
  93000. * @see https://doc.babylonjs.com/how_to/transformnode
  93001. */
  93002. export class TransformNode extends Node {
  93003. /**
  93004. * Object will not rotate to face the camera
  93005. */
  93006. static BILLBOARDMODE_NONE: number;
  93007. /**
  93008. * Object will rotate to face the camera but only on the x axis
  93009. */
  93010. static BILLBOARDMODE_X: number;
  93011. /**
  93012. * Object will rotate to face the camera but only on the y axis
  93013. */
  93014. static BILLBOARDMODE_Y: number;
  93015. /**
  93016. * Object will rotate to face the camera but only on the z axis
  93017. */
  93018. static BILLBOARDMODE_Z: number;
  93019. /**
  93020. * Object will rotate to face the camera
  93021. */
  93022. static BILLBOARDMODE_ALL: number;
  93023. /**
  93024. * Object will rotate to face the camera's position instead of orientation
  93025. */
  93026. static BILLBOARDMODE_USE_POSITION: number;
  93027. private static _TmpRotation;
  93028. private static _TmpScaling;
  93029. private static _TmpTranslation;
  93030. private _forward;
  93031. private _forwardInverted;
  93032. private _up;
  93033. private _right;
  93034. private _rightInverted;
  93035. private _position;
  93036. private _rotation;
  93037. private _rotationQuaternion;
  93038. protected _scaling: Vector3;
  93039. protected _isDirty: boolean;
  93040. private _transformToBoneReferal;
  93041. private _isAbsoluteSynced;
  93042. private _billboardMode;
  93043. /**
  93044. * Gets or sets the billboard mode. Default is 0.
  93045. *
  93046. * | Value | Type | Description |
  93047. * | --- | --- | --- |
  93048. * | 0 | BILLBOARDMODE_NONE | |
  93049. * | 1 | BILLBOARDMODE_X | |
  93050. * | 2 | BILLBOARDMODE_Y | |
  93051. * | 4 | BILLBOARDMODE_Z | |
  93052. * | 7 | BILLBOARDMODE_ALL | |
  93053. *
  93054. */
  93055. get billboardMode(): number;
  93056. set billboardMode(value: number);
  93057. private _preserveParentRotationForBillboard;
  93058. /**
  93059. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93060. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93061. */
  93062. get preserveParentRotationForBillboard(): boolean;
  93063. set preserveParentRotationForBillboard(value: boolean);
  93064. /**
  93065. * 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
  93066. */
  93067. scalingDeterminant: number;
  93068. private _infiniteDistance;
  93069. /**
  93070. * Gets or sets the distance of the object to max, often used by skybox
  93071. */
  93072. get infiniteDistance(): boolean;
  93073. set infiniteDistance(value: boolean);
  93074. /**
  93075. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93076. * By default the system will update normals to compensate
  93077. */
  93078. ignoreNonUniformScaling: boolean;
  93079. /**
  93080. * 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
  93081. */
  93082. reIntegrateRotationIntoRotationQuaternion: boolean;
  93083. /** @hidden */
  93084. _poseMatrix: Nullable<Matrix>;
  93085. /** @hidden */
  93086. _localMatrix: Matrix;
  93087. private _usePivotMatrix;
  93088. private _absolutePosition;
  93089. private _absoluteScaling;
  93090. private _absoluteRotationQuaternion;
  93091. private _pivotMatrix;
  93092. private _pivotMatrixInverse;
  93093. protected _postMultiplyPivotMatrix: boolean;
  93094. protected _isWorldMatrixFrozen: boolean;
  93095. /** @hidden */
  93096. _indexInSceneTransformNodesArray: number;
  93097. /**
  93098. * An event triggered after the world matrix is updated
  93099. */
  93100. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93101. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93102. /**
  93103. * Gets a string identifying the name of the class
  93104. * @returns "TransformNode" string
  93105. */
  93106. getClassName(): string;
  93107. /**
  93108. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93109. */
  93110. get position(): Vector3;
  93111. set position(newPosition: Vector3);
  93112. /**
  93113. * 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)).
  93114. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93115. */
  93116. get rotation(): Vector3;
  93117. set rotation(newRotation: Vector3);
  93118. /**
  93119. * 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)).
  93120. */
  93121. get scaling(): Vector3;
  93122. set scaling(newScaling: Vector3);
  93123. /**
  93124. * 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).
  93125. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93126. */
  93127. get rotationQuaternion(): Nullable<Quaternion>;
  93128. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93129. /**
  93130. * The forward direction of that transform in world space.
  93131. */
  93132. get forward(): Vector3;
  93133. /**
  93134. * The up direction of that transform in world space.
  93135. */
  93136. get up(): Vector3;
  93137. /**
  93138. * The right direction of that transform in world space.
  93139. */
  93140. get right(): Vector3;
  93141. /**
  93142. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93143. * @param matrix the matrix to copy the pose from
  93144. * @returns this TransformNode.
  93145. */
  93146. updatePoseMatrix(matrix: Matrix): TransformNode;
  93147. /**
  93148. * Returns the mesh Pose matrix.
  93149. * @returns the pose matrix
  93150. */
  93151. getPoseMatrix(): Matrix;
  93152. /** @hidden */
  93153. _isSynchronized(): boolean;
  93154. /** @hidden */
  93155. _initCache(): void;
  93156. /**
  93157. * Flag the transform node as dirty (Forcing it to update everything)
  93158. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93159. * @returns this transform node
  93160. */
  93161. markAsDirty(property: string): TransformNode;
  93162. /**
  93163. * Returns the current mesh absolute position.
  93164. * Returns a Vector3.
  93165. */
  93166. get absolutePosition(): Vector3;
  93167. /**
  93168. * Returns the current mesh absolute scaling.
  93169. * Returns a Vector3.
  93170. */
  93171. get absoluteScaling(): Vector3;
  93172. /**
  93173. * Returns the current mesh absolute rotation.
  93174. * Returns a Quaternion.
  93175. */
  93176. get absoluteRotationQuaternion(): Quaternion;
  93177. /**
  93178. * Sets a new matrix to apply before all other transformation
  93179. * @param matrix defines the transform matrix
  93180. * @returns the current TransformNode
  93181. */
  93182. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93183. /**
  93184. * Sets a new pivot matrix to the current node
  93185. * @param matrix defines the new pivot matrix to use
  93186. * @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
  93187. * @returns the current TransformNode
  93188. */
  93189. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93190. /**
  93191. * Returns the mesh pivot matrix.
  93192. * Default : Identity.
  93193. * @returns the matrix
  93194. */
  93195. getPivotMatrix(): Matrix;
  93196. /**
  93197. * Instantiate (when possible) or clone that node with its hierarchy
  93198. * @param newParent defines the new parent to use for the instance (or clone)
  93199. * @param options defines options to configure how copy is done
  93200. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93201. * @returns an instance (or a clone) of the current node with its hiearchy
  93202. */
  93203. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93204. doNotInstantiate: boolean;
  93205. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93206. /**
  93207. * Prevents the World matrix to be computed any longer
  93208. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93209. * @returns the TransformNode.
  93210. */
  93211. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93212. /**
  93213. * Allows back the World matrix computation.
  93214. * @returns the TransformNode.
  93215. */
  93216. unfreezeWorldMatrix(): this;
  93217. /**
  93218. * True if the World matrix has been frozen.
  93219. */
  93220. get isWorldMatrixFrozen(): boolean;
  93221. /**
  93222. * Retuns the mesh absolute position in the World.
  93223. * @returns a Vector3.
  93224. */
  93225. getAbsolutePosition(): Vector3;
  93226. /**
  93227. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93228. * @param absolutePosition the absolute position to set
  93229. * @returns the TransformNode.
  93230. */
  93231. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93232. /**
  93233. * Sets the mesh position in its local space.
  93234. * @param vector3 the position to set in localspace
  93235. * @returns the TransformNode.
  93236. */
  93237. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93238. /**
  93239. * Returns the mesh position in the local space from the current World matrix values.
  93240. * @returns a new Vector3.
  93241. */
  93242. getPositionExpressedInLocalSpace(): Vector3;
  93243. /**
  93244. * Translates the mesh along the passed Vector3 in its local space.
  93245. * @param vector3 the distance to translate in localspace
  93246. * @returns the TransformNode.
  93247. */
  93248. locallyTranslate(vector3: Vector3): TransformNode;
  93249. private static _lookAtVectorCache;
  93250. /**
  93251. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93252. * @param targetPoint the position (must be in same space as current mesh) to look at
  93253. * @param yawCor optional yaw (y-axis) correction in radians
  93254. * @param pitchCor optional pitch (x-axis) correction in radians
  93255. * @param rollCor optional roll (z-axis) correction in radians
  93256. * @param space the choosen space of the target
  93257. * @returns the TransformNode.
  93258. */
  93259. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93260. /**
  93261. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93262. * This Vector3 is expressed in the World space.
  93263. * @param localAxis axis to rotate
  93264. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93265. */
  93266. getDirection(localAxis: Vector3): Vector3;
  93267. /**
  93268. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93269. * localAxis is expressed in the mesh local space.
  93270. * result is computed in the Wordl space from the mesh World matrix.
  93271. * @param localAxis axis to rotate
  93272. * @param result the resulting transformnode
  93273. * @returns this TransformNode.
  93274. */
  93275. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93276. /**
  93277. * Sets this transform node rotation to the given local axis.
  93278. * @param localAxis the axis in local space
  93279. * @param yawCor optional yaw (y-axis) correction in radians
  93280. * @param pitchCor optional pitch (x-axis) correction in radians
  93281. * @param rollCor optional roll (z-axis) correction in radians
  93282. * @returns this TransformNode
  93283. */
  93284. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93285. /**
  93286. * Sets a new pivot point to the current node
  93287. * @param point defines the new pivot point to use
  93288. * @param space defines if the point is in world or local space (local by default)
  93289. * @returns the current TransformNode
  93290. */
  93291. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93292. /**
  93293. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93294. * @returns the pivot point
  93295. */
  93296. getPivotPoint(): Vector3;
  93297. /**
  93298. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93299. * @param result the vector3 to store the result
  93300. * @returns this TransformNode.
  93301. */
  93302. getPivotPointToRef(result: Vector3): TransformNode;
  93303. /**
  93304. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93305. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93306. */
  93307. getAbsolutePivotPoint(): Vector3;
  93308. /**
  93309. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93310. * @param result vector3 to store the result
  93311. * @returns this TransformNode.
  93312. */
  93313. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93314. /**
  93315. * Defines the passed node as the parent of the current node.
  93316. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93317. * @see https://doc.babylonjs.com/how_to/parenting
  93318. * @param node the node ot set as the parent
  93319. * @returns this TransformNode.
  93320. */
  93321. setParent(node: Nullable<Node>): TransformNode;
  93322. private _nonUniformScaling;
  93323. /**
  93324. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93325. */
  93326. get nonUniformScaling(): boolean;
  93327. /** @hidden */
  93328. _updateNonUniformScalingState(value: boolean): boolean;
  93329. /**
  93330. * Attach the current TransformNode to another TransformNode associated with a bone
  93331. * @param bone Bone affecting the TransformNode
  93332. * @param affectedTransformNode TransformNode associated with the bone
  93333. * @returns this object
  93334. */
  93335. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93336. /**
  93337. * Detach the transform node if its associated with a bone
  93338. * @returns this object
  93339. */
  93340. detachFromBone(): TransformNode;
  93341. private static _rotationAxisCache;
  93342. /**
  93343. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93344. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93345. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93346. * The passed axis is also normalized.
  93347. * @param axis the axis to rotate around
  93348. * @param amount the amount to rotate in radians
  93349. * @param space Space to rotate in (Default: local)
  93350. * @returns the TransformNode.
  93351. */
  93352. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93353. /**
  93354. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93355. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93356. * The passed axis is also normalized. .
  93357. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93358. * @param point the point to rotate around
  93359. * @param axis the axis to rotate around
  93360. * @param amount the amount to rotate in radians
  93361. * @returns the TransformNode
  93362. */
  93363. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93364. /**
  93365. * Translates the mesh along the axis vector for the passed distance in the given space.
  93366. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93367. * @param axis the axis to translate in
  93368. * @param distance the distance to translate
  93369. * @param space Space to rotate in (Default: local)
  93370. * @returns the TransformNode.
  93371. */
  93372. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93373. /**
  93374. * Adds a rotation step to the mesh current rotation.
  93375. * x, y, z are Euler angles expressed in radians.
  93376. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93377. * This means this rotation is made in the mesh local space only.
  93378. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93379. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93380. * ```javascript
  93381. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93382. * ```
  93383. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93384. * 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.
  93385. * @param x Rotation to add
  93386. * @param y Rotation to add
  93387. * @param z Rotation to add
  93388. * @returns the TransformNode.
  93389. */
  93390. addRotation(x: number, y: number, z: number): TransformNode;
  93391. /**
  93392. * @hidden
  93393. */
  93394. protected _getEffectiveParent(): Nullable<Node>;
  93395. /**
  93396. * Computes the world matrix of the node
  93397. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93398. * @returns the world matrix
  93399. */
  93400. computeWorldMatrix(force?: boolean): Matrix;
  93401. /**
  93402. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93403. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93404. */
  93405. resetLocalMatrix(independentOfChildren?: boolean): void;
  93406. protected _afterComputeWorldMatrix(): void;
  93407. /**
  93408. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93409. * @param func callback function to add
  93410. *
  93411. * @returns the TransformNode.
  93412. */
  93413. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93414. /**
  93415. * Removes a registered callback function.
  93416. * @param func callback function to remove
  93417. * @returns the TransformNode.
  93418. */
  93419. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93420. /**
  93421. * Gets the position of the current mesh in camera space
  93422. * @param camera defines the camera to use
  93423. * @returns a position
  93424. */
  93425. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93426. /**
  93427. * Returns the distance from the mesh to the active camera
  93428. * @param camera defines the camera to use
  93429. * @returns the distance
  93430. */
  93431. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93432. /**
  93433. * Clone the current transform node
  93434. * @param name Name of the new clone
  93435. * @param newParent New parent for the clone
  93436. * @param doNotCloneChildren Do not clone children hierarchy
  93437. * @returns the new transform node
  93438. */
  93439. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93440. /**
  93441. * Serializes the objects information.
  93442. * @param currentSerializationObject defines the object to serialize in
  93443. * @returns the serialized object
  93444. */
  93445. serialize(currentSerializationObject?: any): any;
  93446. /**
  93447. * Returns a new TransformNode object parsed from the source provided.
  93448. * @param parsedTransformNode is the source.
  93449. * @param scene the scne the object belongs to
  93450. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93451. * @returns a new TransformNode object parsed from the source provided.
  93452. */
  93453. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93454. /**
  93455. * Get all child-transformNodes of this node
  93456. * @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
  93457. * @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
  93458. * @returns an array of TransformNode
  93459. */
  93460. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93461. /**
  93462. * Releases resources associated with this transform node.
  93463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93465. */
  93466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93467. /**
  93468. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93469. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93470. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93471. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93472. * @returns the current mesh
  93473. */
  93474. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93475. private _syncAbsoluteScalingAndRotation;
  93476. }
  93477. }
  93478. declare module BABYLON {
  93479. /**
  93480. * Class used to override all child animations of a given target
  93481. */
  93482. export class AnimationPropertiesOverride {
  93483. /**
  93484. * Gets or sets a value indicating if animation blending must be used
  93485. */
  93486. enableBlending: boolean;
  93487. /**
  93488. * Gets or sets the blending speed to use when enableBlending is true
  93489. */
  93490. blendingSpeed: number;
  93491. /**
  93492. * Gets or sets the default loop mode to use
  93493. */
  93494. loopMode: number;
  93495. }
  93496. }
  93497. declare module BABYLON {
  93498. /**
  93499. * Class used to store bone information
  93500. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93501. */
  93502. export class Bone extends Node {
  93503. /**
  93504. * defines the bone name
  93505. */
  93506. name: string;
  93507. private static _tmpVecs;
  93508. private static _tmpQuat;
  93509. private static _tmpMats;
  93510. /**
  93511. * Gets the list of child bones
  93512. */
  93513. children: Bone[];
  93514. /** Gets the animations associated with this bone */
  93515. animations: Animation[];
  93516. /**
  93517. * Gets or sets bone length
  93518. */
  93519. length: number;
  93520. /**
  93521. * @hidden Internal only
  93522. * Set this value to map this bone to a different index in the transform matrices
  93523. * Set this value to -1 to exclude the bone from the transform matrices
  93524. */
  93525. _index: Nullable<number>;
  93526. private _skeleton;
  93527. private _localMatrix;
  93528. private _restPose;
  93529. private _baseMatrix;
  93530. private _absoluteTransform;
  93531. private _invertedAbsoluteTransform;
  93532. private _parent;
  93533. private _scalingDeterminant;
  93534. private _worldTransform;
  93535. private _localScaling;
  93536. private _localRotation;
  93537. private _localPosition;
  93538. private _needToDecompose;
  93539. private _needToCompose;
  93540. /** @hidden */
  93541. _linkedTransformNode: Nullable<TransformNode>;
  93542. /** @hidden */
  93543. _waitingTransformNodeId: Nullable<string>;
  93544. /** @hidden */
  93545. get _matrix(): Matrix;
  93546. /** @hidden */
  93547. set _matrix(value: Matrix);
  93548. /**
  93549. * Create a new bone
  93550. * @param name defines the bone name
  93551. * @param skeleton defines the parent skeleton
  93552. * @param parentBone defines the parent (can be null if the bone is the root)
  93553. * @param localMatrix defines the local matrix
  93554. * @param restPose defines the rest pose matrix
  93555. * @param baseMatrix defines the base matrix
  93556. * @param index defines index of the bone in the hiearchy
  93557. */
  93558. constructor(
  93559. /**
  93560. * defines the bone name
  93561. */
  93562. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93563. /**
  93564. * Gets the current object class name.
  93565. * @return the class name
  93566. */
  93567. getClassName(): string;
  93568. /**
  93569. * Gets the parent skeleton
  93570. * @returns a skeleton
  93571. */
  93572. getSkeleton(): Skeleton;
  93573. /**
  93574. * Gets parent bone
  93575. * @returns a bone or null if the bone is the root of the bone hierarchy
  93576. */
  93577. getParent(): Nullable<Bone>;
  93578. /**
  93579. * Returns an array containing the root bones
  93580. * @returns an array containing the root bones
  93581. */
  93582. getChildren(): Array<Bone>;
  93583. /**
  93584. * Gets the node index in matrix array generated for rendering
  93585. * @returns the node index
  93586. */
  93587. getIndex(): number;
  93588. /**
  93589. * Sets the parent bone
  93590. * @param parent defines the parent (can be null if the bone is the root)
  93591. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93592. */
  93593. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93594. /**
  93595. * Gets the local matrix
  93596. * @returns a matrix
  93597. */
  93598. getLocalMatrix(): Matrix;
  93599. /**
  93600. * Gets the base matrix (initial matrix which remains unchanged)
  93601. * @returns a matrix
  93602. */
  93603. getBaseMatrix(): Matrix;
  93604. /**
  93605. * Gets the rest pose matrix
  93606. * @returns a matrix
  93607. */
  93608. getRestPose(): Matrix;
  93609. /**
  93610. * Sets the rest pose matrix
  93611. * @param matrix the local-space rest pose to set for this bone
  93612. */
  93613. setRestPose(matrix: Matrix): void;
  93614. /**
  93615. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93616. */
  93617. getWorldMatrix(): Matrix;
  93618. /**
  93619. * Sets the local matrix to rest pose matrix
  93620. */
  93621. returnToRest(): void;
  93622. /**
  93623. * Gets the inverse of the absolute transform matrix.
  93624. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93625. * @returns a matrix
  93626. */
  93627. getInvertedAbsoluteTransform(): Matrix;
  93628. /**
  93629. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93630. * @returns a matrix
  93631. */
  93632. getAbsoluteTransform(): Matrix;
  93633. /**
  93634. * Links with the given transform node.
  93635. * The local matrix of this bone is copied from the transform node every frame.
  93636. * @param transformNode defines the transform node to link to
  93637. */
  93638. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93639. /**
  93640. * Gets the node used to drive the bone's transformation
  93641. * @returns a transform node or null
  93642. */
  93643. getTransformNode(): Nullable<TransformNode>;
  93644. /** Gets or sets current position (in local space) */
  93645. get position(): Vector3;
  93646. set position(newPosition: Vector3);
  93647. /** Gets or sets current rotation (in local space) */
  93648. get rotation(): Vector3;
  93649. set rotation(newRotation: Vector3);
  93650. /** Gets or sets current rotation quaternion (in local space) */
  93651. get rotationQuaternion(): Quaternion;
  93652. set rotationQuaternion(newRotation: Quaternion);
  93653. /** Gets or sets current scaling (in local space) */
  93654. get scaling(): Vector3;
  93655. set scaling(newScaling: Vector3);
  93656. /**
  93657. * Gets the animation properties override
  93658. */
  93659. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93660. private _decompose;
  93661. private _compose;
  93662. /**
  93663. * Update the base and local matrices
  93664. * @param matrix defines the new base or local matrix
  93665. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93666. * @param updateLocalMatrix defines if the local matrix should be updated
  93667. */
  93668. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93669. /** @hidden */
  93670. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93671. /**
  93672. * Flag the bone as dirty (Forcing it to update everything)
  93673. */
  93674. markAsDirty(): void;
  93675. /** @hidden */
  93676. _markAsDirtyAndCompose(): void;
  93677. private _markAsDirtyAndDecompose;
  93678. /**
  93679. * Translate the bone in local or world space
  93680. * @param vec The amount to translate the bone
  93681. * @param space The space that the translation is in
  93682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93683. */
  93684. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93685. /**
  93686. * Set the postion of the bone in local or world space
  93687. * @param position The position to set the bone
  93688. * @param space The space that the position is in
  93689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93690. */
  93691. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93692. /**
  93693. * Set the absolute position of the bone (world space)
  93694. * @param position The position to set the bone
  93695. * @param mesh The mesh that this bone is attached to
  93696. */
  93697. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93698. /**
  93699. * Scale the bone on the x, y and z axes (in local space)
  93700. * @param x The amount to scale the bone on the x axis
  93701. * @param y The amount to scale the bone on the y axis
  93702. * @param z The amount to scale the bone on the z axis
  93703. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93704. */
  93705. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93706. /**
  93707. * Set the bone scaling in local space
  93708. * @param scale defines the scaling vector
  93709. */
  93710. setScale(scale: Vector3): void;
  93711. /**
  93712. * Gets the current scaling in local space
  93713. * @returns the current scaling vector
  93714. */
  93715. getScale(): Vector3;
  93716. /**
  93717. * Gets the current scaling in local space and stores it in a target vector
  93718. * @param result defines the target vector
  93719. */
  93720. getScaleToRef(result: Vector3): void;
  93721. /**
  93722. * Set the yaw, pitch, and roll of the bone in local or world space
  93723. * @param yaw The rotation of the bone on the y axis
  93724. * @param pitch The rotation of the bone on the x axis
  93725. * @param roll The rotation of the bone on the z axis
  93726. * @param space The space that the axes of rotation are in
  93727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93728. */
  93729. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93730. /**
  93731. * Add a rotation to the bone on an axis in local or world space
  93732. * @param axis The axis to rotate the bone on
  93733. * @param amount The amount to rotate the bone
  93734. * @param space The space that the axis is in
  93735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93736. */
  93737. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93738. /**
  93739. * Set the rotation of the bone to a particular axis angle in local or world space
  93740. * @param axis The axis to rotate the bone on
  93741. * @param angle The angle that the bone should be rotated to
  93742. * @param space The space that the axis is in
  93743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93744. */
  93745. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93746. /**
  93747. * Set the euler rotation of the bone in local of world space
  93748. * @param rotation The euler rotation that the bone should be set to
  93749. * @param space The space that the rotation is in
  93750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93751. */
  93752. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93753. /**
  93754. * Set the quaternion rotation of the bone in local of world space
  93755. * @param quat The quaternion rotation that the bone should be set to
  93756. * @param space The space that the rotation is in
  93757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93758. */
  93759. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93760. /**
  93761. * Set the rotation matrix of the bone in local of world space
  93762. * @param rotMat The rotation matrix that the bone should be set to
  93763. * @param space The space that the rotation is in
  93764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93765. */
  93766. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93767. private _rotateWithMatrix;
  93768. private _getNegativeRotationToRef;
  93769. /**
  93770. * Get the position of the bone in local or world space
  93771. * @param space The space that the returned position is in
  93772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93773. * @returns The position of the bone
  93774. */
  93775. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93776. /**
  93777. * Copy the position of the bone to a vector3 in local or world space
  93778. * @param space The space that the returned position is in
  93779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93780. * @param result The vector3 to copy the position to
  93781. */
  93782. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93783. /**
  93784. * Get the absolute position of the bone (world space)
  93785. * @param mesh The mesh that this bone is attached to
  93786. * @returns The absolute position of the bone
  93787. */
  93788. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93789. /**
  93790. * Copy the absolute position of the bone (world space) to the result param
  93791. * @param mesh The mesh that this bone is attached to
  93792. * @param result The vector3 to copy the absolute position to
  93793. */
  93794. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93795. /**
  93796. * Compute the absolute transforms of this bone and its children
  93797. */
  93798. computeAbsoluteTransforms(): void;
  93799. /**
  93800. * Get the world direction from an axis that is in the local space of the bone
  93801. * @param localAxis The local direction that is used to compute the world direction
  93802. * @param mesh The mesh that this bone is attached to
  93803. * @returns The world direction
  93804. */
  93805. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93806. /**
  93807. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93808. * @param localAxis The local direction that is used to compute the world direction
  93809. * @param mesh The mesh that this bone is attached to
  93810. * @param result The vector3 that the world direction will be copied to
  93811. */
  93812. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93813. /**
  93814. * Get the euler rotation of the bone in local or world space
  93815. * @param space The space that the rotation should be in
  93816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93817. * @returns The euler rotation
  93818. */
  93819. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93820. /**
  93821. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93822. * @param space The space that the rotation should be in
  93823. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93824. * @param result The vector3 that the rotation should be copied to
  93825. */
  93826. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93827. /**
  93828. * Get the quaternion rotation of the bone in either local or world space
  93829. * @param space The space that the rotation should be in
  93830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93831. * @returns The quaternion rotation
  93832. */
  93833. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93834. /**
  93835. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93836. * @param space The space that the rotation should be in
  93837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93838. * @param result The quaternion that the rotation should be copied to
  93839. */
  93840. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93841. /**
  93842. * Get the rotation matrix of the bone in local or world space
  93843. * @param space The space that the rotation should be in
  93844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93845. * @returns The rotation matrix
  93846. */
  93847. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93848. /**
  93849. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93850. * @param space The space that the rotation should be in
  93851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93852. * @param result The quaternion that the rotation should be copied to
  93853. */
  93854. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93855. /**
  93856. * Get the world position of a point that is in the local space of the bone
  93857. * @param position The local position
  93858. * @param mesh The mesh that this bone is attached to
  93859. * @returns The world position
  93860. */
  93861. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93862. /**
  93863. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93864. * @param position The local position
  93865. * @param mesh The mesh that this bone is attached to
  93866. * @param result The vector3 that the world position should be copied to
  93867. */
  93868. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93869. /**
  93870. * Get the local position of a point that is in world space
  93871. * @param position The world position
  93872. * @param mesh The mesh that this bone is attached to
  93873. * @returns The local position
  93874. */
  93875. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93876. /**
  93877. * Get the local position of a point that is in world space and copy it to the result param
  93878. * @param position The world position
  93879. * @param mesh The mesh that this bone is attached to
  93880. * @param result The vector3 that the local position should be copied to
  93881. */
  93882. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93883. }
  93884. }
  93885. declare module BABYLON {
  93886. /**
  93887. * Defines a runtime animation
  93888. */
  93889. export class RuntimeAnimation {
  93890. private _events;
  93891. /**
  93892. * The current frame of the runtime animation
  93893. */
  93894. private _currentFrame;
  93895. /**
  93896. * The animation used by the runtime animation
  93897. */
  93898. private _animation;
  93899. /**
  93900. * The target of the runtime animation
  93901. */
  93902. private _target;
  93903. /**
  93904. * The initiating animatable
  93905. */
  93906. private _host;
  93907. /**
  93908. * The original value of the runtime animation
  93909. */
  93910. private _originalValue;
  93911. /**
  93912. * The original blend value of the runtime animation
  93913. */
  93914. private _originalBlendValue;
  93915. /**
  93916. * The offsets cache of the runtime animation
  93917. */
  93918. private _offsetsCache;
  93919. /**
  93920. * The high limits cache of the runtime animation
  93921. */
  93922. private _highLimitsCache;
  93923. /**
  93924. * Specifies if the runtime animation has been stopped
  93925. */
  93926. private _stopped;
  93927. /**
  93928. * The blending factor of the runtime animation
  93929. */
  93930. private _blendingFactor;
  93931. /**
  93932. * The BabylonJS scene
  93933. */
  93934. private _scene;
  93935. /**
  93936. * The current value of the runtime animation
  93937. */
  93938. private _currentValue;
  93939. /** @hidden */
  93940. _animationState: _IAnimationState;
  93941. /**
  93942. * The active target of the runtime animation
  93943. */
  93944. private _activeTargets;
  93945. private _currentActiveTarget;
  93946. private _directTarget;
  93947. /**
  93948. * The target path of the runtime animation
  93949. */
  93950. private _targetPath;
  93951. /**
  93952. * The weight of the runtime animation
  93953. */
  93954. private _weight;
  93955. /**
  93956. * The ratio offset of the runtime animation
  93957. */
  93958. private _ratioOffset;
  93959. /**
  93960. * The previous delay of the runtime animation
  93961. */
  93962. private _previousDelay;
  93963. /**
  93964. * The previous ratio of the runtime animation
  93965. */
  93966. private _previousRatio;
  93967. private _enableBlending;
  93968. private _keys;
  93969. private _minFrame;
  93970. private _maxFrame;
  93971. private _minValue;
  93972. private _maxValue;
  93973. private _targetIsArray;
  93974. /**
  93975. * Gets the current frame of the runtime animation
  93976. */
  93977. get currentFrame(): number;
  93978. /**
  93979. * Gets the weight of the runtime animation
  93980. */
  93981. get weight(): number;
  93982. /**
  93983. * Gets the current value of the runtime animation
  93984. */
  93985. get currentValue(): any;
  93986. /**
  93987. * Gets the target path of the runtime animation
  93988. */
  93989. get targetPath(): string;
  93990. /**
  93991. * Gets the actual target of the runtime animation
  93992. */
  93993. get target(): any;
  93994. /**
  93995. * Gets the additive state of the runtime animation
  93996. */
  93997. get isAdditive(): boolean;
  93998. /** @hidden */
  93999. _onLoop: () => void;
  94000. /**
  94001. * Create a new RuntimeAnimation object
  94002. * @param target defines the target of the animation
  94003. * @param animation defines the source animation object
  94004. * @param scene defines the hosting scene
  94005. * @param host defines the initiating Animatable
  94006. */
  94007. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94008. private _preparePath;
  94009. /**
  94010. * Gets the animation from the runtime animation
  94011. */
  94012. get animation(): Animation;
  94013. /**
  94014. * Resets the runtime animation to the beginning
  94015. * @param restoreOriginal defines whether to restore the target property to the original value
  94016. */
  94017. reset(restoreOriginal?: boolean): void;
  94018. /**
  94019. * Specifies if the runtime animation is stopped
  94020. * @returns Boolean specifying if the runtime animation is stopped
  94021. */
  94022. isStopped(): boolean;
  94023. /**
  94024. * Disposes of the runtime animation
  94025. */
  94026. dispose(): void;
  94027. /**
  94028. * Apply the interpolated value to the target
  94029. * @param currentValue defines the value computed by the animation
  94030. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94031. */
  94032. setValue(currentValue: any, weight: number): void;
  94033. private _getOriginalValues;
  94034. private _setValue;
  94035. /**
  94036. * Gets the loop pmode of the runtime animation
  94037. * @returns Loop Mode
  94038. */
  94039. private _getCorrectLoopMode;
  94040. /**
  94041. * Move the current animation to a given frame
  94042. * @param frame defines the frame to move to
  94043. */
  94044. goToFrame(frame: number): void;
  94045. /**
  94046. * @hidden Internal use only
  94047. */
  94048. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94049. /**
  94050. * Execute the current animation
  94051. * @param delay defines the delay to add to the current frame
  94052. * @param from defines the lower bound of the animation range
  94053. * @param to defines the upper bound of the animation range
  94054. * @param loop defines if the current animation must loop
  94055. * @param speedRatio defines the current speed ratio
  94056. * @param weight defines the weight of the animation (default is -1 so no weight)
  94057. * @param onLoop optional callback called when animation loops
  94058. * @returns a boolean indicating if the animation is running
  94059. */
  94060. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94061. }
  94062. }
  94063. declare module BABYLON {
  94064. /**
  94065. * Class used to store an actual running animation
  94066. */
  94067. export class Animatable {
  94068. /** defines the target object */
  94069. target: any;
  94070. /** defines the starting frame number (default is 0) */
  94071. fromFrame: number;
  94072. /** defines the ending frame number (default is 100) */
  94073. toFrame: number;
  94074. /** defines if the animation must loop (default is false) */
  94075. loopAnimation: boolean;
  94076. /** defines a callback to call when animation ends if it is not looping */
  94077. onAnimationEnd?: (() => void) | null | undefined;
  94078. /** defines a callback to call when animation loops */
  94079. onAnimationLoop?: (() => void) | null | undefined;
  94080. /** defines whether the animation should be evaluated additively */
  94081. isAdditive: boolean;
  94082. private _localDelayOffset;
  94083. private _pausedDelay;
  94084. private _runtimeAnimations;
  94085. private _paused;
  94086. private _scene;
  94087. private _speedRatio;
  94088. private _weight;
  94089. private _syncRoot;
  94090. /**
  94091. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94092. * This will only apply for non looping animation (default is true)
  94093. */
  94094. disposeOnEnd: boolean;
  94095. /**
  94096. * Gets a boolean indicating if the animation has started
  94097. */
  94098. animationStarted: boolean;
  94099. /**
  94100. * Observer raised when the animation ends
  94101. */
  94102. onAnimationEndObservable: Observable<Animatable>;
  94103. /**
  94104. * Observer raised when the animation loops
  94105. */
  94106. onAnimationLoopObservable: Observable<Animatable>;
  94107. /**
  94108. * Gets the root Animatable used to synchronize and normalize animations
  94109. */
  94110. get syncRoot(): Nullable<Animatable>;
  94111. /**
  94112. * Gets the current frame of the first RuntimeAnimation
  94113. * Used to synchronize Animatables
  94114. */
  94115. get masterFrame(): number;
  94116. /**
  94117. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94118. */
  94119. get weight(): number;
  94120. set weight(value: number);
  94121. /**
  94122. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94123. */
  94124. get speedRatio(): number;
  94125. set speedRatio(value: number);
  94126. /**
  94127. * Creates a new Animatable
  94128. * @param scene defines the hosting scene
  94129. * @param target defines the target object
  94130. * @param fromFrame defines the starting frame number (default is 0)
  94131. * @param toFrame defines the ending frame number (default is 100)
  94132. * @param loopAnimation defines if the animation must loop (default is false)
  94133. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94134. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94135. * @param animations defines a group of animation to add to the new Animatable
  94136. * @param onAnimationLoop defines a callback to call when animation loops
  94137. * @param isAdditive defines whether the animation should be evaluated additively
  94138. */
  94139. constructor(scene: Scene,
  94140. /** defines the target object */
  94141. target: any,
  94142. /** defines the starting frame number (default is 0) */
  94143. fromFrame?: number,
  94144. /** defines the ending frame number (default is 100) */
  94145. toFrame?: number,
  94146. /** defines if the animation must loop (default is false) */
  94147. loopAnimation?: boolean, speedRatio?: number,
  94148. /** defines a callback to call when animation ends if it is not looping */
  94149. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94150. /** defines a callback to call when animation loops */
  94151. onAnimationLoop?: (() => void) | null | undefined,
  94152. /** defines whether the animation should be evaluated additively */
  94153. isAdditive?: boolean);
  94154. /**
  94155. * Synchronize and normalize current Animatable with a source Animatable
  94156. * This is useful when using animation weights and when animations are not of the same length
  94157. * @param root defines the root Animatable to synchronize with
  94158. * @returns the current Animatable
  94159. */
  94160. syncWith(root: Animatable): Animatable;
  94161. /**
  94162. * Gets the list of runtime animations
  94163. * @returns an array of RuntimeAnimation
  94164. */
  94165. getAnimations(): RuntimeAnimation[];
  94166. /**
  94167. * Adds more animations to the current animatable
  94168. * @param target defines the target of the animations
  94169. * @param animations defines the new animations to add
  94170. */
  94171. appendAnimations(target: any, animations: Animation[]): void;
  94172. /**
  94173. * Gets the source animation for a specific property
  94174. * @param property defines the propertyu to look for
  94175. * @returns null or the source animation for the given property
  94176. */
  94177. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94178. /**
  94179. * Gets the runtime animation for a specific property
  94180. * @param property defines the propertyu to look for
  94181. * @returns null or the runtime animation for the given property
  94182. */
  94183. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94184. /**
  94185. * Resets the animatable to its original state
  94186. */
  94187. reset(): void;
  94188. /**
  94189. * Allows the animatable to blend with current running animations
  94190. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94191. * @param blendingSpeed defines the blending speed to use
  94192. */
  94193. enableBlending(blendingSpeed: number): void;
  94194. /**
  94195. * Disable animation blending
  94196. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94197. */
  94198. disableBlending(): void;
  94199. /**
  94200. * Jump directly to a given frame
  94201. * @param frame defines the frame to jump to
  94202. */
  94203. goToFrame(frame: number): void;
  94204. /**
  94205. * Pause the animation
  94206. */
  94207. pause(): void;
  94208. /**
  94209. * Restart the animation
  94210. */
  94211. restart(): void;
  94212. private _raiseOnAnimationEnd;
  94213. /**
  94214. * Stop and delete the current animation
  94215. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94216. * @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)
  94217. */
  94218. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94219. /**
  94220. * Wait asynchronously for the animation to end
  94221. * @returns a promise which will be fullfilled when the animation ends
  94222. */
  94223. waitAsync(): Promise<Animatable>;
  94224. /** @hidden */
  94225. _animate(delay: number): boolean;
  94226. }
  94227. interface Scene {
  94228. /** @hidden */
  94229. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94230. /** @hidden */
  94231. _processLateAnimationBindingsForMatrices(holder: {
  94232. totalWeight: number;
  94233. totalAdditiveWeight: number;
  94234. animations: RuntimeAnimation[];
  94235. additiveAnimations: RuntimeAnimation[];
  94236. originalValue: Matrix;
  94237. }): any;
  94238. /** @hidden */
  94239. _processLateAnimationBindingsForQuaternions(holder: {
  94240. totalWeight: number;
  94241. totalAdditiveWeight: number;
  94242. animations: RuntimeAnimation[];
  94243. additiveAnimations: RuntimeAnimation[];
  94244. originalValue: Quaternion;
  94245. }, refQuaternion: Quaternion): Quaternion;
  94246. /** @hidden */
  94247. _processLateAnimationBindings(): void;
  94248. /**
  94249. * Will start the animation sequence of a given target
  94250. * @param target defines the target
  94251. * @param from defines from which frame should animation start
  94252. * @param to defines until which frame should animation run.
  94253. * @param weight defines the weight to apply to the animation (1.0 by default)
  94254. * @param loop defines if the animation loops
  94255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94256. * @param onAnimationEnd defines the function to be executed when the animation ends
  94257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94258. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94259. * @param onAnimationLoop defines the callback to call when an animation loops
  94260. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94261. * @returns the animatable object created for this animation
  94262. */
  94263. 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;
  94264. /**
  94265. * Will start the animation sequence of a given target
  94266. * @param target defines the target
  94267. * @param from defines from which frame should animation start
  94268. * @param to defines until which frame should animation run.
  94269. * @param loop defines if the animation loops
  94270. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94271. * @param onAnimationEnd defines the function to be executed when the animation ends
  94272. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94273. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94274. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94275. * @param onAnimationLoop defines the callback to call when an animation loops
  94276. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94277. * @returns the animatable object created for this animation
  94278. */
  94279. 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;
  94280. /**
  94281. * Will start the animation sequence of a given target and its hierarchy
  94282. * @param target defines the target
  94283. * @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.
  94284. * @param from defines from which frame should animation start
  94285. * @param to defines until which frame should animation run.
  94286. * @param loop defines if the animation loops
  94287. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94288. * @param onAnimationEnd defines the function to be executed when the animation ends
  94289. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94290. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94291. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94292. * @param onAnimationLoop defines the callback to call when an animation loops
  94293. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94294. * @returns the list of created animatables
  94295. */
  94296. 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[];
  94297. /**
  94298. * Begin a new animation on a given node
  94299. * @param target defines the target where the animation will take place
  94300. * @param animations defines the list of animations to start
  94301. * @param from defines the initial value
  94302. * @param to defines the final value
  94303. * @param loop defines if you want animation to loop (off by default)
  94304. * @param speedRatio defines the speed ratio to apply to all animations
  94305. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94306. * @param onAnimationLoop defines the callback to call when an animation loops
  94307. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94308. * @returns the list of created animatables
  94309. */
  94310. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94311. /**
  94312. * Begin a new animation on a given node and its hierarchy
  94313. * @param target defines the root node where the animation will take place
  94314. * @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.
  94315. * @param animations defines the list of animations to start
  94316. * @param from defines the initial value
  94317. * @param to defines the final value
  94318. * @param loop defines if you want animation to loop (off by default)
  94319. * @param speedRatio defines the speed ratio to apply to all animations
  94320. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94321. * @param onAnimationLoop defines the callback to call when an animation loops
  94322. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94323. * @returns the list of animatables created for all nodes
  94324. */
  94325. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94326. /**
  94327. * Gets the animatable associated with a specific target
  94328. * @param target defines the target of the animatable
  94329. * @returns the required animatable if found
  94330. */
  94331. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94332. /**
  94333. * Gets all animatables associated with a given target
  94334. * @param target defines the target to look animatables for
  94335. * @returns an array of Animatables
  94336. */
  94337. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94338. /**
  94339. * Stops and removes all animations that have been applied to the scene
  94340. */
  94341. stopAllAnimations(): void;
  94342. /**
  94343. * Gets the current delta time used by animation engine
  94344. */
  94345. deltaTime: number;
  94346. }
  94347. interface Bone {
  94348. /**
  94349. * Copy an animation range from another bone
  94350. * @param source defines the source bone
  94351. * @param rangeName defines the range name to copy
  94352. * @param frameOffset defines the frame offset
  94353. * @param rescaleAsRequired defines if rescaling must be applied if required
  94354. * @param skelDimensionsRatio defines the scaling ratio
  94355. * @returns true if operation was successful
  94356. */
  94357. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94358. }
  94359. }
  94360. declare module BABYLON {
  94361. /**
  94362. * Class used to handle skinning animations
  94363. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94364. */
  94365. export class Skeleton implements IAnimatable {
  94366. /** defines the skeleton name */
  94367. name: string;
  94368. /** defines the skeleton Id */
  94369. id: string;
  94370. /**
  94371. * Defines the list of child bones
  94372. */
  94373. bones: Bone[];
  94374. /**
  94375. * Defines an estimate of the dimension of the skeleton at rest
  94376. */
  94377. dimensionsAtRest: Vector3;
  94378. /**
  94379. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94380. */
  94381. needInitialSkinMatrix: boolean;
  94382. /**
  94383. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94384. */
  94385. overrideMesh: Nullable<AbstractMesh>;
  94386. /**
  94387. * Gets the list of animations attached to this skeleton
  94388. */
  94389. animations: Array<Animation>;
  94390. private _scene;
  94391. private _isDirty;
  94392. private _transformMatrices;
  94393. private _transformMatrixTexture;
  94394. private _meshesWithPoseMatrix;
  94395. private _animatables;
  94396. private _identity;
  94397. private _synchronizedWithMesh;
  94398. private _ranges;
  94399. private _lastAbsoluteTransformsUpdateId;
  94400. private _canUseTextureForBones;
  94401. private _uniqueId;
  94402. /** @hidden */
  94403. _numBonesWithLinkedTransformNode: number;
  94404. /** @hidden */
  94405. _hasWaitingData: Nullable<boolean>;
  94406. /**
  94407. * Specifies if the skeleton should be serialized
  94408. */
  94409. doNotSerialize: boolean;
  94410. private _useTextureToStoreBoneMatrices;
  94411. /**
  94412. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94413. * Please note that this option is not available if the hardware does not support it
  94414. */
  94415. get useTextureToStoreBoneMatrices(): boolean;
  94416. set useTextureToStoreBoneMatrices(value: boolean);
  94417. private _animationPropertiesOverride;
  94418. /**
  94419. * Gets or sets the animation properties override
  94420. */
  94421. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94422. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94423. /**
  94424. * List of inspectable custom properties (used by the Inspector)
  94425. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94426. */
  94427. inspectableCustomProperties: IInspectable[];
  94428. /**
  94429. * An observable triggered before computing the skeleton's matrices
  94430. */
  94431. onBeforeComputeObservable: Observable<Skeleton>;
  94432. /**
  94433. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94434. */
  94435. get isUsingTextureForMatrices(): boolean;
  94436. /**
  94437. * Gets the unique ID of this skeleton
  94438. */
  94439. get uniqueId(): number;
  94440. /**
  94441. * Creates a new skeleton
  94442. * @param name defines the skeleton name
  94443. * @param id defines the skeleton Id
  94444. * @param scene defines the hosting scene
  94445. */
  94446. constructor(
  94447. /** defines the skeleton name */
  94448. name: string,
  94449. /** defines the skeleton Id */
  94450. id: string, scene: Scene);
  94451. /**
  94452. * Gets the current object class name.
  94453. * @return the class name
  94454. */
  94455. getClassName(): string;
  94456. /**
  94457. * Returns an array containing the root bones
  94458. * @returns an array containing the root bones
  94459. */
  94460. getChildren(): Array<Bone>;
  94461. /**
  94462. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94464. * @returns a Float32Array containing matrices data
  94465. */
  94466. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94467. /**
  94468. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94469. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94470. * @returns a raw texture containing the data
  94471. */
  94472. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94473. /**
  94474. * Gets the current hosting scene
  94475. * @returns a scene object
  94476. */
  94477. getScene(): Scene;
  94478. /**
  94479. * Gets a string representing the current skeleton data
  94480. * @param fullDetails defines a boolean indicating if we want a verbose version
  94481. * @returns a string representing the current skeleton data
  94482. */
  94483. toString(fullDetails?: boolean): string;
  94484. /**
  94485. * Get bone's index searching by name
  94486. * @param name defines bone's name to search for
  94487. * @return the indice of the bone. Returns -1 if not found
  94488. */
  94489. getBoneIndexByName(name: string): number;
  94490. /**
  94491. * Creater a new animation range
  94492. * @param name defines the name of the range
  94493. * @param from defines the start key
  94494. * @param to defines the end key
  94495. */
  94496. createAnimationRange(name: string, from: number, to: number): void;
  94497. /**
  94498. * Delete a specific animation range
  94499. * @param name defines the name of the range
  94500. * @param deleteFrames defines if frames must be removed as well
  94501. */
  94502. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94503. /**
  94504. * Gets a specific animation range
  94505. * @param name defines the name of the range to look for
  94506. * @returns the requested animation range or null if not found
  94507. */
  94508. getAnimationRange(name: string): Nullable<AnimationRange>;
  94509. /**
  94510. * Gets the list of all animation ranges defined on this skeleton
  94511. * @returns an array
  94512. */
  94513. getAnimationRanges(): Nullable<AnimationRange>[];
  94514. /**
  94515. * Copy animation range from a source skeleton.
  94516. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94517. * @param source defines the source skeleton
  94518. * @param name defines the name of the range to copy
  94519. * @param rescaleAsRequired defines if rescaling must be applied if required
  94520. * @returns true if operation was successful
  94521. */
  94522. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94523. /**
  94524. * Forces the skeleton to go to rest pose
  94525. */
  94526. returnToRest(): void;
  94527. private _getHighestAnimationFrame;
  94528. /**
  94529. * Begin a specific animation range
  94530. * @param name defines the name of the range to start
  94531. * @param loop defines if looping must be turned on (false by default)
  94532. * @param speedRatio defines the speed ratio to apply (1 by default)
  94533. * @param onAnimationEnd defines a callback which will be called when animation will end
  94534. * @returns a new animatable
  94535. */
  94536. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94537. /**
  94538. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94539. * @param skeleton defines the Skeleton containing the animation range to convert
  94540. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94541. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94542. * @returns the original skeleton
  94543. */
  94544. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94545. /** @hidden */
  94546. _markAsDirty(): void;
  94547. /** @hidden */
  94548. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94549. /** @hidden */
  94550. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94551. private _computeTransformMatrices;
  94552. /**
  94553. * Build all resources required to render a skeleton
  94554. */
  94555. prepare(): void;
  94556. /**
  94557. * Gets the list of animatables currently running for this skeleton
  94558. * @returns an array of animatables
  94559. */
  94560. getAnimatables(): IAnimatable[];
  94561. /**
  94562. * Clone the current skeleton
  94563. * @param name defines the name of the new skeleton
  94564. * @param id defines the id of the new skeleton
  94565. * @returns the new skeleton
  94566. */
  94567. clone(name: string, id?: string): Skeleton;
  94568. /**
  94569. * Enable animation blending for this skeleton
  94570. * @param blendingSpeed defines the blending speed to apply
  94571. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94572. */
  94573. enableBlending(blendingSpeed?: number): void;
  94574. /**
  94575. * Releases all resources associated with the current skeleton
  94576. */
  94577. dispose(): void;
  94578. /**
  94579. * Serialize the skeleton in a JSON object
  94580. * @returns a JSON object
  94581. */
  94582. serialize(): any;
  94583. /**
  94584. * Creates a new skeleton from serialized data
  94585. * @param parsedSkeleton defines the serialized data
  94586. * @param scene defines the hosting scene
  94587. * @returns a new skeleton
  94588. */
  94589. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94590. /**
  94591. * Compute all node absolute transforms
  94592. * @param forceUpdate defines if computation must be done even if cache is up to date
  94593. */
  94594. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94595. /**
  94596. * Gets the root pose matrix
  94597. * @returns a matrix
  94598. */
  94599. getPoseMatrix(): Nullable<Matrix>;
  94600. /**
  94601. * Sorts bones per internal index
  94602. */
  94603. sortBones(): void;
  94604. private _sortBones;
  94605. }
  94606. }
  94607. declare module BABYLON {
  94608. /**
  94609. * Creates an instance based on a source mesh.
  94610. */
  94611. export class InstancedMesh extends AbstractMesh {
  94612. private _sourceMesh;
  94613. private _currentLOD;
  94614. /** @hidden */
  94615. _indexInSourceMeshInstanceArray: number;
  94616. constructor(name: string, source: Mesh);
  94617. /**
  94618. * Returns the string "InstancedMesh".
  94619. */
  94620. getClassName(): string;
  94621. /** Gets the list of lights affecting that mesh */
  94622. get lightSources(): Light[];
  94623. _resyncLightSources(): void;
  94624. _resyncLightSource(light: Light): void;
  94625. _removeLightSource(light: Light, dispose: boolean): void;
  94626. /**
  94627. * If the source mesh receives shadows
  94628. */
  94629. get receiveShadows(): boolean;
  94630. /**
  94631. * The material of the source mesh
  94632. */
  94633. get material(): Nullable<Material>;
  94634. /**
  94635. * Visibility of the source mesh
  94636. */
  94637. get visibility(): number;
  94638. /**
  94639. * Skeleton of the source mesh
  94640. */
  94641. get skeleton(): Nullable<Skeleton>;
  94642. /**
  94643. * Rendering ground id of the source mesh
  94644. */
  94645. get renderingGroupId(): number;
  94646. set renderingGroupId(value: number);
  94647. /**
  94648. * Returns the total number of vertices (integer).
  94649. */
  94650. getTotalVertices(): number;
  94651. /**
  94652. * Returns a positive integer : the total number of indices in this mesh geometry.
  94653. * @returns the numner of indices or zero if the mesh has no geometry.
  94654. */
  94655. getTotalIndices(): number;
  94656. /**
  94657. * The source mesh of the instance
  94658. */
  94659. get sourceMesh(): Mesh;
  94660. /**
  94661. * Creates a new InstancedMesh object from the mesh model.
  94662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94663. * @param name defines the name of the new instance
  94664. * @returns a new InstancedMesh
  94665. */
  94666. createInstance(name: string): InstancedMesh;
  94667. /**
  94668. * Is this node ready to be used/rendered
  94669. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94670. * @return {boolean} is it ready
  94671. */
  94672. isReady(completeCheck?: boolean): boolean;
  94673. /**
  94674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94675. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94676. * @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.
  94677. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94678. */
  94679. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94680. /**
  94681. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94682. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94683. * The `data` are either a numeric array either a Float32Array.
  94684. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94685. * 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).
  94686. * Note that a new underlying VertexBuffer object is created each call.
  94687. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94688. *
  94689. * Possible `kind` values :
  94690. * - VertexBuffer.PositionKind
  94691. * - VertexBuffer.UVKind
  94692. * - VertexBuffer.UV2Kind
  94693. * - VertexBuffer.UV3Kind
  94694. * - VertexBuffer.UV4Kind
  94695. * - VertexBuffer.UV5Kind
  94696. * - VertexBuffer.UV6Kind
  94697. * - VertexBuffer.ColorKind
  94698. * - VertexBuffer.MatricesIndicesKind
  94699. * - VertexBuffer.MatricesIndicesExtraKind
  94700. * - VertexBuffer.MatricesWeightsKind
  94701. * - VertexBuffer.MatricesWeightsExtraKind
  94702. *
  94703. * Returns the Mesh.
  94704. */
  94705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94706. /**
  94707. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94708. * If the mesh has no geometry, it is simply returned as it is.
  94709. * The `data` are either a numeric array either a Float32Array.
  94710. * No new underlying VertexBuffer object is created.
  94711. * 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.
  94712. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94713. *
  94714. * Possible `kind` values :
  94715. * - VertexBuffer.PositionKind
  94716. * - VertexBuffer.UVKind
  94717. * - VertexBuffer.UV2Kind
  94718. * - VertexBuffer.UV3Kind
  94719. * - VertexBuffer.UV4Kind
  94720. * - VertexBuffer.UV5Kind
  94721. * - VertexBuffer.UV6Kind
  94722. * - VertexBuffer.ColorKind
  94723. * - VertexBuffer.MatricesIndicesKind
  94724. * - VertexBuffer.MatricesIndicesExtraKind
  94725. * - VertexBuffer.MatricesWeightsKind
  94726. * - VertexBuffer.MatricesWeightsExtraKind
  94727. *
  94728. * Returns the Mesh.
  94729. */
  94730. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94731. /**
  94732. * Sets the mesh indices.
  94733. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94734. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94735. * This method creates a new index buffer each call.
  94736. * Returns the Mesh.
  94737. */
  94738. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94739. /**
  94740. * Boolean : True if the mesh owns the requested kind of data.
  94741. */
  94742. isVerticesDataPresent(kind: string): boolean;
  94743. /**
  94744. * Returns an array of indices (IndicesArray).
  94745. */
  94746. getIndices(): Nullable<IndicesArray>;
  94747. get _positions(): Nullable<Vector3[]>;
  94748. /**
  94749. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94750. * This means the mesh underlying bounding box and sphere are recomputed.
  94751. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94752. * @returns the current mesh
  94753. */
  94754. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94755. /** @hidden */
  94756. _preActivate(): InstancedMesh;
  94757. /** @hidden */
  94758. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94759. /** @hidden */
  94760. _postActivate(): void;
  94761. getWorldMatrix(): Matrix;
  94762. get isAnInstance(): boolean;
  94763. /**
  94764. * Returns the current associated LOD AbstractMesh.
  94765. */
  94766. getLOD(camera: Camera): AbstractMesh;
  94767. /** @hidden */
  94768. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94769. /** @hidden */
  94770. _syncSubMeshes(): InstancedMesh;
  94771. /** @hidden */
  94772. _generatePointsArray(): boolean;
  94773. /**
  94774. * Creates a new InstancedMesh from the current mesh.
  94775. * - name (string) : the cloned mesh name
  94776. * - newParent (optional Node) : the optional Node to parent the clone to.
  94777. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94778. *
  94779. * Returns the clone.
  94780. */
  94781. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94782. /**
  94783. * Disposes the InstancedMesh.
  94784. * Returns nothing.
  94785. */
  94786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94787. }
  94788. interface Mesh {
  94789. /**
  94790. * Register a custom buffer that will be instanced
  94791. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94792. * @param kind defines the buffer kind
  94793. * @param stride defines the stride in floats
  94794. */
  94795. registerInstancedBuffer(kind: string, stride: number): void;
  94796. /**
  94797. * true to use the edge renderer for all instances of this mesh
  94798. */
  94799. edgesShareWithInstances: boolean;
  94800. /** @hidden */
  94801. _userInstancedBuffersStorage: {
  94802. data: {
  94803. [key: string]: Float32Array;
  94804. };
  94805. sizes: {
  94806. [key: string]: number;
  94807. };
  94808. vertexBuffers: {
  94809. [key: string]: Nullable<VertexBuffer>;
  94810. };
  94811. strides: {
  94812. [key: string]: number;
  94813. };
  94814. };
  94815. }
  94816. interface AbstractMesh {
  94817. /**
  94818. * Object used to store instanced buffers defined by user
  94819. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94820. */
  94821. instancedBuffers: {
  94822. [key: string]: any;
  94823. };
  94824. }
  94825. }
  94826. declare module BABYLON {
  94827. /**
  94828. * Defines the options associated with the creation of a shader material.
  94829. */
  94830. export interface IShaderMaterialOptions {
  94831. /**
  94832. * Does the material work in alpha blend mode
  94833. */
  94834. needAlphaBlending: boolean;
  94835. /**
  94836. * Does the material work in alpha test mode
  94837. */
  94838. needAlphaTesting: boolean;
  94839. /**
  94840. * The list of attribute names used in the shader
  94841. */
  94842. attributes: string[];
  94843. /**
  94844. * The list of unifrom names used in the shader
  94845. */
  94846. uniforms: string[];
  94847. /**
  94848. * The list of UBO names used in the shader
  94849. */
  94850. uniformBuffers: string[];
  94851. /**
  94852. * The list of sampler names used in the shader
  94853. */
  94854. samplers: string[];
  94855. /**
  94856. * The list of defines used in the shader
  94857. */
  94858. defines: string[];
  94859. }
  94860. /**
  94861. * 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.
  94862. *
  94863. * This returned material effects how the mesh will look based on the code in the shaders.
  94864. *
  94865. * @see https://doc.babylonjs.com/how_to/shader_material
  94866. */
  94867. export class ShaderMaterial extends Material {
  94868. private _shaderPath;
  94869. private _options;
  94870. private _textures;
  94871. private _textureArrays;
  94872. private _floats;
  94873. private _ints;
  94874. private _floatsArrays;
  94875. private _colors3;
  94876. private _colors3Arrays;
  94877. private _colors4;
  94878. private _colors4Arrays;
  94879. private _vectors2;
  94880. private _vectors3;
  94881. private _vectors4;
  94882. private _matrices;
  94883. private _matrixArrays;
  94884. private _matrices3x3;
  94885. private _matrices2x2;
  94886. private _vectors2Arrays;
  94887. private _vectors3Arrays;
  94888. private _vectors4Arrays;
  94889. private _cachedWorldViewMatrix;
  94890. private _cachedWorldViewProjectionMatrix;
  94891. private _renderId;
  94892. private _multiview;
  94893. private _cachedDefines;
  94894. /** Define the Url to load snippets */
  94895. static SnippetUrl: string;
  94896. /** Snippet ID if the material was created from the snippet server */
  94897. snippetId: string;
  94898. /**
  94899. * Instantiate a new shader material.
  94900. * 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.
  94901. * This returned material effects how the mesh will look based on the code in the shaders.
  94902. * @see https://doc.babylonjs.com/how_to/shader_material
  94903. * @param name Define the name of the material in the scene
  94904. * @param scene Define the scene the material belongs to
  94905. * @param shaderPath Defines the route to the shader code in one of three ways:
  94906. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94907. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94908. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94909. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94910. * @param options Define the options used to create the shader
  94911. */
  94912. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94913. /**
  94914. * Gets the shader path used to define the shader code
  94915. * It can be modified to trigger a new compilation
  94916. */
  94917. get shaderPath(): any;
  94918. /**
  94919. * Sets the shader path used to define the shader code
  94920. * It can be modified to trigger a new compilation
  94921. */
  94922. set shaderPath(shaderPath: any);
  94923. /**
  94924. * Gets the options used to compile the shader.
  94925. * They can be modified to trigger a new compilation
  94926. */
  94927. get options(): IShaderMaterialOptions;
  94928. /**
  94929. * Gets the current class name of the material e.g. "ShaderMaterial"
  94930. * Mainly use in serialization.
  94931. * @returns the class name
  94932. */
  94933. getClassName(): string;
  94934. /**
  94935. * Specifies if the material will require alpha blending
  94936. * @returns a boolean specifying if alpha blending is needed
  94937. */
  94938. needAlphaBlending(): boolean;
  94939. /**
  94940. * Specifies if this material should be rendered in alpha test mode
  94941. * @returns a boolean specifying if an alpha test is needed.
  94942. */
  94943. needAlphaTesting(): boolean;
  94944. private _checkUniform;
  94945. /**
  94946. * Set a texture in the shader.
  94947. * @param name Define the name of the uniform samplers as defined in the shader
  94948. * @param texture Define the texture to bind to this sampler
  94949. * @return the material itself allowing "fluent" like uniform updates
  94950. */
  94951. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94952. /**
  94953. * Set a texture array in the shader.
  94954. * @param name Define the name of the uniform sampler array as defined in the shader
  94955. * @param textures Define the list of textures to bind to this sampler
  94956. * @return the material itself allowing "fluent" like uniform updates
  94957. */
  94958. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94959. /**
  94960. * Set a float in the shader.
  94961. * @param name Define the name of the uniform as defined in the shader
  94962. * @param value Define the value to give to the uniform
  94963. * @return the material itself allowing "fluent" like uniform updates
  94964. */
  94965. setFloat(name: string, value: number): ShaderMaterial;
  94966. /**
  94967. * Set a int in the shader.
  94968. * @param name Define the name of the uniform as defined in the shader
  94969. * @param value Define the value to give to the uniform
  94970. * @return the material itself allowing "fluent" like uniform updates
  94971. */
  94972. setInt(name: string, value: number): ShaderMaterial;
  94973. /**
  94974. * Set an array of floats in the shader.
  94975. * @param name Define the name of the uniform as defined in the shader
  94976. * @param value Define the value to give to the uniform
  94977. * @return the material itself allowing "fluent" like uniform updates
  94978. */
  94979. setFloats(name: string, value: number[]): ShaderMaterial;
  94980. /**
  94981. * Set a vec3 in the shader from a Color3.
  94982. * @param name Define the name of the uniform as defined in the shader
  94983. * @param value Define the value to give to the uniform
  94984. * @return the material itself allowing "fluent" like uniform updates
  94985. */
  94986. setColor3(name: string, value: Color3): ShaderMaterial;
  94987. /**
  94988. * Set a vec3 array in the shader from a Color3 array.
  94989. * @param name Define the name of the uniform as defined in the shader
  94990. * @param value Define the value to give to the uniform
  94991. * @return the material itself allowing "fluent" like uniform updates
  94992. */
  94993. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94994. /**
  94995. * Set a vec4 in the shader from a Color4.
  94996. * @param name Define the name of the uniform as defined in the shader
  94997. * @param value Define the value to give to the uniform
  94998. * @return the material itself allowing "fluent" like uniform updates
  94999. */
  95000. setColor4(name: string, value: Color4): ShaderMaterial;
  95001. /**
  95002. * Set a vec4 array in the shader from a Color4 array.
  95003. * @param name Define the name of the uniform as defined in the shader
  95004. * @param value Define the value to give to the uniform
  95005. * @return the material itself allowing "fluent" like uniform updates
  95006. */
  95007. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95008. /**
  95009. * Set a vec2 in the shader from a Vector2.
  95010. * @param name Define the name of the uniform as defined in the shader
  95011. * @param value Define the value to give to the uniform
  95012. * @return the material itself allowing "fluent" like uniform updates
  95013. */
  95014. setVector2(name: string, value: Vector2): ShaderMaterial;
  95015. /**
  95016. * Set a vec3 in the shader from a Vector3.
  95017. * @param name Define the name of the uniform as defined in the shader
  95018. * @param value Define the value to give to the uniform
  95019. * @return the material itself allowing "fluent" like uniform updates
  95020. */
  95021. setVector3(name: string, value: Vector3): ShaderMaterial;
  95022. /**
  95023. * Set a vec4 in the shader from a Vector4.
  95024. * @param name Define the name of the uniform as defined in the shader
  95025. * @param value Define the value to give to the uniform
  95026. * @return the material itself allowing "fluent" like uniform updates
  95027. */
  95028. setVector4(name: string, value: Vector4): ShaderMaterial;
  95029. /**
  95030. * Set a mat4 in the shader from a Matrix.
  95031. * @param name Define the name of the uniform as defined in the shader
  95032. * @param value Define the value to give to the uniform
  95033. * @return the material itself allowing "fluent" like uniform updates
  95034. */
  95035. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95036. /**
  95037. * Set a float32Array in the shader from a matrix array.
  95038. * @param name Define the name of the uniform as defined in the shader
  95039. * @param value Define the value to give to the uniform
  95040. * @return the material itself allowing "fluent" like uniform updates
  95041. */
  95042. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95043. /**
  95044. * Set a mat3 in the shader from a Float32Array.
  95045. * @param name Define the name of the uniform as defined in the shader
  95046. * @param value Define the value to give to the uniform
  95047. * @return the material itself allowing "fluent" like uniform updates
  95048. */
  95049. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95050. /**
  95051. * Set a mat2 in the shader from a Float32Array.
  95052. * @param name Define the name of the uniform as defined in the shader
  95053. * @param value Define the value to give to the uniform
  95054. * @return the material itself allowing "fluent" like uniform updates
  95055. */
  95056. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95057. /**
  95058. * Set a vec2 array in the shader from a number array.
  95059. * @param name Define the name of the uniform as defined in the shader
  95060. * @param value Define the value to give to the uniform
  95061. * @return the material itself allowing "fluent" like uniform updates
  95062. */
  95063. setArray2(name: string, value: number[]): ShaderMaterial;
  95064. /**
  95065. * Set a vec3 array in the shader from a number array.
  95066. * @param name Define the name of the uniform as defined in the shader
  95067. * @param value Define the value to give to the uniform
  95068. * @return the material itself allowing "fluent" like uniform updates
  95069. */
  95070. setArray3(name: string, value: number[]): ShaderMaterial;
  95071. /**
  95072. * Set a vec4 array in the shader from a number array.
  95073. * @param name Define the name of the uniform as defined in the shader
  95074. * @param value Define the value to give to the uniform
  95075. * @return the material itself allowing "fluent" like uniform updates
  95076. */
  95077. setArray4(name: string, value: number[]): ShaderMaterial;
  95078. private _checkCache;
  95079. /**
  95080. * Specifies that the submesh is ready to be used
  95081. * @param mesh defines the mesh to check
  95082. * @param subMesh defines which submesh to check
  95083. * @param useInstances specifies that instances should be used
  95084. * @returns a boolean indicating that the submesh is ready or not
  95085. */
  95086. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95087. /**
  95088. * Checks if the material is ready to render the requested mesh
  95089. * @param mesh Define the mesh to render
  95090. * @param useInstances Define whether or not the material is used with instances
  95091. * @returns true if ready, otherwise false
  95092. */
  95093. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95094. /**
  95095. * Binds the world matrix to the material
  95096. * @param world defines the world transformation matrix
  95097. * @param effectOverride - If provided, use this effect instead of internal effect
  95098. */
  95099. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95100. /**
  95101. * Binds the submesh to this material by preparing the effect and shader to draw
  95102. * @param world defines the world transformation matrix
  95103. * @param mesh defines the mesh containing the submesh
  95104. * @param subMesh defines the submesh to bind the material to
  95105. */
  95106. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95107. /**
  95108. * Binds the material to the mesh
  95109. * @param world defines the world transformation matrix
  95110. * @param mesh defines the mesh to bind the material to
  95111. * @param effectOverride - If provided, use this effect instead of internal effect
  95112. */
  95113. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95114. protected _afterBind(mesh?: Mesh): void;
  95115. /**
  95116. * Gets the active textures from the material
  95117. * @returns an array of textures
  95118. */
  95119. getActiveTextures(): BaseTexture[];
  95120. /**
  95121. * Specifies if the material uses a texture
  95122. * @param texture defines the texture to check against the material
  95123. * @returns a boolean specifying if the material uses the texture
  95124. */
  95125. hasTexture(texture: BaseTexture): boolean;
  95126. /**
  95127. * Makes a duplicate of the material, and gives it a new name
  95128. * @param name defines the new name for the duplicated material
  95129. * @returns the cloned material
  95130. */
  95131. clone(name: string): ShaderMaterial;
  95132. /**
  95133. * Disposes the material
  95134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95137. */
  95138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95139. /**
  95140. * Serializes this material in a JSON representation
  95141. * @returns the serialized material object
  95142. */
  95143. serialize(): any;
  95144. /**
  95145. * Creates a shader material from parsed shader material data
  95146. * @param source defines the JSON represnetation of the material
  95147. * @param scene defines the hosting scene
  95148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95149. * @returns a new material
  95150. */
  95151. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95152. /**
  95153. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95154. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95155. * @param url defines the url to load from
  95156. * @param scene defines the hosting scene
  95157. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95158. * @returns a promise that will resolve to the new ShaderMaterial
  95159. */
  95160. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95161. /**
  95162. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95163. * @param snippetId defines the snippet to load
  95164. * @param scene defines the hosting scene
  95165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95166. * @returns a promise that will resolve to the new ShaderMaterial
  95167. */
  95168. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95169. }
  95170. }
  95171. declare module BABYLON {
  95172. /** @hidden */
  95173. export var colorPixelShader: {
  95174. name: string;
  95175. shader: string;
  95176. };
  95177. }
  95178. declare module BABYLON {
  95179. /** @hidden */
  95180. export var colorVertexShader: {
  95181. name: string;
  95182. shader: string;
  95183. };
  95184. }
  95185. declare module BABYLON {
  95186. /**
  95187. * Line mesh
  95188. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95189. */
  95190. export class LinesMesh extends Mesh {
  95191. /**
  95192. * If vertex color should be applied to the mesh
  95193. */
  95194. readonly useVertexColor?: boolean | undefined;
  95195. /**
  95196. * If vertex alpha should be applied to the mesh
  95197. */
  95198. readonly useVertexAlpha?: boolean | undefined;
  95199. /**
  95200. * Color of the line (Default: White)
  95201. */
  95202. color: Color3;
  95203. /**
  95204. * Alpha of the line (Default: 1)
  95205. */
  95206. alpha: number;
  95207. /**
  95208. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95209. * This margin is expressed in world space coordinates, so its value may vary.
  95210. * Default value is 0.1
  95211. */
  95212. intersectionThreshold: number;
  95213. private _colorShader;
  95214. private color4;
  95215. /**
  95216. * Creates a new LinesMesh
  95217. * @param name defines the name
  95218. * @param scene defines the hosting scene
  95219. * @param parent defines the parent mesh if any
  95220. * @param source defines the optional source LinesMesh used to clone data from
  95221. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95222. * When false, achieved by calling a clone(), also passing False.
  95223. * This will make creation of children, recursive.
  95224. * @param useVertexColor defines if this LinesMesh supports vertex color
  95225. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95226. */
  95227. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95228. /**
  95229. * If vertex color should be applied to the mesh
  95230. */
  95231. useVertexColor?: boolean | undefined,
  95232. /**
  95233. * If vertex alpha should be applied to the mesh
  95234. */
  95235. useVertexAlpha?: boolean | undefined);
  95236. private _addClipPlaneDefine;
  95237. private _removeClipPlaneDefine;
  95238. isReady(): boolean;
  95239. /**
  95240. * Returns the string "LineMesh"
  95241. */
  95242. getClassName(): string;
  95243. /**
  95244. * @hidden
  95245. */
  95246. get material(): Material;
  95247. /**
  95248. * @hidden
  95249. */
  95250. set material(value: Material);
  95251. /**
  95252. * @hidden
  95253. */
  95254. get checkCollisions(): boolean;
  95255. /** @hidden */
  95256. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95257. /** @hidden */
  95258. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95259. /**
  95260. * Disposes of the line mesh
  95261. * @param doNotRecurse If children should be disposed
  95262. */
  95263. dispose(doNotRecurse?: boolean): void;
  95264. /**
  95265. * Returns a new LineMesh object cloned from the current one.
  95266. */
  95267. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95268. /**
  95269. * Creates a new InstancedLinesMesh object from the mesh model.
  95270. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95271. * @param name defines the name of the new instance
  95272. * @returns a new InstancedLinesMesh
  95273. */
  95274. createInstance(name: string): InstancedLinesMesh;
  95275. }
  95276. /**
  95277. * Creates an instance based on a source LinesMesh
  95278. */
  95279. export class InstancedLinesMesh extends InstancedMesh {
  95280. /**
  95281. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95282. * This margin is expressed in world space coordinates, so its value may vary.
  95283. * Initilized with the intersectionThreshold value of the source LinesMesh
  95284. */
  95285. intersectionThreshold: number;
  95286. constructor(name: string, source: LinesMesh);
  95287. /**
  95288. * Returns the string "InstancedLinesMesh".
  95289. */
  95290. getClassName(): string;
  95291. }
  95292. }
  95293. declare module BABYLON {
  95294. /** @hidden */
  95295. export var linePixelShader: {
  95296. name: string;
  95297. shader: string;
  95298. };
  95299. }
  95300. declare module BABYLON {
  95301. /** @hidden */
  95302. export var lineVertexShader: {
  95303. name: string;
  95304. shader: string;
  95305. };
  95306. }
  95307. declare module BABYLON {
  95308. interface Scene {
  95309. /** @hidden */
  95310. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95311. }
  95312. interface AbstractMesh {
  95313. /**
  95314. * Gets the edgesRenderer associated with the mesh
  95315. */
  95316. edgesRenderer: Nullable<EdgesRenderer>;
  95317. }
  95318. interface LinesMesh {
  95319. /**
  95320. * Enables the edge rendering mode on the mesh.
  95321. * This mode makes the mesh edges visible
  95322. * @param epsilon defines the maximal distance between two angles to detect a face
  95323. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95324. * @returns the currentAbstractMesh
  95325. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95326. */
  95327. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95328. }
  95329. interface InstancedLinesMesh {
  95330. /**
  95331. * Enables the edge rendering mode on the mesh.
  95332. * This mode makes the mesh edges visible
  95333. * @param epsilon defines the maximal distance between two angles to detect a face
  95334. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95335. * @returns the current InstancedLinesMesh
  95336. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95337. */
  95338. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95339. }
  95340. /**
  95341. * Defines the minimum contract an Edges renderer should follow.
  95342. */
  95343. export interface IEdgesRenderer extends IDisposable {
  95344. /**
  95345. * Gets or sets a boolean indicating if the edgesRenderer is active
  95346. */
  95347. isEnabled: boolean;
  95348. /**
  95349. * Renders the edges of the attached mesh,
  95350. */
  95351. render(): void;
  95352. /**
  95353. * Checks wether or not the edges renderer is ready to render.
  95354. * @return true if ready, otherwise false.
  95355. */
  95356. isReady(): boolean;
  95357. /**
  95358. * List of instances to render in case the source mesh has instances
  95359. */
  95360. customInstances: SmartArray<Matrix>;
  95361. }
  95362. /**
  95363. * Defines the additional options of the edges renderer
  95364. */
  95365. export interface IEdgesRendererOptions {
  95366. /**
  95367. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95368. * If not defined, the default value is true
  95369. */
  95370. useAlternateEdgeFinder?: boolean;
  95371. /**
  95372. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95373. * If not defined, the default value is true.
  95374. * 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)
  95375. * This option is used only if useAlternateEdgeFinder = true
  95376. */
  95377. useFastVertexMerger?: boolean;
  95378. /**
  95379. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95380. * The default value is 1e-6
  95381. * This option is used only if useAlternateEdgeFinder = true
  95382. */
  95383. epsilonVertexMerge?: number;
  95384. /**
  95385. * 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
  95386. * 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.
  95387. * This option is used only if useAlternateEdgeFinder = true
  95388. */
  95389. applyTessellation?: boolean;
  95390. /**
  95391. * 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
  95392. * The default value is 1e-6
  95393. * This option is used only if useAlternateEdgeFinder = true
  95394. */
  95395. epsilonVertexAligned?: number;
  95396. }
  95397. /**
  95398. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95399. */
  95400. export class EdgesRenderer implements IEdgesRenderer {
  95401. /**
  95402. * Define the size of the edges with an orthographic camera
  95403. */
  95404. edgesWidthScalerForOrthographic: number;
  95405. /**
  95406. * Define the size of the edges with a perspective camera
  95407. */
  95408. edgesWidthScalerForPerspective: number;
  95409. protected _source: AbstractMesh;
  95410. protected _linesPositions: number[];
  95411. protected _linesNormals: number[];
  95412. protected _linesIndices: number[];
  95413. protected _epsilon: number;
  95414. protected _indicesCount: number;
  95415. protected _lineShader: ShaderMaterial;
  95416. protected _ib: DataBuffer;
  95417. protected _buffers: {
  95418. [key: string]: Nullable<VertexBuffer>;
  95419. };
  95420. protected _buffersForInstances: {
  95421. [key: string]: Nullable<VertexBuffer>;
  95422. };
  95423. protected _checkVerticesInsteadOfIndices: boolean;
  95424. protected _options: Nullable<IEdgesRendererOptions>;
  95425. private _meshRebuildObserver;
  95426. private _meshDisposeObserver;
  95427. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95428. isEnabled: boolean;
  95429. /**
  95430. * List of instances to render in case the source mesh has instances
  95431. */
  95432. customInstances: SmartArray<Matrix>;
  95433. private static GetShader;
  95434. /**
  95435. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95436. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95437. * @param source Mesh used to create edges
  95438. * @param epsilon sum of angles in adjacency to check for edge
  95439. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95440. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95441. * @param options The options to apply when generating the edges
  95442. */
  95443. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95444. protected _prepareRessources(): void;
  95445. /** @hidden */
  95446. _rebuild(): void;
  95447. /**
  95448. * Releases the required resources for the edges renderer
  95449. */
  95450. dispose(): void;
  95451. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95452. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95453. /**
  95454. * Checks if the pair of p0 and p1 is en edge
  95455. * @param faceIndex
  95456. * @param edge
  95457. * @param faceNormals
  95458. * @param p0
  95459. * @param p1
  95460. * @private
  95461. */
  95462. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95463. /**
  95464. * push line into the position, normal and index buffer
  95465. * @protected
  95466. */
  95467. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95468. /**
  95469. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95470. */
  95471. private _tessellateTriangle;
  95472. private _generateEdgesLinesAlternate;
  95473. /**
  95474. * Generates lines edges from adjacencjes
  95475. * @private
  95476. */
  95477. _generateEdgesLines(): void;
  95478. /**
  95479. * Checks wether or not the edges renderer is ready to render.
  95480. * @return true if ready, otherwise false.
  95481. */
  95482. isReady(): boolean;
  95483. /**
  95484. * Renders the edges of the attached mesh,
  95485. */
  95486. render(): void;
  95487. }
  95488. /**
  95489. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95490. */
  95491. export class LineEdgesRenderer extends EdgesRenderer {
  95492. /**
  95493. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95494. * @param source LineMesh used to generate edges
  95495. * @param epsilon not important (specified angle for edge detection)
  95496. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95497. */
  95498. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95499. /**
  95500. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95501. */
  95502. _generateEdgesLines(): void;
  95503. }
  95504. }
  95505. declare module BABYLON {
  95506. /**
  95507. * This represents the object necessary to create a rendering group.
  95508. * This is exclusively used and created by the rendering manager.
  95509. * To modify the behavior, you use the available helpers in your scene or meshes.
  95510. * @hidden
  95511. */
  95512. export class RenderingGroup {
  95513. index: number;
  95514. private static _zeroVector;
  95515. private _scene;
  95516. private _opaqueSubMeshes;
  95517. private _transparentSubMeshes;
  95518. private _alphaTestSubMeshes;
  95519. private _depthOnlySubMeshes;
  95520. private _particleSystems;
  95521. private _spriteManagers;
  95522. private _opaqueSortCompareFn;
  95523. private _alphaTestSortCompareFn;
  95524. private _transparentSortCompareFn;
  95525. private _renderOpaque;
  95526. private _renderAlphaTest;
  95527. private _renderTransparent;
  95528. /** @hidden */
  95529. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95530. onBeforeTransparentRendering: () => void;
  95531. /**
  95532. * Set the opaque sort comparison function.
  95533. * If null the sub meshes will be render in the order they were created
  95534. */
  95535. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95536. /**
  95537. * Set the alpha test sort comparison function.
  95538. * If null the sub meshes will be render in the order they were created
  95539. */
  95540. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95541. /**
  95542. * Set the transparent sort comparison function.
  95543. * If null the sub meshes will be render in the order they were created
  95544. */
  95545. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95546. /**
  95547. * Creates a new rendering group.
  95548. * @param index The rendering group index
  95549. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95550. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95551. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95552. */
  95553. 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>);
  95554. /**
  95555. * Render all the sub meshes contained in the group.
  95556. * @param customRenderFunction Used to override the default render behaviour of the group.
  95557. * @returns true if rendered some submeshes.
  95558. */
  95559. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95560. /**
  95561. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95562. * @param subMeshes The submeshes to render
  95563. */
  95564. private renderOpaqueSorted;
  95565. /**
  95566. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95567. * @param subMeshes The submeshes to render
  95568. */
  95569. private renderAlphaTestSorted;
  95570. /**
  95571. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95572. * @param subMeshes The submeshes to render
  95573. */
  95574. private renderTransparentSorted;
  95575. /**
  95576. * Renders the submeshes in a specified order.
  95577. * @param subMeshes The submeshes to sort before render
  95578. * @param sortCompareFn The comparison function use to sort
  95579. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95580. * @param transparent Specifies to activate blending if true
  95581. */
  95582. private static renderSorted;
  95583. /**
  95584. * Renders the submeshes in the order they were dispatched (no sort applied).
  95585. * @param subMeshes The submeshes to render
  95586. */
  95587. private static renderUnsorted;
  95588. /**
  95589. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95590. * are rendered back to front if in the same alpha index.
  95591. *
  95592. * @param a The first submesh
  95593. * @param b The second submesh
  95594. * @returns The result of the comparison
  95595. */
  95596. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95597. /**
  95598. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95599. * are rendered back to front.
  95600. *
  95601. * @param a The first submesh
  95602. * @param b The second submesh
  95603. * @returns The result of the comparison
  95604. */
  95605. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95606. /**
  95607. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95608. * are rendered front to back (prevent overdraw).
  95609. *
  95610. * @param a The first submesh
  95611. * @param b The second submesh
  95612. * @returns The result of the comparison
  95613. */
  95614. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95615. /**
  95616. * Resets the different lists of submeshes to prepare a new frame.
  95617. */
  95618. prepare(): void;
  95619. dispose(): void;
  95620. /**
  95621. * Inserts the submesh in its correct queue depending on its material.
  95622. * @param subMesh The submesh to dispatch
  95623. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95624. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95625. */
  95626. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95627. dispatchSprites(spriteManager: ISpriteManager): void;
  95628. dispatchParticles(particleSystem: IParticleSystem): void;
  95629. private _renderParticles;
  95630. private _renderSprites;
  95631. }
  95632. }
  95633. declare module BABYLON {
  95634. /**
  95635. * Interface describing the different options available in the rendering manager
  95636. * regarding Auto Clear between groups.
  95637. */
  95638. export interface IRenderingManagerAutoClearSetup {
  95639. /**
  95640. * Defines whether or not autoclear is enable.
  95641. */
  95642. autoClear: boolean;
  95643. /**
  95644. * Defines whether or not to autoclear the depth buffer.
  95645. */
  95646. depth: boolean;
  95647. /**
  95648. * Defines whether or not to autoclear the stencil buffer.
  95649. */
  95650. stencil: boolean;
  95651. }
  95652. /**
  95653. * This class is used by the onRenderingGroupObservable
  95654. */
  95655. export class RenderingGroupInfo {
  95656. /**
  95657. * The Scene that being rendered
  95658. */
  95659. scene: Scene;
  95660. /**
  95661. * The camera currently used for the rendering pass
  95662. */
  95663. camera: Nullable<Camera>;
  95664. /**
  95665. * The ID of the renderingGroup being processed
  95666. */
  95667. renderingGroupId: number;
  95668. }
  95669. /**
  95670. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95671. * It is enable to manage the different groups as well as the different necessary sort functions.
  95672. * This should not be used directly aside of the few static configurations
  95673. */
  95674. export class RenderingManager {
  95675. /**
  95676. * The max id used for rendering groups (not included)
  95677. */
  95678. static MAX_RENDERINGGROUPS: number;
  95679. /**
  95680. * The min id used for rendering groups (included)
  95681. */
  95682. static MIN_RENDERINGGROUPS: number;
  95683. /**
  95684. * Used to globally prevent autoclearing scenes.
  95685. */
  95686. static AUTOCLEAR: boolean;
  95687. /**
  95688. * @hidden
  95689. */
  95690. _useSceneAutoClearSetup: boolean;
  95691. private _scene;
  95692. private _renderingGroups;
  95693. private _depthStencilBufferAlreadyCleaned;
  95694. private _autoClearDepthStencil;
  95695. private _customOpaqueSortCompareFn;
  95696. private _customAlphaTestSortCompareFn;
  95697. private _customTransparentSortCompareFn;
  95698. private _renderingGroupInfo;
  95699. /**
  95700. * Instantiates a new rendering group for a particular scene
  95701. * @param scene Defines the scene the groups belongs to
  95702. */
  95703. constructor(scene: Scene);
  95704. private _clearDepthStencilBuffer;
  95705. /**
  95706. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95707. * @hidden
  95708. */
  95709. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95710. /**
  95711. * Resets the different information of the group to prepare a new frame
  95712. * @hidden
  95713. */
  95714. reset(): void;
  95715. /**
  95716. * Dispose and release the group and its associated resources.
  95717. * @hidden
  95718. */
  95719. dispose(): void;
  95720. /**
  95721. * Clear the info related to rendering groups preventing retention points during dispose.
  95722. */
  95723. freeRenderingGroups(): void;
  95724. private _prepareRenderingGroup;
  95725. /**
  95726. * Add a sprite manager to the rendering manager in order to render it this frame.
  95727. * @param spriteManager Define the sprite manager to render
  95728. */
  95729. dispatchSprites(spriteManager: ISpriteManager): void;
  95730. /**
  95731. * Add a particle system to the rendering manager in order to render it this frame.
  95732. * @param particleSystem Define the particle system to render
  95733. */
  95734. dispatchParticles(particleSystem: IParticleSystem): void;
  95735. /**
  95736. * Add a submesh to the manager in order to render it this frame
  95737. * @param subMesh The submesh to dispatch
  95738. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95739. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95740. */
  95741. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95742. /**
  95743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95744. * This allowed control for front to back rendering or reversly depending of the special needs.
  95745. *
  95746. * @param renderingGroupId The rendering group id corresponding to its index
  95747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95750. */
  95751. 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;
  95752. /**
  95753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95754. *
  95755. * @param renderingGroupId The rendering group id corresponding to its index
  95756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95757. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95758. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95759. */
  95760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95761. /**
  95762. * Gets the current auto clear configuration for one rendering group of the rendering
  95763. * manager.
  95764. * @param index the rendering group index to get the information for
  95765. * @returns The auto clear setup for the requested rendering group
  95766. */
  95767. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95768. }
  95769. }
  95770. declare module BABYLON {
  95771. /**
  95772. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95773. */
  95774. export interface ICustomShaderOptions {
  95775. /**
  95776. * Gets or sets the custom shader name to use
  95777. */
  95778. shaderName: string;
  95779. /**
  95780. * The list of attribute names used in the shader
  95781. */
  95782. attributes?: string[];
  95783. /**
  95784. * The list of unifrom names used in the shader
  95785. */
  95786. uniforms?: string[];
  95787. /**
  95788. * The list of sampler names used in the shader
  95789. */
  95790. samplers?: string[];
  95791. /**
  95792. * The list of defines used in the shader
  95793. */
  95794. defines?: string[];
  95795. }
  95796. /**
  95797. * Interface to implement to create a shadow generator compatible with BJS.
  95798. */
  95799. export interface IShadowGenerator {
  95800. /**
  95801. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95802. * @returns The render target texture if present otherwise, null
  95803. */
  95804. getShadowMap(): Nullable<RenderTargetTexture>;
  95805. /**
  95806. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95807. * @param subMesh The submesh we want to render in the shadow map
  95808. * @param useInstances Defines wether will draw in the map using instances
  95809. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95810. * @returns true if ready otherwise, false
  95811. */
  95812. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95813. /**
  95814. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95815. * @param defines Defines of the material we want to update
  95816. * @param lightIndex Index of the light in the enabled light list of the material
  95817. */
  95818. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95819. /**
  95820. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95821. * defined in the generator but impacting the effect).
  95822. * It implies the unifroms available on the materials are the standard BJS ones.
  95823. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95824. * @param effect The effect we are binfing the information for
  95825. */
  95826. bindShadowLight(lightIndex: string, effect: Effect): void;
  95827. /**
  95828. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95829. * (eq to shadow prjection matrix * light transform matrix)
  95830. * @returns The transform matrix used to create the shadow map
  95831. */
  95832. getTransformMatrix(): Matrix;
  95833. /**
  95834. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95835. * Cube and 2D textures for instance.
  95836. */
  95837. recreateShadowMap(): void;
  95838. /**
  95839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95840. * @param onCompiled Callback triggered at the and of the effects compilation
  95841. * @param options Sets of optional options forcing the compilation with different modes
  95842. */
  95843. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95844. useInstances: boolean;
  95845. }>): void;
  95846. /**
  95847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95848. * @param options Sets of optional options forcing the compilation with different modes
  95849. * @returns A promise that resolves when the compilation completes
  95850. */
  95851. forceCompilationAsync(options?: Partial<{
  95852. useInstances: boolean;
  95853. }>): Promise<void>;
  95854. /**
  95855. * Serializes the shadow generator setup to a json object.
  95856. * @returns The serialized JSON object
  95857. */
  95858. serialize(): any;
  95859. /**
  95860. * Disposes the Shadow map and related Textures and effects.
  95861. */
  95862. dispose(): void;
  95863. }
  95864. /**
  95865. * Default implementation IShadowGenerator.
  95866. * This is the main object responsible of generating shadows in the framework.
  95867. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95868. */
  95869. export class ShadowGenerator implements IShadowGenerator {
  95870. /**
  95871. * Name of the shadow generator class
  95872. */
  95873. static CLASSNAME: string;
  95874. /**
  95875. * Shadow generator mode None: no filtering applied.
  95876. */
  95877. static readonly FILTER_NONE: number;
  95878. /**
  95879. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95880. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95881. */
  95882. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95883. /**
  95884. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95885. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95886. */
  95887. static readonly FILTER_POISSONSAMPLING: number;
  95888. /**
  95889. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95890. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95891. */
  95892. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95893. /**
  95894. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95895. * edge artifacts on steep falloff.
  95896. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95897. */
  95898. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95899. /**
  95900. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95901. * edge artifacts on steep falloff.
  95902. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95903. */
  95904. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95905. /**
  95906. * Shadow generator mode PCF: Percentage Closer Filtering
  95907. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95908. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95909. */
  95910. static readonly FILTER_PCF: number;
  95911. /**
  95912. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95913. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95914. * Contact Hardening
  95915. */
  95916. static readonly FILTER_PCSS: number;
  95917. /**
  95918. * Reserved for PCF and PCSS
  95919. * Highest Quality.
  95920. *
  95921. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95922. *
  95923. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95924. */
  95925. static readonly QUALITY_HIGH: number;
  95926. /**
  95927. * Reserved for PCF and PCSS
  95928. * Good tradeoff for quality/perf cross devices
  95929. *
  95930. * Execute PCF on a 3*3 kernel.
  95931. *
  95932. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95933. */
  95934. static readonly QUALITY_MEDIUM: number;
  95935. /**
  95936. * Reserved for PCF and PCSS
  95937. * The lowest quality but the fastest.
  95938. *
  95939. * Execute PCF on a 1*1 kernel.
  95940. *
  95941. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95942. */
  95943. static readonly QUALITY_LOW: number;
  95944. /** Gets or sets the custom shader name to use */
  95945. customShaderOptions: ICustomShaderOptions;
  95946. /**
  95947. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95948. */
  95949. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95950. /**
  95951. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95952. */
  95953. onAfterShadowMapRenderObservable: Observable<Effect>;
  95954. /**
  95955. * Observable triggered before a mesh is rendered in the shadow map.
  95956. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95957. */
  95958. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95959. /**
  95960. * Observable triggered after a mesh is rendered in the shadow map.
  95961. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95962. */
  95963. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95964. protected _bias: number;
  95965. /**
  95966. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95967. */
  95968. get bias(): number;
  95969. /**
  95970. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95971. */
  95972. set bias(bias: number);
  95973. protected _normalBias: number;
  95974. /**
  95975. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95976. */
  95977. get normalBias(): number;
  95978. /**
  95979. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95980. */
  95981. set normalBias(normalBias: number);
  95982. protected _blurBoxOffset: number;
  95983. /**
  95984. * Gets the blur box offset: offset applied during the blur pass.
  95985. * Only useful if useKernelBlur = false
  95986. */
  95987. get blurBoxOffset(): number;
  95988. /**
  95989. * Sets the blur box offset: offset applied during the blur pass.
  95990. * Only useful if useKernelBlur = false
  95991. */
  95992. set blurBoxOffset(value: number);
  95993. protected _blurScale: number;
  95994. /**
  95995. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95996. * 2 means half of the size.
  95997. */
  95998. get blurScale(): number;
  95999. /**
  96000. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96001. * 2 means half of the size.
  96002. */
  96003. set blurScale(value: number);
  96004. protected _blurKernel: number;
  96005. /**
  96006. * Gets the blur kernel: kernel size of the blur pass.
  96007. * Only useful if useKernelBlur = true
  96008. */
  96009. get blurKernel(): number;
  96010. /**
  96011. * Sets the blur kernel: kernel size of the blur pass.
  96012. * Only useful if useKernelBlur = true
  96013. */
  96014. set blurKernel(value: number);
  96015. protected _useKernelBlur: boolean;
  96016. /**
  96017. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96018. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96019. */
  96020. get useKernelBlur(): boolean;
  96021. /**
  96022. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96023. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96024. */
  96025. set useKernelBlur(value: boolean);
  96026. protected _depthScale: number;
  96027. /**
  96028. * Gets the depth scale used in ESM mode.
  96029. */
  96030. get depthScale(): number;
  96031. /**
  96032. * Sets the depth scale used in ESM mode.
  96033. * This can override the scale stored on the light.
  96034. */
  96035. set depthScale(value: number);
  96036. protected _validateFilter(filter: number): number;
  96037. protected _filter: number;
  96038. /**
  96039. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96040. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96041. */
  96042. get filter(): number;
  96043. /**
  96044. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96045. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96046. */
  96047. set filter(value: number);
  96048. /**
  96049. * Gets if the current filter is set to Poisson Sampling.
  96050. */
  96051. get usePoissonSampling(): boolean;
  96052. /**
  96053. * Sets the current filter to Poisson Sampling.
  96054. */
  96055. set usePoissonSampling(value: boolean);
  96056. /**
  96057. * Gets if the current filter is set to ESM.
  96058. */
  96059. get useExponentialShadowMap(): boolean;
  96060. /**
  96061. * Sets the current filter is to ESM.
  96062. */
  96063. set useExponentialShadowMap(value: boolean);
  96064. /**
  96065. * Gets if the current filter is set to filtered ESM.
  96066. */
  96067. get useBlurExponentialShadowMap(): boolean;
  96068. /**
  96069. * Gets if the current filter is set to filtered ESM.
  96070. */
  96071. set useBlurExponentialShadowMap(value: boolean);
  96072. /**
  96073. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96074. * exponential to prevent steep falloff artifacts).
  96075. */
  96076. get useCloseExponentialShadowMap(): boolean;
  96077. /**
  96078. * Sets the current filter to "close ESM" (using the inverse of the
  96079. * exponential to prevent steep falloff artifacts).
  96080. */
  96081. set useCloseExponentialShadowMap(value: boolean);
  96082. /**
  96083. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96084. * exponential to prevent steep falloff artifacts).
  96085. */
  96086. get useBlurCloseExponentialShadowMap(): boolean;
  96087. /**
  96088. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96089. * exponential to prevent steep falloff artifacts).
  96090. */
  96091. set useBlurCloseExponentialShadowMap(value: boolean);
  96092. /**
  96093. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96094. */
  96095. get usePercentageCloserFiltering(): boolean;
  96096. /**
  96097. * Sets the current filter to "PCF" (percentage closer filtering).
  96098. */
  96099. set usePercentageCloserFiltering(value: boolean);
  96100. protected _filteringQuality: number;
  96101. /**
  96102. * Gets the PCF or PCSS Quality.
  96103. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96104. */
  96105. get filteringQuality(): number;
  96106. /**
  96107. * Sets the PCF or PCSS Quality.
  96108. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96109. */
  96110. set filteringQuality(filteringQuality: number);
  96111. /**
  96112. * Gets if the current filter is set to "PCSS" (contact hardening).
  96113. */
  96114. get useContactHardeningShadow(): boolean;
  96115. /**
  96116. * Sets the current filter to "PCSS" (contact hardening).
  96117. */
  96118. set useContactHardeningShadow(value: boolean);
  96119. protected _contactHardeningLightSizeUVRatio: number;
  96120. /**
  96121. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96122. * Using a ratio helps keeping shape stability independently of the map size.
  96123. *
  96124. * It does not account for the light projection as it was having too much
  96125. * instability during the light setup or during light position changes.
  96126. *
  96127. * Only valid if useContactHardeningShadow is true.
  96128. */
  96129. get contactHardeningLightSizeUVRatio(): number;
  96130. /**
  96131. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96132. * Using a ratio helps keeping shape stability independently of the map size.
  96133. *
  96134. * It does not account for the light projection as it was having too much
  96135. * instability during the light setup or during light position changes.
  96136. *
  96137. * Only valid if useContactHardeningShadow is true.
  96138. */
  96139. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96140. protected _darkness: number;
  96141. /** Gets or sets the actual darkness of a shadow */
  96142. get darkness(): number;
  96143. set darkness(value: number);
  96144. /**
  96145. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96146. * 0 means strongest and 1 would means no shadow.
  96147. * @returns the darkness.
  96148. */
  96149. getDarkness(): number;
  96150. /**
  96151. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96152. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96153. * @returns the shadow generator allowing fluent coding.
  96154. */
  96155. setDarkness(darkness: number): ShadowGenerator;
  96156. protected _transparencyShadow: boolean;
  96157. /** Gets or sets the ability to have transparent shadow */
  96158. get transparencyShadow(): boolean;
  96159. set transparencyShadow(value: boolean);
  96160. /**
  96161. * Sets the ability to have transparent shadow (boolean).
  96162. * @param transparent True if transparent else False
  96163. * @returns the shadow generator allowing fluent coding
  96164. */
  96165. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96166. /**
  96167. * Enables or disables shadows with varying strength based on the transparency
  96168. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96169. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96170. * mesh.visibility * alphaTexture.a
  96171. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96172. */
  96173. enableSoftTransparentShadow: boolean;
  96174. protected _shadowMap: Nullable<RenderTargetTexture>;
  96175. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96176. /**
  96177. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96178. * @returns The render target texture if present otherwise, null
  96179. */
  96180. getShadowMap(): Nullable<RenderTargetTexture>;
  96181. /**
  96182. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96183. * @returns The render target texture if the shadow map is present otherwise, null
  96184. */
  96185. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96186. /**
  96187. * Gets the class name of that object
  96188. * @returns "ShadowGenerator"
  96189. */
  96190. getClassName(): string;
  96191. /**
  96192. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96193. * @param mesh Mesh to add
  96194. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96195. * @returns the Shadow Generator itself
  96196. */
  96197. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96198. /**
  96199. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96200. * @param mesh Mesh to remove
  96201. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96202. * @returns the Shadow Generator itself
  96203. */
  96204. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96205. /**
  96206. * Controls the extent to which the shadows fade out at the edge of the frustum
  96207. */
  96208. frustumEdgeFalloff: number;
  96209. protected _light: IShadowLight;
  96210. /**
  96211. * Returns the associated light object.
  96212. * @returns the light generating the shadow
  96213. */
  96214. getLight(): IShadowLight;
  96215. /**
  96216. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96217. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96218. * It might on the other hand introduce peter panning.
  96219. */
  96220. forceBackFacesOnly: boolean;
  96221. protected _scene: Scene;
  96222. protected _lightDirection: Vector3;
  96223. protected _effect: Effect;
  96224. protected _viewMatrix: Matrix;
  96225. protected _projectionMatrix: Matrix;
  96226. protected _transformMatrix: Matrix;
  96227. protected _cachedPosition: Vector3;
  96228. protected _cachedDirection: Vector3;
  96229. protected _cachedDefines: string;
  96230. protected _currentRenderID: number;
  96231. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96232. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96233. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96234. protected _blurPostProcesses: PostProcess[];
  96235. protected _mapSize: number;
  96236. protected _currentFaceIndex: number;
  96237. protected _currentFaceIndexCache: number;
  96238. protected _textureType: number;
  96239. protected _defaultTextureMatrix: Matrix;
  96240. protected _storedUniqueId: Nullable<number>;
  96241. /** @hidden */
  96242. static _SceneComponentInitialization: (scene: Scene) => void;
  96243. /**
  96244. * Creates a ShadowGenerator object.
  96245. * A ShadowGenerator is the required tool to use the shadows.
  96246. * Each light casting shadows needs to use its own ShadowGenerator.
  96247. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96248. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96249. * @param light The light object generating the shadows.
  96250. * @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.
  96251. */
  96252. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96253. protected _initializeGenerator(): void;
  96254. protected _createTargetRenderTexture(): void;
  96255. protected _initializeShadowMap(): void;
  96256. protected _initializeBlurRTTAndPostProcesses(): void;
  96257. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96258. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96259. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96260. protected _applyFilterValues(): void;
  96261. /**
  96262. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96263. * @param onCompiled Callback triggered at the and of the effects compilation
  96264. * @param options Sets of optional options forcing the compilation with different modes
  96265. */
  96266. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96267. useInstances: boolean;
  96268. }>): void;
  96269. /**
  96270. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96271. * @param options Sets of optional options forcing the compilation with different modes
  96272. * @returns A promise that resolves when the compilation completes
  96273. */
  96274. forceCompilationAsync(options?: Partial<{
  96275. useInstances: boolean;
  96276. }>): Promise<void>;
  96277. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96278. private _prepareShadowDefines;
  96279. /**
  96280. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96281. * @param subMesh The submesh we want to render in the shadow map
  96282. * @param useInstances Defines wether will draw in the map using instances
  96283. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96284. * @returns true if ready otherwise, false
  96285. */
  96286. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96287. /**
  96288. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96289. * @param defines Defines of the material we want to update
  96290. * @param lightIndex Index of the light in the enabled light list of the material
  96291. */
  96292. prepareDefines(defines: any, lightIndex: number): void;
  96293. /**
  96294. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96295. * defined in the generator but impacting the effect).
  96296. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96297. * @param effect The effect we are binfing the information for
  96298. */
  96299. bindShadowLight(lightIndex: string, effect: Effect): void;
  96300. /**
  96301. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96302. * (eq to shadow prjection matrix * light transform matrix)
  96303. * @returns The transform matrix used to create the shadow map
  96304. */
  96305. getTransformMatrix(): Matrix;
  96306. /**
  96307. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96308. * Cube and 2D textures for instance.
  96309. */
  96310. recreateShadowMap(): void;
  96311. protected _disposeBlurPostProcesses(): void;
  96312. protected _disposeRTTandPostProcesses(): void;
  96313. /**
  96314. * Disposes the ShadowGenerator.
  96315. * Returns nothing.
  96316. */
  96317. dispose(): void;
  96318. /**
  96319. * Serializes the shadow generator setup to a json object.
  96320. * @returns The serialized JSON object
  96321. */
  96322. serialize(): any;
  96323. /**
  96324. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96325. * @param parsedShadowGenerator The JSON object to parse
  96326. * @param scene The scene to create the shadow map for
  96327. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96328. * @returns The parsed shadow generator
  96329. */
  96330. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96331. }
  96332. }
  96333. declare module BABYLON {
  96334. /**
  96335. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96336. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96337. * 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.
  96338. */
  96339. export abstract class Light extends Node {
  96340. /**
  96341. * Falloff Default: light is falling off following the material specification:
  96342. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96343. */
  96344. static readonly FALLOFF_DEFAULT: number;
  96345. /**
  96346. * Falloff Physical: light is falling off following the inverse squared distance law.
  96347. */
  96348. static readonly FALLOFF_PHYSICAL: number;
  96349. /**
  96350. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96351. * to enhance interoperability with other engines.
  96352. */
  96353. static readonly FALLOFF_GLTF: number;
  96354. /**
  96355. * Falloff Standard: light is falling off like in the standard material
  96356. * to enhance interoperability with other materials.
  96357. */
  96358. static readonly FALLOFF_STANDARD: number;
  96359. /**
  96360. * If every light affecting the material is in this lightmapMode,
  96361. * material.lightmapTexture adds or multiplies
  96362. * (depends on material.useLightmapAsShadowmap)
  96363. * after every other light calculations.
  96364. */
  96365. static readonly LIGHTMAP_DEFAULT: number;
  96366. /**
  96367. * material.lightmapTexture as only diffuse lighting from this light
  96368. * adds only specular lighting from this light
  96369. * adds dynamic shadows
  96370. */
  96371. static readonly LIGHTMAP_SPECULAR: number;
  96372. /**
  96373. * material.lightmapTexture as only lighting
  96374. * no light calculation from this light
  96375. * only adds dynamic shadows from this light
  96376. */
  96377. static readonly LIGHTMAP_SHADOWSONLY: number;
  96378. /**
  96379. * Each light type uses the default quantity according to its type:
  96380. * point/spot lights use luminous intensity
  96381. * directional lights use illuminance
  96382. */
  96383. static readonly INTENSITYMODE_AUTOMATIC: number;
  96384. /**
  96385. * lumen (lm)
  96386. */
  96387. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96388. /**
  96389. * candela (lm/sr)
  96390. */
  96391. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96392. /**
  96393. * lux (lm/m^2)
  96394. */
  96395. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96396. /**
  96397. * nit (cd/m^2)
  96398. */
  96399. static readonly INTENSITYMODE_LUMINANCE: number;
  96400. /**
  96401. * Light type const id of the point light.
  96402. */
  96403. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96404. /**
  96405. * Light type const id of the directional light.
  96406. */
  96407. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96408. /**
  96409. * Light type const id of the spot light.
  96410. */
  96411. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96412. /**
  96413. * Light type const id of the hemispheric light.
  96414. */
  96415. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96416. /**
  96417. * Diffuse gives the basic color to an object.
  96418. */
  96419. diffuse: Color3;
  96420. /**
  96421. * Specular produces a highlight color on an object.
  96422. * Note: This is note affecting PBR materials.
  96423. */
  96424. specular: Color3;
  96425. /**
  96426. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96427. * falling off base on range or angle.
  96428. * This can be set to any values in Light.FALLOFF_x.
  96429. *
  96430. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96431. * other types of materials.
  96432. */
  96433. falloffType: number;
  96434. /**
  96435. * Strength of the light.
  96436. * Note: By default it is define in the framework own unit.
  96437. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96438. */
  96439. intensity: number;
  96440. private _range;
  96441. protected _inverseSquaredRange: number;
  96442. /**
  96443. * Defines how far from the source the light is impacting in scene units.
  96444. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96445. */
  96446. get range(): number;
  96447. /**
  96448. * Defines how far from the source the light is impacting in scene units.
  96449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96450. */
  96451. set range(value: number);
  96452. /**
  96453. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96454. * of light.
  96455. */
  96456. private _photometricScale;
  96457. private _intensityMode;
  96458. /**
  96459. * Gets the photometric scale used to interpret the intensity.
  96460. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96461. */
  96462. get intensityMode(): number;
  96463. /**
  96464. * Sets the photometric scale used to interpret the intensity.
  96465. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96466. */
  96467. set intensityMode(value: number);
  96468. private _radius;
  96469. /**
  96470. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96471. */
  96472. get radius(): number;
  96473. /**
  96474. * sets the light radius used by PBR Materials to simulate soft area lights.
  96475. */
  96476. set radius(value: number);
  96477. private _renderPriority;
  96478. /**
  96479. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96480. * exceeding the number allowed of the materials.
  96481. */
  96482. renderPriority: number;
  96483. private _shadowEnabled;
  96484. /**
  96485. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96486. * the current shadow generator.
  96487. */
  96488. get shadowEnabled(): boolean;
  96489. /**
  96490. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96491. * the current shadow generator.
  96492. */
  96493. set shadowEnabled(value: boolean);
  96494. private _includedOnlyMeshes;
  96495. /**
  96496. * Gets the only meshes impacted by this light.
  96497. */
  96498. get includedOnlyMeshes(): AbstractMesh[];
  96499. /**
  96500. * Sets the only meshes impacted by this light.
  96501. */
  96502. set includedOnlyMeshes(value: AbstractMesh[]);
  96503. private _excludedMeshes;
  96504. /**
  96505. * Gets the meshes not impacted by this light.
  96506. */
  96507. get excludedMeshes(): AbstractMesh[];
  96508. /**
  96509. * Sets the meshes not impacted by this light.
  96510. */
  96511. set excludedMeshes(value: AbstractMesh[]);
  96512. private _excludeWithLayerMask;
  96513. /**
  96514. * Gets the layer id use to find what meshes are not impacted by the light.
  96515. * Inactive if 0
  96516. */
  96517. get excludeWithLayerMask(): number;
  96518. /**
  96519. * Sets the layer id use to find what meshes are not impacted by the light.
  96520. * Inactive if 0
  96521. */
  96522. set excludeWithLayerMask(value: number);
  96523. private _includeOnlyWithLayerMask;
  96524. /**
  96525. * Gets the layer id use to find what meshes are impacted by the light.
  96526. * Inactive if 0
  96527. */
  96528. get includeOnlyWithLayerMask(): number;
  96529. /**
  96530. * Sets the layer id use to find what meshes are impacted by the light.
  96531. * Inactive if 0
  96532. */
  96533. set includeOnlyWithLayerMask(value: number);
  96534. private _lightmapMode;
  96535. /**
  96536. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96537. */
  96538. get lightmapMode(): number;
  96539. /**
  96540. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96541. */
  96542. set lightmapMode(value: number);
  96543. /**
  96544. * Shadow generator associted to the light.
  96545. * @hidden Internal use only.
  96546. */
  96547. _shadowGenerator: Nullable<IShadowGenerator>;
  96548. /**
  96549. * @hidden Internal use only.
  96550. */
  96551. _excludedMeshesIds: string[];
  96552. /**
  96553. * @hidden Internal use only.
  96554. */
  96555. _includedOnlyMeshesIds: string[];
  96556. /**
  96557. * The current light unifom buffer.
  96558. * @hidden Internal use only.
  96559. */
  96560. _uniformBuffer: UniformBuffer;
  96561. /** @hidden */
  96562. _renderId: number;
  96563. /**
  96564. * Creates a Light object in the scene.
  96565. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96566. * @param name The firendly name of the light
  96567. * @param scene The scene the light belongs too
  96568. */
  96569. constructor(name: string, scene: Scene);
  96570. protected abstract _buildUniformLayout(): void;
  96571. /**
  96572. * Sets the passed Effect "effect" with the Light information.
  96573. * @param effect The effect to update
  96574. * @param lightIndex The index of the light in the effect to update
  96575. * @returns The light
  96576. */
  96577. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96578. /**
  96579. * Sets the passed Effect "effect" with the Light textures.
  96580. * @param effect The effect to update
  96581. * @param lightIndex The index of the light in the effect to update
  96582. * @returns The light
  96583. */
  96584. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96585. /**
  96586. * Binds the lights information from the scene to the effect for the given mesh.
  96587. * @param lightIndex Light index
  96588. * @param scene The scene where the light belongs to
  96589. * @param effect The effect we are binding the data to
  96590. * @param useSpecular Defines if specular is supported
  96591. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96592. */
  96593. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96594. /**
  96595. * Sets the passed Effect "effect" with the Light information.
  96596. * @param effect The effect to update
  96597. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96598. * @returns The light
  96599. */
  96600. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96601. /**
  96602. * Returns the string "Light".
  96603. * @returns the class name
  96604. */
  96605. getClassName(): string;
  96606. /** @hidden */
  96607. readonly _isLight: boolean;
  96608. /**
  96609. * Converts the light information to a readable string for debug purpose.
  96610. * @param fullDetails Supports for multiple levels of logging within scene loading
  96611. * @returns the human readable light info
  96612. */
  96613. toString(fullDetails?: boolean): string;
  96614. /** @hidden */
  96615. protected _syncParentEnabledState(): void;
  96616. /**
  96617. * Set the enabled state of this node.
  96618. * @param value - the new enabled state
  96619. */
  96620. setEnabled(value: boolean): void;
  96621. /**
  96622. * Returns the Light associated shadow generator if any.
  96623. * @return the associated shadow generator.
  96624. */
  96625. getShadowGenerator(): Nullable<IShadowGenerator>;
  96626. /**
  96627. * Returns a Vector3, the absolute light position in the World.
  96628. * @returns the world space position of the light
  96629. */
  96630. getAbsolutePosition(): Vector3;
  96631. /**
  96632. * Specifies if the light will affect the passed mesh.
  96633. * @param mesh The mesh to test against the light
  96634. * @return true the mesh is affected otherwise, false.
  96635. */
  96636. canAffectMesh(mesh: AbstractMesh): boolean;
  96637. /**
  96638. * Sort function to order lights for rendering.
  96639. * @param a First Light object to compare to second.
  96640. * @param b Second Light object to compare first.
  96641. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96642. */
  96643. static CompareLightsPriority(a: Light, b: Light): number;
  96644. /**
  96645. * Releases resources associated with this node.
  96646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96648. */
  96649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96650. /**
  96651. * Returns the light type ID (integer).
  96652. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96653. */
  96654. getTypeID(): number;
  96655. /**
  96656. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96657. * @returns the scaled intensity in intensity mode unit
  96658. */
  96659. getScaledIntensity(): number;
  96660. /**
  96661. * Returns a new Light object, named "name", from the current one.
  96662. * @param name The name of the cloned light
  96663. * @param newParent The parent of this light, if it has one
  96664. * @returns the new created light
  96665. */
  96666. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96667. /**
  96668. * Serializes the current light into a Serialization object.
  96669. * @returns the serialized object.
  96670. */
  96671. serialize(): any;
  96672. /**
  96673. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96674. * This new light is named "name" and added to the passed scene.
  96675. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96676. * @param name The friendly name of the light
  96677. * @param scene The scene the new light will belong to
  96678. * @returns the constructor function
  96679. */
  96680. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96681. /**
  96682. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96683. * @param parsedLight The JSON representation of the light
  96684. * @param scene The scene to create the parsed light in
  96685. * @returns the created light after parsing
  96686. */
  96687. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96688. private _hookArrayForExcluded;
  96689. private _hookArrayForIncludedOnly;
  96690. private _resyncMeshes;
  96691. /**
  96692. * Forces the meshes to update their light related information in their rendering used effects
  96693. * @hidden Internal Use Only
  96694. */
  96695. _markMeshesAsLightDirty(): void;
  96696. /**
  96697. * Recomputes the cached photometric scale if needed.
  96698. */
  96699. private _computePhotometricScale;
  96700. /**
  96701. * Returns the Photometric Scale according to the light type and intensity mode.
  96702. */
  96703. private _getPhotometricScale;
  96704. /**
  96705. * Reorder the light in the scene according to their defined priority.
  96706. * @hidden Internal Use Only
  96707. */
  96708. _reorderLightsInScene(): void;
  96709. /**
  96710. * Prepares the list of defines specific to the light type.
  96711. * @param defines the list of defines
  96712. * @param lightIndex defines the index of the light for the effect
  96713. */
  96714. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96715. }
  96716. }
  96717. declare module BABYLON {
  96718. /**
  96719. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96720. * This is the base of the follow, arc rotate cameras and Free camera
  96721. * @see https://doc.babylonjs.com/features/cameras
  96722. */
  96723. export class TargetCamera extends Camera {
  96724. private static _RigCamTransformMatrix;
  96725. private static _TargetTransformMatrix;
  96726. private static _TargetFocalPoint;
  96727. private _tmpUpVector;
  96728. private _tmpTargetVector;
  96729. /**
  96730. * Define the current direction the camera is moving to
  96731. */
  96732. cameraDirection: Vector3;
  96733. /**
  96734. * Define the current rotation the camera is rotating to
  96735. */
  96736. cameraRotation: Vector2;
  96737. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96738. ignoreParentScaling: boolean;
  96739. /**
  96740. * When set, the up vector of the camera will be updated by the rotation of the camera
  96741. */
  96742. updateUpVectorFromRotation: boolean;
  96743. private _tmpQuaternion;
  96744. /**
  96745. * Define the current rotation of the camera
  96746. */
  96747. rotation: Vector3;
  96748. /**
  96749. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96750. */
  96751. rotationQuaternion: Quaternion;
  96752. /**
  96753. * Define the current speed of the camera
  96754. */
  96755. speed: number;
  96756. /**
  96757. * Add constraint to the camera to prevent it to move freely in all directions and
  96758. * around all axis.
  96759. */
  96760. noRotationConstraint: boolean;
  96761. /**
  96762. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96763. * panning
  96764. */
  96765. invertRotation: boolean;
  96766. /**
  96767. * Speed multiplier for inverse camera panning
  96768. */
  96769. inverseRotationSpeed: number;
  96770. /**
  96771. * Define the current target of the camera as an object or a position.
  96772. */
  96773. lockedTarget: any;
  96774. /** @hidden */
  96775. _currentTarget: Vector3;
  96776. /** @hidden */
  96777. _initialFocalDistance: number;
  96778. /** @hidden */
  96779. _viewMatrix: Matrix;
  96780. /** @hidden */
  96781. _camMatrix: Matrix;
  96782. /** @hidden */
  96783. _cameraTransformMatrix: Matrix;
  96784. /** @hidden */
  96785. _cameraRotationMatrix: Matrix;
  96786. /** @hidden */
  96787. _referencePoint: Vector3;
  96788. /** @hidden */
  96789. _transformedReferencePoint: Vector3;
  96790. /** @hidden */
  96791. _reset: () => void;
  96792. private _defaultUp;
  96793. /**
  96794. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96795. * This is the base of the follow, arc rotate cameras and Free camera
  96796. * @see https://doc.babylonjs.com/features/cameras
  96797. * @param name Defines the name of the camera in the scene
  96798. * @param position Defines the start position of the camera in the scene
  96799. * @param scene Defines the scene the camera belongs to
  96800. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96801. */
  96802. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96803. /**
  96804. * Gets the position in front of the camera at a given distance.
  96805. * @param distance The distance from the camera we want the position to be
  96806. * @returns the position
  96807. */
  96808. getFrontPosition(distance: number): Vector3;
  96809. /** @hidden */
  96810. _getLockedTargetPosition(): Nullable<Vector3>;
  96811. private _storedPosition;
  96812. private _storedRotation;
  96813. private _storedRotationQuaternion;
  96814. /**
  96815. * Store current camera state of the camera (fov, position, rotation, etc..)
  96816. * @returns the camera
  96817. */
  96818. storeState(): Camera;
  96819. /**
  96820. * Restored camera state. You must call storeState() first
  96821. * @returns whether it was successful or not
  96822. * @hidden
  96823. */
  96824. _restoreStateValues(): boolean;
  96825. /** @hidden */
  96826. _initCache(): void;
  96827. /** @hidden */
  96828. _updateCache(ignoreParentClass?: boolean): void;
  96829. /** @hidden */
  96830. _isSynchronizedViewMatrix(): boolean;
  96831. /** @hidden */
  96832. _computeLocalCameraSpeed(): number;
  96833. /**
  96834. * Defines the target the camera should look at.
  96835. * @param target Defines the new target as a Vector or a mesh
  96836. */
  96837. setTarget(target: Vector3): void;
  96838. /**
  96839. * Return the current target position of the camera. This value is expressed in local space.
  96840. * @returns the target position
  96841. */
  96842. getTarget(): Vector3;
  96843. /** @hidden */
  96844. _decideIfNeedsToMove(): boolean;
  96845. /** @hidden */
  96846. _updatePosition(): void;
  96847. /** @hidden */
  96848. _checkInputs(): void;
  96849. protected _updateCameraRotationMatrix(): void;
  96850. /**
  96851. * 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)
  96852. * @returns the current camera
  96853. */
  96854. private _rotateUpVectorWithCameraRotationMatrix;
  96855. private _cachedRotationZ;
  96856. private _cachedQuaternionRotationZ;
  96857. /** @hidden */
  96858. _getViewMatrix(): Matrix;
  96859. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96860. /**
  96861. * @hidden
  96862. */
  96863. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96864. /**
  96865. * @hidden
  96866. */
  96867. _updateRigCameras(): void;
  96868. private _getRigCamPositionAndTarget;
  96869. /**
  96870. * Gets the current object class name.
  96871. * @return the class name
  96872. */
  96873. getClassName(): string;
  96874. }
  96875. }
  96876. declare module BABYLON {
  96877. /**
  96878. * Gather the list of keyboard event types as constants.
  96879. */
  96880. export class KeyboardEventTypes {
  96881. /**
  96882. * The keydown event is fired when a key becomes active (pressed).
  96883. */
  96884. static readonly KEYDOWN: number;
  96885. /**
  96886. * The keyup event is fired when a key has been released.
  96887. */
  96888. static readonly KEYUP: number;
  96889. }
  96890. /**
  96891. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96892. */
  96893. export class KeyboardInfo {
  96894. /**
  96895. * Defines the type of event (KeyboardEventTypes)
  96896. */
  96897. type: number;
  96898. /**
  96899. * Defines the related dom event
  96900. */
  96901. event: KeyboardEvent;
  96902. /**
  96903. * Instantiates a new keyboard info.
  96904. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96905. * @param type Defines the type of event (KeyboardEventTypes)
  96906. * @param event Defines the related dom event
  96907. */
  96908. constructor(
  96909. /**
  96910. * Defines the type of event (KeyboardEventTypes)
  96911. */
  96912. type: number,
  96913. /**
  96914. * Defines the related dom event
  96915. */
  96916. event: KeyboardEvent);
  96917. }
  96918. /**
  96919. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96920. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96921. */
  96922. export class KeyboardInfoPre extends KeyboardInfo {
  96923. /**
  96924. * Defines the type of event (KeyboardEventTypes)
  96925. */
  96926. type: number;
  96927. /**
  96928. * Defines the related dom event
  96929. */
  96930. event: KeyboardEvent;
  96931. /**
  96932. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96933. */
  96934. skipOnPointerObservable: boolean;
  96935. /**
  96936. * Instantiates a new keyboard pre info.
  96937. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96938. * @param type Defines the type of event (KeyboardEventTypes)
  96939. * @param event Defines the related dom event
  96940. */
  96941. constructor(
  96942. /**
  96943. * Defines the type of event (KeyboardEventTypes)
  96944. */
  96945. type: number,
  96946. /**
  96947. * Defines the related dom event
  96948. */
  96949. event: KeyboardEvent);
  96950. }
  96951. }
  96952. declare module BABYLON {
  96953. /**
  96954. * Manage the keyboard inputs to control the movement of a free camera.
  96955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96956. */
  96957. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96958. /**
  96959. * Defines the camera the input is attached to.
  96960. */
  96961. camera: FreeCamera;
  96962. /**
  96963. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96964. */
  96965. keysUp: number[];
  96966. /**
  96967. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96968. */
  96969. keysUpward: number[];
  96970. /**
  96971. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96972. */
  96973. keysDown: number[];
  96974. /**
  96975. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96976. */
  96977. keysDownward: number[];
  96978. /**
  96979. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96980. */
  96981. keysLeft: number[];
  96982. /**
  96983. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96984. */
  96985. keysRight: number[];
  96986. private _keys;
  96987. private _onCanvasBlurObserver;
  96988. private _onKeyboardObserver;
  96989. private _engine;
  96990. private _scene;
  96991. /**
  96992. * Attach the input controls to a specific dom element to get the input from.
  96993. * @param element Defines the element the controls should be listened from
  96994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96995. */
  96996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96997. /**
  96998. * Detach the current controls from the specified dom element.
  96999. * @param element Defines the element to stop listening the inputs from
  97000. */
  97001. detachControl(element: Nullable<HTMLElement>): void;
  97002. /**
  97003. * Update the current camera state depending on the inputs that have been used this frame.
  97004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97005. */
  97006. checkInputs(): void;
  97007. /**
  97008. * Gets the class name of the current intput.
  97009. * @returns the class name
  97010. */
  97011. getClassName(): string;
  97012. /** @hidden */
  97013. _onLostFocus(): void;
  97014. /**
  97015. * Get the friendly name associated with the input class.
  97016. * @returns the input friendly name
  97017. */
  97018. getSimpleName(): string;
  97019. }
  97020. }
  97021. declare module BABYLON {
  97022. /**
  97023. * Gather the list of pointer event types as constants.
  97024. */
  97025. export class PointerEventTypes {
  97026. /**
  97027. * 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.
  97028. */
  97029. static readonly POINTERDOWN: number;
  97030. /**
  97031. * The pointerup event is fired when a pointer is no longer active.
  97032. */
  97033. static readonly POINTERUP: number;
  97034. /**
  97035. * The pointermove event is fired when a pointer changes coordinates.
  97036. */
  97037. static readonly POINTERMOVE: number;
  97038. /**
  97039. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97040. */
  97041. static readonly POINTERWHEEL: number;
  97042. /**
  97043. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97044. */
  97045. static readonly POINTERPICK: number;
  97046. /**
  97047. * The pointertap event is fired when a the object has been touched and released without drag.
  97048. */
  97049. static readonly POINTERTAP: number;
  97050. /**
  97051. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97052. */
  97053. static readonly POINTERDOUBLETAP: number;
  97054. }
  97055. /**
  97056. * Base class of pointer info types.
  97057. */
  97058. export class PointerInfoBase {
  97059. /**
  97060. * Defines the type of event (PointerEventTypes)
  97061. */
  97062. type: number;
  97063. /**
  97064. * Defines the related dom event
  97065. */
  97066. event: PointerEvent | MouseWheelEvent;
  97067. /**
  97068. * Instantiates the base class of pointers info.
  97069. * @param type Defines the type of event (PointerEventTypes)
  97070. * @param event Defines the related dom event
  97071. */
  97072. constructor(
  97073. /**
  97074. * Defines the type of event (PointerEventTypes)
  97075. */
  97076. type: number,
  97077. /**
  97078. * Defines the related dom event
  97079. */
  97080. event: PointerEvent | MouseWheelEvent);
  97081. }
  97082. /**
  97083. * This class is used to store pointer related info for the onPrePointerObservable event.
  97084. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97085. */
  97086. export class PointerInfoPre extends PointerInfoBase {
  97087. /**
  97088. * Ray from a pointer if availible (eg. 6dof controller)
  97089. */
  97090. ray: Nullable<Ray>;
  97091. /**
  97092. * Defines the local position of the pointer on the canvas.
  97093. */
  97094. localPosition: Vector2;
  97095. /**
  97096. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97097. */
  97098. skipOnPointerObservable: boolean;
  97099. /**
  97100. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97101. * @param type Defines the type of event (PointerEventTypes)
  97102. * @param event Defines the related dom event
  97103. * @param localX Defines the local x coordinates of the pointer when the event occured
  97104. * @param localY Defines the local y coordinates of the pointer when the event occured
  97105. */
  97106. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97107. }
  97108. /**
  97109. * This type contains all the data related to a pointer event in Babylon.js.
  97110. * 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.
  97111. */
  97112. export class PointerInfo extends PointerInfoBase {
  97113. /**
  97114. * Defines the picking info associated to the info (if any)\
  97115. */
  97116. pickInfo: Nullable<PickingInfo>;
  97117. /**
  97118. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97119. * @param type Defines the type of event (PointerEventTypes)
  97120. * @param event Defines the related dom event
  97121. * @param pickInfo Defines the picking info associated to the info (if any)\
  97122. */
  97123. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97124. /**
  97125. * Defines the picking info associated to the info (if any)\
  97126. */
  97127. pickInfo: Nullable<PickingInfo>);
  97128. }
  97129. /**
  97130. * Data relating to a touch event on the screen.
  97131. */
  97132. export interface PointerTouch {
  97133. /**
  97134. * X coordinate of touch.
  97135. */
  97136. x: number;
  97137. /**
  97138. * Y coordinate of touch.
  97139. */
  97140. y: number;
  97141. /**
  97142. * Id of touch. Unique for each finger.
  97143. */
  97144. pointerId: number;
  97145. /**
  97146. * Event type passed from DOM.
  97147. */
  97148. type: any;
  97149. }
  97150. }
  97151. declare module BABYLON {
  97152. /**
  97153. * Manage the mouse inputs to control the movement of a free camera.
  97154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97155. */
  97156. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97157. /**
  97158. * Define if touch is enabled in the mouse input
  97159. */
  97160. touchEnabled: boolean;
  97161. /**
  97162. * Defines the camera the input is attached to.
  97163. */
  97164. camera: FreeCamera;
  97165. /**
  97166. * Defines the buttons associated with the input to handle camera move.
  97167. */
  97168. buttons: number[];
  97169. /**
  97170. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97171. */
  97172. angularSensibility: number;
  97173. private _pointerInput;
  97174. private _onMouseMove;
  97175. private _observer;
  97176. private previousPosition;
  97177. /**
  97178. * Observable for when a pointer move event occurs containing the move offset
  97179. */
  97180. onPointerMovedObservable: Observable<{
  97181. offsetX: number;
  97182. offsetY: number;
  97183. }>;
  97184. /**
  97185. * @hidden
  97186. * If the camera should be rotated automatically based on pointer movement
  97187. */
  97188. _allowCameraRotation: boolean;
  97189. /**
  97190. * Manage the mouse inputs to control the movement of a free camera.
  97191. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97192. * @param touchEnabled Defines if touch is enabled or not
  97193. */
  97194. constructor(
  97195. /**
  97196. * Define if touch is enabled in the mouse input
  97197. */
  97198. touchEnabled?: boolean);
  97199. /**
  97200. * Attach the input controls to a specific dom element to get the input from.
  97201. * @param element Defines the element the controls should be listened from
  97202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97203. */
  97204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97205. /**
  97206. * Called on JS contextmenu event.
  97207. * Override this method to provide functionality.
  97208. */
  97209. protected onContextMenu(evt: PointerEvent): void;
  97210. /**
  97211. * Detach the current controls from the specified dom element.
  97212. * @param element Defines the element to stop listening the inputs from
  97213. */
  97214. detachControl(element: Nullable<HTMLElement>): void;
  97215. /**
  97216. * Gets the class name of the current intput.
  97217. * @returns the class name
  97218. */
  97219. getClassName(): string;
  97220. /**
  97221. * Get the friendly name associated with the input class.
  97222. * @returns the input friendly name
  97223. */
  97224. getSimpleName(): string;
  97225. }
  97226. }
  97227. declare module BABYLON {
  97228. /**
  97229. * Manage the touch inputs to control the movement of a free camera.
  97230. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97231. */
  97232. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97233. /**
  97234. * Defines the camera the input is attached to.
  97235. */
  97236. camera: FreeCamera;
  97237. /**
  97238. * Defines the touch sensibility for rotation.
  97239. * The higher the faster.
  97240. */
  97241. touchAngularSensibility: number;
  97242. /**
  97243. * Defines the touch sensibility for move.
  97244. * The higher the faster.
  97245. */
  97246. touchMoveSensibility: number;
  97247. private _offsetX;
  97248. private _offsetY;
  97249. private _pointerPressed;
  97250. private _pointerInput;
  97251. private _observer;
  97252. private _onLostFocus;
  97253. /**
  97254. * Attach the input controls to a specific dom element to get the input from.
  97255. * @param element Defines the element the controls should be listened from
  97256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97257. */
  97258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97259. /**
  97260. * Detach the current controls from the specified dom element.
  97261. * @param element Defines the element to stop listening the inputs from
  97262. */
  97263. detachControl(element: Nullable<HTMLElement>): void;
  97264. /**
  97265. * Update the current camera state depending on the inputs that have been used this frame.
  97266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97267. */
  97268. checkInputs(): void;
  97269. /**
  97270. * Gets the class name of the current intput.
  97271. * @returns the class name
  97272. */
  97273. getClassName(): string;
  97274. /**
  97275. * Get the friendly name associated with the input class.
  97276. * @returns the input friendly name
  97277. */
  97278. getSimpleName(): string;
  97279. }
  97280. }
  97281. declare module BABYLON {
  97282. /**
  97283. * Default Inputs manager for the FreeCamera.
  97284. * It groups all the default supported inputs for ease of use.
  97285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97286. */
  97287. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97288. /**
  97289. * @hidden
  97290. */
  97291. _mouseInput: Nullable<FreeCameraMouseInput>;
  97292. /**
  97293. * Instantiates a new FreeCameraInputsManager.
  97294. * @param camera Defines the camera the inputs belong to
  97295. */
  97296. constructor(camera: FreeCamera);
  97297. /**
  97298. * Add keyboard input support to the input manager.
  97299. * @returns the current input manager
  97300. */
  97301. addKeyboard(): FreeCameraInputsManager;
  97302. /**
  97303. * Add mouse input support to the input manager.
  97304. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97305. * @returns the current input manager
  97306. */
  97307. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97308. /**
  97309. * Removes the mouse input support from the manager
  97310. * @returns the current input manager
  97311. */
  97312. removeMouse(): FreeCameraInputsManager;
  97313. /**
  97314. * Add touch input support to the input manager.
  97315. * @returns the current input manager
  97316. */
  97317. addTouch(): FreeCameraInputsManager;
  97318. /**
  97319. * Remove all attached input methods from a camera
  97320. */
  97321. clear(): void;
  97322. }
  97323. }
  97324. declare module BABYLON {
  97325. /**
  97326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97327. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97328. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97329. */
  97330. export class FreeCamera extends TargetCamera {
  97331. /**
  97332. * Define the collision ellipsoid of the camera.
  97333. * This is helpful to simulate a camera body like the player body around the camera
  97334. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97335. */
  97336. ellipsoid: Vector3;
  97337. /**
  97338. * Define an offset for the position of the ellipsoid around the camera.
  97339. * This can be helpful to determine the center of the body near the gravity center of the body
  97340. * instead of its head.
  97341. */
  97342. ellipsoidOffset: Vector3;
  97343. /**
  97344. * Enable or disable collisions of the camera with the rest of the scene objects.
  97345. */
  97346. checkCollisions: boolean;
  97347. /**
  97348. * Enable or disable gravity on the camera.
  97349. */
  97350. applyGravity: boolean;
  97351. /**
  97352. * Define the input manager associated to the camera.
  97353. */
  97354. inputs: FreeCameraInputsManager;
  97355. /**
  97356. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97357. * Higher values reduce sensitivity.
  97358. */
  97359. get angularSensibility(): number;
  97360. /**
  97361. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97362. * Higher values reduce sensitivity.
  97363. */
  97364. set angularSensibility(value: number);
  97365. /**
  97366. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97367. */
  97368. get keysUp(): number[];
  97369. set keysUp(value: number[]);
  97370. /**
  97371. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97372. */
  97373. get keysUpward(): number[];
  97374. set keysUpward(value: number[]);
  97375. /**
  97376. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97377. */
  97378. get keysDown(): number[];
  97379. set keysDown(value: number[]);
  97380. /**
  97381. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97382. */
  97383. get keysDownward(): number[];
  97384. set keysDownward(value: number[]);
  97385. /**
  97386. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97387. */
  97388. get keysLeft(): number[];
  97389. set keysLeft(value: number[]);
  97390. /**
  97391. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97392. */
  97393. get keysRight(): number[];
  97394. set keysRight(value: number[]);
  97395. /**
  97396. * Event raised when the camera collide with a mesh in the scene.
  97397. */
  97398. onCollide: (collidedMesh: AbstractMesh) => void;
  97399. private _collider;
  97400. private _needMoveForGravity;
  97401. private _oldPosition;
  97402. private _diffPosition;
  97403. private _newPosition;
  97404. /** @hidden */
  97405. _localDirection: Vector3;
  97406. /** @hidden */
  97407. _transformedDirection: Vector3;
  97408. /**
  97409. * Instantiates a Free Camera.
  97410. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97411. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97412. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97413. * @param name Define the name of the camera in the scene
  97414. * @param position Define the start position of the camera in the scene
  97415. * @param scene Define the scene the camera belongs to
  97416. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97417. */
  97418. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97419. /**
  97420. * Attached controls to the current camera.
  97421. * @param element Defines the element the controls should be listened from
  97422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97423. */
  97424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97425. /**
  97426. * Detach the current controls from the camera.
  97427. * The camera will stop reacting to inputs.
  97428. * @param element Defines the element to stop listening the inputs from
  97429. */
  97430. detachControl(element: HTMLElement): void;
  97431. private _collisionMask;
  97432. /**
  97433. * Define a collision mask to limit the list of object the camera can collide with
  97434. */
  97435. get collisionMask(): number;
  97436. set collisionMask(mask: number);
  97437. /** @hidden */
  97438. _collideWithWorld(displacement: Vector3): void;
  97439. private _onCollisionPositionChange;
  97440. /** @hidden */
  97441. _checkInputs(): void;
  97442. /** @hidden */
  97443. _decideIfNeedsToMove(): boolean;
  97444. /** @hidden */
  97445. _updatePosition(): void;
  97446. /**
  97447. * Destroy the camera and release the current resources hold by it.
  97448. */
  97449. dispose(): void;
  97450. /**
  97451. * Gets the current object class name.
  97452. * @return the class name
  97453. */
  97454. getClassName(): string;
  97455. }
  97456. }
  97457. declare module BABYLON {
  97458. /**
  97459. * Represents a gamepad control stick position
  97460. */
  97461. export class StickValues {
  97462. /**
  97463. * The x component of the control stick
  97464. */
  97465. x: number;
  97466. /**
  97467. * The y component of the control stick
  97468. */
  97469. y: number;
  97470. /**
  97471. * Initializes the gamepad x and y control stick values
  97472. * @param x The x component of the gamepad control stick value
  97473. * @param y The y component of the gamepad control stick value
  97474. */
  97475. constructor(
  97476. /**
  97477. * The x component of the control stick
  97478. */
  97479. x: number,
  97480. /**
  97481. * The y component of the control stick
  97482. */
  97483. y: number);
  97484. }
  97485. /**
  97486. * An interface which manages callbacks for gamepad button changes
  97487. */
  97488. export interface GamepadButtonChanges {
  97489. /**
  97490. * Called when a gamepad has been changed
  97491. */
  97492. changed: boolean;
  97493. /**
  97494. * Called when a gamepad press event has been triggered
  97495. */
  97496. pressChanged: boolean;
  97497. /**
  97498. * Called when a touch event has been triggered
  97499. */
  97500. touchChanged: boolean;
  97501. /**
  97502. * Called when a value has changed
  97503. */
  97504. valueChanged: boolean;
  97505. }
  97506. /**
  97507. * Represents a gamepad
  97508. */
  97509. export class Gamepad {
  97510. /**
  97511. * The id of the gamepad
  97512. */
  97513. id: string;
  97514. /**
  97515. * The index of the gamepad
  97516. */
  97517. index: number;
  97518. /**
  97519. * The browser gamepad
  97520. */
  97521. browserGamepad: any;
  97522. /**
  97523. * Specifies what type of gamepad this represents
  97524. */
  97525. type: number;
  97526. private _leftStick;
  97527. private _rightStick;
  97528. /** @hidden */
  97529. _isConnected: boolean;
  97530. private _leftStickAxisX;
  97531. private _leftStickAxisY;
  97532. private _rightStickAxisX;
  97533. private _rightStickAxisY;
  97534. /**
  97535. * Triggered when the left control stick has been changed
  97536. */
  97537. private _onleftstickchanged;
  97538. /**
  97539. * Triggered when the right control stick has been changed
  97540. */
  97541. private _onrightstickchanged;
  97542. /**
  97543. * Represents a gamepad controller
  97544. */
  97545. static GAMEPAD: number;
  97546. /**
  97547. * Represents a generic controller
  97548. */
  97549. static GENERIC: number;
  97550. /**
  97551. * Represents an XBox controller
  97552. */
  97553. static XBOX: number;
  97554. /**
  97555. * Represents a pose-enabled controller
  97556. */
  97557. static POSE_ENABLED: number;
  97558. /**
  97559. * Represents an Dual Shock controller
  97560. */
  97561. static DUALSHOCK: number;
  97562. /**
  97563. * Specifies whether the left control stick should be Y-inverted
  97564. */
  97565. protected _invertLeftStickY: boolean;
  97566. /**
  97567. * Specifies if the gamepad has been connected
  97568. */
  97569. get isConnected(): boolean;
  97570. /**
  97571. * Initializes the gamepad
  97572. * @param id The id of the gamepad
  97573. * @param index The index of the gamepad
  97574. * @param browserGamepad The browser gamepad
  97575. * @param leftStickX The x component of the left joystick
  97576. * @param leftStickY The y component of the left joystick
  97577. * @param rightStickX The x component of the right joystick
  97578. * @param rightStickY The y component of the right joystick
  97579. */
  97580. constructor(
  97581. /**
  97582. * The id of the gamepad
  97583. */
  97584. id: string,
  97585. /**
  97586. * The index of the gamepad
  97587. */
  97588. index: number,
  97589. /**
  97590. * The browser gamepad
  97591. */
  97592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97593. /**
  97594. * Callback triggered when the left joystick has changed
  97595. * @param callback
  97596. */
  97597. onleftstickchanged(callback: (values: StickValues) => void): void;
  97598. /**
  97599. * Callback triggered when the right joystick has changed
  97600. * @param callback
  97601. */
  97602. onrightstickchanged(callback: (values: StickValues) => void): void;
  97603. /**
  97604. * Gets the left joystick
  97605. */
  97606. get leftStick(): StickValues;
  97607. /**
  97608. * Sets the left joystick values
  97609. */
  97610. set leftStick(newValues: StickValues);
  97611. /**
  97612. * Gets the right joystick
  97613. */
  97614. get rightStick(): StickValues;
  97615. /**
  97616. * Sets the right joystick value
  97617. */
  97618. set rightStick(newValues: StickValues);
  97619. /**
  97620. * Updates the gamepad joystick positions
  97621. */
  97622. update(): void;
  97623. /**
  97624. * Disposes the gamepad
  97625. */
  97626. dispose(): void;
  97627. }
  97628. /**
  97629. * Represents a generic gamepad
  97630. */
  97631. export class GenericPad extends Gamepad {
  97632. private _buttons;
  97633. private _onbuttondown;
  97634. private _onbuttonup;
  97635. /**
  97636. * Observable triggered when a button has been pressed
  97637. */
  97638. onButtonDownObservable: Observable<number>;
  97639. /**
  97640. * Observable triggered when a button has been released
  97641. */
  97642. onButtonUpObservable: Observable<number>;
  97643. /**
  97644. * Callback triggered when a button has been pressed
  97645. * @param callback Called when a button has been pressed
  97646. */
  97647. onbuttondown(callback: (buttonPressed: number) => void): void;
  97648. /**
  97649. * Callback triggered when a button has been released
  97650. * @param callback Called when a button has been released
  97651. */
  97652. onbuttonup(callback: (buttonReleased: number) => void): void;
  97653. /**
  97654. * Initializes the generic gamepad
  97655. * @param id The id of the generic gamepad
  97656. * @param index The index of the generic gamepad
  97657. * @param browserGamepad The browser gamepad
  97658. */
  97659. constructor(id: string, index: number, browserGamepad: any);
  97660. private _setButtonValue;
  97661. /**
  97662. * Updates the generic gamepad
  97663. */
  97664. update(): void;
  97665. /**
  97666. * Disposes the generic gamepad
  97667. */
  97668. dispose(): void;
  97669. }
  97670. }
  97671. declare module BABYLON {
  97672. /**
  97673. * Defines the types of pose enabled controllers that are supported
  97674. */
  97675. export enum PoseEnabledControllerType {
  97676. /**
  97677. * HTC Vive
  97678. */
  97679. VIVE = 0,
  97680. /**
  97681. * Oculus Rift
  97682. */
  97683. OCULUS = 1,
  97684. /**
  97685. * Windows mixed reality
  97686. */
  97687. WINDOWS = 2,
  97688. /**
  97689. * Samsung gear VR
  97690. */
  97691. GEAR_VR = 3,
  97692. /**
  97693. * Google Daydream
  97694. */
  97695. DAYDREAM = 4,
  97696. /**
  97697. * Generic
  97698. */
  97699. GENERIC = 5
  97700. }
  97701. /**
  97702. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97703. */
  97704. export interface MutableGamepadButton {
  97705. /**
  97706. * Value of the button/trigger
  97707. */
  97708. value: number;
  97709. /**
  97710. * If the button/trigger is currently touched
  97711. */
  97712. touched: boolean;
  97713. /**
  97714. * If the button/trigger is currently pressed
  97715. */
  97716. pressed: boolean;
  97717. }
  97718. /**
  97719. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97720. * @hidden
  97721. */
  97722. export interface ExtendedGamepadButton extends GamepadButton {
  97723. /**
  97724. * If the button/trigger is currently pressed
  97725. */
  97726. readonly pressed: boolean;
  97727. /**
  97728. * If the button/trigger is currently touched
  97729. */
  97730. readonly touched: boolean;
  97731. /**
  97732. * Value of the button/trigger
  97733. */
  97734. readonly value: number;
  97735. }
  97736. /** @hidden */
  97737. export interface _GamePadFactory {
  97738. /**
  97739. * Returns whether or not the current gamepad can be created for this type of controller.
  97740. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97741. * @returns true if it can be created, otherwise false
  97742. */
  97743. canCreate(gamepadInfo: any): boolean;
  97744. /**
  97745. * Creates a new instance of the Gamepad.
  97746. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97747. * @returns the new gamepad instance
  97748. */
  97749. create(gamepadInfo: any): Gamepad;
  97750. }
  97751. /**
  97752. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97753. */
  97754. export class PoseEnabledControllerHelper {
  97755. /** @hidden */
  97756. static _ControllerFactories: _GamePadFactory[];
  97757. /** @hidden */
  97758. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97759. /**
  97760. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97761. * @param vrGamepad the gamepad to initialized
  97762. * @returns a vr controller of the type the gamepad identified as
  97763. */
  97764. static InitiateController(vrGamepad: any): Gamepad;
  97765. }
  97766. /**
  97767. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97768. */
  97769. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97770. /**
  97771. * If the controller is used in a webXR session
  97772. */
  97773. isXR: boolean;
  97774. private _deviceRoomPosition;
  97775. private _deviceRoomRotationQuaternion;
  97776. /**
  97777. * The device position in babylon space
  97778. */
  97779. devicePosition: Vector3;
  97780. /**
  97781. * The device rotation in babylon space
  97782. */
  97783. deviceRotationQuaternion: Quaternion;
  97784. /**
  97785. * The scale factor of the device in babylon space
  97786. */
  97787. deviceScaleFactor: number;
  97788. /**
  97789. * (Likely devicePosition should be used instead) The device position in its room space
  97790. */
  97791. position: Vector3;
  97792. /**
  97793. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97794. */
  97795. rotationQuaternion: Quaternion;
  97796. /**
  97797. * The type of controller (Eg. Windows mixed reality)
  97798. */
  97799. controllerType: PoseEnabledControllerType;
  97800. protected _calculatedPosition: Vector3;
  97801. private _calculatedRotation;
  97802. /**
  97803. * The raw pose from the device
  97804. */
  97805. rawPose: DevicePose;
  97806. private _trackPosition;
  97807. private _maxRotationDistFromHeadset;
  97808. private _draggedRoomRotation;
  97809. /**
  97810. * @hidden
  97811. */
  97812. _disableTrackPosition(fixedPosition: Vector3): void;
  97813. /**
  97814. * Internal, the mesh attached to the controller
  97815. * @hidden
  97816. */
  97817. _mesh: Nullable<AbstractMesh>;
  97818. private _poseControlledCamera;
  97819. private _leftHandSystemQuaternion;
  97820. /**
  97821. * Internal, matrix used to convert room space to babylon space
  97822. * @hidden
  97823. */
  97824. _deviceToWorld: Matrix;
  97825. /**
  97826. * Node to be used when casting a ray from the controller
  97827. * @hidden
  97828. */
  97829. _pointingPoseNode: Nullable<TransformNode>;
  97830. /**
  97831. * Name of the child mesh that can be used to cast a ray from the controller
  97832. */
  97833. static readonly POINTING_POSE: string;
  97834. /**
  97835. * Creates a new PoseEnabledController from a gamepad
  97836. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97837. */
  97838. constructor(browserGamepad: any);
  97839. private _workingMatrix;
  97840. /**
  97841. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97842. */
  97843. update(): void;
  97844. /**
  97845. * Updates only the pose device and mesh without doing any button event checking
  97846. */
  97847. protected _updatePoseAndMesh(): void;
  97848. /**
  97849. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97850. * @param poseData raw pose fromthe device
  97851. */
  97852. updateFromDevice(poseData: DevicePose): void;
  97853. /**
  97854. * @hidden
  97855. */
  97856. _meshAttachedObservable: Observable<AbstractMesh>;
  97857. /**
  97858. * Attaches a mesh to the controller
  97859. * @param mesh the mesh to be attached
  97860. */
  97861. attachToMesh(mesh: AbstractMesh): void;
  97862. /**
  97863. * Attaches the controllers mesh to a camera
  97864. * @param camera the camera the mesh should be attached to
  97865. */
  97866. attachToPoseControlledCamera(camera: TargetCamera): void;
  97867. /**
  97868. * Disposes of the controller
  97869. */
  97870. dispose(): void;
  97871. /**
  97872. * The mesh that is attached to the controller
  97873. */
  97874. get mesh(): Nullable<AbstractMesh>;
  97875. /**
  97876. * Gets the ray of the controller in the direction the controller is pointing
  97877. * @param length the length the resulting ray should be
  97878. * @returns a ray in the direction the controller is pointing
  97879. */
  97880. getForwardRay(length?: number): Ray;
  97881. }
  97882. }
  97883. declare module BABYLON {
  97884. /**
  97885. * Defines the WebVRController object that represents controllers tracked in 3D space
  97886. */
  97887. export abstract class WebVRController extends PoseEnabledController {
  97888. /**
  97889. * Internal, the default controller model for the controller
  97890. */
  97891. protected _defaultModel: Nullable<AbstractMesh>;
  97892. /**
  97893. * Fired when the trigger state has changed
  97894. */
  97895. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97896. /**
  97897. * Fired when the main button state has changed
  97898. */
  97899. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97900. /**
  97901. * Fired when the secondary button state has changed
  97902. */
  97903. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97904. /**
  97905. * Fired when the pad state has changed
  97906. */
  97907. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97908. /**
  97909. * Fired when controllers stick values have changed
  97910. */
  97911. onPadValuesChangedObservable: Observable<StickValues>;
  97912. /**
  97913. * Array of button availible on the controller
  97914. */
  97915. protected _buttons: Array<MutableGamepadButton>;
  97916. private _onButtonStateChange;
  97917. /**
  97918. * Fired when a controller button's state has changed
  97919. * @param callback the callback containing the button that was modified
  97920. */
  97921. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97922. /**
  97923. * X and Y axis corresponding to the controllers joystick
  97924. */
  97925. pad: StickValues;
  97926. /**
  97927. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97928. */
  97929. hand: string;
  97930. /**
  97931. * The default controller model for the controller
  97932. */
  97933. get defaultModel(): Nullable<AbstractMesh>;
  97934. /**
  97935. * Creates a new WebVRController from a gamepad
  97936. * @param vrGamepad the gamepad that the WebVRController should be created from
  97937. */
  97938. constructor(vrGamepad: any);
  97939. /**
  97940. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97941. */
  97942. update(): void;
  97943. /**
  97944. * Function to be called when a button is modified
  97945. */
  97946. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97947. /**
  97948. * Loads a mesh and attaches it to the controller
  97949. * @param scene the scene the mesh should be added to
  97950. * @param meshLoaded callback for when the mesh has been loaded
  97951. */
  97952. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97953. private _setButtonValue;
  97954. private _changes;
  97955. private _checkChanges;
  97956. /**
  97957. * Disposes of th webVRCOntroller
  97958. */
  97959. dispose(): void;
  97960. }
  97961. }
  97962. declare module BABYLON {
  97963. /**
  97964. * The HemisphericLight simulates the ambient environment light,
  97965. * so the passed direction is the light reflection direction, not the incoming direction.
  97966. */
  97967. export class HemisphericLight extends Light {
  97968. /**
  97969. * The groundColor is the light in the opposite direction to the one specified during creation.
  97970. * 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.
  97971. */
  97972. groundColor: Color3;
  97973. /**
  97974. * The light reflection direction, not the incoming direction.
  97975. */
  97976. direction: Vector3;
  97977. /**
  97978. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97979. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97980. * The HemisphericLight can't cast shadows.
  97981. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97982. * @param name The friendly name of the light
  97983. * @param direction The direction of the light reflection
  97984. * @param scene The scene the light belongs to
  97985. */
  97986. constructor(name: string, direction: Vector3, scene: Scene);
  97987. protected _buildUniformLayout(): void;
  97988. /**
  97989. * Returns the string "HemisphericLight".
  97990. * @return The class name
  97991. */
  97992. getClassName(): string;
  97993. /**
  97994. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97995. * Returns the updated direction.
  97996. * @param target The target the direction should point to
  97997. * @return The computed direction
  97998. */
  97999. setDirectionToTarget(target: Vector3): Vector3;
  98000. /**
  98001. * Returns the shadow generator associated to the light.
  98002. * @returns Always null for hemispheric lights because it does not support shadows.
  98003. */
  98004. getShadowGenerator(): Nullable<IShadowGenerator>;
  98005. /**
  98006. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98007. * @param effect The effect to update
  98008. * @param lightIndex The index of the light in the effect to update
  98009. * @returns The hemispheric light
  98010. */
  98011. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98012. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98013. /**
  98014. * Computes the world matrix of the node
  98015. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98016. * @param useWasUpdatedFlag defines a reserved property
  98017. * @returns the world matrix
  98018. */
  98019. computeWorldMatrix(): Matrix;
  98020. /**
  98021. * Returns the integer 3.
  98022. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98023. */
  98024. getTypeID(): number;
  98025. /**
  98026. * Prepares the list of defines specific to the light type.
  98027. * @param defines the list of defines
  98028. * @param lightIndex defines the index of the light for the effect
  98029. */
  98030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98031. }
  98032. }
  98033. declare module BABYLON {
  98034. /** @hidden */
  98035. export var vrMultiviewToSingleviewPixelShader: {
  98036. name: string;
  98037. shader: string;
  98038. };
  98039. }
  98040. declare module BABYLON {
  98041. /**
  98042. * Renders to multiple views with a single draw call
  98043. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98044. */
  98045. export class MultiviewRenderTarget extends RenderTargetTexture {
  98046. /**
  98047. * Creates a multiview render target
  98048. * @param scene scene used with the render target
  98049. * @param size the size of the render target (used for each view)
  98050. */
  98051. constructor(scene: Scene, size?: number | {
  98052. width: number;
  98053. height: number;
  98054. } | {
  98055. ratio: number;
  98056. });
  98057. /**
  98058. * @hidden
  98059. * @param faceIndex the face index, if its a cube texture
  98060. */
  98061. _bindFrameBuffer(faceIndex?: number): void;
  98062. /**
  98063. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98064. * @returns the view count
  98065. */
  98066. getViewCount(): number;
  98067. }
  98068. }
  98069. declare module BABYLON {
  98070. interface Engine {
  98071. /**
  98072. * Creates a new multiview render target
  98073. * @param width defines the width of the texture
  98074. * @param height defines the height of the texture
  98075. * @returns the created multiview texture
  98076. */
  98077. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98078. /**
  98079. * Binds a multiview framebuffer to be drawn to
  98080. * @param multiviewTexture texture to bind
  98081. */
  98082. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98083. }
  98084. interface Camera {
  98085. /**
  98086. * @hidden
  98087. * 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)
  98088. */
  98089. _useMultiviewToSingleView: boolean;
  98090. /**
  98091. * @hidden
  98092. * 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)
  98093. */
  98094. _multiviewTexture: Nullable<RenderTargetTexture>;
  98095. /**
  98096. * @hidden
  98097. * ensures the multiview texture of the camera exists and has the specified width/height
  98098. * @param width height to set on the multiview texture
  98099. * @param height width to set on the multiview texture
  98100. */
  98101. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98102. }
  98103. interface Scene {
  98104. /** @hidden */
  98105. _transformMatrixR: Matrix;
  98106. /** @hidden */
  98107. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98108. /** @hidden */
  98109. _createMultiviewUbo(): void;
  98110. /** @hidden */
  98111. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98112. /** @hidden */
  98113. _renderMultiviewToSingleView(camera: Camera): void;
  98114. }
  98115. }
  98116. declare module BABYLON {
  98117. /**
  98118. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98119. * This will not be used for webXR as it supports displaying texture arrays directly
  98120. */
  98121. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98122. /**
  98123. * Initializes a VRMultiviewToSingleview
  98124. * @param name name of the post process
  98125. * @param camera camera to be applied to
  98126. * @param scaleFactor scaling factor to the size of the output texture
  98127. */
  98128. constructor(name: string, camera: Camera, scaleFactor: number);
  98129. }
  98130. }
  98131. declare module BABYLON {
  98132. /**
  98133. * Interface used to define additional presentation attributes
  98134. */
  98135. export interface IVRPresentationAttributes {
  98136. /**
  98137. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98138. */
  98139. highRefreshRate: boolean;
  98140. /**
  98141. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98142. */
  98143. foveationLevel: number;
  98144. }
  98145. interface Engine {
  98146. /** @hidden */
  98147. _vrDisplay: any;
  98148. /** @hidden */
  98149. _vrSupported: boolean;
  98150. /** @hidden */
  98151. _oldSize: Size;
  98152. /** @hidden */
  98153. _oldHardwareScaleFactor: number;
  98154. /** @hidden */
  98155. _vrExclusivePointerMode: boolean;
  98156. /** @hidden */
  98157. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98158. /** @hidden */
  98159. _onVRDisplayPointerRestricted: () => void;
  98160. /** @hidden */
  98161. _onVRDisplayPointerUnrestricted: () => void;
  98162. /** @hidden */
  98163. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98164. /** @hidden */
  98165. _onVrDisplayDisconnect: Nullable<() => void>;
  98166. /** @hidden */
  98167. _onVrDisplayPresentChange: Nullable<() => void>;
  98168. /**
  98169. * Observable signaled when VR display mode changes
  98170. */
  98171. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98172. /**
  98173. * Observable signaled when VR request present is complete
  98174. */
  98175. onVRRequestPresentComplete: Observable<boolean>;
  98176. /**
  98177. * Observable signaled when VR request present starts
  98178. */
  98179. onVRRequestPresentStart: Observable<Engine>;
  98180. /**
  98181. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98182. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98183. */
  98184. isInVRExclusivePointerMode: boolean;
  98185. /**
  98186. * Gets a boolean indicating if a webVR device was detected
  98187. * @returns true if a webVR device was detected
  98188. */
  98189. isVRDevicePresent(): boolean;
  98190. /**
  98191. * Gets the current webVR device
  98192. * @returns the current webVR device (or null)
  98193. */
  98194. getVRDevice(): any;
  98195. /**
  98196. * Initializes a webVR display and starts listening to display change events
  98197. * The onVRDisplayChangedObservable will be notified upon these changes
  98198. * @returns A promise containing a VRDisplay and if vr is supported
  98199. */
  98200. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98201. /** @hidden */
  98202. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98203. /**
  98204. * Gets or sets the presentation attributes used to configure VR rendering
  98205. */
  98206. vrPresentationAttributes?: IVRPresentationAttributes;
  98207. /**
  98208. * Call this function to switch to webVR mode
  98209. * Will do nothing if webVR is not supported or if there is no webVR device
  98210. * @param options the webvr options provided to the camera. mainly used for multiview
  98211. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98212. */
  98213. enableVR(options: WebVROptions): void;
  98214. /** @hidden */
  98215. _onVRFullScreenTriggered(): void;
  98216. }
  98217. }
  98218. declare module BABYLON {
  98219. /**
  98220. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98221. * IMPORTANT!! The data is right-hand data.
  98222. * @export
  98223. * @interface DevicePose
  98224. */
  98225. export interface DevicePose {
  98226. /**
  98227. * The position of the device, values in array are [x,y,z].
  98228. */
  98229. readonly position: Nullable<Float32Array>;
  98230. /**
  98231. * The linearVelocity of the device, values in array are [x,y,z].
  98232. */
  98233. readonly linearVelocity: Nullable<Float32Array>;
  98234. /**
  98235. * The linearAcceleration of the device, values in array are [x,y,z].
  98236. */
  98237. readonly linearAcceleration: Nullable<Float32Array>;
  98238. /**
  98239. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98240. */
  98241. readonly orientation: Nullable<Float32Array>;
  98242. /**
  98243. * The angularVelocity of the device, values in array are [x,y,z].
  98244. */
  98245. readonly angularVelocity: Nullable<Float32Array>;
  98246. /**
  98247. * The angularAcceleration of the device, values in array are [x,y,z].
  98248. */
  98249. readonly angularAcceleration: Nullable<Float32Array>;
  98250. }
  98251. /**
  98252. * Interface representing a pose controlled object in Babylon.
  98253. * A pose controlled object has both regular pose values as well as pose values
  98254. * from an external device such as a VR head mounted display
  98255. */
  98256. export interface PoseControlled {
  98257. /**
  98258. * The position of the object in babylon space.
  98259. */
  98260. position: Vector3;
  98261. /**
  98262. * The rotation quaternion of the object in babylon space.
  98263. */
  98264. rotationQuaternion: Quaternion;
  98265. /**
  98266. * The position of the device in babylon space.
  98267. */
  98268. devicePosition?: Vector3;
  98269. /**
  98270. * The rotation quaternion of the device in babylon space.
  98271. */
  98272. deviceRotationQuaternion: Quaternion;
  98273. /**
  98274. * The raw pose coming from the device.
  98275. */
  98276. rawPose: Nullable<DevicePose>;
  98277. /**
  98278. * The scale of the device to be used when translating from device space to babylon space.
  98279. */
  98280. deviceScaleFactor: number;
  98281. /**
  98282. * Updates the poseControlled values based on the input device pose.
  98283. * @param poseData the pose data to update the object with
  98284. */
  98285. updateFromDevice(poseData: DevicePose): void;
  98286. }
  98287. /**
  98288. * Set of options to customize the webVRCamera
  98289. */
  98290. export interface WebVROptions {
  98291. /**
  98292. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98293. */
  98294. trackPosition?: boolean;
  98295. /**
  98296. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98297. */
  98298. positionScale?: number;
  98299. /**
  98300. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98301. */
  98302. displayName?: string;
  98303. /**
  98304. * Should the native controller meshes be initialized. (default: true)
  98305. */
  98306. controllerMeshes?: boolean;
  98307. /**
  98308. * Creating a default HemiLight only on controllers. (default: true)
  98309. */
  98310. defaultLightingOnControllers?: boolean;
  98311. /**
  98312. * If you don't want to use the default VR button of the helper. (default: false)
  98313. */
  98314. useCustomVRButton?: boolean;
  98315. /**
  98316. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98317. */
  98318. customVRButton?: HTMLButtonElement;
  98319. /**
  98320. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98321. */
  98322. rayLength?: number;
  98323. /**
  98324. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98325. */
  98326. defaultHeight?: number;
  98327. /**
  98328. * If multiview should be used if availible (default: false)
  98329. */
  98330. useMultiview?: boolean;
  98331. }
  98332. /**
  98333. * This represents a WebVR camera.
  98334. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98335. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98336. */
  98337. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98338. private webVROptions;
  98339. /**
  98340. * @hidden
  98341. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98342. */
  98343. _vrDevice: any;
  98344. /**
  98345. * The rawPose of the vrDevice.
  98346. */
  98347. rawPose: Nullable<DevicePose>;
  98348. private _onVREnabled;
  98349. private _specsVersion;
  98350. private _attached;
  98351. private _frameData;
  98352. protected _descendants: Array<Node>;
  98353. private _deviceRoomPosition;
  98354. /** @hidden */
  98355. _deviceRoomRotationQuaternion: Quaternion;
  98356. private _standingMatrix;
  98357. /**
  98358. * Represents device position in babylon space.
  98359. */
  98360. devicePosition: Vector3;
  98361. /**
  98362. * Represents device rotation in babylon space.
  98363. */
  98364. deviceRotationQuaternion: Quaternion;
  98365. /**
  98366. * The scale of the device to be used when translating from device space to babylon space.
  98367. */
  98368. deviceScaleFactor: number;
  98369. private _deviceToWorld;
  98370. private _worldToDevice;
  98371. /**
  98372. * References to the webVR controllers for the vrDevice.
  98373. */
  98374. controllers: Array<WebVRController>;
  98375. /**
  98376. * Emits an event when a controller is attached.
  98377. */
  98378. onControllersAttachedObservable: Observable<WebVRController[]>;
  98379. /**
  98380. * Emits an event when a controller's mesh has been loaded;
  98381. */
  98382. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98383. /**
  98384. * Emits an event when the HMD's pose has been updated.
  98385. */
  98386. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98387. private _poseSet;
  98388. /**
  98389. * If the rig cameras be used as parent instead of this camera.
  98390. */
  98391. rigParenting: boolean;
  98392. private _lightOnControllers;
  98393. private _defaultHeight?;
  98394. /**
  98395. * Instantiates a WebVRFreeCamera.
  98396. * @param name The name of the WebVRFreeCamera
  98397. * @param position The starting anchor position for the camera
  98398. * @param scene The scene the camera belongs to
  98399. * @param webVROptions a set of customizable options for the webVRCamera
  98400. */
  98401. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98402. /**
  98403. * Gets the device distance from the ground in meters.
  98404. * @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.
  98405. */
  98406. deviceDistanceToRoomGround(): number;
  98407. /**
  98408. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98409. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98410. */
  98411. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98412. /**
  98413. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98414. * @returns A promise with a boolean set to if the standing matrix is supported.
  98415. */
  98416. useStandingMatrixAsync(): Promise<boolean>;
  98417. /**
  98418. * Disposes the camera
  98419. */
  98420. dispose(): void;
  98421. /**
  98422. * Gets a vrController by name.
  98423. * @param name The name of the controller to retreive
  98424. * @returns the controller matching the name specified or null if not found
  98425. */
  98426. getControllerByName(name: string): Nullable<WebVRController>;
  98427. private _leftController;
  98428. /**
  98429. * The controller corresponding to the users left hand.
  98430. */
  98431. get leftController(): Nullable<WebVRController>;
  98432. private _rightController;
  98433. /**
  98434. * The controller corresponding to the users right hand.
  98435. */
  98436. get rightController(): Nullable<WebVRController>;
  98437. /**
  98438. * Casts a ray forward from the vrCamera's gaze.
  98439. * @param length Length of the ray (default: 100)
  98440. * @returns the ray corresponding to the gaze
  98441. */
  98442. getForwardRay(length?: number): Ray;
  98443. /**
  98444. * @hidden
  98445. * Updates the camera based on device's frame data
  98446. */
  98447. _checkInputs(): void;
  98448. /**
  98449. * Updates the poseControlled values based on the input device pose.
  98450. * @param poseData Pose coming from the device
  98451. */
  98452. updateFromDevice(poseData: DevicePose): void;
  98453. private _htmlElementAttached;
  98454. private _detachIfAttached;
  98455. /**
  98456. * WebVR's attach control will start broadcasting frames to the device.
  98457. * Note that in certain browsers (chrome for example) this function must be called
  98458. * within a user-interaction callback. Example:
  98459. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98460. *
  98461. * @param element html element to attach the vrDevice to
  98462. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98463. */
  98464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98465. /**
  98466. * Detaches the camera from the html element and disables VR
  98467. *
  98468. * @param element html element to detach from
  98469. */
  98470. detachControl(element: HTMLElement): void;
  98471. /**
  98472. * @returns the name of this class
  98473. */
  98474. getClassName(): string;
  98475. /**
  98476. * Calls resetPose on the vrDisplay
  98477. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98478. */
  98479. resetToCurrentRotation(): void;
  98480. /**
  98481. * @hidden
  98482. * Updates the rig cameras (left and right eye)
  98483. */
  98484. _updateRigCameras(): void;
  98485. private _workingVector;
  98486. private _oneVector;
  98487. private _workingMatrix;
  98488. private updateCacheCalled;
  98489. private _correctPositionIfNotTrackPosition;
  98490. /**
  98491. * @hidden
  98492. * Updates the cached values of the camera
  98493. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98494. */
  98495. _updateCache(ignoreParentClass?: boolean): void;
  98496. /**
  98497. * @hidden
  98498. * Get current device position in babylon world
  98499. */
  98500. _computeDevicePosition(): void;
  98501. /**
  98502. * Updates the current device position and rotation in the babylon world
  98503. */
  98504. update(): void;
  98505. /**
  98506. * @hidden
  98507. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98508. * @returns an identity matrix
  98509. */
  98510. _getViewMatrix(): Matrix;
  98511. private _tmpMatrix;
  98512. /**
  98513. * This function is called by the two RIG cameras.
  98514. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98515. * @hidden
  98516. */
  98517. _getWebVRViewMatrix(): Matrix;
  98518. /** @hidden */
  98519. _getWebVRProjectionMatrix(): Matrix;
  98520. private _onGamepadConnectedObserver;
  98521. private _onGamepadDisconnectedObserver;
  98522. private _updateCacheWhenTrackingDisabledObserver;
  98523. /**
  98524. * Initializes the controllers and their meshes
  98525. */
  98526. initControllers(): void;
  98527. }
  98528. }
  98529. declare module BABYLON {
  98530. /**
  98531. * "Static Class" containing the most commonly used helper while dealing with material for
  98532. * rendering purpose.
  98533. *
  98534. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98535. *
  98536. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98537. */
  98538. export class MaterialHelper {
  98539. /**
  98540. * Bind the current view position to an effect.
  98541. * @param effect The effect to be bound
  98542. * @param scene The scene the eyes position is used from
  98543. * @param variableName name of the shader variable that will hold the eye position
  98544. */
  98545. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98546. /**
  98547. * Helps preparing the defines values about the UVs in used in the effect.
  98548. * UVs are shared as much as we can accross channels in the shaders.
  98549. * @param texture The texture we are preparing the UVs for
  98550. * @param defines The defines to update
  98551. * @param key The channel key "diffuse", "specular"... used in the shader
  98552. */
  98553. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98554. /**
  98555. * Binds a texture matrix value to its corrsponding uniform
  98556. * @param texture The texture to bind the matrix for
  98557. * @param uniformBuffer The uniform buffer receivin the data
  98558. * @param key The channel key "diffuse", "specular"... used in the shader
  98559. */
  98560. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98561. /**
  98562. * Gets the current status of the fog (should it be enabled?)
  98563. * @param mesh defines the mesh to evaluate for fog support
  98564. * @param scene defines the hosting scene
  98565. * @returns true if fog must be enabled
  98566. */
  98567. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98568. /**
  98569. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98570. * @param mesh defines the current mesh
  98571. * @param scene defines the current scene
  98572. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98573. * @param pointsCloud defines if point cloud rendering has to be turned on
  98574. * @param fogEnabled defines if fog has to be turned on
  98575. * @param alphaTest defines if alpha testing has to be turned on
  98576. * @param defines defines the current list of defines
  98577. */
  98578. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98579. /**
  98580. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98581. * @param scene defines the current scene
  98582. * @param engine defines the current engine
  98583. * @param defines specifies the list of active defines
  98584. * @param useInstances defines if instances have to be turned on
  98585. * @param useClipPlane defines if clip plane have to be turned on
  98586. * @param useInstances defines if instances have to be turned on
  98587. * @param useThinInstances defines if thin instances have to be turned on
  98588. */
  98589. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98590. /**
  98591. * Prepares the defines for bones
  98592. * @param mesh The mesh containing the geometry data we will draw
  98593. * @param defines The defines to update
  98594. */
  98595. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98596. /**
  98597. * Prepares the defines for morph targets
  98598. * @param mesh The mesh containing the geometry data we will draw
  98599. * @param defines The defines to update
  98600. */
  98601. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98602. /**
  98603. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98604. * @param mesh The mesh containing the geometry data we will draw
  98605. * @param defines The defines to update
  98606. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98607. * @param useBones Precise whether bones should be used or not (override mesh info)
  98608. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98609. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98610. * @returns false if defines are considered not dirty and have not been checked
  98611. */
  98612. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98613. /**
  98614. * Prepares the defines related to multiview
  98615. * @param scene The scene we are intending to draw
  98616. * @param defines The defines to update
  98617. */
  98618. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98619. /**
  98620. * Prepares the defines related to the prepass
  98621. * @param scene The scene we are intending to draw
  98622. * @param defines The defines to update
  98623. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  98624. */
  98625. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  98626. /**
  98627. * Prepares the defines related to the light information passed in parameter
  98628. * @param scene The scene we are intending to draw
  98629. * @param mesh The mesh the effect is compiling for
  98630. * @param light The light the effect is compiling for
  98631. * @param lightIndex The index of the light
  98632. * @param defines The defines to update
  98633. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98634. * @param state Defines the current state regarding what is needed (normals, etc...)
  98635. */
  98636. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98637. needNormals: boolean;
  98638. needRebuild: boolean;
  98639. shadowEnabled: boolean;
  98640. specularEnabled: boolean;
  98641. lightmapMode: boolean;
  98642. }): void;
  98643. /**
  98644. * Prepares the defines related to the light information passed in parameter
  98645. * @param scene The scene we are intending to draw
  98646. * @param mesh The mesh the effect is compiling for
  98647. * @param defines The defines to update
  98648. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98649. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98650. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98651. * @returns true if normals will be required for the rest of the effect
  98652. */
  98653. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98654. /**
  98655. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98656. * @param lightIndex defines the light index
  98657. * @param uniformsList The uniform list
  98658. * @param samplersList The sampler list
  98659. * @param projectedLightTexture defines if projected texture must be used
  98660. * @param uniformBuffersList defines an optional list of uniform buffers
  98661. */
  98662. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98663. /**
  98664. * Prepares the uniforms and samplers list to be used in the effect
  98665. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98666. * @param samplersList The sampler list
  98667. * @param defines The defines helping in the list generation
  98668. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98669. */
  98670. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98671. /**
  98672. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98673. * @param defines The defines to update while falling back
  98674. * @param fallbacks The authorized effect fallbacks
  98675. * @param maxSimultaneousLights The maximum number of lights allowed
  98676. * @param rank the current rank of the Effect
  98677. * @returns The newly affected rank
  98678. */
  98679. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98680. private static _TmpMorphInfluencers;
  98681. /**
  98682. * Prepares the list of attributes required for morph targets according to the effect defines.
  98683. * @param attribs The current list of supported attribs
  98684. * @param mesh The mesh to prepare the morph targets attributes for
  98685. * @param influencers The number of influencers
  98686. */
  98687. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98688. /**
  98689. * Prepares the list of attributes required for morph targets according to the effect defines.
  98690. * @param attribs The current list of supported attribs
  98691. * @param mesh The mesh to prepare the morph targets attributes for
  98692. * @param defines The current Defines of the effect
  98693. */
  98694. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98695. /**
  98696. * Prepares the list of attributes required for bones according to the effect defines.
  98697. * @param attribs The current list of supported attribs
  98698. * @param mesh The mesh to prepare the bones attributes for
  98699. * @param defines The current Defines of the effect
  98700. * @param fallbacks The current efffect fallback strategy
  98701. */
  98702. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98703. /**
  98704. * Check and prepare the list of attributes required for instances according to the effect defines.
  98705. * @param attribs The current list of supported attribs
  98706. * @param defines The current MaterialDefines of the effect
  98707. */
  98708. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98709. /**
  98710. * Add the list of attributes required for instances to the attribs array.
  98711. * @param attribs The current list of supported attribs
  98712. */
  98713. static PushAttributesForInstances(attribs: string[]): void;
  98714. /**
  98715. * Binds the light information to the effect.
  98716. * @param light The light containing the generator
  98717. * @param effect The effect we are binding the data to
  98718. * @param lightIndex The light index in the effect used to render
  98719. */
  98720. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98721. /**
  98722. * Binds the lights information from the scene to the effect for the given mesh.
  98723. * @param light Light to bind
  98724. * @param lightIndex Light index
  98725. * @param scene The scene where the light belongs to
  98726. * @param effect The effect we are binding the data to
  98727. * @param useSpecular Defines if specular is supported
  98728. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98729. */
  98730. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98731. /**
  98732. * Binds the lights information from the scene to the effect for the given mesh.
  98733. * @param scene The scene the lights belongs to
  98734. * @param mesh The mesh we are binding the information to render
  98735. * @param effect The effect we are binding the data to
  98736. * @param defines The generated defines for the effect
  98737. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98738. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98739. */
  98740. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98741. private static _tempFogColor;
  98742. /**
  98743. * Binds the fog information from the scene to the effect for the given mesh.
  98744. * @param scene The scene the lights belongs to
  98745. * @param mesh The mesh we are binding the information to render
  98746. * @param effect The effect we are binding the data to
  98747. * @param linearSpace Defines if the fog effect is applied in linear space
  98748. */
  98749. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98750. /**
  98751. * Binds the bones information from the mesh to the effect.
  98752. * @param mesh The mesh we are binding the information to render
  98753. * @param effect The effect we are binding the data to
  98754. */
  98755. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98756. /**
  98757. * Binds the morph targets information from the mesh to the effect.
  98758. * @param abstractMesh The mesh we are binding the information to render
  98759. * @param effect The effect we are binding the data to
  98760. */
  98761. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98762. /**
  98763. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98764. * @param defines The generated defines used in the effect
  98765. * @param effect The effect we are binding the data to
  98766. * @param scene The scene we are willing to render with logarithmic scale for
  98767. */
  98768. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98769. /**
  98770. * Binds the clip plane information from the scene to the effect.
  98771. * @param scene The scene the clip plane information are extracted from
  98772. * @param effect The effect we are binding the data to
  98773. */
  98774. static BindClipPlane(effect: Effect, scene: Scene): void;
  98775. }
  98776. }
  98777. declare module BABYLON {
  98778. /**
  98779. * Block used to expose an input value
  98780. */
  98781. export class InputBlock extends NodeMaterialBlock {
  98782. private _mode;
  98783. private _associatedVariableName;
  98784. private _storedValue;
  98785. private _valueCallback;
  98786. private _type;
  98787. private _animationType;
  98788. /** Gets or set a value used to limit the range of float values */
  98789. min: number;
  98790. /** Gets or set a value used to limit the range of float values */
  98791. max: number;
  98792. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98793. isBoolean: boolean;
  98794. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98795. matrixMode: number;
  98796. /** @hidden */
  98797. _systemValue: Nullable<NodeMaterialSystemValues>;
  98798. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98799. visibleInInspector: boolean;
  98800. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98801. isConstant: boolean;
  98802. /** Gets or sets the group to use to display this block in the Inspector */
  98803. groupInInspector: string;
  98804. /** Gets an observable raised when the value is changed */
  98805. onValueChangedObservable: Observable<InputBlock>;
  98806. /**
  98807. * Gets or sets the connection point type (default is float)
  98808. */
  98809. get type(): NodeMaterialBlockConnectionPointTypes;
  98810. /**
  98811. * Creates a new InputBlock
  98812. * @param name defines the block name
  98813. * @param target defines the target of that block (Vertex by default)
  98814. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98815. */
  98816. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98817. /**
  98818. * Validates if a name is a reserve word.
  98819. * @param newName the new name to be given to the node.
  98820. * @returns false if the name is a reserve word, else true.
  98821. */
  98822. validateBlockName(newName: string): boolean;
  98823. /**
  98824. * Gets the output component
  98825. */
  98826. get output(): NodeMaterialConnectionPoint;
  98827. /**
  98828. * Set the source of this connection point to a vertex attribute
  98829. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98830. * @returns the current connection point
  98831. */
  98832. setAsAttribute(attributeName?: string): InputBlock;
  98833. /**
  98834. * Set the source of this connection point to a system value
  98835. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98836. * @returns the current connection point
  98837. */
  98838. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98839. /**
  98840. * Gets or sets the value of that point.
  98841. * Please note that this value will be ignored if valueCallback is defined
  98842. */
  98843. get value(): any;
  98844. set value(value: any);
  98845. /**
  98846. * Gets or sets a callback used to get the value of that point.
  98847. * Please note that setting this value will force the connection point to ignore the value property
  98848. */
  98849. get valueCallback(): () => any;
  98850. set valueCallback(value: () => any);
  98851. /**
  98852. * Gets or sets the associated variable name in the shader
  98853. */
  98854. get associatedVariableName(): string;
  98855. set associatedVariableName(value: string);
  98856. /** Gets or sets the type of animation applied to the input */
  98857. get animationType(): AnimatedInputBlockTypes;
  98858. set animationType(value: AnimatedInputBlockTypes);
  98859. /**
  98860. * Gets a boolean indicating that this connection point not defined yet
  98861. */
  98862. get isUndefined(): boolean;
  98863. /**
  98864. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98865. * In this case the connection point name must be the name of the uniform to use.
  98866. * Can only be set on inputs
  98867. */
  98868. get isUniform(): boolean;
  98869. set isUniform(value: boolean);
  98870. /**
  98871. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98872. * In this case the connection point name must be the name of the attribute to use
  98873. * Can only be set on inputs
  98874. */
  98875. get isAttribute(): boolean;
  98876. set isAttribute(value: boolean);
  98877. /**
  98878. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98879. * Can only be set on exit points
  98880. */
  98881. get isVarying(): boolean;
  98882. set isVarying(value: boolean);
  98883. /**
  98884. * Gets a boolean indicating that the current connection point is a system value
  98885. */
  98886. get isSystemValue(): boolean;
  98887. /**
  98888. * Gets or sets the current well known value or null if not defined as a system value
  98889. */
  98890. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98891. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98892. /**
  98893. * Gets the current class name
  98894. * @returns the class name
  98895. */
  98896. getClassName(): string;
  98897. /**
  98898. * Animate the input if animationType !== None
  98899. * @param scene defines the rendering scene
  98900. */
  98901. animate(scene: Scene): void;
  98902. private _emitDefine;
  98903. initialize(state: NodeMaterialBuildState): void;
  98904. /**
  98905. * Set the input block to its default value (based on its type)
  98906. */
  98907. setDefaultValue(): void;
  98908. private _emitConstant;
  98909. /** @hidden */
  98910. get _noContextSwitch(): boolean;
  98911. private _emit;
  98912. /** @hidden */
  98913. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98914. /** @hidden */
  98915. _transmit(effect: Effect, scene: Scene): void;
  98916. protected _buildBlock(state: NodeMaterialBuildState): void;
  98917. protected _dumpPropertiesCode(): string;
  98918. dispose(): void;
  98919. serialize(): any;
  98920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98921. }
  98922. }
  98923. declare module BABYLON {
  98924. /**
  98925. * Enum used to define the compatibility state between two connection points
  98926. */
  98927. export enum NodeMaterialConnectionPointCompatibilityStates {
  98928. /** Points are compatibles */
  98929. Compatible = 0,
  98930. /** Points are incompatible because of their types */
  98931. TypeIncompatible = 1,
  98932. /** Points are incompatible because of their targets (vertex vs fragment) */
  98933. TargetIncompatible = 2
  98934. }
  98935. /**
  98936. * Defines the direction of a connection point
  98937. */
  98938. export enum NodeMaterialConnectionPointDirection {
  98939. /** Input */
  98940. Input = 0,
  98941. /** Output */
  98942. Output = 1
  98943. }
  98944. /**
  98945. * Defines a connection point for a block
  98946. */
  98947. export class NodeMaterialConnectionPoint {
  98948. /** @hidden */
  98949. _ownerBlock: NodeMaterialBlock;
  98950. /** @hidden */
  98951. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98952. private _endpoints;
  98953. private _associatedVariableName;
  98954. private _direction;
  98955. /** @hidden */
  98956. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98957. /** @hidden */
  98958. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98959. private _type;
  98960. /** @hidden */
  98961. _enforceAssociatedVariableName: boolean;
  98962. /** Gets the direction of the point */
  98963. get direction(): NodeMaterialConnectionPointDirection;
  98964. /** Indicates that this connection point needs dual validation before being connected to another point */
  98965. needDualDirectionValidation: boolean;
  98966. /**
  98967. * Gets or sets the additional types supported by this connection point
  98968. */
  98969. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98970. /**
  98971. * Gets or sets the additional types excluded by this connection point
  98972. */
  98973. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98974. /**
  98975. * Observable triggered when this point is connected
  98976. */
  98977. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98978. /**
  98979. * Gets or sets the associated variable name in the shader
  98980. */
  98981. get associatedVariableName(): string;
  98982. set associatedVariableName(value: string);
  98983. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98984. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98985. /**
  98986. * Gets or sets the connection point type (default is float)
  98987. */
  98988. get type(): NodeMaterialBlockConnectionPointTypes;
  98989. set type(value: NodeMaterialBlockConnectionPointTypes);
  98990. /**
  98991. * Gets or sets the connection point name
  98992. */
  98993. name: string;
  98994. /**
  98995. * Gets or sets the connection point name
  98996. */
  98997. displayName: string;
  98998. /**
  98999. * Gets or sets a boolean indicating that this connection point can be omitted
  99000. */
  99001. isOptional: boolean;
  99002. /**
  99003. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99004. */
  99005. isExposedOnFrame: boolean;
  99006. /**
  99007. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99008. */
  99009. define: string;
  99010. /** @hidden */
  99011. _prioritizeVertex: boolean;
  99012. private _target;
  99013. /** Gets or sets the target of that connection point */
  99014. get target(): NodeMaterialBlockTargets;
  99015. set target(value: NodeMaterialBlockTargets);
  99016. /**
  99017. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99018. */
  99019. get isConnected(): boolean;
  99020. /**
  99021. * Gets a boolean indicating that the current point is connected to an input block
  99022. */
  99023. get isConnectedToInputBlock(): boolean;
  99024. /**
  99025. * Gets a the connected input block (if any)
  99026. */
  99027. get connectInputBlock(): Nullable<InputBlock>;
  99028. /** Get the other side of the connection (if any) */
  99029. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99030. /** Get the block that owns this connection point */
  99031. get ownerBlock(): NodeMaterialBlock;
  99032. /** Get the block connected on the other side of this connection (if any) */
  99033. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99034. /** Get the block connected on the endpoints of this connection (if any) */
  99035. get connectedBlocks(): Array<NodeMaterialBlock>;
  99036. /** Gets the list of connected endpoints */
  99037. get endpoints(): NodeMaterialConnectionPoint[];
  99038. /** Gets a boolean indicating if that output point is connected to at least one input */
  99039. get hasEndpoints(): boolean;
  99040. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99041. get isConnectedInVertexShader(): boolean;
  99042. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99043. get isConnectedInFragmentShader(): boolean;
  99044. /**
  99045. * Creates a block suitable to be used as an input for this input point.
  99046. * If null is returned, a block based on the point type will be created.
  99047. * @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
  99048. */
  99049. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99050. /**
  99051. * Creates a new connection point
  99052. * @param name defines the connection point name
  99053. * @param ownerBlock defines the block hosting this connection point
  99054. * @param direction defines the direction of the connection point
  99055. */
  99056. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99057. /**
  99058. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99059. * @returns the class name
  99060. */
  99061. getClassName(): string;
  99062. /**
  99063. * Gets a boolean indicating if the current point can be connected to another point
  99064. * @param connectionPoint defines the other connection point
  99065. * @returns a boolean
  99066. */
  99067. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99068. /**
  99069. * Gets a number indicating if the current point can be connected to another point
  99070. * @param connectionPoint defines the other connection point
  99071. * @returns a number defining the compatibility state
  99072. */
  99073. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99074. /**
  99075. * Connect this point to another connection point
  99076. * @param connectionPoint defines the other connection point
  99077. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99078. * @returns the current connection point
  99079. */
  99080. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99081. /**
  99082. * Disconnect this point from one of his endpoint
  99083. * @param endpoint defines the other connection point
  99084. * @returns the current connection point
  99085. */
  99086. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99087. /**
  99088. * Serializes this point in a JSON representation
  99089. * @param isInput defines if the connection point is an input (default is true)
  99090. * @returns the serialized point object
  99091. */
  99092. serialize(isInput?: boolean): any;
  99093. /**
  99094. * Release resources
  99095. */
  99096. dispose(): void;
  99097. }
  99098. }
  99099. declare module BABYLON {
  99100. /**
  99101. * Enum used to define the material modes
  99102. */
  99103. export enum NodeMaterialModes {
  99104. /** Regular material */
  99105. Material = 0,
  99106. /** For post process */
  99107. PostProcess = 1,
  99108. /** For particle system */
  99109. Particle = 2
  99110. }
  99111. }
  99112. declare module BABYLON {
  99113. /**
  99114. * Block used to read a texture from a sampler
  99115. */
  99116. export class TextureBlock extends NodeMaterialBlock {
  99117. private _defineName;
  99118. private _linearDefineName;
  99119. private _gammaDefineName;
  99120. private _tempTextureRead;
  99121. private _samplerName;
  99122. private _transformedUVName;
  99123. private _textureTransformName;
  99124. private _textureInfoName;
  99125. private _mainUVName;
  99126. private _mainUVDefineName;
  99127. private _fragmentOnly;
  99128. /**
  99129. * Gets or sets the texture associated with the node
  99130. */
  99131. texture: Nullable<Texture>;
  99132. /**
  99133. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99134. */
  99135. convertToGammaSpace: boolean;
  99136. /**
  99137. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99138. */
  99139. convertToLinearSpace: boolean;
  99140. /**
  99141. * Create a new TextureBlock
  99142. * @param name defines the block name
  99143. */
  99144. constructor(name: string, fragmentOnly?: boolean);
  99145. /**
  99146. * Gets the current class name
  99147. * @returns the class name
  99148. */
  99149. getClassName(): string;
  99150. /**
  99151. * Gets the uv input component
  99152. */
  99153. get uv(): NodeMaterialConnectionPoint;
  99154. /**
  99155. * Gets the rgba output component
  99156. */
  99157. get rgba(): NodeMaterialConnectionPoint;
  99158. /**
  99159. * Gets the rgb output component
  99160. */
  99161. get rgb(): NodeMaterialConnectionPoint;
  99162. /**
  99163. * Gets the r output component
  99164. */
  99165. get r(): NodeMaterialConnectionPoint;
  99166. /**
  99167. * Gets the g output component
  99168. */
  99169. get g(): NodeMaterialConnectionPoint;
  99170. /**
  99171. * Gets the b output component
  99172. */
  99173. get b(): NodeMaterialConnectionPoint;
  99174. /**
  99175. * Gets the a output component
  99176. */
  99177. get a(): NodeMaterialConnectionPoint;
  99178. get target(): NodeMaterialBlockTargets;
  99179. autoConfigure(material: NodeMaterial): void;
  99180. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99182. isReady(): boolean;
  99183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99184. private get _isMixed();
  99185. private _injectVertexCode;
  99186. private _writeTextureRead;
  99187. private _writeOutput;
  99188. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99189. protected _dumpPropertiesCode(): string;
  99190. serialize(): any;
  99191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99192. }
  99193. }
  99194. declare module BABYLON {
  99195. /** @hidden */
  99196. export var reflectionFunction: {
  99197. name: string;
  99198. shader: string;
  99199. };
  99200. }
  99201. declare module BABYLON {
  99202. /**
  99203. * Base block used to read a reflection texture from a sampler
  99204. */
  99205. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99206. /** @hidden */
  99207. _define3DName: string;
  99208. /** @hidden */
  99209. _defineCubicName: string;
  99210. /** @hidden */
  99211. _defineExplicitName: string;
  99212. /** @hidden */
  99213. _defineProjectionName: string;
  99214. /** @hidden */
  99215. _defineLocalCubicName: string;
  99216. /** @hidden */
  99217. _defineSphericalName: string;
  99218. /** @hidden */
  99219. _definePlanarName: string;
  99220. /** @hidden */
  99221. _defineEquirectangularName: string;
  99222. /** @hidden */
  99223. _defineMirroredEquirectangularFixedName: string;
  99224. /** @hidden */
  99225. _defineEquirectangularFixedName: string;
  99226. /** @hidden */
  99227. _defineSkyboxName: string;
  99228. /** @hidden */
  99229. _defineOppositeZ: string;
  99230. /** @hidden */
  99231. _cubeSamplerName: string;
  99232. /** @hidden */
  99233. _2DSamplerName: string;
  99234. protected _positionUVWName: string;
  99235. protected _directionWName: string;
  99236. protected _reflectionVectorName: string;
  99237. /** @hidden */
  99238. _reflectionCoordsName: string;
  99239. /** @hidden */
  99240. _reflectionMatrixName: string;
  99241. protected _reflectionColorName: string;
  99242. /**
  99243. * Gets or sets the texture associated with the node
  99244. */
  99245. texture: Nullable<BaseTexture>;
  99246. /**
  99247. * Create a new ReflectionTextureBaseBlock
  99248. * @param name defines the block name
  99249. */
  99250. constructor(name: string);
  99251. /**
  99252. * Gets the current class name
  99253. * @returns the class name
  99254. */
  99255. getClassName(): string;
  99256. /**
  99257. * Gets the world position input component
  99258. */
  99259. abstract get position(): NodeMaterialConnectionPoint;
  99260. /**
  99261. * Gets the world position input component
  99262. */
  99263. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99264. /**
  99265. * Gets the world normal input component
  99266. */
  99267. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99268. /**
  99269. * Gets the world input component
  99270. */
  99271. abstract get world(): NodeMaterialConnectionPoint;
  99272. /**
  99273. * Gets the camera (or eye) position component
  99274. */
  99275. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99276. /**
  99277. * Gets the view input component
  99278. */
  99279. abstract get view(): NodeMaterialConnectionPoint;
  99280. protected _getTexture(): Nullable<BaseTexture>;
  99281. autoConfigure(material: NodeMaterial): void;
  99282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99283. isReady(): boolean;
  99284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99285. /**
  99286. * Gets the code to inject in the vertex shader
  99287. * @param state current state of the node material building
  99288. * @returns the shader code
  99289. */
  99290. handleVertexSide(state: NodeMaterialBuildState): string;
  99291. /**
  99292. * Handles the inits for the fragment code path
  99293. * @param state node material build state
  99294. */
  99295. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99296. /**
  99297. * Generates the reflection coords code for the fragment code path
  99298. * @param worldNormalVarName name of the world normal variable
  99299. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99300. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99301. * @returns the shader code
  99302. */
  99303. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99304. /**
  99305. * Generates the reflection color code for the fragment code path
  99306. * @param lodVarName name of the lod variable
  99307. * @param swizzleLookupTexture swizzle to use for the final color variable
  99308. * @returns the shader code
  99309. */
  99310. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99311. /**
  99312. * Generates the code corresponding to the connected output points
  99313. * @param state node material build state
  99314. * @param varName name of the variable to output
  99315. * @returns the shader code
  99316. */
  99317. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99318. protected _buildBlock(state: NodeMaterialBuildState): this;
  99319. protected _dumpPropertiesCode(): string;
  99320. serialize(): any;
  99321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99322. }
  99323. }
  99324. declare module BABYLON {
  99325. /**
  99326. * Defines a connection point to be used for points with a custom object type
  99327. */
  99328. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99329. private _blockType;
  99330. private _blockName;
  99331. private _nameForCheking?;
  99332. /**
  99333. * Creates a new connection point
  99334. * @param name defines the connection point name
  99335. * @param ownerBlock defines the block hosting this connection point
  99336. * @param direction defines the direction of the connection point
  99337. */
  99338. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99339. /**
  99340. * Gets a number indicating if the current point can be connected to another point
  99341. * @param connectionPoint defines the other connection point
  99342. * @returns a number defining the compatibility state
  99343. */
  99344. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99345. /**
  99346. * Creates a block suitable to be used as an input for this input point.
  99347. * If null is returned, a block based on the point type will be created.
  99348. * @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
  99349. */
  99350. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99351. }
  99352. }
  99353. declare module BABYLON {
  99354. /**
  99355. * Enum defining the type of properties that can be edited in the property pages in the NME
  99356. */
  99357. export enum PropertyTypeForEdition {
  99358. /** property is a boolean */
  99359. Boolean = 0,
  99360. /** property is a float */
  99361. Float = 1,
  99362. /** property is a Vector2 */
  99363. Vector2 = 2,
  99364. /** property is a list of values */
  99365. List = 3
  99366. }
  99367. /**
  99368. * Interface that defines an option in a variable of type list
  99369. */
  99370. export interface IEditablePropertyListOption {
  99371. /** label of the option */
  99372. "label": string;
  99373. /** value of the option */
  99374. "value": number;
  99375. }
  99376. /**
  99377. * Interface that defines the options available for an editable property
  99378. */
  99379. export interface IEditablePropertyOption {
  99380. /** min value */
  99381. "min"?: number;
  99382. /** max value */
  99383. "max"?: number;
  99384. /** notifiers: indicates which actions to take when the property is changed */
  99385. "notifiers"?: {
  99386. /** the material should be rebuilt */
  99387. "rebuild"?: boolean;
  99388. /** the preview should be updated */
  99389. "update"?: boolean;
  99390. };
  99391. /** list of the options for a variable of type list */
  99392. "options"?: IEditablePropertyListOption[];
  99393. }
  99394. /**
  99395. * Interface that describes an editable property
  99396. */
  99397. export interface IPropertyDescriptionForEdition {
  99398. /** name of the property */
  99399. "propertyName": string;
  99400. /** display name of the property */
  99401. "displayName": string;
  99402. /** type of the property */
  99403. "type": PropertyTypeForEdition;
  99404. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99405. "groupName": string;
  99406. /** options for the property */
  99407. "options": IEditablePropertyOption;
  99408. }
  99409. /**
  99410. * Decorator that flags a property in a node material block as being editable
  99411. */
  99412. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99413. }
  99414. declare module BABYLON {
  99415. /**
  99416. * Block used to implement the refraction part of the sub surface module of the PBR material
  99417. */
  99418. export class RefractionBlock extends NodeMaterialBlock {
  99419. /** @hidden */
  99420. _define3DName: string;
  99421. /** @hidden */
  99422. _refractionMatrixName: string;
  99423. /** @hidden */
  99424. _defineLODRefractionAlpha: string;
  99425. /** @hidden */
  99426. _defineLinearSpecularRefraction: string;
  99427. /** @hidden */
  99428. _defineOppositeZ: string;
  99429. /** @hidden */
  99430. _cubeSamplerName: string;
  99431. /** @hidden */
  99432. _2DSamplerName: string;
  99433. /** @hidden */
  99434. _vRefractionMicrosurfaceInfosName: string;
  99435. /** @hidden */
  99436. _vRefractionInfosName: string;
  99437. private _scene;
  99438. /**
  99439. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99440. * Materials half opaque for instance using refraction could benefit from this control.
  99441. */
  99442. linkRefractionWithTransparency: boolean;
  99443. /**
  99444. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99445. */
  99446. invertRefractionY: boolean;
  99447. /**
  99448. * Gets or sets the texture associated with the node
  99449. */
  99450. texture: Nullable<BaseTexture>;
  99451. /**
  99452. * Create a new RefractionBlock
  99453. * @param name defines the block name
  99454. */
  99455. constructor(name: string);
  99456. /**
  99457. * Gets the current class name
  99458. * @returns the class name
  99459. */
  99460. getClassName(): string;
  99461. /**
  99462. * Gets the intensity input component
  99463. */
  99464. get intensity(): NodeMaterialConnectionPoint;
  99465. /**
  99466. * Gets the index of refraction input component
  99467. */
  99468. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99469. /**
  99470. * Gets the tint at distance input component
  99471. */
  99472. get tintAtDistance(): NodeMaterialConnectionPoint;
  99473. /**
  99474. * Gets the view input component
  99475. */
  99476. get view(): NodeMaterialConnectionPoint;
  99477. /**
  99478. * Gets the refraction object output component
  99479. */
  99480. get refraction(): NodeMaterialConnectionPoint;
  99481. /**
  99482. * Returns true if the block has a texture
  99483. */
  99484. get hasTexture(): boolean;
  99485. protected _getTexture(): Nullable<BaseTexture>;
  99486. autoConfigure(material: NodeMaterial): void;
  99487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99488. isReady(): boolean;
  99489. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99490. /**
  99491. * Gets the main code of the block (fragment side)
  99492. * @param state current state of the node material building
  99493. * @returns the shader code
  99494. */
  99495. getCode(state: NodeMaterialBuildState): string;
  99496. protected _buildBlock(state: NodeMaterialBuildState): this;
  99497. protected _dumpPropertiesCode(): string;
  99498. serialize(): any;
  99499. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99500. }
  99501. }
  99502. declare module BABYLON {
  99503. /**
  99504. * Base block used as input for post process
  99505. */
  99506. export class CurrentScreenBlock extends NodeMaterialBlock {
  99507. private _samplerName;
  99508. private _linearDefineName;
  99509. private _gammaDefineName;
  99510. private _mainUVName;
  99511. private _tempTextureRead;
  99512. /**
  99513. * Gets or sets the texture associated with the node
  99514. */
  99515. texture: Nullable<BaseTexture>;
  99516. /**
  99517. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99518. */
  99519. convertToGammaSpace: boolean;
  99520. /**
  99521. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99522. */
  99523. convertToLinearSpace: boolean;
  99524. /**
  99525. * Create a new CurrentScreenBlock
  99526. * @param name defines the block name
  99527. */
  99528. constructor(name: string);
  99529. /**
  99530. * Gets the current class name
  99531. * @returns the class name
  99532. */
  99533. getClassName(): string;
  99534. /**
  99535. * Gets the uv input component
  99536. */
  99537. get uv(): NodeMaterialConnectionPoint;
  99538. /**
  99539. * Gets the rgba output component
  99540. */
  99541. get rgba(): NodeMaterialConnectionPoint;
  99542. /**
  99543. * Gets the rgb output component
  99544. */
  99545. get rgb(): NodeMaterialConnectionPoint;
  99546. /**
  99547. * Gets the r output component
  99548. */
  99549. get r(): NodeMaterialConnectionPoint;
  99550. /**
  99551. * Gets the g output component
  99552. */
  99553. get g(): NodeMaterialConnectionPoint;
  99554. /**
  99555. * Gets the b output component
  99556. */
  99557. get b(): NodeMaterialConnectionPoint;
  99558. /**
  99559. * Gets the a output component
  99560. */
  99561. get a(): NodeMaterialConnectionPoint;
  99562. /**
  99563. * Initialize the block and prepare the context for build
  99564. * @param state defines the state that will be used for the build
  99565. */
  99566. initialize(state: NodeMaterialBuildState): void;
  99567. get target(): NodeMaterialBlockTargets;
  99568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99569. isReady(): boolean;
  99570. private _injectVertexCode;
  99571. private _writeTextureRead;
  99572. private _writeOutput;
  99573. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99574. serialize(): any;
  99575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99576. }
  99577. }
  99578. declare module BABYLON {
  99579. /**
  99580. * Base block used for the particle texture
  99581. */
  99582. export class ParticleTextureBlock extends NodeMaterialBlock {
  99583. private _samplerName;
  99584. private _linearDefineName;
  99585. private _gammaDefineName;
  99586. private _tempTextureRead;
  99587. /**
  99588. * Gets or sets the texture associated with the node
  99589. */
  99590. texture: Nullable<BaseTexture>;
  99591. /**
  99592. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99593. */
  99594. convertToGammaSpace: boolean;
  99595. /**
  99596. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99597. */
  99598. convertToLinearSpace: boolean;
  99599. /**
  99600. * Create a new ParticleTextureBlock
  99601. * @param name defines the block name
  99602. */
  99603. constructor(name: string);
  99604. /**
  99605. * Gets the current class name
  99606. * @returns the class name
  99607. */
  99608. getClassName(): string;
  99609. /**
  99610. * Gets the uv input component
  99611. */
  99612. get uv(): NodeMaterialConnectionPoint;
  99613. /**
  99614. * Gets the rgba output component
  99615. */
  99616. get rgba(): NodeMaterialConnectionPoint;
  99617. /**
  99618. * Gets the rgb output component
  99619. */
  99620. get rgb(): NodeMaterialConnectionPoint;
  99621. /**
  99622. * Gets the r output component
  99623. */
  99624. get r(): NodeMaterialConnectionPoint;
  99625. /**
  99626. * Gets the g output component
  99627. */
  99628. get g(): NodeMaterialConnectionPoint;
  99629. /**
  99630. * Gets the b output component
  99631. */
  99632. get b(): NodeMaterialConnectionPoint;
  99633. /**
  99634. * Gets the a output component
  99635. */
  99636. get a(): NodeMaterialConnectionPoint;
  99637. /**
  99638. * Initialize the block and prepare the context for build
  99639. * @param state defines the state that will be used for the build
  99640. */
  99641. initialize(state: NodeMaterialBuildState): void;
  99642. autoConfigure(material: NodeMaterial): void;
  99643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99644. isReady(): boolean;
  99645. private _writeOutput;
  99646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99647. serialize(): any;
  99648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99649. }
  99650. }
  99651. declare module BABYLON {
  99652. /**
  99653. * Class used to store shared data between 2 NodeMaterialBuildState
  99654. */
  99655. export class NodeMaterialBuildStateSharedData {
  99656. /**
  99657. * Gets the list of emitted varyings
  99658. */
  99659. temps: string[];
  99660. /**
  99661. * Gets the list of emitted varyings
  99662. */
  99663. varyings: string[];
  99664. /**
  99665. * Gets the varying declaration string
  99666. */
  99667. varyingDeclaration: string;
  99668. /**
  99669. * Input blocks
  99670. */
  99671. inputBlocks: InputBlock[];
  99672. /**
  99673. * Input blocks
  99674. */
  99675. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99676. /**
  99677. * Bindable blocks (Blocks that need to set data to the effect)
  99678. */
  99679. bindableBlocks: NodeMaterialBlock[];
  99680. /**
  99681. * List of blocks that can provide a compilation fallback
  99682. */
  99683. blocksWithFallbacks: NodeMaterialBlock[];
  99684. /**
  99685. * List of blocks that can provide a define update
  99686. */
  99687. blocksWithDefines: NodeMaterialBlock[];
  99688. /**
  99689. * List of blocks that can provide a repeatable content
  99690. */
  99691. repeatableContentBlocks: NodeMaterialBlock[];
  99692. /**
  99693. * List of blocks that can provide a dynamic list of uniforms
  99694. */
  99695. dynamicUniformBlocks: NodeMaterialBlock[];
  99696. /**
  99697. * List of blocks that can block the isReady function for the material
  99698. */
  99699. blockingBlocks: NodeMaterialBlock[];
  99700. /**
  99701. * Gets the list of animated inputs
  99702. */
  99703. animatedInputs: InputBlock[];
  99704. /**
  99705. * Build Id used to avoid multiple recompilations
  99706. */
  99707. buildId: number;
  99708. /** List of emitted variables */
  99709. variableNames: {
  99710. [key: string]: number;
  99711. };
  99712. /** List of emitted defines */
  99713. defineNames: {
  99714. [key: string]: number;
  99715. };
  99716. /** Should emit comments? */
  99717. emitComments: boolean;
  99718. /** Emit build activity */
  99719. verbose: boolean;
  99720. /** Gets or sets the hosting scene */
  99721. scene: Scene;
  99722. /**
  99723. * Gets the compilation hints emitted at compilation time
  99724. */
  99725. hints: {
  99726. needWorldViewMatrix: boolean;
  99727. needWorldViewProjectionMatrix: boolean;
  99728. needAlphaBlending: boolean;
  99729. needAlphaTesting: boolean;
  99730. };
  99731. /**
  99732. * List of compilation checks
  99733. */
  99734. checks: {
  99735. emitVertex: boolean;
  99736. emitFragment: boolean;
  99737. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99738. };
  99739. /**
  99740. * Is vertex program allowed to be empty?
  99741. */
  99742. allowEmptyVertexProgram: boolean;
  99743. /** Creates a new shared data */
  99744. constructor();
  99745. /**
  99746. * Emits console errors and exceptions if there is a failing check
  99747. */
  99748. emitErrors(): void;
  99749. }
  99750. }
  99751. declare module BABYLON {
  99752. /**
  99753. * Class used to store node based material build state
  99754. */
  99755. export class NodeMaterialBuildState {
  99756. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99757. supportUniformBuffers: boolean;
  99758. /**
  99759. * Gets the list of emitted attributes
  99760. */
  99761. attributes: string[];
  99762. /**
  99763. * Gets the list of emitted uniforms
  99764. */
  99765. uniforms: string[];
  99766. /**
  99767. * Gets the list of emitted constants
  99768. */
  99769. constants: string[];
  99770. /**
  99771. * Gets the list of emitted samplers
  99772. */
  99773. samplers: string[];
  99774. /**
  99775. * Gets the list of emitted functions
  99776. */
  99777. functions: {
  99778. [key: string]: string;
  99779. };
  99780. /**
  99781. * Gets the list of emitted extensions
  99782. */
  99783. extensions: {
  99784. [key: string]: string;
  99785. };
  99786. /**
  99787. * Gets the target of the compilation state
  99788. */
  99789. target: NodeMaterialBlockTargets;
  99790. /**
  99791. * Gets the list of emitted counters
  99792. */
  99793. counters: {
  99794. [key: string]: number;
  99795. };
  99796. /**
  99797. * Shared data between multiple NodeMaterialBuildState instances
  99798. */
  99799. sharedData: NodeMaterialBuildStateSharedData;
  99800. /** @hidden */
  99801. _vertexState: NodeMaterialBuildState;
  99802. /** @hidden */
  99803. _attributeDeclaration: string;
  99804. /** @hidden */
  99805. _uniformDeclaration: string;
  99806. /** @hidden */
  99807. _constantDeclaration: string;
  99808. /** @hidden */
  99809. _samplerDeclaration: string;
  99810. /** @hidden */
  99811. _varyingTransfer: string;
  99812. /** @hidden */
  99813. _injectAtEnd: string;
  99814. private _repeatableContentAnchorIndex;
  99815. /** @hidden */
  99816. _builtCompilationString: string;
  99817. /**
  99818. * Gets the emitted compilation strings
  99819. */
  99820. compilationString: string;
  99821. /**
  99822. * Finalize the compilation strings
  99823. * @param state defines the current compilation state
  99824. */
  99825. finalize(state: NodeMaterialBuildState): void;
  99826. /** @hidden */
  99827. get _repeatableContentAnchor(): string;
  99828. /** @hidden */
  99829. _getFreeVariableName(prefix: string): string;
  99830. /** @hidden */
  99831. _getFreeDefineName(prefix: string): string;
  99832. /** @hidden */
  99833. _excludeVariableName(name: string): void;
  99834. /** @hidden */
  99835. _emit2DSampler(name: string): void;
  99836. /** @hidden */
  99837. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99838. /** @hidden */
  99839. _emitExtension(name: string, extension: string, define?: string): void;
  99840. /** @hidden */
  99841. _emitFunction(name: string, code: string, comments: string): void;
  99842. /** @hidden */
  99843. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99844. replaceStrings?: {
  99845. search: RegExp;
  99846. replace: string;
  99847. }[];
  99848. repeatKey?: string;
  99849. }): string;
  99850. /** @hidden */
  99851. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99852. repeatKey?: string;
  99853. removeAttributes?: boolean;
  99854. removeUniforms?: boolean;
  99855. removeVaryings?: boolean;
  99856. removeIfDef?: boolean;
  99857. replaceStrings?: {
  99858. search: RegExp;
  99859. replace: string;
  99860. }[];
  99861. }, storeKey?: string): void;
  99862. /** @hidden */
  99863. _registerTempVariable(name: string): boolean;
  99864. /** @hidden */
  99865. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99866. /** @hidden */
  99867. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99868. /** @hidden */
  99869. _emitFloat(value: number): string;
  99870. }
  99871. }
  99872. declare module BABYLON {
  99873. /**
  99874. * Helper class used to generate session unique ID
  99875. */
  99876. export class UniqueIdGenerator {
  99877. private static _UniqueIdCounter;
  99878. /**
  99879. * Gets an unique (relatively to the current scene) Id
  99880. */
  99881. static get UniqueId(): number;
  99882. }
  99883. }
  99884. declare module BABYLON {
  99885. /**
  99886. * Defines a block that can be used inside a node based material
  99887. */
  99888. export class NodeMaterialBlock {
  99889. private _buildId;
  99890. private _buildTarget;
  99891. private _target;
  99892. private _isFinalMerger;
  99893. private _isInput;
  99894. private _name;
  99895. protected _isUnique: boolean;
  99896. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99897. inputsAreExclusive: boolean;
  99898. /** @hidden */
  99899. _codeVariableName: string;
  99900. /** @hidden */
  99901. _inputs: NodeMaterialConnectionPoint[];
  99902. /** @hidden */
  99903. _outputs: NodeMaterialConnectionPoint[];
  99904. /** @hidden */
  99905. _preparationId: number;
  99906. /**
  99907. * Gets the name of the block
  99908. */
  99909. get name(): string;
  99910. /**
  99911. * Sets the name of the block. Will check if the name is valid.
  99912. */
  99913. set name(newName: string);
  99914. /**
  99915. * Gets or sets the unique id of the node
  99916. */
  99917. uniqueId: number;
  99918. /**
  99919. * Gets or sets the comments associated with this block
  99920. */
  99921. comments: string;
  99922. /**
  99923. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99924. */
  99925. get isUnique(): boolean;
  99926. /**
  99927. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99928. */
  99929. get isFinalMerger(): boolean;
  99930. /**
  99931. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99932. */
  99933. get isInput(): boolean;
  99934. /**
  99935. * Gets or sets the build Id
  99936. */
  99937. get buildId(): number;
  99938. set buildId(value: number);
  99939. /**
  99940. * Gets or sets the target of the block
  99941. */
  99942. get target(): NodeMaterialBlockTargets;
  99943. set target(value: NodeMaterialBlockTargets);
  99944. /**
  99945. * Gets the list of input points
  99946. */
  99947. get inputs(): NodeMaterialConnectionPoint[];
  99948. /** Gets the list of output points */
  99949. get outputs(): NodeMaterialConnectionPoint[];
  99950. /**
  99951. * Find an input by its name
  99952. * @param name defines the name of the input to look for
  99953. * @returns the input or null if not found
  99954. */
  99955. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99956. /**
  99957. * Find an output by its name
  99958. * @param name defines the name of the outputto look for
  99959. * @returns the output or null if not found
  99960. */
  99961. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99962. /**
  99963. * Creates a new NodeMaterialBlock
  99964. * @param name defines the block name
  99965. * @param target defines the target of that block (Vertex by default)
  99966. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99967. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99968. */
  99969. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99970. /**
  99971. * Initialize the block and prepare the context for build
  99972. * @param state defines the state that will be used for the build
  99973. */
  99974. initialize(state: NodeMaterialBuildState): void;
  99975. /**
  99976. * Bind data to effect. Will only be called for blocks with isBindable === true
  99977. * @param effect defines the effect to bind data to
  99978. * @param nodeMaterial defines the hosting NodeMaterial
  99979. * @param mesh defines the mesh that will be rendered
  99980. * @param subMesh defines the submesh that will be rendered
  99981. */
  99982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99983. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99984. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99985. protected _writeFloat(value: number): string;
  99986. /**
  99987. * Gets the current class name e.g. "NodeMaterialBlock"
  99988. * @returns the class name
  99989. */
  99990. getClassName(): string;
  99991. /**
  99992. * Register a new input. Must be called inside a block constructor
  99993. * @param name defines the connection point name
  99994. * @param type defines the connection point type
  99995. * @param isOptional defines a boolean indicating that this input can be omitted
  99996. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99997. * @param point an already created connection point. If not provided, create a new one
  99998. * @returns the current block
  99999. */
  100000. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100001. /**
  100002. * Register a new output. Must be called inside a block constructor
  100003. * @param name defines the connection point name
  100004. * @param type defines the connection point type
  100005. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100006. * @param point an already created connection point. If not provided, create a new one
  100007. * @returns the current block
  100008. */
  100009. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100010. /**
  100011. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100012. * @param forOutput defines an optional connection point to check compatibility with
  100013. * @returns the first available input or null
  100014. */
  100015. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100016. /**
  100017. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100018. * @param forBlock defines an optional block to check compatibility with
  100019. * @returns the first available input or null
  100020. */
  100021. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100022. /**
  100023. * Gets the sibling of the given output
  100024. * @param current defines the current output
  100025. * @returns the next output in the list or null
  100026. */
  100027. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100028. /**
  100029. * Connect current block with another block
  100030. * @param other defines the block to connect with
  100031. * @param options define the various options to help pick the right connections
  100032. * @returns the current block
  100033. */
  100034. connectTo(other: NodeMaterialBlock, options?: {
  100035. input?: string;
  100036. output?: string;
  100037. outputSwizzle?: string;
  100038. }): this | undefined;
  100039. protected _buildBlock(state: NodeMaterialBuildState): void;
  100040. /**
  100041. * Add uniforms, samplers and uniform buffers at compilation time
  100042. * @param state defines the state to update
  100043. * @param nodeMaterial defines the node material requesting the update
  100044. * @param defines defines the material defines to update
  100045. * @param uniformBuffers defines the list of uniform buffer names
  100046. */
  100047. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100048. /**
  100049. * Add potential fallbacks if shader compilation fails
  100050. * @param mesh defines the mesh to be rendered
  100051. * @param fallbacks defines the current prioritized list of fallbacks
  100052. */
  100053. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100054. /**
  100055. * Initialize defines for shader compilation
  100056. * @param mesh defines the mesh to be rendered
  100057. * @param nodeMaterial defines the node material requesting the update
  100058. * @param defines defines the material defines to update
  100059. * @param useInstances specifies that instances should be used
  100060. */
  100061. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100062. /**
  100063. * Update defines for shader compilation
  100064. * @param mesh defines the mesh to be rendered
  100065. * @param nodeMaterial defines the node material requesting the update
  100066. * @param defines defines the material defines to update
  100067. * @param useInstances specifies that instances should be used
  100068. * @param subMesh defines which submesh to render
  100069. */
  100070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100071. /**
  100072. * Lets the block try to connect some inputs automatically
  100073. * @param material defines the hosting NodeMaterial
  100074. */
  100075. autoConfigure(material: NodeMaterial): void;
  100076. /**
  100077. * Function called when a block is declared as repeatable content generator
  100078. * @param vertexShaderState defines the current compilation state for the vertex shader
  100079. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100080. * @param mesh defines the mesh to be rendered
  100081. * @param defines defines the material defines to update
  100082. */
  100083. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100084. /**
  100085. * Checks if the block is ready
  100086. * @param mesh defines the mesh to be rendered
  100087. * @param nodeMaterial defines the node material requesting the update
  100088. * @param defines defines the material defines to update
  100089. * @param useInstances specifies that instances should be used
  100090. * @returns true if the block is ready
  100091. */
  100092. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100093. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100094. private _processBuild;
  100095. /**
  100096. * Validates the new name for the block node.
  100097. * @param newName the new name to be given to the node.
  100098. * @returns false if the name is a reserve word, else true.
  100099. */
  100100. validateBlockName(newName: string): boolean;
  100101. /**
  100102. * Compile the current node and generate the shader code
  100103. * @param state defines the current compilation state (uniforms, samplers, current string)
  100104. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100105. * @returns true if already built
  100106. */
  100107. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100108. protected _inputRename(name: string): string;
  100109. protected _outputRename(name: string): string;
  100110. protected _dumpPropertiesCode(): string;
  100111. /** @hidden */
  100112. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100113. /** @hidden */
  100114. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100115. /**
  100116. * Clone the current block to a new identical block
  100117. * @param scene defines the hosting scene
  100118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100119. * @returns a copy of the current block
  100120. */
  100121. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100122. /**
  100123. * Serializes this block in a JSON representation
  100124. * @returns the serialized block object
  100125. */
  100126. serialize(): any;
  100127. /** @hidden */
  100128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100129. private _deserializePortDisplayNamesAndExposedOnFrame;
  100130. /**
  100131. * Release resources
  100132. */
  100133. dispose(): void;
  100134. }
  100135. }
  100136. declare module BABYLON {
  100137. /**
  100138. * Base class of materials working in push mode in babylon JS
  100139. * @hidden
  100140. */
  100141. export class PushMaterial extends Material {
  100142. protected _activeEffect: Effect;
  100143. protected _normalMatrix: Matrix;
  100144. constructor(name: string, scene: Scene);
  100145. getEffect(): Effect;
  100146. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100147. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100148. /**
  100149. * Binds the given world matrix to the active effect
  100150. *
  100151. * @param world the matrix to bind
  100152. */
  100153. bindOnlyWorldMatrix(world: Matrix): void;
  100154. /**
  100155. * Binds the given normal matrix to the active effect
  100156. *
  100157. * @param normalMatrix the matrix to bind
  100158. */
  100159. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100160. bind(world: Matrix, mesh?: Mesh): void;
  100161. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100162. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100163. }
  100164. }
  100165. declare module BABYLON {
  100166. /**
  100167. * Root class for all node material optimizers
  100168. */
  100169. export class NodeMaterialOptimizer {
  100170. /**
  100171. * Function used to optimize a NodeMaterial graph
  100172. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100173. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100174. */
  100175. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100176. }
  100177. }
  100178. declare module BABYLON {
  100179. /**
  100180. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100181. */
  100182. export class TransformBlock extends NodeMaterialBlock {
  100183. /**
  100184. * Defines the value to use to complement W value to transform it to a Vector4
  100185. */
  100186. complementW: number;
  100187. /**
  100188. * Defines the value to use to complement z value to transform it to a Vector4
  100189. */
  100190. complementZ: number;
  100191. /**
  100192. * Creates a new TransformBlock
  100193. * @param name defines the block name
  100194. */
  100195. constructor(name: string);
  100196. /**
  100197. * Gets the current class name
  100198. * @returns the class name
  100199. */
  100200. getClassName(): string;
  100201. /**
  100202. * Gets the vector input
  100203. */
  100204. get vector(): NodeMaterialConnectionPoint;
  100205. /**
  100206. * Gets the output component
  100207. */
  100208. get output(): NodeMaterialConnectionPoint;
  100209. /**
  100210. * Gets the xyz output component
  100211. */
  100212. get xyz(): NodeMaterialConnectionPoint;
  100213. /**
  100214. * Gets the matrix transform input
  100215. */
  100216. get transform(): NodeMaterialConnectionPoint;
  100217. protected _buildBlock(state: NodeMaterialBuildState): this;
  100218. /**
  100219. * Update defines for shader compilation
  100220. * @param mesh defines the mesh to be rendered
  100221. * @param nodeMaterial defines the node material requesting the update
  100222. * @param defines defines the material defines to update
  100223. * @param useInstances specifies that instances should be used
  100224. * @param subMesh defines which submesh to render
  100225. */
  100226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100227. serialize(): any;
  100228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100229. protected _dumpPropertiesCode(): string;
  100230. }
  100231. }
  100232. declare module BABYLON {
  100233. /**
  100234. * Block used to output the vertex position
  100235. */
  100236. export class VertexOutputBlock extends NodeMaterialBlock {
  100237. /**
  100238. * Creates a new VertexOutputBlock
  100239. * @param name defines the block name
  100240. */
  100241. constructor(name: string);
  100242. /**
  100243. * Gets the current class name
  100244. * @returns the class name
  100245. */
  100246. getClassName(): string;
  100247. /**
  100248. * Gets the vector input component
  100249. */
  100250. get vector(): NodeMaterialConnectionPoint;
  100251. protected _buildBlock(state: NodeMaterialBuildState): this;
  100252. }
  100253. }
  100254. declare module BABYLON {
  100255. /**
  100256. * Block used to output the final color
  100257. */
  100258. export class FragmentOutputBlock extends NodeMaterialBlock {
  100259. /**
  100260. * Create a new FragmentOutputBlock
  100261. * @param name defines the block name
  100262. */
  100263. constructor(name: string);
  100264. /**
  100265. * Gets the current class name
  100266. * @returns the class name
  100267. */
  100268. getClassName(): string;
  100269. /**
  100270. * Gets the rgba input component
  100271. */
  100272. get rgba(): NodeMaterialConnectionPoint;
  100273. /**
  100274. * Gets the rgb input component
  100275. */
  100276. get rgb(): NodeMaterialConnectionPoint;
  100277. /**
  100278. * Gets the a input component
  100279. */
  100280. get a(): NodeMaterialConnectionPoint;
  100281. protected _buildBlock(state: NodeMaterialBuildState): this;
  100282. }
  100283. }
  100284. declare module BABYLON {
  100285. /**
  100286. * Block used for the particle ramp gradient section
  100287. */
  100288. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100289. /**
  100290. * Create a new ParticleRampGradientBlock
  100291. * @param name defines the block name
  100292. */
  100293. constructor(name: string);
  100294. /**
  100295. * Gets the current class name
  100296. * @returns the class name
  100297. */
  100298. getClassName(): string;
  100299. /**
  100300. * Gets the color input component
  100301. */
  100302. get color(): NodeMaterialConnectionPoint;
  100303. /**
  100304. * Gets the rampColor output component
  100305. */
  100306. get rampColor(): NodeMaterialConnectionPoint;
  100307. /**
  100308. * Initialize the block and prepare the context for build
  100309. * @param state defines the state that will be used for the build
  100310. */
  100311. initialize(state: NodeMaterialBuildState): void;
  100312. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100313. }
  100314. }
  100315. declare module BABYLON {
  100316. /**
  100317. * Block used for the particle blend multiply section
  100318. */
  100319. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100320. /**
  100321. * Create a new ParticleBlendMultiplyBlock
  100322. * @param name defines the block name
  100323. */
  100324. constructor(name: string);
  100325. /**
  100326. * Gets the current class name
  100327. * @returns the class name
  100328. */
  100329. getClassName(): string;
  100330. /**
  100331. * Gets the color input component
  100332. */
  100333. get color(): NodeMaterialConnectionPoint;
  100334. /**
  100335. * Gets the alphaTexture input component
  100336. */
  100337. get alphaTexture(): NodeMaterialConnectionPoint;
  100338. /**
  100339. * Gets the alphaColor input component
  100340. */
  100341. get alphaColor(): NodeMaterialConnectionPoint;
  100342. /**
  100343. * Gets the blendColor output component
  100344. */
  100345. get blendColor(): NodeMaterialConnectionPoint;
  100346. /**
  100347. * Initialize the block and prepare the context for build
  100348. * @param state defines the state that will be used for the build
  100349. */
  100350. initialize(state: NodeMaterialBuildState): void;
  100351. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100352. }
  100353. }
  100354. declare module BABYLON {
  100355. /**
  100356. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100357. */
  100358. export class VectorMergerBlock extends NodeMaterialBlock {
  100359. /**
  100360. * Create a new VectorMergerBlock
  100361. * @param name defines the block name
  100362. */
  100363. constructor(name: string);
  100364. /**
  100365. * Gets the current class name
  100366. * @returns the class name
  100367. */
  100368. getClassName(): string;
  100369. /**
  100370. * Gets the xyz component (input)
  100371. */
  100372. get xyzIn(): NodeMaterialConnectionPoint;
  100373. /**
  100374. * Gets the xy component (input)
  100375. */
  100376. get xyIn(): NodeMaterialConnectionPoint;
  100377. /**
  100378. * Gets the x component (input)
  100379. */
  100380. get x(): NodeMaterialConnectionPoint;
  100381. /**
  100382. * Gets the y component (input)
  100383. */
  100384. get y(): NodeMaterialConnectionPoint;
  100385. /**
  100386. * Gets the z component (input)
  100387. */
  100388. get z(): NodeMaterialConnectionPoint;
  100389. /**
  100390. * Gets the w component (input)
  100391. */
  100392. get w(): NodeMaterialConnectionPoint;
  100393. /**
  100394. * Gets the xyzw component (output)
  100395. */
  100396. get xyzw(): NodeMaterialConnectionPoint;
  100397. /**
  100398. * Gets the xyz component (output)
  100399. */
  100400. get xyzOut(): NodeMaterialConnectionPoint;
  100401. /**
  100402. * Gets the xy component (output)
  100403. */
  100404. get xyOut(): NodeMaterialConnectionPoint;
  100405. /**
  100406. * Gets the xy component (output)
  100407. * @deprecated Please use xyOut instead.
  100408. */
  100409. get xy(): NodeMaterialConnectionPoint;
  100410. /**
  100411. * Gets the xyz component (output)
  100412. * @deprecated Please use xyzOut instead.
  100413. */
  100414. get xyz(): NodeMaterialConnectionPoint;
  100415. protected _buildBlock(state: NodeMaterialBuildState): this;
  100416. }
  100417. }
  100418. declare module BABYLON {
  100419. /**
  100420. * Block used to remap a float from a range to a new one
  100421. */
  100422. export class RemapBlock extends NodeMaterialBlock {
  100423. /**
  100424. * Gets or sets the source range
  100425. */
  100426. sourceRange: Vector2;
  100427. /**
  100428. * Gets or sets the target range
  100429. */
  100430. targetRange: Vector2;
  100431. /**
  100432. * Creates a new RemapBlock
  100433. * @param name defines the block name
  100434. */
  100435. constructor(name: string);
  100436. /**
  100437. * Gets the current class name
  100438. * @returns the class name
  100439. */
  100440. getClassName(): string;
  100441. /**
  100442. * Gets the input component
  100443. */
  100444. get input(): NodeMaterialConnectionPoint;
  100445. /**
  100446. * Gets the source min input component
  100447. */
  100448. get sourceMin(): NodeMaterialConnectionPoint;
  100449. /**
  100450. * Gets the source max input component
  100451. */
  100452. get sourceMax(): NodeMaterialConnectionPoint;
  100453. /**
  100454. * Gets the target min input component
  100455. */
  100456. get targetMin(): NodeMaterialConnectionPoint;
  100457. /**
  100458. * Gets the target max input component
  100459. */
  100460. get targetMax(): NodeMaterialConnectionPoint;
  100461. /**
  100462. * Gets the output component
  100463. */
  100464. get output(): NodeMaterialConnectionPoint;
  100465. protected _buildBlock(state: NodeMaterialBuildState): this;
  100466. protected _dumpPropertiesCode(): string;
  100467. serialize(): any;
  100468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100469. }
  100470. }
  100471. declare module BABYLON {
  100472. /**
  100473. * Block used to multiply 2 values
  100474. */
  100475. export class MultiplyBlock extends NodeMaterialBlock {
  100476. /**
  100477. * Creates a new MultiplyBlock
  100478. * @param name defines the block name
  100479. */
  100480. constructor(name: string);
  100481. /**
  100482. * Gets the current class name
  100483. * @returns the class name
  100484. */
  100485. getClassName(): string;
  100486. /**
  100487. * Gets the left operand input component
  100488. */
  100489. get left(): NodeMaterialConnectionPoint;
  100490. /**
  100491. * Gets the right operand input component
  100492. */
  100493. get right(): NodeMaterialConnectionPoint;
  100494. /**
  100495. * Gets the output component
  100496. */
  100497. get output(): NodeMaterialConnectionPoint;
  100498. protected _buildBlock(state: NodeMaterialBuildState): this;
  100499. }
  100500. }
  100501. declare module BABYLON {
  100502. /**
  100503. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100504. */
  100505. export class ColorSplitterBlock extends NodeMaterialBlock {
  100506. /**
  100507. * Create a new ColorSplitterBlock
  100508. * @param name defines the block name
  100509. */
  100510. constructor(name: string);
  100511. /**
  100512. * Gets the current class name
  100513. * @returns the class name
  100514. */
  100515. getClassName(): string;
  100516. /**
  100517. * Gets the rgba component (input)
  100518. */
  100519. get rgba(): NodeMaterialConnectionPoint;
  100520. /**
  100521. * Gets the rgb component (input)
  100522. */
  100523. get rgbIn(): NodeMaterialConnectionPoint;
  100524. /**
  100525. * Gets the rgb component (output)
  100526. */
  100527. get rgbOut(): NodeMaterialConnectionPoint;
  100528. /**
  100529. * Gets the r component (output)
  100530. */
  100531. get r(): NodeMaterialConnectionPoint;
  100532. /**
  100533. * Gets the g component (output)
  100534. */
  100535. get g(): NodeMaterialConnectionPoint;
  100536. /**
  100537. * Gets the b component (output)
  100538. */
  100539. get b(): NodeMaterialConnectionPoint;
  100540. /**
  100541. * Gets the a component (output)
  100542. */
  100543. get a(): NodeMaterialConnectionPoint;
  100544. protected _inputRename(name: string): string;
  100545. protected _outputRename(name: string): string;
  100546. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100547. }
  100548. }
  100549. declare module BABYLON {
  100550. /**
  100551. * Interface used to configure the node material editor
  100552. */
  100553. export interface INodeMaterialEditorOptions {
  100554. /** Define the URl to load node editor script */
  100555. editorURL?: string;
  100556. }
  100557. /** @hidden */
  100558. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100559. NORMAL: boolean;
  100560. TANGENT: boolean;
  100561. UV1: boolean;
  100562. /** BONES */
  100563. NUM_BONE_INFLUENCERS: number;
  100564. BonesPerMesh: number;
  100565. BONETEXTURE: boolean;
  100566. /** MORPH TARGETS */
  100567. MORPHTARGETS: boolean;
  100568. MORPHTARGETS_NORMAL: boolean;
  100569. MORPHTARGETS_TANGENT: boolean;
  100570. MORPHTARGETS_UV: boolean;
  100571. NUM_MORPH_INFLUENCERS: number;
  100572. /** IMAGE PROCESSING */
  100573. IMAGEPROCESSING: boolean;
  100574. VIGNETTE: boolean;
  100575. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100576. VIGNETTEBLENDMODEOPAQUE: boolean;
  100577. TONEMAPPING: boolean;
  100578. TONEMAPPING_ACES: boolean;
  100579. CONTRAST: boolean;
  100580. EXPOSURE: boolean;
  100581. COLORCURVES: boolean;
  100582. COLORGRADING: boolean;
  100583. COLORGRADING3D: boolean;
  100584. SAMPLER3DGREENDEPTH: boolean;
  100585. SAMPLER3DBGRMAP: boolean;
  100586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100587. /** MISC. */
  100588. BUMPDIRECTUV: number;
  100589. constructor();
  100590. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100591. }
  100592. /**
  100593. * Class used to configure NodeMaterial
  100594. */
  100595. export interface INodeMaterialOptions {
  100596. /**
  100597. * Defines if blocks should emit comments
  100598. */
  100599. emitComments: boolean;
  100600. }
  100601. /**
  100602. * Class used to create a node based material built by assembling shader blocks
  100603. */
  100604. export class NodeMaterial extends PushMaterial {
  100605. private static _BuildIdGenerator;
  100606. private _options;
  100607. private _vertexCompilationState;
  100608. private _fragmentCompilationState;
  100609. private _sharedData;
  100610. private _buildId;
  100611. private _buildWasSuccessful;
  100612. private _cachedWorldViewMatrix;
  100613. private _cachedWorldViewProjectionMatrix;
  100614. private _optimizers;
  100615. private _animationFrame;
  100616. /** Define the Url to load node editor script */
  100617. static EditorURL: string;
  100618. /** Define the Url to load snippets */
  100619. static SnippetUrl: string;
  100620. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100621. static IgnoreTexturesAtLoadTime: boolean;
  100622. private BJSNODEMATERIALEDITOR;
  100623. /** Get the inspector from bundle or global */
  100624. private _getGlobalNodeMaterialEditor;
  100625. /**
  100626. * Snippet ID if the material was created from the snippet server
  100627. */
  100628. snippetId: string;
  100629. /**
  100630. * Gets or sets data used by visual editor
  100631. * @see https://nme.babylonjs.com
  100632. */
  100633. editorData: any;
  100634. /**
  100635. * 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)
  100636. */
  100637. ignoreAlpha: boolean;
  100638. /**
  100639. * Defines the maximum number of lights that can be used in the material
  100640. */
  100641. maxSimultaneousLights: number;
  100642. /**
  100643. * Observable raised when the material is built
  100644. */
  100645. onBuildObservable: Observable<NodeMaterial>;
  100646. /**
  100647. * Gets or sets the root nodes of the material vertex shader
  100648. */
  100649. _vertexOutputNodes: NodeMaterialBlock[];
  100650. /**
  100651. * Gets or sets the root nodes of the material fragment (pixel) shader
  100652. */
  100653. _fragmentOutputNodes: NodeMaterialBlock[];
  100654. /** Gets or sets options to control the node material overall behavior */
  100655. get options(): INodeMaterialOptions;
  100656. set options(options: INodeMaterialOptions);
  100657. /**
  100658. * Default configuration related to image processing available in the standard Material.
  100659. */
  100660. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100661. /**
  100662. * Gets the image processing configuration used either in this material.
  100663. */
  100664. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100665. /**
  100666. * Sets the Default image processing configuration used either in the this material.
  100667. *
  100668. * If sets to null, the scene one is in use.
  100669. */
  100670. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100671. /**
  100672. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100673. */
  100674. attachedBlocks: NodeMaterialBlock[];
  100675. /**
  100676. * Specifies the mode of the node material
  100677. * @hidden
  100678. */
  100679. _mode: NodeMaterialModes;
  100680. /**
  100681. * Gets the mode property
  100682. */
  100683. get mode(): NodeMaterialModes;
  100684. /**
  100685. * Create a new node based material
  100686. * @param name defines the material name
  100687. * @param scene defines the hosting scene
  100688. * @param options defines creation option
  100689. */
  100690. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100691. /**
  100692. * Gets the current class name of the material e.g. "NodeMaterial"
  100693. * @returns the class name
  100694. */
  100695. getClassName(): string;
  100696. /**
  100697. * Keep track of the image processing observer to allow dispose and replace.
  100698. */
  100699. private _imageProcessingObserver;
  100700. /**
  100701. * Attaches a new image processing configuration to the Standard Material.
  100702. * @param configuration
  100703. */
  100704. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100705. /**
  100706. * Get a block by its name
  100707. * @param name defines the name of the block to retrieve
  100708. * @returns the required block or null if not found
  100709. */
  100710. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100711. /**
  100712. * Get a block by its name
  100713. * @param predicate defines the predicate used to find the good candidate
  100714. * @returns the required block or null if not found
  100715. */
  100716. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100717. /**
  100718. * Get an input block by its name
  100719. * @param predicate defines the predicate used to find the good candidate
  100720. * @returns the required input block or null if not found
  100721. */
  100722. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100723. /**
  100724. * Gets the list of input blocks attached to this material
  100725. * @returns an array of InputBlocks
  100726. */
  100727. getInputBlocks(): InputBlock[];
  100728. /**
  100729. * Adds a new optimizer to the list of optimizers
  100730. * @param optimizer defines the optimizers to add
  100731. * @returns the current material
  100732. */
  100733. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100734. /**
  100735. * Remove an optimizer from the list of optimizers
  100736. * @param optimizer defines the optimizers to remove
  100737. * @returns the current material
  100738. */
  100739. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100740. /**
  100741. * Add a new block to the list of output nodes
  100742. * @param node defines the node to add
  100743. * @returns the current material
  100744. */
  100745. addOutputNode(node: NodeMaterialBlock): this;
  100746. /**
  100747. * Remove a block from the list of root nodes
  100748. * @param node defines the node to remove
  100749. * @returns the current material
  100750. */
  100751. removeOutputNode(node: NodeMaterialBlock): this;
  100752. private _addVertexOutputNode;
  100753. private _removeVertexOutputNode;
  100754. private _addFragmentOutputNode;
  100755. private _removeFragmentOutputNode;
  100756. /**
  100757. * Specifies if the material will require alpha blending
  100758. * @returns a boolean specifying if alpha blending is needed
  100759. */
  100760. needAlphaBlending(): boolean;
  100761. /**
  100762. * Specifies if this material should be rendered in alpha test mode
  100763. * @returns a boolean specifying if an alpha test is needed.
  100764. */
  100765. needAlphaTesting(): boolean;
  100766. private _initializeBlock;
  100767. private _resetDualBlocks;
  100768. /**
  100769. * Remove a block from the current node material
  100770. * @param block defines the block to remove
  100771. */
  100772. removeBlock(block: NodeMaterialBlock): void;
  100773. /**
  100774. * Build the material and generates the inner effect
  100775. * @param verbose defines if the build should log activity
  100776. */
  100777. build(verbose?: boolean): void;
  100778. /**
  100779. * Runs an otpimization phase to try to improve the shader code
  100780. */
  100781. optimize(): void;
  100782. private _prepareDefinesForAttributes;
  100783. /**
  100784. * Create a post process from the material
  100785. * @param camera The camera to apply the render pass to.
  100786. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100788. * @param engine The engine which the post process will be applied. (default: current engine)
  100789. * @param reusable If the post process can be reused on the same frame. (default: false)
  100790. * @param textureType Type of textures used when performing the post process. (default: 0)
  100791. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100792. * @returns the post process created
  100793. */
  100794. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100795. /**
  100796. * Create the post process effect from the material
  100797. * @param postProcess The post process to create the effect for
  100798. */
  100799. createEffectForPostProcess(postProcess: PostProcess): void;
  100800. private _createEffectOrPostProcess;
  100801. private _createEffectForParticles;
  100802. /**
  100803. * Create the effect to be used as the custom effect for a particle system
  100804. * @param particleSystem Particle system to create the effect for
  100805. * @param onCompiled defines a function to call when the effect creation is successful
  100806. * @param onError defines a function to call when the effect creation has failed
  100807. */
  100808. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100809. private _processDefines;
  100810. /**
  100811. * Get if the submesh is ready to be used and all its information available.
  100812. * Child classes can use it to update shaders
  100813. * @param mesh defines the mesh to check
  100814. * @param subMesh defines which submesh to check
  100815. * @param useInstances specifies that instances should be used
  100816. * @returns a boolean indicating that the submesh is ready or not
  100817. */
  100818. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100819. /**
  100820. * Get a string representing the shaders built by the current node graph
  100821. */
  100822. get compiledShaders(): string;
  100823. /**
  100824. * Binds the world matrix to the material
  100825. * @param world defines the world transformation matrix
  100826. */
  100827. bindOnlyWorldMatrix(world: Matrix): void;
  100828. /**
  100829. * Binds the submesh to this material by preparing the effect and shader to draw
  100830. * @param world defines the world transformation matrix
  100831. * @param mesh defines the mesh containing the submesh
  100832. * @param subMesh defines the submesh to bind the material to
  100833. */
  100834. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100835. /**
  100836. * Gets the active textures from the material
  100837. * @returns an array of textures
  100838. */
  100839. getActiveTextures(): BaseTexture[];
  100840. /**
  100841. * Gets the list of texture blocks
  100842. * @returns an array of texture blocks
  100843. */
  100844. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100845. /**
  100846. * Specifies if the material uses a texture
  100847. * @param texture defines the texture to check against the material
  100848. * @returns a boolean specifying if the material uses the texture
  100849. */
  100850. hasTexture(texture: BaseTexture): boolean;
  100851. /**
  100852. * Disposes the material
  100853. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100854. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100855. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100856. */
  100857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100858. /** Creates the node editor window. */
  100859. private _createNodeEditor;
  100860. /**
  100861. * Launch the node material editor
  100862. * @param config Define the configuration of the editor
  100863. * @return a promise fulfilled when the node editor is visible
  100864. */
  100865. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100866. /**
  100867. * Clear the current material
  100868. */
  100869. clear(): void;
  100870. /**
  100871. * Clear the current material and set it to a default state
  100872. */
  100873. setToDefault(): void;
  100874. /**
  100875. * Clear the current material and set it to a default state for post process
  100876. */
  100877. setToDefaultPostProcess(): void;
  100878. /**
  100879. * Clear the current material and set it to a default state for particle
  100880. */
  100881. setToDefaultParticle(): void;
  100882. /**
  100883. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100884. * @param url defines the url to load from
  100885. * @returns a promise that will fullfil when the material is fully loaded
  100886. */
  100887. loadAsync(url: string): Promise<void>;
  100888. private _gatherBlocks;
  100889. /**
  100890. * Generate a string containing the code declaration required to create an equivalent of this material
  100891. * @returns a string
  100892. */
  100893. generateCode(): string;
  100894. /**
  100895. * Serializes this material in a JSON representation
  100896. * @returns the serialized material object
  100897. */
  100898. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100899. private _restoreConnections;
  100900. /**
  100901. * Clear the current graph and load a new one from a serialization object
  100902. * @param source defines the JSON representation of the material
  100903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100904. * @param merge defines whether or not the source must be merged or replace the current content
  100905. */
  100906. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100907. /**
  100908. * Makes a duplicate of the current material.
  100909. * @param name - name to use for the new material.
  100910. */
  100911. clone(name: string): NodeMaterial;
  100912. /**
  100913. * Creates a node material from parsed material data
  100914. * @param source defines the JSON representation of the material
  100915. * @param scene defines the hosting scene
  100916. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100917. * @returns a new node material
  100918. */
  100919. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100920. /**
  100921. * Creates a node material from a snippet saved in a remote file
  100922. * @param name defines the name of the material to create
  100923. * @param url defines the url to load from
  100924. * @param scene defines the hosting scene
  100925. * @returns a promise that will resolve to the new node material
  100926. */
  100927. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100928. /**
  100929. * Creates a node material from a snippet saved by the node material editor
  100930. * @param snippetId defines the snippet to load
  100931. * @param scene defines the hosting scene
  100932. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100933. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100934. * @returns a promise that will resolve to the new node material
  100935. */
  100936. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100937. /**
  100938. * Creates a new node material set to default basic configuration
  100939. * @param name defines the name of the material
  100940. * @param scene defines the hosting scene
  100941. * @returns a new NodeMaterial
  100942. */
  100943. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100944. }
  100945. }
  100946. declare module BABYLON {
  100947. /**
  100948. * Size options for a post process
  100949. */
  100950. export type PostProcessOptions = {
  100951. width: number;
  100952. height: number;
  100953. };
  100954. /**
  100955. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100956. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100957. */
  100958. export class PostProcess {
  100959. /** Name of the PostProcess. */
  100960. name: string;
  100961. /**
  100962. * Gets or sets the unique id of the post process
  100963. */
  100964. uniqueId: number;
  100965. /**
  100966. * Width of the texture to apply the post process on
  100967. */
  100968. width: number;
  100969. /**
  100970. * Height of the texture to apply the post process on
  100971. */
  100972. height: number;
  100973. /**
  100974. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100975. */
  100976. nodeMaterialSource: Nullable<NodeMaterial>;
  100977. /**
  100978. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100979. * @hidden
  100980. */
  100981. _outputTexture: Nullable<InternalTexture>;
  100982. /**
  100983. * Sampling mode used by the shader
  100984. * See https://doc.babylonjs.com/classes/3.1/texture
  100985. */
  100986. renderTargetSamplingMode: number;
  100987. /**
  100988. * Clear color to use when screen clearing
  100989. */
  100990. clearColor: Color4;
  100991. /**
  100992. * If the buffer needs to be cleared before applying the post process. (default: true)
  100993. * Should be set to false if shader will overwrite all previous pixels.
  100994. */
  100995. autoClear: boolean;
  100996. /**
  100997. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100998. */
  100999. alphaMode: number;
  101000. /**
  101001. * Sets the setAlphaBlendConstants of the babylon engine
  101002. */
  101003. alphaConstants: Color4;
  101004. /**
  101005. * Animations to be used for the post processing
  101006. */
  101007. animations: Animation[];
  101008. /**
  101009. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101010. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101011. */
  101012. enablePixelPerfectMode: boolean;
  101013. /**
  101014. * Force the postprocess to be applied without taking in account viewport
  101015. */
  101016. forceFullscreenViewport: boolean;
  101017. /**
  101018. * List of inspectable custom properties (used by the Inspector)
  101019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101020. */
  101021. inspectableCustomProperties: IInspectable[];
  101022. /**
  101023. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101024. *
  101025. * | Value | Type | Description |
  101026. * | ----- | ----------------------------------- | ----------- |
  101027. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101028. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101029. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101030. *
  101031. */
  101032. scaleMode: number;
  101033. /**
  101034. * Force textures to be a power of two (default: false)
  101035. */
  101036. alwaysForcePOT: boolean;
  101037. private _samples;
  101038. /**
  101039. * Number of sample textures (default: 1)
  101040. */
  101041. get samples(): number;
  101042. set samples(n: number);
  101043. /**
  101044. * Modify the scale of the post process to be the same as the viewport (default: false)
  101045. */
  101046. adaptScaleToCurrentViewport: boolean;
  101047. private _camera;
  101048. protected _scene: Scene;
  101049. private _engine;
  101050. private _options;
  101051. private _reusable;
  101052. private _textureType;
  101053. private _textureFormat;
  101054. /**
  101055. * Smart array of input and output textures for the post process.
  101056. * @hidden
  101057. */
  101058. _textures: SmartArray<InternalTexture>;
  101059. /**
  101060. * The index in _textures that corresponds to the output texture.
  101061. * @hidden
  101062. */
  101063. _currentRenderTextureInd: number;
  101064. private _effect;
  101065. private _samplers;
  101066. private _fragmentUrl;
  101067. private _vertexUrl;
  101068. private _parameters;
  101069. private _scaleRatio;
  101070. protected _indexParameters: any;
  101071. private _shareOutputWithPostProcess;
  101072. private _texelSize;
  101073. private _forcedOutputTexture;
  101074. /**
  101075. * Returns the fragment url or shader name used in the post process.
  101076. * @returns the fragment url or name in the shader store.
  101077. */
  101078. getEffectName(): string;
  101079. /**
  101080. * An event triggered when the postprocess is activated.
  101081. */
  101082. onActivateObservable: Observable<Camera>;
  101083. private _onActivateObserver;
  101084. /**
  101085. * A function that is added to the onActivateObservable
  101086. */
  101087. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101088. /**
  101089. * An event triggered when the postprocess changes its size.
  101090. */
  101091. onSizeChangedObservable: Observable<PostProcess>;
  101092. private _onSizeChangedObserver;
  101093. /**
  101094. * A function that is added to the onSizeChangedObservable
  101095. */
  101096. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101097. /**
  101098. * An event triggered when the postprocess applies its effect.
  101099. */
  101100. onApplyObservable: Observable<Effect>;
  101101. private _onApplyObserver;
  101102. /**
  101103. * A function that is added to the onApplyObservable
  101104. */
  101105. set onApply(callback: (effect: Effect) => void);
  101106. /**
  101107. * An event triggered before rendering the postprocess
  101108. */
  101109. onBeforeRenderObservable: Observable<Effect>;
  101110. private _onBeforeRenderObserver;
  101111. /**
  101112. * A function that is added to the onBeforeRenderObservable
  101113. */
  101114. set onBeforeRender(callback: (effect: Effect) => void);
  101115. /**
  101116. * An event triggered after rendering the postprocess
  101117. */
  101118. onAfterRenderObservable: Observable<Effect>;
  101119. private _onAfterRenderObserver;
  101120. /**
  101121. * A function that is added to the onAfterRenderObservable
  101122. */
  101123. set onAfterRender(callback: (efect: Effect) => void);
  101124. /**
  101125. * 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
  101126. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101127. */
  101128. get inputTexture(): InternalTexture;
  101129. set inputTexture(value: InternalTexture);
  101130. /**
  101131. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101132. * the only way to unset it is to use this function to restore its internal state
  101133. */
  101134. restoreDefaultInputTexture(): void;
  101135. /**
  101136. * Gets the camera which post process is applied to.
  101137. * @returns The camera the post process is applied to.
  101138. */
  101139. getCamera(): Camera;
  101140. /**
  101141. * Gets the texel size of the postprocess.
  101142. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101143. */
  101144. get texelSize(): Vector2;
  101145. /**
  101146. * Creates a new instance PostProcess
  101147. * @param name The name of the PostProcess.
  101148. * @param fragmentUrl The url of the fragment shader to be used.
  101149. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101150. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101151. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101152. * @param camera The camera to apply the render pass to.
  101153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101154. * @param engine The engine which the post process will be applied. (default: current engine)
  101155. * @param reusable If the post process can be reused on the same frame. (default: false)
  101156. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101157. * @param textureType Type of textures used when performing the post process. (default: 0)
  101158. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101159. * @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
  101160. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101161. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101162. */
  101163. constructor(
  101164. /** Name of the PostProcess. */
  101165. 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);
  101166. /**
  101167. * Gets a string idenfifying the name of the class
  101168. * @returns "PostProcess" string
  101169. */
  101170. getClassName(): string;
  101171. /**
  101172. * Gets the engine which this post process belongs to.
  101173. * @returns The engine the post process was enabled with.
  101174. */
  101175. getEngine(): Engine;
  101176. /**
  101177. * The effect that is created when initializing the post process.
  101178. * @returns The created effect corresponding the the postprocess.
  101179. */
  101180. getEffect(): Effect;
  101181. /**
  101182. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101183. * @param postProcess The post process to share the output with.
  101184. * @returns This post process.
  101185. */
  101186. shareOutputWith(postProcess: PostProcess): PostProcess;
  101187. /**
  101188. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101189. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101190. */
  101191. useOwnOutput(): void;
  101192. /**
  101193. * Updates the effect with the current post process compile time values and recompiles the shader.
  101194. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101195. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101196. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101197. * @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
  101198. * @param onCompiled Called when the shader has been compiled.
  101199. * @param onError Called if there is an error when compiling a shader.
  101200. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101201. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101202. */
  101203. 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;
  101204. /**
  101205. * The post process is reusable if it can be used multiple times within one frame.
  101206. * @returns If the post process is reusable
  101207. */
  101208. isReusable(): boolean;
  101209. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101210. markTextureDirty(): void;
  101211. /**
  101212. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101213. * 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.
  101214. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101215. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101216. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101217. * @returns The target texture that was bound to be written to.
  101218. */
  101219. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101220. /**
  101221. * If the post process is supported.
  101222. */
  101223. get isSupported(): boolean;
  101224. /**
  101225. * The aspect ratio of the output texture.
  101226. */
  101227. get aspectRatio(): number;
  101228. /**
  101229. * Get a value indicating if the post-process is ready to be used
  101230. * @returns true if the post-process is ready (shader is compiled)
  101231. */
  101232. isReady(): boolean;
  101233. /**
  101234. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101235. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101236. */
  101237. apply(): Nullable<Effect>;
  101238. private _disposeTextures;
  101239. /**
  101240. * Disposes the post process.
  101241. * @param camera The camera to dispose the post process on.
  101242. */
  101243. dispose(camera?: Camera): void;
  101244. }
  101245. }
  101246. declare module BABYLON {
  101247. /** @hidden */
  101248. export var kernelBlurVaryingDeclaration: {
  101249. name: string;
  101250. shader: string;
  101251. };
  101252. }
  101253. declare module BABYLON {
  101254. /** @hidden */
  101255. export var kernelBlurFragment: {
  101256. name: string;
  101257. shader: string;
  101258. };
  101259. }
  101260. declare module BABYLON {
  101261. /** @hidden */
  101262. export var kernelBlurFragment2: {
  101263. name: string;
  101264. shader: string;
  101265. };
  101266. }
  101267. declare module BABYLON {
  101268. /** @hidden */
  101269. export var kernelBlurPixelShader: {
  101270. name: string;
  101271. shader: string;
  101272. };
  101273. }
  101274. declare module BABYLON {
  101275. /** @hidden */
  101276. export var kernelBlurVertex: {
  101277. name: string;
  101278. shader: string;
  101279. };
  101280. }
  101281. declare module BABYLON {
  101282. /** @hidden */
  101283. export var kernelBlurVertexShader: {
  101284. name: string;
  101285. shader: string;
  101286. };
  101287. }
  101288. declare module BABYLON {
  101289. /**
  101290. * The Blur Post Process which blurs an image based on a kernel and direction.
  101291. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101292. */
  101293. export class BlurPostProcess extends PostProcess {
  101294. /** The direction in which to blur the image. */
  101295. direction: Vector2;
  101296. private blockCompilation;
  101297. protected _kernel: number;
  101298. protected _idealKernel: number;
  101299. protected _packedFloat: boolean;
  101300. private _staticDefines;
  101301. /**
  101302. * Sets the length in pixels of the blur sample region
  101303. */
  101304. set kernel(v: number);
  101305. /**
  101306. * Gets the length in pixels of the blur sample region
  101307. */
  101308. get kernel(): number;
  101309. /**
  101310. * Sets wether or not the blur needs to unpack/repack floats
  101311. */
  101312. set packedFloat(v: boolean);
  101313. /**
  101314. * Gets wether or not the blur is unpacking/repacking floats
  101315. */
  101316. get packedFloat(): boolean;
  101317. /**
  101318. * Creates a new instance BlurPostProcess
  101319. * @param name The name of the effect.
  101320. * @param direction The direction in which to blur the image.
  101321. * @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.
  101322. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101323. * @param camera The camera to apply the render pass to.
  101324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101325. * @param engine The engine which the post process will be applied. (default: current engine)
  101326. * @param reusable If the post process can be reused on the same frame. (default: false)
  101327. * @param textureType Type of textures used when performing the post process. (default: 0)
  101328. * @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)
  101329. */
  101330. constructor(name: string,
  101331. /** The direction in which to blur the image. */
  101332. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101333. /**
  101334. * Updates the effect with the current post process compile time values and recompiles the shader.
  101335. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101336. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101337. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101338. * @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
  101339. * @param onCompiled Called when the shader has been compiled.
  101340. * @param onError Called if there is an error when compiling a shader.
  101341. */
  101342. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101343. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101344. /**
  101345. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101346. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101347. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101348. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101349. * The gaps between physical kernels are compensated for in the weighting of the samples
  101350. * @param idealKernel Ideal blur kernel.
  101351. * @return Nearest best kernel.
  101352. */
  101353. protected _nearestBestKernel(idealKernel: number): number;
  101354. /**
  101355. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101356. * @param x The point on the Gaussian distribution to sample.
  101357. * @return the value of the Gaussian function at x.
  101358. */
  101359. protected _gaussianWeight(x: number): number;
  101360. /**
  101361. * Generates a string that can be used as a floating point number in GLSL.
  101362. * @param x Value to print.
  101363. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101364. * @return GLSL float string.
  101365. */
  101366. protected _glslFloat(x: number, decimalFigures?: number): string;
  101367. }
  101368. }
  101369. declare module BABYLON {
  101370. /**
  101371. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101372. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101373. * You can then easily use it as a reflectionTexture on a flat surface.
  101374. * In case the surface is not a plane, please consider relying on reflection probes.
  101375. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101376. */
  101377. export class MirrorTexture extends RenderTargetTexture {
  101378. private scene;
  101379. /**
  101380. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101381. * 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.
  101382. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101383. */
  101384. mirrorPlane: Plane;
  101385. /**
  101386. * Define the blur ratio used to blur the reflection if needed.
  101387. */
  101388. set blurRatio(value: number);
  101389. get blurRatio(): number;
  101390. /**
  101391. * Define the adaptive blur kernel used to blur the reflection if needed.
  101392. * This will autocompute the closest best match for the `blurKernel`
  101393. */
  101394. set adaptiveBlurKernel(value: number);
  101395. /**
  101396. * Define the blur kernel used to blur the reflection if needed.
  101397. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101398. */
  101399. set blurKernel(value: number);
  101400. /**
  101401. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101402. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101403. */
  101404. set blurKernelX(value: number);
  101405. get blurKernelX(): number;
  101406. /**
  101407. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101408. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101409. */
  101410. set blurKernelY(value: number);
  101411. get blurKernelY(): number;
  101412. private _autoComputeBlurKernel;
  101413. protected _onRatioRescale(): void;
  101414. private _updateGammaSpace;
  101415. private _imageProcessingConfigChangeObserver;
  101416. private _transformMatrix;
  101417. private _mirrorMatrix;
  101418. private _savedViewMatrix;
  101419. private _blurX;
  101420. private _blurY;
  101421. private _adaptiveBlurKernel;
  101422. private _blurKernelX;
  101423. private _blurKernelY;
  101424. private _blurRatio;
  101425. /**
  101426. * Instantiates a Mirror Texture.
  101427. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101428. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101429. * You can then easily use it as a reflectionTexture on a flat surface.
  101430. * In case the surface is not a plane, please consider relying on reflection probes.
  101431. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101432. * @param name
  101433. * @param size
  101434. * @param scene
  101435. * @param generateMipMaps
  101436. * @param type
  101437. * @param samplingMode
  101438. * @param generateDepthBuffer
  101439. */
  101440. constructor(name: string, size: number | {
  101441. width: number;
  101442. height: number;
  101443. } | {
  101444. ratio: number;
  101445. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101446. private _preparePostProcesses;
  101447. /**
  101448. * Clone the mirror texture.
  101449. * @returns the cloned texture
  101450. */
  101451. clone(): MirrorTexture;
  101452. /**
  101453. * Serialize the texture to a JSON representation you could use in Parse later on
  101454. * @returns the serialized JSON representation
  101455. */
  101456. serialize(): any;
  101457. /**
  101458. * Dispose the texture and release its associated resources.
  101459. */
  101460. dispose(): void;
  101461. }
  101462. }
  101463. declare module BABYLON {
  101464. /**
  101465. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101466. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101467. */
  101468. export class Texture extends BaseTexture {
  101469. /**
  101470. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101471. */
  101472. static SerializeBuffers: boolean;
  101473. /** @hidden */
  101474. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101475. /** @hidden */
  101476. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101477. /** @hidden */
  101478. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101479. /** nearest is mag = nearest and min = nearest and mip = linear */
  101480. static readonly NEAREST_SAMPLINGMODE: number;
  101481. /** nearest is mag = nearest and min = nearest and mip = linear */
  101482. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101483. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101484. static readonly BILINEAR_SAMPLINGMODE: number;
  101485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101486. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101487. /** Trilinear is mag = linear and min = linear and mip = linear */
  101488. static readonly TRILINEAR_SAMPLINGMODE: number;
  101489. /** Trilinear is mag = linear and min = linear and mip = linear */
  101490. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101491. /** mag = nearest and min = nearest and mip = nearest */
  101492. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101493. /** mag = nearest and min = linear and mip = nearest */
  101494. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101495. /** mag = nearest and min = linear and mip = linear */
  101496. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101497. /** mag = nearest and min = linear and mip = none */
  101498. static readonly NEAREST_LINEAR: number;
  101499. /** mag = nearest and min = nearest and mip = none */
  101500. static readonly NEAREST_NEAREST: number;
  101501. /** mag = linear and min = nearest and mip = nearest */
  101502. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101503. /** mag = linear and min = nearest and mip = linear */
  101504. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101505. /** mag = linear and min = linear and mip = none */
  101506. static readonly LINEAR_LINEAR: number;
  101507. /** mag = linear and min = nearest and mip = none */
  101508. static readonly LINEAR_NEAREST: number;
  101509. /** Explicit coordinates mode */
  101510. static readonly EXPLICIT_MODE: number;
  101511. /** Spherical coordinates mode */
  101512. static readonly SPHERICAL_MODE: number;
  101513. /** Planar coordinates mode */
  101514. static readonly PLANAR_MODE: number;
  101515. /** Cubic coordinates mode */
  101516. static readonly CUBIC_MODE: number;
  101517. /** Projection coordinates mode */
  101518. static readonly PROJECTION_MODE: number;
  101519. /** Inverse Cubic coordinates mode */
  101520. static readonly SKYBOX_MODE: number;
  101521. /** Inverse Cubic coordinates mode */
  101522. static readonly INVCUBIC_MODE: number;
  101523. /** Equirectangular coordinates mode */
  101524. static readonly EQUIRECTANGULAR_MODE: number;
  101525. /** Equirectangular Fixed coordinates mode */
  101526. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101527. /** Equirectangular Fixed Mirrored coordinates mode */
  101528. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101529. /** Texture is not repeating outside of 0..1 UVs */
  101530. static readonly CLAMP_ADDRESSMODE: number;
  101531. /** Texture is repeating outside of 0..1 UVs */
  101532. static readonly WRAP_ADDRESSMODE: number;
  101533. /** Texture is repeating and mirrored */
  101534. static readonly MIRROR_ADDRESSMODE: number;
  101535. /**
  101536. * 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
  101537. */
  101538. static UseSerializedUrlIfAny: boolean;
  101539. /**
  101540. * Define the url of the texture.
  101541. */
  101542. url: Nullable<string>;
  101543. /**
  101544. * Define an offset on the texture to offset the u coordinates of the UVs
  101545. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101546. */
  101547. uOffset: number;
  101548. /**
  101549. * Define an offset on the texture to offset the v coordinates of the UVs
  101550. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101551. */
  101552. vOffset: number;
  101553. /**
  101554. * Define an offset on the texture to scale the u coordinates of the UVs
  101555. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101556. */
  101557. uScale: number;
  101558. /**
  101559. * Define an offset on the texture to scale the v coordinates of the UVs
  101560. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101561. */
  101562. vScale: number;
  101563. /**
  101564. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101565. * @see https://doc.babylonjs.com/how_to/more_materials
  101566. */
  101567. uAng: number;
  101568. /**
  101569. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101570. * @see https://doc.babylonjs.com/how_to/more_materials
  101571. */
  101572. vAng: number;
  101573. /**
  101574. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101575. * @see https://doc.babylonjs.com/how_to/more_materials
  101576. */
  101577. wAng: number;
  101578. /**
  101579. * Defines the center of rotation (U)
  101580. */
  101581. uRotationCenter: number;
  101582. /**
  101583. * Defines the center of rotation (V)
  101584. */
  101585. vRotationCenter: number;
  101586. /**
  101587. * Defines the center of rotation (W)
  101588. */
  101589. wRotationCenter: number;
  101590. /**
  101591. * Are mip maps generated for this texture or not.
  101592. */
  101593. get noMipmap(): boolean;
  101594. /**
  101595. * List of inspectable custom properties (used by the Inspector)
  101596. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101597. */
  101598. inspectableCustomProperties: Nullable<IInspectable[]>;
  101599. private _noMipmap;
  101600. /** @hidden */
  101601. _invertY: boolean;
  101602. private _rowGenerationMatrix;
  101603. private _cachedTextureMatrix;
  101604. private _projectionModeMatrix;
  101605. private _t0;
  101606. private _t1;
  101607. private _t2;
  101608. private _cachedUOffset;
  101609. private _cachedVOffset;
  101610. private _cachedUScale;
  101611. private _cachedVScale;
  101612. private _cachedUAng;
  101613. private _cachedVAng;
  101614. private _cachedWAng;
  101615. private _cachedProjectionMatrixId;
  101616. private _cachedCoordinatesMode;
  101617. /** @hidden */
  101618. protected _initialSamplingMode: number;
  101619. /** @hidden */
  101620. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101621. private _deleteBuffer;
  101622. protected _format: Nullable<number>;
  101623. private _delayedOnLoad;
  101624. private _delayedOnError;
  101625. private _mimeType?;
  101626. /**
  101627. * Observable triggered once the texture has been loaded.
  101628. */
  101629. onLoadObservable: Observable<Texture>;
  101630. protected _isBlocking: boolean;
  101631. /**
  101632. * Is the texture preventing material to render while loading.
  101633. * If false, a default texture will be used instead of the loading one during the preparation step.
  101634. */
  101635. set isBlocking(value: boolean);
  101636. get isBlocking(): boolean;
  101637. /**
  101638. * Get the current sampling mode associated with the texture.
  101639. */
  101640. get samplingMode(): number;
  101641. /**
  101642. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101643. */
  101644. get invertY(): boolean;
  101645. /**
  101646. * Instantiates a new texture.
  101647. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101648. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101649. * @param url defines the url of the picture to load as a texture
  101650. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101651. * @param noMipmap defines if the texture will require mip maps or not
  101652. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101653. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101654. * @param onLoad defines a callback triggered when the texture has been loaded
  101655. * @param onError defines a callback triggered when an error occurred during the loading session
  101656. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101657. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101658. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101659. * @param mimeType defines an optional mime type information
  101660. */
  101661. 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);
  101662. /**
  101663. * Update the url (and optional buffer) of this texture if url was null during construction.
  101664. * @param url the url of the texture
  101665. * @param buffer the buffer of the texture (defaults to null)
  101666. * @param onLoad callback called when the texture is loaded (defaults to null)
  101667. */
  101668. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101669. /**
  101670. * Finish the loading sequence of a texture flagged as delayed load.
  101671. * @hidden
  101672. */
  101673. delayLoad(): void;
  101674. private _prepareRowForTextureGeneration;
  101675. /**
  101676. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101677. * @returns the transform matrix of the texture.
  101678. */
  101679. getTextureMatrix(uBase?: number): Matrix;
  101680. /**
  101681. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101682. * @returns The reflection texture transform
  101683. */
  101684. getReflectionTextureMatrix(): Matrix;
  101685. /**
  101686. * Clones the texture.
  101687. * @returns the cloned texture
  101688. */
  101689. clone(): Texture;
  101690. /**
  101691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101692. * @returns The JSON representation of the texture
  101693. */
  101694. serialize(): any;
  101695. /**
  101696. * Get the current class name of the texture useful for serialization or dynamic coding.
  101697. * @returns "Texture"
  101698. */
  101699. getClassName(): string;
  101700. /**
  101701. * Dispose the texture and release its associated resources.
  101702. */
  101703. dispose(): void;
  101704. /**
  101705. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101706. * @param parsedTexture Define the JSON representation of the texture
  101707. * @param scene Define the scene the parsed texture should be instantiated in
  101708. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101709. * @returns The parsed texture if successful
  101710. */
  101711. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101712. /**
  101713. * Creates a texture from its base 64 representation.
  101714. * @param data Define the base64 payload without the data: prefix
  101715. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101716. * @param scene Define the scene the texture should belong to
  101717. * @param noMipmap Forces the texture to not create mip map information if true
  101718. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101719. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101720. * @param onLoad define a callback triggered when the texture has been loaded
  101721. * @param onError define a callback triggered when an error occurred during the loading session
  101722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101723. * @returns the created texture
  101724. */
  101725. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101726. /**
  101727. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101728. * @param data Define the base64 payload without the data: prefix
  101729. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101730. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101731. * @param scene Define the scene the texture should belong to
  101732. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101733. * @param noMipmap Forces the texture to not create mip map information if true
  101734. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101735. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101736. * @param onLoad define a callback triggered when the texture has been loaded
  101737. * @param onError define a callback triggered when an error occurred during the loading session
  101738. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101739. * @returns the created texture
  101740. */
  101741. 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;
  101742. }
  101743. }
  101744. declare module BABYLON {
  101745. /**
  101746. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101747. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101748. */
  101749. export class PostProcessManager {
  101750. private _scene;
  101751. private _indexBuffer;
  101752. private _vertexBuffers;
  101753. /**
  101754. * Creates a new instance PostProcess
  101755. * @param scene The scene that the post process is associated with.
  101756. */
  101757. constructor(scene: Scene);
  101758. private _prepareBuffers;
  101759. private _buildIndexBuffer;
  101760. /**
  101761. * Rebuilds the vertex buffers of the manager.
  101762. * @hidden
  101763. */
  101764. _rebuild(): void;
  101765. /**
  101766. * Prepares a frame to be run through a post process.
  101767. * @param sourceTexture The input texture to the post procesess. (default: null)
  101768. * @param postProcesses An array of post processes to be run. (default: null)
  101769. * @returns True if the post processes were able to be run.
  101770. * @hidden
  101771. */
  101772. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101773. /**
  101774. * Manually render a set of post processes to a texture.
  101775. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101776. * @param postProcesses An array of post processes to be run.
  101777. * @param targetTexture The target texture to render to.
  101778. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101779. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101780. * @param lodLevel defines which lod of the texture to render to
  101781. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101782. */
  101783. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101784. /**
  101785. * Finalize the result of the output of the postprocesses.
  101786. * @param doNotPresent If true the result will not be displayed to the screen.
  101787. * @param targetTexture The target texture to render to.
  101788. * @param faceIndex The index of the face to bind the target texture to.
  101789. * @param postProcesses The array of post processes to render.
  101790. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101791. * @hidden
  101792. */
  101793. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101794. /**
  101795. * Disposes of the post process manager.
  101796. */
  101797. dispose(): void;
  101798. }
  101799. }
  101800. declare module BABYLON {
  101801. /**
  101802. * This Helps creating a texture that will be created from a camera in your scene.
  101803. * It is basically a dynamic texture that could be used to create special effects for instance.
  101804. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101805. */
  101806. export class RenderTargetTexture extends Texture {
  101807. isCube: boolean;
  101808. /**
  101809. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101810. */
  101811. static readonly REFRESHRATE_RENDER_ONCE: number;
  101812. /**
  101813. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101814. */
  101815. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101816. /**
  101817. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101818. * the central point of your effect and can save a lot of performances.
  101819. */
  101820. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101821. /**
  101822. * Use this predicate to dynamically define the list of mesh you want to render.
  101823. * If set, the renderList property will be overwritten.
  101824. */
  101825. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101826. private _renderList;
  101827. /**
  101828. * Use this list to define the list of mesh you want to render.
  101829. */
  101830. get renderList(): Nullable<Array<AbstractMesh>>;
  101831. set renderList(value: Nullable<Array<AbstractMesh>>);
  101832. /**
  101833. * Use this function to overload the renderList array at rendering time.
  101834. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101835. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101836. * the cube (if the RTT is a cube, else layerOrFace=0).
  101837. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101838. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101839. * hold dummy elements!
  101840. */
  101841. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101842. private _hookArray;
  101843. /**
  101844. * Define if particles should be rendered in your texture.
  101845. */
  101846. renderParticles: boolean;
  101847. /**
  101848. * Define if sprites should be rendered in your texture.
  101849. */
  101850. renderSprites: boolean;
  101851. /**
  101852. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101853. */
  101854. coordinatesMode: number;
  101855. /**
  101856. * Define the camera used to render the texture.
  101857. */
  101858. activeCamera: Nullable<Camera>;
  101859. /**
  101860. * Override the mesh isReady function with your own one.
  101861. */
  101862. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101863. /**
  101864. * Override the render function of the texture with your own one.
  101865. */
  101866. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101867. /**
  101868. * Define if camera post processes should be use while rendering the texture.
  101869. */
  101870. useCameraPostProcesses: boolean;
  101871. /**
  101872. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101873. */
  101874. ignoreCameraViewport: boolean;
  101875. private _postProcessManager;
  101876. private _postProcesses;
  101877. private _resizeObserver;
  101878. /**
  101879. * An event triggered when the texture is unbind.
  101880. */
  101881. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101882. /**
  101883. * An event triggered when the texture is unbind.
  101884. */
  101885. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101886. private _onAfterUnbindObserver;
  101887. /**
  101888. * Set a after unbind callback in the texture.
  101889. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101890. */
  101891. set onAfterUnbind(callback: () => void);
  101892. /**
  101893. * An event triggered before rendering the texture
  101894. */
  101895. onBeforeRenderObservable: Observable<number>;
  101896. private _onBeforeRenderObserver;
  101897. /**
  101898. * Set a before render callback in the texture.
  101899. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101900. */
  101901. set onBeforeRender(callback: (faceIndex: number) => void);
  101902. /**
  101903. * An event triggered after rendering the texture
  101904. */
  101905. onAfterRenderObservable: Observable<number>;
  101906. private _onAfterRenderObserver;
  101907. /**
  101908. * Set a after render callback in the texture.
  101909. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101910. */
  101911. set onAfterRender(callback: (faceIndex: number) => void);
  101912. /**
  101913. * An event triggered after the texture clear
  101914. */
  101915. onClearObservable: Observable<Engine>;
  101916. private _onClearObserver;
  101917. /**
  101918. * Set a clear callback in the texture.
  101919. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101920. */
  101921. set onClear(callback: (Engine: Engine) => void);
  101922. /**
  101923. * An event triggered when the texture is resized.
  101924. */
  101925. onResizeObservable: Observable<RenderTargetTexture>;
  101926. /**
  101927. * Define the clear color of the Render Target if it should be different from the scene.
  101928. */
  101929. clearColor: Color4;
  101930. protected _size: number | {
  101931. width: number;
  101932. height: number;
  101933. layers?: number;
  101934. };
  101935. protected _initialSizeParameter: number | {
  101936. width: number;
  101937. height: number;
  101938. } | {
  101939. ratio: number;
  101940. };
  101941. protected _sizeRatio: Nullable<number>;
  101942. /** @hidden */
  101943. _generateMipMaps: boolean;
  101944. protected _renderingManager: RenderingManager;
  101945. /** @hidden */
  101946. _waitingRenderList: string[];
  101947. protected _doNotChangeAspectRatio: boolean;
  101948. protected _currentRefreshId: number;
  101949. protected _refreshRate: number;
  101950. protected _textureMatrix: Matrix;
  101951. protected _samples: number;
  101952. protected _renderTargetOptions: RenderTargetCreationOptions;
  101953. /**
  101954. * Gets render target creation options that were used.
  101955. */
  101956. get renderTargetOptions(): RenderTargetCreationOptions;
  101957. protected _onRatioRescale(): void;
  101958. /**
  101959. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101960. * It must define where the camera used to render the texture is set
  101961. */
  101962. boundingBoxPosition: Vector3;
  101963. private _boundingBoxSize;
  101964. /**
  101965. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101966. * When defined, the cubemap will switch to local mode
  101967. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101968. * @example https://www.babylonjs-playground.com/#RNASML
  101969. */
  101970. set boundingBoxSize(value: Vector3);
  101971. get boundingBoxSize(): Vector3;
  101972. /**
  101973. * In case the RTT has been created with a depth texture, get the associated
  101974. * depth texture.
  101975. * Otherwise, return null.
  101976. */
  101977. get depthStencilTexture(): Nullable<InternalTexture>;
  101978. /**
  101979. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101980. * or used a shadow, depth texture...
  101981. * @param name The friendly name of the texture
  101982. * @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)
  101983. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101984. * @param generateMipMaps True if mip maps need to be generated after render.
  101985. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101986. * @param type The type of the buffer in the RTT (int, half float, float...)
  101987. * @param isCube True if a cube texture needs to be created
  101988. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101989. * @param generateDepthBuffer True to generate a depth buffer
  101990. * @param generateStencilBuffer True to generate a stencil buffer
  101991. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101992. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101993. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101994. */
  101995. constructor(name: string, size: number | {
  101996. width: number;
  101997. height: number;
  101998. layers?: number;
  101999. } | {
  102000. ratio: number;
  102001. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102002. /**
  102003. * Creates a depth stencil texture.
  102004. * This is only available in WebGL 2 or with the depth texture extension available.
  102005. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102006. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102007. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102008. */
  102009. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102010. private _processSizeParameter;
  102011. /**
  102012. * Define the number of samples to use in case of MSAA.
  102013. * It defaults to one meaning no MSAA has been enabled.
  102014. */
  102015. get samples(): number;
  102016. set samples(value: number);
  102017. /**
  102018. * Resets the refresh counter of the texture and start bak from scratch.
  102019. * Could be useful to regenerate the texture if it is setup to render only once.
  102020. */
  102021. resetRefreshCounter(): void;
  102022. /**
  102023. * Define the refresh rate of the texture or the rendering frequency.
  102024. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102025. */
  102026. get refreshRate(): number;
  102027. set refreshRate(value: number);
  102028. /**
  102029. * Adds a post process to the render target rendering passes.
  102030. * @param postProcess define the post process to add
  102031. */
  102032. addPostProcess(postProcess: PostProcess): void;
  102033. /**
  102034. * Clear all the post processes attached to the render target
  102035. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102036. */
  102037. clearPostProcesses(dispose?: boolean): void;
  102038. /**
  102039. * Remove one of the post process from the list of attached post processes to the texture
  102040. * @param postProcess define the post process to remove from the list
  102041. */
  102042. removePostProcess(postProcess: PostProcess): void;
  102043. /** @hidden */
  102044. _shouldRender(): boolean;
  102045. /**
  102046. * Gets the actual render size of the texture.
  102047. * @returns the width of the render size
  102048. */
  102049. getRenderSize(): number;
  102050. /**
  102051. * Gets the actual render width of the texture.
  102052. * @returns the width of the render size
  102053. */
  102054. getRenderWidth(): number;
  102055. /**
  102056. * Gets the actual render height of the texture.
  102057. * @returns the height of the render size
  102058. */
  102059. getRenderHeight(): number;
  102060. /**
  102061. * Gets the actual number of layers of the texture.
  102062. * @returns the number of layers
  102063. */
  102064. getRenderLayers(): number;
  102065. /**
  102066. * Get if the texture can be rescaled or not.
  102067. */
  102068. get canRescale(): boolean;
  102069. /**
  102070. * Resize the texture using a ratio.
  102071. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102072. */
  102073. scale(ratio: number): void;
  102074. /**
  102075. * Get the texture reflection matrix used to rotate/transform the reflection.
  102076. * @returns the reflection matrix
  102077. */
  102078. getReflectionTextureMatrix(): Matrix;
  102079. /**
  102080. * Resize the texture to a new desired size.
  102081. * Be carrefull as it will recreate all the data in the new texture.
  102082. * @param size Define the new size. It can be:
  102083. * - a number for squared texture,
  102084. * - an object containing { width: number, height: number }
  102085. * - or an object containing a ratio { ratio: number }
  102086. */
  102087. resize(size: number | {
  102088. width: number;
  102089. height: number;
  102090. } | {
  102091. ratio: number;
  102092. }): void;
  102093. private _defaultRenderListPrepared;
  102094. /**
  102095. * Renders all the objects from the render list into the texture.
  102096. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102097. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102098. */
  102099. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102100. private _bestReflectionRenderTargetDimension;
  102101. private _prepareRenderingManager;
  102102. /**
  102103. * @hidden
  102104. * @param faceIndex face index to bind to if this is a cubetexture
  102105. * @param layer defines the index of the texture to bind in the array
  102106. */
  102107. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102108. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102109. private renderToTarget;
  102110. /**
  102111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102112. * This allowed control for front to back rendering or reversly depending of the special needs.
  102113. *
  102114. * @param renderingGroupId The rendering group id corresponding to its index
  102115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102118. */
  102119. 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;
  102120. /**
  102121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102122. *
  102123. * @param renderingGroupId The rendering group id corresponding to its index
  102124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102125. */
  102126. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102127. /**
  102128. * Clones the texture.
  102129. * @returns the cloned texture
  102130. */
  102131. clone(): RenderTargetTexture;
  102132. /**
  102133. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102134. * @returns The JSON representation of the texture
  102135. */
  102136. serialize(): any;
  102137. /**
  102138. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102139. */
  102140. disposeFramebufferObjects(): void;
  102141. /**
  102142. * Dispose the texture and release its associated resources.
  102143. */
  102144. dispose(): void;
  102145. /** @hidden */
  102146. _rebuild(): void;
  102147. /**
  102148. * Clear the info related to rendering groups preventing retention point in material dispose.
  102149. */
  102150. freeRenderingGroups(): void;
  102151. /**
  102152. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102153. * @returns the view count
  102154. */
  102155. getViewCount(): number;
  102156. }
  102157. }
  102158. declare module BABYLON {
  102159. /**
  102160. * Class used to manipulate GUIDs
  102161. */
  102162. export class GUID {
  102163. /**
  102164. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102165. * Be aware Math.random() could cause collisions, but:
  102166. * "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"
  102167. * @returns a pseudo random id
  102168. */
  102169. static RandomId(): string;
  102170. }
  102171. }
  102172. declare module BABYLON {
  102173. /**
  102174. * Options to be used when creating a shadow depth material
  102175. */
  102176. export interface IIOptionShadowDepthMaterial {
  102177. /** Variables in the vertex shader code that need to have their names remapped.
  102178. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102179. * "var_name" should be either: worldPos or vNormalW
  102180. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102181. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102182. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102183. */
  102184. remappedVariables?: string[];
  102185. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102186. standalone?: boolean;
  102187. }
  102188. /**
  102189. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102190. */
  102191. export class ShadowDepthWrapper {
  102192. private _scene;
  102193. private _options?;
  102194. private _baseMaterial;
  102195. private _onEffectCreatedObserver;
  102196. private _subMeshToEffect;
  102197. private _subMeshToDepthEffect;
  102198. private _meshes;
  102199. /** @hidden */
  102200. _matriceNames: any;
  102201. /** Gets the standalone status of the wrapper */
  102202. get standalone(): boolean;
  102203. /** Gets the base material the wrapper is built upon */
  102204. get baseMaterial(): Material;
  102205. /**
  102206. * Instantiate a new shadow depth wrapper.
  102207. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102208. * generate the shadow depth map. For more information, please refer to the documentation:
  102209. * https://doc.babylonjs.com/babylon101/shadows
  102210. * @param baseMaterial Material to wrap
  102211. * @param scene Define the scene the material belongs to
  102212. * @param options Options used to create the wrapper
  102213. */
  102214. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102215. /**
  102216. * Gets the effect to use to generate the depth map
  102217. * @param subMesh subMesh to get the effect for
  102218. * @param shadowGenerator shadow generator to get the effect for
  102219. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102220. */
  102221. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102222. /**
  102223. * Specifies that the submesh is ready to be used for depth rendering
  102224. * @param subMesh submesh to check
  102225. * @param defines the list of defines to take into account when checking the effect
  102226. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102227. * @param useInstances specifies that instances should be used
  102228. * @returns a boolean indicating that the submesh is ready or not
  102229. */
  102230. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102231. /**
  102232. * Disposes the resources
  102233. */
  102234. dispose(): void;
  102235. private _makeEffect;
  102236. }
  102237. }
  102238. declare module BABYLON {
  102239. interface ThinEngine {
  102240. /**
  102241. * Unbind a list of render target textures from the webGL context
  102242. * This is used only when drawBuffer extension or webGL2 are active
  102243. * @param textures defines the render target textures to unbind
  102244. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102245. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102246. */
  102247. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102248. /**
  102249. * Create a multi render target texture
  102250. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102251. * @param size defines the size of the texture
  102252. * @param options defines the creation options
  102253. * @returns the cube texture as an InternalTexture
  102254. */
  102255. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102256. /**
  102257. * Update the sample count for a given multiple render target texture
  102258. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102259. * @param textures defines the textures to update
  102260. * @param samples defines the sample count to set
  102261. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102262. */
  102263. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102264. /**
  102265. * Select a subsets of attachments to draw to.
  102266. * @param attachments gl attachments
  102267. */
  102268. bindAttachments(attachments: number[]): void;
  102269. }
  102270. }
  102271. declare module BABYLON {
  102272. /**
  102273. * Creation options of the multi render target texture.
  102274. */
  102275. export interface IMultiRenderTargetOptions {
  102276. /**
  102277. * Define if the texture needs to create mip maps after render.
  102278. */
  102279. generateMipMaps?: boolean;
  102280. /**
  102281. * Define the types of all the draw buffers we want to create
  102282. */
  102283. types?: number[];
  102284. /**
  102285. * Define the sampling modes of all the draw buffers we want to create
  102286. */
  102287. samplingModes?: number[];
  102288. /**
  102289. * Define if a depth buffer is required
  102290. */
  102291. generateDepthBuffer?: boolean;
  102292. /**
  102293. * Define if a stencil buffer is required
  102294. */
  102295. generateStencilBuffer?: boolean;
  102296. /**
  102297. * Define if a depth texture is required instead of a depth buffer
  102298. */
  102299. generateDepthTexture?: boolean;
  102300. /**
  102301. * Define the number of desired draw buffers
  102302. */
  102303. textureCount?: number;
  102304. /**
  102305. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102306. */
  102307. doNotChangeAspectRatio?: boolean;
  102308. /**
  102309. * Define the default type of the buffers we are creating
  102310. */
  102311. defaultType?: number;
  102312. }
  102313. /**
  102314. * A multi render target, like a render target provides the ability to render to a texture.
  102315. * Unlike the render target, it can render to several draw buffers in one draw.
  102316. * This is specially interesting in deferred rendering or for any effects requiring more than
  102317. * just one color from a single pass.
  102318. */
  102319. export class MultiRenderTarget extends RenderTargetTexture {
  102320. private _internalTextures;
  102321. private _textures;
  102322. private _multiRenderTargetOptions;
  102323. private _count;
  102324. /**
  102325. * Get if draw buffers are currently supported by the used hardware and browser.
  102326. */
  102327. get isSupported(): boolean;
  102328. /**
  102329. * Get the list of textures generated by the multi render target.
  102330. */
  102331. get textures(): Texture[];
  102332. /**
  102333. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102334. */
  102335. get count(): number;
  102336. /**
  102337. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102338. */
  102339. get depthTexture(): Texture;
  102340. /**
  102341. * Set the wrapping mode on U of all the textures we are rendering to.
  102342. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102343. */
  102344. set wrapU(wrap: number);
  102345. /**
  102346. * Set the wrapping mode on V of all the textures we are rendering to.
  102347. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102348. */
  102349. set wrapV(wrap: number);
  102350. /**
  102351. * Instantiate a new multi render target texture.
  102352. * A multi render target, like a render target provides the ability to render to a texture.
  102353. * Unlike the render target, it can render to several draw buffers in one draw.
  102354. * This is specially interesting in deferred rendering or for any effects requiring more than
  102355. * just one color from a single pass.
  102356. * @param name Define the name of the texture
  102357. * @param size Define the size of the buffers to render to
  102358. * @param count Define the number of target we are rendering into
  102359. * @param scene Define the scene the texture belongs to
  102360. * @param options Define the options used to create the multi render target
  102361. */
  102362. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102363. /** @hidden */
  102364. _rebuild(): void;
  102365. private _createInternalTextures;
  102366. private _createTextures;
  102367. /**
  102368. * Define the number of samples used if MSAA is enabled.
  102369. */
  102370. get samples(): number;
  102371. set samples(value: number);
  102372. /**
  102373. * Resize all the textures in the multi render target.
  102374. * Be carrefull as it will recreate all the data in the new texture.
  102375. * @param size Define the new size
  102376. */
  102377. resize(size: any): void;
  102378. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102379. /**
  102380. * Dispose the render targets and their associated resources
  102381. */
  102382. dispose(): void;
  102383. /**
  102384. * Release all the underlying texture used as draw buffers.
  102385. */
  102386. releaseInternalTextures(): void;
  102387. }
  102388. }
  102389. declare module BABYLON {
  102390. /** @hidden */
  102391. export var imageProcessingPixelShader: {
  102392. name: string;
  102393. shader: string;
  102394. };
  102395. }
  102396. declare module BABYLON {
  102397. /**
  102398. * ImageProcessingPostProcess
  102399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102400. */
  102401. export class ImageProcessingPostProcess extends PostProcess {
  102402. /**
  102403. * Default configuration related to image processing available in the PBR Material.
  102404. */
  102405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102406. /**
  102407. * Gets the image processing configuration used either in this material.
  102408. */
  102409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102410. /**
  102411. * Sets the Default image processing configuration used either in the this material.
  102412. *
  102413. * If sets to null, the scene one is in use.
  102414. */
  102415. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102416. /**
  102417. * Keep track of the image processing observer to allow dispose and replace.
  102418. */
  102419. private _imageProcessingObserver;
  102420. /**
  102421. * Attaches a new image processing configuration to the PBR Material.
  102422. * @param configuration
  102423. */
  102424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102425. /**
  102426. * If the post process is supported.
  102427. */
  102428. get isSupported(): boolean;
  102429. /**
  102430. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102431. */
  102432. get colorCurves(): Nullable<ColorCurves>;
  102433. /**
  102434. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102435. */
  102436. set colorCurves(value: Nullable<ColorCurves>);
  102437. /**
  102438. * Gets wether the color curves effect is enabled.
  102439. */
  102440. get colorCurvesEnabled(): boolean;
  102441. /**
  102442. * Sets wether the color curves effect is enabled.
  102443. */
  102444. set colorCurvesEnabled(value: boolean);
  102445. /**
  102446. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102447. */
  102448. get colorGradingTexture(): Nullable<BaseTexture>;
  102449. /**
  102450. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102451. */
  102452. set colorGradingTexture(value: Nullable<BaseTexture>);
  102453. /**
  102454. * Gets wether the color grading effect is enabled.
  102455. */
  102456. get colorGradingEnabled(): boolean;
  102457. /**
  102458. * Gets wether the color grading effect is enabled.
  102459. */
  102460. set colorGradingEnabled(value: boolean);
  102461. /**
  102462. * Gets exposure used in the effect.
  102463. */
  102464. get exposure(): number;
  102465. /**
  102466. * Sets exposure used in the effect.
  102467. */
  102468. set exposure(value: number);
  102469. /**
  102470. * Gets wether tonemapping is enabled or not.
  102471. */
  102472. get toneMappingEnabled(): boolean;
  102473. /**
  102474. * Sets wether tonemapping is enabled or not
  102475. */
  102476. set toneMappingEnabled(value: boolean);
  102477. /**
  102478. * Gets the type of tone mapping effect.
  102479. */
  102480. get toneMappingType(): number;
  102481. /**
  102482. * Sets the type of tone mapping effect.
  102483. */
  102484. set toneMappingType(value: number);
  102485. /**
  102486. * Gets contrast used in the effect.
  102487. */
  102488. get contrast(): number;
  102489. /**
  102490. * Sets contrast used in the effect.
  102491. */
  102492. set contrast(value: number);
  102493. /**
  102494. * Gets Vignette stretch size.
  102495. */
  102496. get vignetteStretch(): number;
  102497. /**
  102498. * Sets Vignette stretch size.
  102499. */
  102500. set vignetteStretch(value: number);
  102501. /**
  102502. * Gets Vignette centre X Offset.
  102503. */
  102504. get vignetteCentreX(): number;
  102505. /**
  102506. * Sets Vignette centre X Offset.
  102507. */
  102508. set vignetteCentreX(value: number);
  102509. /**
  102510. * Gets Vignette centre Y Offset.
  102511. */
  102512. get vignetteCentreY(): number;
  102513. /**
  102514. * Sets Vignette centre Y Offset.
  102515. */
  102516. set vignetteCentreY(value: number);
  102517. /**
  102518. * Gets Vignette weight or intensity of the vignette effect.
  102519. */
  102520. get vignetteWeight(): number;
  102521. /**
  102522. * Sets Vignette weight or intensity of the vignette effect.
  102523. */
  102524. set vignetteWeight(value: number);
  102525. /**
  102526. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102527. * if vignetteEnabled is set to true.
  102528. */
  102529. get vignetteColor(): Color4;
  102530. /**
  102531. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102532. * if vignetteEnabled is set to true.
  102533. */
  102534. set vignetteColor(value: Color4);
  102535. /**
  102536. * Gets Camera field of view used by the Vignette effect.
  102537. */
  102538. get vignetteCameraFov(): number;
  102539. /**
  102540. * Sets Camera field of view used by the Vignette effect.
  102541. */
  102542. set vignetteCameraFov(value: number);
  102543. /**
  102544. * Gets the vignette blend mode allowing different kind of effect.
  102545. */
  102546. get vignetteBlendMode(): number;
  102547. /**
  102548. * Sets the vignette blend mode allowing different kind of effect.
  102549. */
  102550. set vignetteBlendMode(value: number);
  102551. /**
  102552. * Gets wether the vignette effect is enabled.
  102553. */
  102554. get vignetteEnabled(): boolean;
  102555. /**
  102556. * Sets wether the vignette effect is enabled.
  102557. */
  102558. set vignetteEnabled(value: boolean);
  102559. private _fromLinearSpace;
  102560. /**
  102561. * Gets wether the input of the processing is in Gamma or Linear Space.
  102562. */
  102563. get fromLinearSpace(): boolean;
  102564. /**
  102565. * Sets wether the input of the processing is in Gamma or Linear Space.
  102566. */
  102567. set fromLinearSpace(value: boolean);
  102568. /**
  102569. * Defines cache preventing GC.
  102570. */
  102571. private _defines;
  102572. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102573. /**
  102574. * "ImageProcessingPostProcess"
  102575. * @returns "ImageProcessingPostProcess"
  102576. */
  102577. getClassName(): string;
  102578. /**
  102579. * @hidden
  102580. */
  102581. _updateParameters(): void;
  102582. dispose(camera?: Camera): void;
  102583. }
  102584. }
  102585. declare module BABYLON {
  102586. /** @hidden */
  102587. export var fibonacci: {
  102588. name: string;
  102589. shader: string;
  102590. };
  102591. }
  102592. declare module BABYLON {
  102593. /** @hidden */
  102594. export var subSurfaceScatteringFunctions: {
  102595. name: string;
  102596. shader: string;
  102597. };
  102598. }
  102599. declare module BABYLON {
  102600. /** @hidden */
  102601. export var diffusionProfile: {
  102602. name: string;
  102603. shader: string;
  102604. };
  102605. }
  102606. declare module BABYLON {
  102607. /** @hidden */
  102608. export var subSurfaceScatteringPixelShader: {
  102609. name: string;
  102610. shader: string;
  102611. };
  102612. }
  102613. declare module BABYLON {
  102614. /**
  102615. * Sub surface scattering post process
  102616. */
  102617. export class SubSurfaceScatteringPostProcess extends PostProcess {
  102618. /** @hidden */
  102619. texelWidth: number;
  102620. /** @hidden */
  102621. texelHeight: number;
  102622. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  102623. }
  102624. }
  102625. declare module BABYLON {
  102626. /**
  102627. * Interface for defining prepass effects in the prepass post-process pipeline
  102628. */
  102629. export interface PrePassEffectConfiguration {
  102630. /**
  102631. * Post process to attach for this effect
  102632. */
  102633. postProcess: PostProcess;
  102634. /**
  102635. * Is the effect enabled
  102636. */
  102637. enabled: boolean;
  102638. /**
  102639. * Disposes the effect configuration
  102640. */
  102641. dispose(): void;
  102642. /**
  102643. * Disposes the effect configuration
  102644. */
  102645. createPostProcess: () => PostProcess;
  102646. }
  102647. }
  102648. declare module BABYLON {
  102649. /**
  102650. * Contains all parameters needed for the prepass to perform
  102651. * screen space subsurface scattering
  102652. */
  102653. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  102654. private _ssDiffusionS;
  102655. private _ssFilterRadii;
  102656. private _ssDiffusionD;
  102657. /**
  102658. * Post process to attach for screen space subsurface scattering
  102659. */
  102660. postProcess: SubSurfaceScatteringPostProcess;
  102661. /**
  102662. * Diffusion profile color for subsurface scattering
  102663. */
  102664. get ssDiffusionS(): number[];
  102665. /**
  102666. * Diffusion profile max color channel value for subsurface scattering
  102667. */
  102668. get ssDiffusionD(): number[];
  102669. /**
  102670. * Diffusion profile filter radius for subsurface scattering
  102671. */
  102672. get ssFilterRadii(): number[];
  102673. /**
  102674. * Is subsurface enabled
  102675. */
  102676. enabled: boolean;
  102677. /**
  102678. * Diffusion profile colors for subsurface scattering
  102679. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  102680. * See ...
  102681. * Note that you can only store up to 5 of them
  102682. */
  102683. ssDiffusionProfileColors: Color3[];
  102684. /**
  102685. * Defines the ratio real world => scene units.
  102686. * Used for subsurface scattering
  102687. */
  102688. metersPerUnit: number;
  102689. private _scene;
  102690. /**
  102691. * Builds a subsurface configuration object
  102692. * @param scene The scene
  102693. */
  102694. constructor(scene: Scene);
  102695. /**
  102696. * Adds a new diffusion profile.
  102697. * Useful for more realistic subsurface scattering on diverse materials.
  102698. * @param color The color of the diffusion profile. Should be the average color of the material.
  102699. * @return The index of the diffusion profile for the material subsurface configuration
  102700. */
  102701. addDiffusionProfile(color: Color3): number;
  102702. /**
  102703. * Creates the sss post process
  102704. * @return The created post process
  102705. */
  102706. createPostProcess(): SubSurfaceScatteringPostProcess;
  102707. /**
  102708. * Deletes all diffusion profiles.
  102709. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  102710. */
  102711. clearAllDiffusionProfiles(): void;
  102712. /**
  102713. * Disposes this object
  102714. */
  102715. dispose(): void;
  102716. /**
  102717. * @hidden
  102718. * https://zero-radiance.github.io/post/sampling-diffusion/
  102719. *
  102720. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  102721. * ------------------------------------------------------------------------------------
  102722. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  102723. * PDF[r, phi, s] = r * R[r, phi, s]
  102724. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  102725. * ------------------------------------------------------------------------------------
  102726. * We importance sample the color channel with the widest scattering distance.
  102727. */
  102728. getDiffusionProfileParameters(color: Color3): number;
  102729. /**
  102730. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  102731. * 'u' is the random number (the value of the CDF): [0, 1).
  102732. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  102733. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  102734. */
  102735. private _sampleBurleyDiffusionProfile;
  102736. }
  102737. }
  102738. declare module BABYLON {
  102739. /**
  102740. * Renders a pre pass of the scene
  102741. * This means every mesh in the scene will be rendered to a render target texture
  102742. * And then this texture will be composited to the rendering canvas with post processes
  102743. * It is necessary for effects like subsurface scattering or deferred shading
  102744. */
  102745. export class PrePassRenderer {
  102746. /** @hidden */
  102747. static _SceneComponentInitialization: (scene: Scene) => void;
  102748. private _scene;
  102749. private _engine;
  102750. private _isDirty;
  102751. /**
  102752. * Number of textures in the multi render target texture where the scene is directly rendered
  102753. */
  102754. readonly mrtCount: number;
  102755. /**
  102756. * The render target where the scene is directly rendered
  102757. */
  102758. prePassRT: MultiRenderTarget;
  102759. private _mrtTypes;
  102760. private _multiRenderAttachments;
  102761. private _defaultAttachments;
  102762. private _clearAttachments;
  102763. private _postProcesses;
  102764. private readonly _clearColor;
  102765. /**
  102766. * Image processing post process for composition
  102767. */
  102768. imageProcessingPostProcess: ImageProcessingPostProcess;
  102769. /**
  102770. * Configuration for sub surface scattering post process
  102771. */
  102772. subSurfaceConfiguration: SubSurfaceConfiguration;
  102773. /**
  102774. * Should materials render their geometry on the MRT
  102775. */
  102776. materialsShouldRenderGeometry: boolean;
  102777. /**
  102778. * Should materials render the irradiance information on the MRT
  102779. */
  102780. materialsShouldRenderIrradiance: boolean;
  102781. private _enabled;
  102782. /**
  102783. * Indicates if the prepass is enabled
  102784. */
  102785. get enabled(): boolean;
  102786. /**
  102787. * How many samples are used for MSAA of the scene render target
  102788. */
  102789. get samples(): number;
  102790. set samples(n: number);
  102791. /**
  102792. * Instanciates a prepass renderer
  102793. * @param scene The scene
  102794. */
  102795. constructor(scene: Scene);
  102796. private _initializeAttachments;
  102797. private _createCompositionEffect;
  102798. /**
  102799. * Indicates if rendering a prepass is supported
  102800. */
  102801. get isSupported(): boolean;
  102802. /**
  102803. * Sets the proper output textures to draw in the engine.
  102804. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  102805. */
  102806. bindAttachmentsForEffect(effect: Effect): void;
  102807. /**
  102808. * @hidden
  102809. */
  102810. _beforeCameraDraw(): void;
  102811. /**
  102812. * @hidden
  102813. */
  102814. _afterCameraDraw(): void;
  102815. private _checkRTSize;
  102816. private _bindFrameBuffer;
  102817. /**
  102818. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  102819. */
  102820. clear(): void;
  102821. private _setState;
  102822. private _enable;
  102823. private _disable;
  102824. private _resetPostProcessChain;
  102825. private _bindPostProcessChain;
  102826. /**
  102827. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  102828. */
  102829. markAsDirty(): void;
  102830. private _update;
  102831. /**
  102832. * Disposes the prepass renderer.
  102833. */
  102834. dispose(): void;
  102835. }
  102836. }
  102837. declare module BABYLON {
  102838. /**
  102839. * Options for compiling materials.
  102840. */
  102841. export interface IMaterialCompilationOptions {
  102842. /**
  102843. * Defines whether clip planes are enabled.
  102844. */
  102845. clipPlane: boolean;
  102846. /**
  102847. * Defines whether instances are enabled.
  102848. */
  102849. useInstances: boolean;
  102850. }
  102851. /**
  102852. * Options passed when calling customShaderNameResolve
  102853. */
  102854. export interface ICustomShaderNameResolveOptions {
  102855. /**
  102856. * 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
  102857. */
  102858. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  102859. }
  102860. /**
  102861. * Base class for the main features of a material in Babylon.js
  102862. */
  102863. export class Material implements IAnimatable {
  102864. /**
  102865. * Returns the triangle fill mode
  102866. */
  102867. static readonly TriangleFillMode: number;
  102868. /**
  102869. * Returns the wireframe mode
  102870. */
  102871. static readonly WireFrameFillMode: number;
  102872. /**
  102873. * Returns the point fill mode
  102874. */
  102875. static readonly PointFillMode: number;
  102876. /**
  102877. * Returns the point list draw mode
  102878. */
  102879. static readonly PointListDrawMode: number;
  102880. /**
  102881. * Returns the line list draw mode
  102882. */
  102883. static readonly LineListDrawMode: number;
  102884. /**
  102885. * Returns the line loop draw mode
  102886. */
  102887. static readonly LineLoopDrawMode: number;
  102888. /**
  102889. * Returns the line strip draw mode
  102890. */
  102891. static readonly LineStripDrawMode: number;
  102892. /**
  102893. * Returns the triangle strip draw mode
  102894. */
  102895. static readonly TriangleStripDrawMode: number;
  102896. /**
  102897. * Returns the triangle fan draw mode
  102898. */
  102899. static readonly TriangleFanDrawMode: number;
  102900. /**
  102901. * Stores the clock-wise side orientation
  102902. */
  102903. static readonly ClockWiseSideOrientation: number;
  102904. /**
  102905. * Stores the counter clock-wise side orientation
  102906. */
  102907. static readonly CounterClockWiseSideOrientation: number;
  102908. /**
  102909. * The dirty texture flag value
  102910. */
  102911. static readonly TextureDirtyFlag: number;
  102912. /**
  102913. * The dirty light flag value
  102914. */
  102915. static readonly LightDirtyFlag: number;
  102916. /**
  102917. * The dirty fresnel flag value
  102918. */
  102919. static readonly FresnelDirtyFlag: number;
  102920. /**
  102921. * The dirty attribute flag value
  102922. */
  102923. static readonly AttributesDirtyFlag: number;
  102924. /**
  102925. * The dirty misc flag value
  102926. */
  102927. static readonly MiscDirtyFlag: number;
  102928. /**
  102929. * The all dirty flag value
  102930. */
  102931. static readonly AllDirtyFlag: number;
  102932. /**
  102933. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102934. */
  102935. static readonly MATERIAL_OPAQUE: number;
  102936. /**
  102937. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102938. */
  102939. static readonly MATERIAL_ALPHATEST: number;
  102940. /**
  102941. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102942. */
  102943. static readonly MATERIAL_ALPHABLEND: number;
  102944. /**
  102945. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102946. * They are also discarded below the alpha cutoff threshold to improve performances.
  102947. */
  102948. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  102949. /**
  102950. * The Whiteout method is used to blend normals.
  102951. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  102952. */
  102953. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  102954. /**
  102955. * The Reoriented Normal Mapping method is used to blend normals.
  102956. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  102957. */
  102958. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  102959. /**
  102960. * Custom callback helping to override the default shader used in the material.
  102961. */
  102962. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  102963. /**
  102964. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  102965. */
  102966. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  102967. /**
  102968. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  102969. * This means that the material can keep using a previous shader while a new one is being compiled.
  102970. * This is mostly used when shader parallel compilation is supported (true by default)
  102971. */
  102972. allowShaderHotSwapping: boolean;
  102973. /**
  102974. * The ID of the material
  102975. */
  102976. id: string;
  102977. /**
  102978. * Gets or sets the unique id of the material
  102979. */
  102980. uniqueId: number;
  102981. /**
  102982. * The name of the material
  102983. */
  102984. name: string;
  102985. /**
  102986. * Gets or sets user defined metadata
  102987. */
  102988. metadata: any;
  102989. /**
  102990. * For internal use only. Please do not use.
  102991. */
  102992. reservedDataStore: any;
  102993. /**
  102994. * Specifies if the ready state should be checked on each call
  102995. */
  102996. checkReadyOnEveryCall: boolean;
  102997. /**
  102998. * Specifies if the ready state should be checked once
  102999. */
  103000. checkReadyOnlyOnce: boolean;
  103001. /**
  103002. * The state of the material
  103003. */
  103004. state: string;
  103005. /**
  103006. * If the material can be rendered to several textures with MRT extension
  103007. */
  103008. get canRenderToMRT(): boolean;
  103009. /**
  103010. * The alpha value of the material
  103011. */
  103012. protected _alpha: number;
  103013. /**
  103014. * List of inspectable custom properties (used by the Inspector)
  103015. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103016. */
  103017. inspectableCustomProperties: IInspectable[];
  103018. /**
  103019. * Sets the alpha value of the material
  103020. */
  103021. set alpha(value: number);
  103022. /**
  103023. * Gets the alpha value of the material
  103024. */
  103025. get alpha(): number;
  103026. /**
  103027. * Specifies if back face culling is enabled
  103028. */
  103029. protected _backFaceCulling: boolean;
  103030. /**
  103031. * Sets the back-face culling state
  103032. */
  103033. set backFaceCulling(value: boolean);
  103034. /**
  103035. * Gets the back-face culling state
  103036. */
  103037. get backFaceCulling(): boolean;
  103038. /**
  103039. * Stores the value for side orientation
  103040. */
  103041. sideOrientation: number;
  103042. /**
  103043. * Callback triggered when the material is compiled
  103044. */
  103045. onCompiled: Nullable<(effect: Effect) => void>;
  103046. /**
  103047. * Callback triggered when an error occurs
  103048. */
  103049. onError: Nullable<(effect: Effect, errors: string) => void>;
  103050. /**
  103051. * Callback triggered to get the render target textures
  103052. */
  103053. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103054. /**
  103055. * Gets a boolean indicating that current material needs to register RTT
  103056. */
  103057. get hasRenderTargetTextures(): boolean;
  103058. /**
  103059. * Specifies if the material should be serialized
  103060. */
  103061. doNotSerialize: boolean;
  103062. /**
  103063. * @hidden
  103064. */
  103065. _storeEffectOnSubMeshes: boolean;
  103066. /**
  103067. * Stores the animations for the material
  103068. */
  103069. animations: Nullable<Array<Animation>>;
  103070. /**
  103071. * An event triggered when the material is disposed
  103072. */
  103073. onDisposeObservable: Observable<Material>;
  103074. /**
  103075. * An observer which watches for dispose events
  103076. */
  103077. private _onDisposeObserver;
  103078. private _onUnBindObservable;
  103079. /**
  103080. * Called during a dispose event
  103081. */
  103082. set onDispose(callback: () => void);
  103083. private _onBindObservable;
  103084. /**
  103085. * An event triggered when the material is bound
  103086. */
  103087. get onBindObservable(): Observable<AbstractMesh>;
  103088. /**
  103089. * An observer which watches for bind events
  103090. */
  103091. private _onBindObserver;
  103092. /**
  103093. * Called during a bind event
  103094. */
  103095. set onBind(callback: (Mesh: AbstractMesh) => void);
  103096. /**
  103097. * An event triggered when the material is unbound
  103098. */
  103099. get onUnBindObservable(): Observable<Material>;
  103100. protected _onEffectCreatedObservable: Nullable<Observable<{
  103101. effect: Effect;
  103102. subMesh: Nullable<SubMesh>;
  103103. }>>;
  103104. /**
  103105. * An event triggered when the effect is (re)created
  103106. */
  103107. get onEffectCreatedObservable(): Observable<{
  103108. effect: Effect;
  103109. subMesh: Nullable<SubMesh>;
  103110. }>;
  103111. /**
  103112. * Stores the value of the alpha mode
  103113. */
  103114. private _alphaMode;
  103115. /**
  103116. * Sets the value of the alpha mode.
  103117. *
  103118. * | Value | Type | Description |
  103119. * | --- | --- | --- |
  103120. * | 0 | ALPHA_DISABLE | |
  103121. * | 1 | ALPHA_ADD | |
  103122. * | 2 | ALPHA_COMBINE | |
  103123. * | 3 | ALPHA_SUBTRACT | |
  103124. * | 4 | ALPHA_MULTIPLY | |
  103125. * | 5 | ALPHA_MAXIMIZED | |
  103126. * | 6 | ALPHA_ONEONE | |
  103127. * | 7 | ALPHA_PREMULTIPLIED | |
  103128. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103129. * | 9 | ALPHA_INTERPOLATE | |
  103130. * | 10 | ALPHA_SCREENMODE | |
  103131. *
  103132. */
  103133. set alphaMode(value: number);
  103134. /**
  103135. * Gets the value of the alpha mode
  103136. */
  103137. get alphaMode(): number;
  103138. /**
  103139. * Stores the state of the need depth pre-pass value
  103140. */
  103141. private _needDepthPrePass;
  103142. /**
  103143. * Sets the need depth pre-pass value
  103144. */
  103145. set needDepthPrePass(value: boolean);
  103146. /**
  103147. * Gets the depth pre-pass value
  103148. */
  103149. get needDepthPrePass(): boolean;
  103150. /**
  103151. * Specifies if depth writing should be disabled
  103152. */
  103153. disableDepthWrite: boolean;
  103154. /**
  103155. * Specifies if color writing should be disabled
  103156. */
  103157. disableColorWrite: boolean;
  103158. /**
  103159. * Specifies if depth writing should be forced
  103160. */
  103161. forceDepthWrite: boolean;
  103162. /**
  103163. * Specifies the depth function that should be used. 0 means the default engine function
  103164. */
  103165. depthFunction: number;
  103166. /**
  103167. * Specifies if there should be a separate pass for culling
  103168. */
  103169. separateCullingPass: boolean;
  103170. /**
  103171. * Stores the state specifing if fog should be enabled
  103172. */
  103173. private _fogEnabled;
  103174. /**
  103175. * Sets the state for enabling fog
  103176. */
  103177. set fogEnabled(value: boolean);
  103178. /**
  103179. * Gets the value of the fog enabled state
  103180. */
  103181. get fogEnabled(): boolean;
  103182. /**
  103183. * Stores the size of points
  103184. */
  103185. pointSize: number;
  103186. /**
  103187. * Stores the z offset value
  103188. */
  103189. zOffset: number;
  103190. get wireframe(): boolean;
  103191. /**
  103192. * Sets the state of wireframe mode
  103193. */
  103194. set wireframe(value: boolean);
  103195. /**
  103196. * Gets the value specifying if point clouds are enabled
  103197. */
  103198. get pointsCloud(): boolean;
  103199. /**
  103200. * Sets the state of point cloud mode
  103201. */
  103202. set pointsCloud(value: boolean);
  103203. /**
  103204. * Gets the material fill mode
  103205. */
  103206. get fillMode(): number;
  103207. /**
  103208. * Sets the material fill mode
  103209. */
  103210. set fillMode(value: number);
  103211. /**
  103212. * @hidden
  103213. * Stores the effects for the material
  103214. */
  103215. _effect: Nullable<Effect>;
  103216. /**
  103217. * Specifies if uniform buffers should be used
  103218. */
  103219. private _useUBO;
  103220. /**
  103221. * Stores a reference to the scene
  103222. */
  103223. private _scene;
  103224. /**
  103225. * Stores the fill mode state
  103226. */
  103227. private _fillMode;
  103228. /**
  103229. * Specifies if the depth write state should be cached
  103230. */
  103231. private _cachedDepthWriteState;
  103232. /**
  103233. * Specifies if the color write state should be cached
  103234. */
  103235. private _cachedColorWriteState;
  103236. /**
  103237. * Specifies if the depth function state should be cached
  103238. */
  103239. private _cachedDepthFunctionState;
  103240. /**
  103241. * Stores the uniform buffer
  103242. */
  103243. protected _uniformBuffer: UniformBuffer;
  103244. /** @hidden */
  103245. _indexInSceneMaterialArray: number;
  103246. /** @hidden */
  103247. meshMap: Nullable<{
  103248. [id: string]: AbstractMesh | undefined;
  103249. }>;
  103250. /**
  103251. * Creates a material instance
  103252. * @param name defines the name of the material
  103253. * @param scene defines the scene to reference
  103254. * @param doNotAdd specifies if the material should be added to the scene
  103255. */
  103256. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103257. /**
  103258. * Returns a string representation of the current material
  103259. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103260. * @returns a string with material information
  103261. */
  103262. toString(fullDetails?: boolean): string;
  103263. /**
  103264. * Gets the class name of the material
  103265. * @returns a string with the class name of the material
  103266. */
  103267. getClassName(): string;
  103268. /**
  103269. * Specifies if updates for the material been locked
  103270. */
  103271. get isFrozen(): boolean;
  103272. /**
  103273. * Locks updates for the material
  103274. */
  103275. freeze(): void;
  103276. /**
  103277. * Unlocks updates for the material
  103278. */
  103279. unfreeze(): void;
  103280. /**
  103281. * Specifies if the material is ready to be used
  103282. * @param mesh defines the mesh to check
  103283. * @param useInstances specifies if instances should be used
  103284. * @returns a boolean indicating if the material is ready to be used
  103285. */
  103286. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103287. /**
  103288. * Specifies that the submesh is ready to be used
  103289. * @param mesh defines the mesh to check
  103290. * @param subMesh defines which submesh to check
  103291. * @param useInstances specifies that instances should be used
  103292. * @returns a boolean indicating that the submesh is ready or not
  103293. */
  103294. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103295. /**
  103296. * Returns the material effect
  103297. * @returns the effect associated with the material
  103298. */
  103299. getEffect(): Nullable<Effect>;
  103300. /**
  103301. * Returns the current scene
  103302. * @returns a Scene
  103303. */
  103304. getScene(): Scene;
  103305. /**
  103306. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103307. */
  103308. protected _forceAlphaTest: boolean;
  103309. /**
  103310. * The transparency mode of the material.
  103311. */
  103312. protected _transparencyMode: Nullable<number>;
  103313. /**
  103314. * Gets the current transparency mode.
  103315. */
  103316. get transparencyMode(): Nullable<number>;
  103317. /**
  103318. * Sets the transparency mode of the material.
  103319. *
  103320. * | Value | Type | Description |
  103321. * | ----- | ----------------------------------- | ----------- |
  103322. * | 0 | OPAQUE | |
  103323. * | 1 | ALPHATEST | |
  103324. * | 2 | ALPHABLEND | |
  103325. * | 3 | ALPHATESTANDBLEND | |
  103326. *
  103327. */
  103328. set transparencyMode(value: Nullable<number>);
  103329. /**
  103330. * Returns true if alpha blending should be disabled.
  103331. */
  103332. protected get _disableAlphaBlending(): boolean;
  103333. /**
  103334. * Specifies whether or not this material should be rendered in alpha blend mode.
  103335. * @returns a boolean specifying if alpha blending is needed
  103336. */
  103337. needAlphaBlending(): boolean;
  103338. /**
  103339. * Specifies if the mesh will require alpha blending
  103340. * @param mesh defines the mesh to check
  103341. * @returns a boolean specifying if alpha blending is needed for the mesh
  103342. */
  103343. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103344. /**
  103345. * Specifies whether or not this material should be rendered in alpha test mode.
  103346. * @returns a boolean specifying if an alpha test is needed.
  103347. */
  103348. needAlphaTesting(): boolean;
  103349. /**
  103350. * Specifies if material alpha testing should be turned on for the mesh
  103351. * @param mesh defines the mesh to check
  103352. */
  103353. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103354. /**
  103355. * Gets the texture used for the alpha test
  103356. * @returns the texture to use for alpha testing
  103357. */
  103358. getAlphaTestTexture(): Nullable<BaseTexture>;
  103359. /**
  103360. * Marks the material to indicate that it needs to be re-calculated
  103361. */
  103362. markDirty(): void;
  103363. /** @hidden */
  103364. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103365. /**
  103366. * Binds the material to the mesh
  103367. * @param world defines the world transformation matrix
  103368. * @param mesh defines the mesh to bind the material to
  103369. */
  103370. bind(world: Matrix, mesh?: Mesh): void;
  103371. /**
  103372. * Binds the submesh to the material
  103373. * @param world defines the world transformation matrix
  103374. * @param mesh defines the mesh containing the submesh
  103375. * @param subMesh defines the submesh to bind the material to
  103376. */
  103377. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103378. /**
  103379. * Binds the world matrix to the material
  103380. * @param world defines the world transformation matrix
  103381. */
  103382. bindOnlyWorldMatrix(world: Matrix): void;
  103383. /**
  103384. * Binds the scene's uniform buffer to the effect.
  103385. * @param effect defines the effect to bind to the scene uniform buffer
  103386. * @param sceneUbo defines the uniform buffer storing scene data
  103387. */
  103388. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103389. /**
  103390. * Binds the view matrix to the effect
  103391. * @param effect defines the effect to bind the view matrix to
  103392. */
  103393. bindView(effect: Effect): void;
  103394. /**
  103395. * Binds the view projection matrix to the effect
  103396. * @param effect defines the effect to bind the view projection matrix to
  103397. */
  103398. bindViewProjection(effect: Effect): void;
  103399. /**
  103400. * Processes to execute after binding the material to a mesh
  103401. * @param mesh defines the rendered mesh
  103402. */
  103403. protected _afterBind(mesh?: Mesh): void;
  103404. /**
  103405. * Unbinds the material from the mesh
  103406. */
  103407. unbind(): void;
  103408. /**
  103409. * Gets the active textures from the material
  103410. * @returns an array of textures
  103411. */
  103412. getActiveTextures(): BaseTexture[];
  103413. /**
  103414. * Specifies if the material uses a texture
  103415. * @param texture defines the texture to check against the material
  103416. * @returns a boolean specifying if the material uses the texture
  103417. */
  103418. hasTexture(texture: BaseTexture): boolean;
  103419. /**
  103420. * Makes a duplicate of the material, and gives it a new name
  103421. * @param name defines the new name for the duplicated material
  103422. * @returns the cloned material
  103423. */
  103424. clone(name: string): Nullable<Material>;
  103425. /**
  103426. * Gets the meshes bound to the material
  103427. * @returns an array of meshes bound to the material
  103428. */
  103429. getBindedMeshes(): AbstractMesh[];
  103430. /**
  103431. * Force shader compilation
  103432. * @param mesh defines the mesh associated with this material
  103433. * @param onCompiled defines a function to execute once the material is compiled
  103434. * @param options defines the options to configure the compilation
  103435. * @param onError defines a function to execute if the material fails compiling
  103436. */
  103437. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103438. /**
  103439. * Force shader compilation
  103440. * @param mesh defines the mesh that will use this material
  103441. * @param options defines additional options for compiling the shaders
  103442. * @returns a promise that resolves when the compilation completes
  103443. */
  103444. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  103445. private static readonly _AllDirtyCallBack;
  103446. private static readonly _ImageProcessingDirtyCallBack;
  103447. private static readonly _TextureDirtyCallBack;
  103448. private static readonly _FresnelDirtyCallBack;
  103449. private static readonly _MiscDirtyCallBack;
  103450. private static readonly _LightsDirtyCallBack;
  103451. private static readonly _AttributeDirtyCallBack;
  103452. private static _FresnelAndMiscDirtyCallBack;
  103453. private static _TextureAndMiscDirtyCallBack;
  103454. private static readonly _DirtyCallbackArray;
  103455. private static readonly _RunDirtyCallBacks;
  103456. /**
  103457. * Marks a define in the material to indicate that it needs to be re-computed
  103458. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  103459. */
  103460. markAsDirty(flag: number): void;
  103461. /**
  103462. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  103463. * @param func defines a function which checks material defines against the submeshes
  103464. */
  103465. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  103466. /**
  103467. * Indicates that the scene should check if the rendering now needs a prepass
  103468. */
  103469. protected _markScenePrePassDirty(): void;
  103470. /**
  103471. * Indicates that we need to re-calculated for all submeshes
  103472. */
  103473. protected _markAllSubMeshesAsAllDirty(): void;
  103474. /**
  103475. * Indicates that image processing needs to be re-calculated for all submeshes
  103476. */
  103477. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  103478. /**
  103479. * Indicates that textures need to be re-calculated for all submeshes
  103480. */
  103481. protected _markAllSubMeshesAsTexturesDirty(): void;
  103482. /**
  103483. * Indicates that fresnel needs to be re-calculated for all submeshes
  103484. */
  103485. protected _markAllSubMeshesAsFresnelDirty(): void;
  103486. /**
  103487. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  103488. */
  103489. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  103490. /**
  103491. * Indicates that lights need to be re-calculated for all submeshes
  103492. */
  103493. protected _markAllSubMeshesAsLightsDirty(): void;
  103494. /**
  103495. * Indicates that attributes need to be re-calculated for all submeshes
  103496. */
  103497. protected _markAllSubMeshesAsAttributesDirty(): void;
  103498. /**
  103499. * Indicates that misc needs to be re-calculated for all submeshes
  103500. */
  103501. protected _markAllSubMeshesAsMiscDirty(): void;
  103502. /**
  103503. * Indicates that textures and misc need to be re-calculated for all submeshes
  103504. */
  103505. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  103506. /**
  103507. * Sets the required values to the prepass renderer.
  103508. * @param prePassRenderer defines the prepass renderer to setup.
  103509. * @returns true if the pre pass is needed.
  103510. */
  103511. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103512. /**
  103513. * Disposes the material
  103514. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103515. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103516. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103517. */
  103518. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103519. /** @hidden */
  103520. private releaseVertexArrayObject;
  103521. /**
  103522. * Serializes this material
  103523. * @returns the serialized material object
  103524. */
  103525. serialize(): any;
  103526. /**
  103527. * Creates a material from parsed material data
  103528. * @param parsedMaterial defines parsed material data
  103529. * @param scene defines the hosting scene
  103530. * @param rootUrl defines the root URL to use to load textures
  103531. * @returns a new material
  103532. */
  103533. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  103534. }
  103535. }
  103536. declare module BABYLON {
  103537. /**
  103538. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103539. * separate meshes. This can be use to improve performances.
  103540. * @see https://doc.babylonjs.com/how_to/multi_materials
  103541. */
  103542. export class MultiMaterial extends Material {
  103543. private _subMaterials;
  103544. /**
  103545. * Gets or Sets the list of Materials used within the multi material.
  103546. * They need to be ordered according to the submeshes order in the associated mesh
  103547. */
  103548. get subMaterials(): Nullable<Material>[];
  103549. set subMaterials(value: Nullable<Material>[]);
  103550. /**
  103551. * Function used to align with Node.getChildren()
  103552. * @returns the list of Materials used within the multi material
  103553. */
  103554. getChildren(): Nullable<Material>[];
  103555. /**
  103556. * Instantiates a new Multi Material
  103557. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103558. * separate meshes. This can be use to improve performances.
  103559. * @see https://doc.babylonjs.com/how_to/multi_materials
  103560. * @param name Define the name in the scene
  103561. * @param scene Define the scene the material belongs to
  103562. */
  103563. constructor(name: string, scene: Scene);
  103564. private _hookArray;
  103565. /**
  103566. * Get one of the submaterial by its index in the submaterials array
  103567. * @param index The index to look the sub material at
  103568. * @returns The Material if the index has been defined
  103569. */
  103570. getSubMaterial(index: number): Nullable<Material>;
  103571. /**
  103572. * Get the list of active textures for the whole sub materials list.
  103573. * @returns All the textures that will be used during the rendering
  103574. */
  103575. getActiveTextures(): BaseTexture[];
  103576. /**
  103577. * Gets the current class name of the material e.g. "MultiMaterial"
  103578. * Mainly use in serialization.
  103579. * @returns the class name
  103580. */
  103581. getClassName(): string;
  103582. /**
  103583. * Checks if the material is ready to render the requested sub mesh
  103584. * @param mesh Define the mesh the submesh belongs to
  103585. * @param subMesh Define the sub mesh to look readyness for
  103586. * @param useInstances Define whether or not the material is used with instances
  103587. * @returns true if ready, otherwise false
  103588. */
  103589. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103590. /**
  103591. * Clones the current material and its related sub materials
  103592. * @param name Define the name of the newly cloned material
  103593. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  103594. * @returns the cloned material
  103595. */
  103596. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  103597. /**
  103598. * Serializes the materials into a JSON representation.
  103599. * @returns the JSON representation
  103600. */
  103601. serialize(): any;
  103602. /**
  103603. * Dispose the material and release its associated resources
  103604. * @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)
  103605. * @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)
  103606. * @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)
  103607. */
  103608. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  103609. /**
  103610. * Creates a MultiMaterial from parsed MultiMaterial data.
  103611. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  103612. * @param scene defines the hosting scene
  103613. * @returns a new MultiMaterial
  103614. */
  103615. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  103616. }
  103617. }
  103618. declare module BABYLON {
  103619. /**
  103620. * Defines a subdivision inside a mesh
  103621. */
  103622. export class SubMesh implements ICullable {
  103623. /** the material index to use */
  103624. materialIndex: number;
  103625. /** vertex index start */
  103626. verticesStart: number;
  103627. /** vertices count */
  103628. verticesCount: number;
  103629. /** index start */
  103630. indexStart: number;
  103631. /** indices count */
  103632. indexCount: number;
  103633. /** @hidden */
  103634. _materialDefines: Nullable<MaterialDefines>;
  103635. /** @hidden */
  103636. _materialEffect: Nullable<Effect>;
  103637. /** @hidden */
  103638. _effectOverride: Nullable<Effect>;
  103639. /**
  103640. * Gets material defines used by the effect associated to the sub mesh
  103641. */
  103642. get materialDefines(): Nullable<MaterialDefines>;
  103643. /**
  103644. * Sets material defines used by the effect associated to the sub mesh
  103645. */
  103646. set materialDefines(defines: Nullable<MaterialDefines>);
  103647. /**
  103648. * Gets associated effect
  103649. */
  103650. get effect(): Nullable<Effect>;
  103651. /**
  103652. * Sets associated effect (effect used to render this submesh)
  103653. * @param effect defines the effect to associate with
  103654. * @param defines defines the set of defines used to compile this effect
  103655. */
  103656. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  103657. /** @hidden */
  103658. _linesIndexCount: number;
  103659. private _mesh;
  103660. private _renderingMesh;
  103661. private _boundingInfo;
  103662. private _linesIndexBuffer;
  103663. /** @hidden */
  103664. _lastColliderWorldVertices: Nullable<Vector3[]>;
  103665. /** @hidden */
  103666. _trianglePlanes: Plane[];
  103667. /** @hidden */
  103668. _lastColliderTransformMatrix: Nullable<Matrix>;
  103669. /** @hidden */
  103670. _renderId: number;
  103671. /** @hidden */
  103672. _alphaIndex: number;
  103673. /** @hidden */
  103674. _distanceToCamera: number;
  103675. /** @hidden */
  103676. _id: number;
  103677. private _currentMaterial;
  103678. /**
  103679. * Add a new submesh to a mesh
  103680. * @param materialIndex defines the material index to use
  103681. * @param verticesStart defines vertex index start
  103682. * @param verticesCount defines vertices count
  103683. * @param indexStart defines index start
  103684. * @param indexCount defines indices count
  103685. * @param mesh defines the parent mesh
  103686. * @param renderingMesh defines an optional rendering mesh
  103687. * @param createBoundingBox defines if bounding box should be created for this submesh
  103688. * @returns the new submesh
  103689. */
  103690. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  103691. /**
  103692. * Creates a new submesh
  103693. * @param materialIndex defines the material index to use
  103694. * @param verticesStart defines vertex index start
  103695. * @param verticesCount defines vertices count
  103696. * @param indexStart defines index start
  103697. * @param indexCount defines indices count
  103698. * @param mesh defines the parent mesh
  103699. * @param renderingMesh defines an optional rendering mesh
  103700. * @param createBoundingBox defines if bounding box should be created for this submesh
  103701. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  103702. */
  103703. constructor(
  103704. /** the material index to use */
  103705. materialIndex: number,
  103706. /** vertex index start */
  103707. verticesStart: number,
  103708. /** vertices count */
  103709. verticesCount: number,
  103710. /** index start */
  103711. indexStart: number,
  103712. /** indices count */
  103713. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  103714. /**
  103715. * Returns true if this submesh covers the entire parent mesh
  103716. * @ignorenaming
  103717. */
  103718. get IsGlobal(): boolean;
  103719. /**
  103720. * Returns the submesh BoudingInfo object
  103721. * @returns current bounding info (or mesh's one if the submesh is global)
  103722. */
  103723. getBoundingInfo(): BoundingInfo;
  103724. /**
  103725. * Sets the submesh BoundingInfo
  103726. * @param boundingInfo defines the new bounding info to use
  103727. * @returns the SubMesh
  103728. */
  103729. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  103730. /**
  103731. * Returns the mesh of the current submesh
  103732. * @return the parent mesh
  103733. */
  103734. getMesh(): AbstractMesh;
  103735. /**
  103736. * Returns the rendering mesh of the submesh
  103737. * @returns the rendering mesh (could be different from parent mesh)
  103738. */
  103739. getRenderingMesh(): Mesh;
  103740. /**
  103741. * Returns the replacement mesh of the submesh
  103742. * @returns the replacement mesh (could be different from parent mesh)
  103743. */
  103744. getReplacementMesh(): Nullable<AbstractMesh>;
  103745. /**
  103746. * Returns the effective mesh of the submesh
  103747. * @returns the effective mesh (could be different from parent mesh)
  103748. */
  103749. getEffectiveMesh(): AbstractMesh;
  103750. /**
  103751. * Returns the submesh material
  103752. * @returns null or the current material
  103753. */
  103754. getMaterial(): Nullable<Material>;
  103755. private _IsMultiMaterial;
  103756. /**
  103757. * Sets a new updated BoundingInfo object to the submesh
  103758. * @param data defines an optional position array to use to determine the bounding info
  103759. * @returns the SubMesh
  103760. */
  103761. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  103762. /** @hidden */
  103763. _checkCollision(collider: Collider): boolean;
  103764. /**
  103765. * Updates the submesh BoundingInfo
  103766. * @param world defines the world matrix to use to update the bounding info
  103767. * @returns the submesh
  103768. */
  103769. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  103770. /**
  103771. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  103772. * @param frustumPlanes defines the frustum planes
  103773. * @returns true if the submesh is intersecting with the frustum
  103774. */
  103775. isInFrustum(frustumPlanes: Plane[]): boolean;
  103776. /**
  103777. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  103778. * @param frustumPlanes defines the frustum planes
  103779. * @returns true if the submesh is inside the frustum
  103780. */
  103781. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  103782. /**
  103783. * Renders the submesh
  103784. * @param enableAlphaMode defines if alpha needs to be used
  103785. * @returns the submesh
  103786. */
  103787. render(enableAlphaMode: boolean): SubMesh;
  103788. /**
  103789. * @hidden
  103790. */
  103791. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  103792. /**
  103793. * Checks if the submesh intersects with a ray
  103794. * @param ray defines the ray to test
  103795. * @returns true is the passed ray intersects the submesh bounding box
  103796. */
  103797. canIntersects(ray: Ray): boolean;
  103798. /**
  103799. * Intersects current submesh with a ray
  103800. * @param ray defines the ray to test
  103801. * @param positions defines mesh's positions array
  103802. * @param indices defines mesh's indices array
  103803. * @param fastCheck defines if the first intersection will be used (and not the closest)
  103804. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103805. * @returns intersection info or null if no intersection
  103806. */
  103807. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  103808. /** @hidden */
  103809. private _intersectLines;
  103810. /** @hidden */
  103811. private _intersectUnIndexedLines;
  103812. /** @hidden */
  103813. private _intersectTriangles;
  103814. /** @hidden */
  103815. private _intersectUnIndexedTriangles;
  103816. /** @hidden */
  103817. _rebuild(): void;
  103818. /**
  103819. * Creates a new submesh from the passed mesh
  103820. * @param newMesh defines the new hosting mesh
  103821. * @param newRenderingMesh defines an optional rendering mesh
  103822. * @returns the new submesh
  103823. */
  103824. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  103825. /**
  103826. * Release associated resources
  103827. */
  103828. dispose(): void;
  103829. /**
  103830. * Gets the class name
  103831. * @returns the string "SubMesh".
  103832. */
  103833. getClassName(): string;
  103834. /**
  103835. * Creates a new submesh from indices data
  103836. * @param materialIndex the index of the main mesh material
  103837. * @param startIndex the index where to start the copy in the mesh indices array
  103838. * @param indexCount the number of indices to copy then from the startIndex
  103839. * @param mesh the main mesh to create the submesh from
  103840. * @param renderingMesh the optional rendering mesh
  103841. * @returns a new submesh
  103842. */
  103843. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  103844. }
  103845. }
  103846. declare module BABYLON {
  103847. /**
  103848. * Class used to represent data loading progression
  103849. */
  103850. export class SceneLoaderFlags {
  103851. private static _ForceFullSceneLoadingForIncremental;
  103852. private static _ShowLoadingScreen;
  103853. private static _CleanBoneMatrixWeights;
  103854. private static _loggingLevel;
  103855. /**
  103856. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  103857. */
  103858. static get ForceFullSceneLoadingForIncremental(): boolean;
  103859. static set ForceFullSceneLoadingForIncremental(value: boolean);
  103860. /**
  103861. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  103862. */
  103863. static get ShowLoadingScreen(): boolean;
  103864. static set ShowLoadingScreen(value: boolean);
  103865. /**
  103866. * Defines the current logging level (while loading the scene)
  103867. * @ignorenaming
  103868. */
  103869. static get loggingLevel(): number;
  103870. static set loggingLevel(value: number);
  103871. /**
  103872. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  103873. */
  103874. static get CleanBoneMatrixWeights(): boolean;
  103875. static set CleanBoneMatrixWeights(value: boolean);
  103876. }
  103877. }
  103878. declare module BABYLON {
  103879. /**
  103880. * Class used to store geometry data (vertex buffers + index buffer)
  103881. */
  103882. export class Geometry implements IGetSetVerticesData {
  103883. /**
  103884. * Gets or sets the ID of the geometry
  103885. */
  103886. id: string;
  103887. /**
  103888. * Gets or sets the unique ID of the geometry
  103889. */
  103890. uniqueId: number;
  103891. /**
  103892. * Gets the delay loading state of the geometry (none by default which means not delayed)
  103893. */
  103894. delayLoadState: number;
  103895. /**
  103896. * Gets the file containing the data to load when running in delay load state
  103897. */
  103898. delayLoadingFile: Nullable<string>;
  103899. /**
  103900. * Callback called when the geometry is updated
  103901. */
  103902. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  103903. private _scene;
  103904. private _engine;
  103905. private _meshes;
  103906. private _totalVertices;
  103907. /** @hidden */
  103908. _indices: IndicesArray;
  103909. /** @hidden */
  103910. _vertexBuffers: {
  103911. [key: string]: VertexBuffer;
  103912. };
  103913. private _isDisposed;
  103914. private _extend;
  103915. private _boundingBias;
  103916. /** @hidden */
  103917. _delayInfo: Array<string>;
  103918. private _indexBuffer;
  103919. private _indexBufferIsUpdatable;
  103920. /** @hidden */
  103921. _boundingInfo: Nullable<BoundingInfo>;
  103922. /** @hidden */
  103923. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  103924. /** @hidden */
  103925. _softwareSkinningFrameId: number;
  103926. private _vertexArrayObjects;
  103927. private _updatable;
  103928. /** @hidden */
  103929. _positions: Nullable<Vector3[]>;
  103930. /**
  103931. * 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
  103932. */
  103933. get boundingBias(): Vector2;
  103934. /**
  103935. * 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
  103936. */
  103937. set boundingBias(value: Vector2);
  103938. /**
  103939. * Static function used to attach a new empty geometry to a mesh
  103940. * @param mesh defines the mesh to attach the geometry to
  103941. * @returns the new Geometry
  103942. */
  103943. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  103944. /** Get the list of meshes using this geometry */
  103945. get meshes(): Mesh[];
  103946. /**
  103947. * 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
  103948. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  103949. */
  103950. useBoundingInfoFromGeometry: boolean;
  103951. /**
  103952. * Creates a new geometry
  103953. * @param id defines the unique ID
  103954. * @param scene defines the hosting scene
  103955. * @param vertexData defines the VertexData used to get geometry data
  103956. * @param updatable defines if geometry must be updatable (false by default)
  103957. * @param mesh defines the mesh that will be associated with the geometry
  103958. */
  103959. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  103960. /**
  103961. * Gets the current extend of the geometry
  103962. */
  103963. get extend(): {
  103964. minimum: Vector3;
  103965. maximum: Vector3;
  103966. };
  103967. /**
  103968. * Gets the hosting scene
  103969. * @returns the hosting Scene
  103970. */
  103971. getScene(): Scene;
  103972. /**
  103973. * Gets the hosting engine
  103974. * @returns the hosting Engine
  103975. */
  103976. getEngine(): Engine;
  103977. /**
  103978. * Defines if the geometry is ready to use
  103979. * @returns true if the geometry is ready to be used
  103980. */
  103981. isReady(): boolean;
  103982. /**
  103983. * Gets a value indicating that the geometry should not be serialized
  103984. */
  103985. get doNotSerialize(): boolean;
  103986. /** @hidden */
  103987. _rebuild(): void;
  103988. /**
  103989. * Affects all geometry data in one call
  103990. * @param vertexData defines the geometry data
  103991. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  103992. */
  103993. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  103994. /**
  103995. * Set specific vertex data
  103996. * @param kind defines the data kind (Position, normal, etc...)
  103997. * @param data defines the vertex data to use
  103998. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103999. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104000. */
  104001. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104002. /**
  104003. * Removes a specific vertex data
  104004. * @param kind defines the data kind (Position, normal, etc...)
  104005. */
  104006. removeVerticesData(kind: string): void;
  104007. /**
  104008. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104009. * @param buffer defines the vertex buffer to use
  104010. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104011. */
  104012. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104013. /**
  104014. * Update a specific vertex buffer
  104015. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104016. * It will do nothing if the buffer is not updatable
  104017. * @param kind defines the data kind (Position, normal, etc...)
  104018. * @param data defines the data to use
  104019. * @param offset defines the offset in the target buffer where to store the data
  104020. * @param useBytes set to true if the offset is in bytes
  104021. */
  104022. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104023. /**
  104024. * Update a specific vertex buffer
  104025. * This function will create a new buffer if the current one is not updatable
  104026. * @param kind defines the data kind (Position, normal, etc...)
  104027. * @param data defines the data to use
  104028. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104029. */
  104030. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104031. private _updateBoundingInfo;
  104032. /** @hidden */
  104033. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104034. /**
  104035. * Gets total number of vertices
  104036. * @returns the total number of vertices
  104037. */
  104038. getTotalVertices(): number;
  104039. /**
  104040. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104041. * @param kind defines the data kind (Position, normal, etc...)
  104042. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104043. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104044. * @returns a float array containing vertex data
  104045. */
  104046. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104047. /**
  104048. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104049. * @param kind defines the data kind (Position, normal, etc...)
  104050. * @returns true if the vertex buffer with the specified kind is updatable
  104051. */
  104052. isVertexBufferUpdatable(kind: string): boolean;
  104053. /**
  104054. * Gets a specific vertex buffer
  104055. * @param kind defines the data kind (Position, normal, etc...)
  104056. * @returns a VertexBuffer
  104057. */
  104058. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104059. /**
  104060. * Returns all vertex buffers
  104061. * @return an object holding all vertex buffers indexed by kind
  104062. */
  104063. getVertexBuffers(): Nullable<{
  104064. [key: string]: VertexBuffer;
  104065. }>;
  104066. /**
  104067. * Gets a boolean indicating if specific vertex buffer is present
  104068. * @param kind defines the data kind (Position, normal, etc...)
  104069. * @returns true if data is present
  104070. */
  104071. isVerticesDataPresent(kind: string): boolean;
  104072. /**
  104073. * Gets a list of all attached data kinds (Position, normal, etc...)
  104074. * @returns a list of string containing all kinds
  104075. */
  104076. getVerticesDataKinds(): string[];
  104077. /**
  104078. * Update index buffer
  104079. * @param indices defines the indices to store in the index buffer
  104080. * @param offset defines the offset in the target buffer where to store the data
  104081. * @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)
  104082. */
  104083. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104084. /**
  104085. * Creates a new index buffer
  104086. * @param indices defines the indices to store in the index buffer
  104087. * @param totalVertices defines the total number of vertices (could be null)
  104088. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104089. */
  104090. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104091. /**
  104092. * Return the total number of indices
  104093. * @returns the total number of indices
  104094. */
  104095. getTotalIndices(): number;
  104096. /**
  104097. * Gets the index buffer array
  104098. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104099. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104100. * @returns the index buffer array
  104101. */
  104102. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104103. /**
  104104. * Gets the index buffer
  104105. * @return the index buffer
  104106. */
  104107. getIndexBuffer(): Nullable<DataBuffer>;
  104108. /** @hidden */
  104109. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104110. /**
  104111. * Release the associated resources for a specific mesh
  104112. * @param mesh defines the source mesh
  104113. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104114. */
  104115. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104116. /**
  104117. * Apply current geometry to a given mesh
  104118. * @param mesh defines the mesh to apply geometry to
  104119. */
  104120. applyToMesh(mesh: Mesh): void;
  104121. private _updateExtend;
  104122. private _applyToMesh;
  104123. private notifyUpdate;
  104124. /**
  104125. * Load the geometry if it was flagged as delay loaded
  104126. * @param scene defines the hosting scene
  104127. * @param onLoaded defines a callback called when the geometry is loaded
  104128. */
  104129. load(scene: Scene, onLoaded?: () => void): void;
  104130. private _queueLoad;
  104131. /**
  104132. * Invert the geometry to move from a right handed system to a left handed one.
  104133. */
  104134. toLeftHanded(): void;
  104135. /** @hidden */
  104136. _resetPointsArrayCache(): void;
  104137. /** @hidden */
  104138. _generatePointsArray(): boolean;
  104139. /**
  104140. * Gets a value indicating if the geometry is disposed
  104141. * @returns true if the geometry was disposed
  104142. */
  104143. isDisposed(): boolean;
  104144. private _disposeVertexArrayObjects;
  104145. /**
  104146. * Free all associated resources
  104147. */
  104148. dispose(): void;
  104149. /**
  104150. * Clone the current geometry into a new geometry
  104151. * @param id defines the unique ID of the new geometry
  104152. * @returns a new geometry object
  104153. */
  104154. copy(id: string): Geometry;
  104155. /**
  104156. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104157. * @return a JSON representation of the current geometry data (without the vertices data)
  104158. */
  104159. serialize(): any;
  104160. private toNumberArray;
  104161. /**
  104162. * Serialize all vertices data into a JSON oject
  104163. * @returns a JSON representation of the current geometry data
  104164. */
  104165. serializeVerticeData(): any;
  104166. /**
  104167. * Extracts a clone of a mesh geometry
  104168. * @param mesh defines the source mesh
  104169. * @param id defines the unique ID of the new geometry object
  104170. * @returns the new geometry object
  104171. */
  104172. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104173. /**
  104174. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104175. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104176. * Be aware Math.random() could cause collisions, but:
  104177. * "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"
  104178. * @returns a string containing a new GUID
  104179. */
  104180. static RandomId(): string;
  104181. /** @hidden */
  104182. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104183. private static _CleanMatricesWeights;
  104184. /**
  104185. * Create a new geometry from persisted data (Using .babylon file format)
  104186. * @param parsedVertexData defines the persisted data
  104187. * @param scene defines the hosting scene
  104188. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104189. * @returns the new geometry object
  104190. */
  104191. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104192. }
  104193. }
  104194. declare module BABYLON {
  104195. /**
  104196. * Define an interface for all classes that will get and set the data on vertices
  104197. */
  104198. export interface IGetSetVerticesData {
  104199. /**
  104200. * Gets a boolean indicating if specific vertex data is present
  104201. * @param kind defines the vertex data kind to use
  104202. * @returns true is data kind is present
  104203. */
  104204. isVerticesDataPresent(kind: string): boolean;
  104205. /**
  104206. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104207. * @param kind defines the data kind (Position, normal, etc...)
  104208. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104209. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104210. * @returns a float array containing vertex data
  104211. */
  104212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104213. /**
  104214. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104215. * @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.
  104216. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104217. * @returns the indices array or an empty array if the mesh has no geometry
  104218. */
  104219. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104220. /**
  104221. * Set specific vertex data
  104222. * @param kind defines the data kind (Position, normal, etc...)
  104223. * @param data defines the vertex data to use
  104224. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104225. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104226. */
  104227. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104228. /**
  104229. * Update a specific associated vertex buffer
  104230. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104231. * - VertexBuffer.PositionKind
  104232. * - VertexBuffer.UVKind
  104233. * - VertexBuffer.UV2Kind
  104234. * - VertexBuffer.UV3Kind
  104235. * - VertexBuffer.UV4Kind
  104236. * - VertexBuffer.UV5Kind
  104237. * - VertexBuffer.UV6Kind
  104238. * - VertexBuffer.ColorKind
  104239. * - VertexBuffer.MatricesIndicesKind
  104240. * - VertexBuffer.MatricesIndicesExtraKind
  104241. * - VertexBuffer.MatricesWeightsKind
  104242. * - VertexBuffer.MatricesWeightsExtraKind
  104243. * @param data defines the data source
  104244. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104245. * @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)
  104246. */
  104247. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104248. /**
  104249. * Creates a new index buffer
  104250. * @param indices defines the indices to store in the index buffer
  104251. * @param totalVertices defines the total number of vertices (could be null)
  104252. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104253. */
  104254. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104255. }
  104256. /**
  104257. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104258. */
  104259. export class VertexData {
  104260. /**
  104261. * Mesh side orientation : usually the external or front surface
  104262. */
  104263. static readonly FRONTSIDE: number;
  104264. /**
  104265. * Mesh side orientation : usually the internal or back surface
  104266. */
  104267. static readonly BACKSIDE: number;
  104268. /**
  104269. * Mesh side orientation : both internal and external or front and back surfaces
  104270. */
  104271. static readonly DOUBLESIDE: number;
  104272. /**
  104273. * Mesh side orientation : by default, `FRONTSIDE`
  104274. */
  104275. static readonly DEFAULTSIDE: number;
  104276. /**
  104277. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104278. */
  104279. positions: Nullable<FloatArray>;
  104280. /**
  104281. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104282. */
  104283. normals: Nullable<FloatArray>;
  104284. /**
  104285. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104286. */
  104287. tangents: Nullable<FloatArray>;
  104288. /**
  104289. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104290. */
  104291. uvs: Nullable<FloatArray>;
  104292. /**
  104293. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104294. */
  104295. uvs2: Nullable<FloatArray>;
  104296. /**
  104297. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104298. */
  104299. uvs3: Nullable<FloatArray>;
  104300. /**
  104301. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104302. */
  104303. uvs4: Nullable<FloatArray>;
  104304. /**
  104305. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104306. */
  104307. uvs5: Nullable<FloatArray>;
  104308. /**
  104309. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104310. */
  104311. uvs6: Nullable<FloatArray>;
  104312. /**
  104313. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104314. */
  104315. colors: Nullable<FloatArray>;
  104316. /**
  104317. * 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).
  104318. */
  104319. matricesIndices: Nullable<FloatArray>;
  104320. /**
  104321. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104322. */
  104323. matricesWeights: Nullable<FloatArray>;
  104324. /**
  104325. * An array extending the number of possible indices
  104326. */
  104327. matricesIndicesExtra: Nullable<FloatArray>;
  104328. /**
  104329. * An array extending the number of possible weights when the number of indices is extended
  104330. */
  104331. matricesWeightsExtra: Nullable<FloatArray>;
  104332. /**
  104333. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104334. */
  104335. indices: Nullable<IndicesArray>;
  104336. /**
  104337. * Uses the passed data array to set the set the values for the specified kind of data
  104338. * @param data a linear array of floating numbers
  104339. * @param kind the type of data that is being set, eg positions, colors etc
  104340. */
  104341. set(data: FloatArray, kind: string): void;
  104342. /**
  104343. * Associates the vertexData to the passed Mesh.
  104344. * Sets it as updatable or not (default `false`)
  104345. * @param mesh the mesh the vertexData is applied to
  104346. * @param updatable when used and having the value true allows new data to update the vertexData
  104347. * @returns the VertexData
  104348. */
  104349. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104350. /**
  104351. * Associates the vertexData to the passed Geometry.
  104352. * Sets it as updatable or not (default `false`)
  104353. * @param geometry the geometry the vertexData is applied to
  104354. * @param updatable when used and having the value true allows new data to update the vertexData
  104355. * @returns VertexData
  104356. */
  104357. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104358. /**
  104359. * Updates the associated mesh
  104360. * @param mesh the mesh to be updated
  104361. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104362. * @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
  104363. * @returns VertexData
  104364. */
  104365. updateMesh(mesh: Mesh): VertexData;
  104366. /**
  104367. * Updates the associated geometry
  104368. * @param geometry the geometry to be updated
  104369. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104370. * @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
  104371. * @returns VertexData.
  104372. */
  104373. updateGeometry(geometry: Geometry): VertexData;
  104374. private _applyTo;
  104375. private _update;
  104376. /**
  104377. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104378. * @param matrix the transforming matrix
  104379. * @returns the VertexData
  104380. */
  104381. transform(matrix: Matrix): VertexData;
  104382. /**
  104383. * Merges the passed VertexData into the current one
  104384. * @param other the VertexData to be merged into the current one
  104385. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104386. * @returns the modified VertexData
  104387. */
  104388. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104389. private _mergeElement;
  104390. private _validate;
  104391. /**
  104392. * Serializes the VertexData
  104393. * @returns a serialized object
  104394. */
  104395. serialize(): any;
  104396. /**
  104397. * Extracts the vertexData from a mesh
  104398. * @param mesh the mesh from which to extract the VertexData
  104399. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104400. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104401. * @returns the object VertexData associated to the passed mesh
  104402. */
  104403. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104404. /**
  104405. * Extracts the vertexData from the geometry
  104406. * @param geometry the geometry from which to extract the VertexData
  104407. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104408. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104409. * @returns the object VertexData associated to the passed mesh
  104410. */
  104411. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104412. private static _ExtractFrom;
  104413. /**
  104414. * Creates the VertexData for a Ribbon
  104415. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104416. * * pathArray array of paths, each of which an array of successive Vector3
  104417. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104418. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104419. * * 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
  104420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104421. * * 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)
  104422. * * 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)
  104423. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104424. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104425. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104426. * @returns the VertexData of the ribbon
  104427. */
  104428. static CreateRibbon(options: {
  104429. pathArray: Vector3[][];
  104430. closeArray?: boolean;
  104431. closePath?: boolean;
  104432. offset?: number;
  104433. sideOrientation?: number;
  104434. frontUVs?: Vector4;
  104435. backUVs?: Vector4;
  104436. invertUV?: boolean;
  104437. uvs?: Vector2[];
  104438. colors?: Color4[];
  104439. }): VertexData;
  104440. /**
  104441. * Creates the VertexData for a box
  104442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104443. * * size sets the width, height and depth of the box to the value of size, optional default 1
  104444. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  104445. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  104446. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  104447. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104448. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104450. * * 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)
  104451. * * 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)
  104452. * @returns the VertexData of the box
  104453. */
  104454. static CreateBox(options: {
  104455. size?: number;
  104456. width?: number;
  104457. height?: number;
  104458. depth?: number;
  104459. faceUV?: Vector4[];
  104460. faceColors?: Color4[];
  104461. sideOrientation?: number;
  104462. frontUVs?: Vector4;
  104463. backUVs?: Vector4;
  104464. }): VertexData;
  104465. /**
  104466. * Creates the VertexData for a tiled box
  104467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104468. * * faceTiles sets the pattern, tile size and number of tiles for a face
  104469. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104470. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104472. * @returns the VertexData of the box
  104473. */
  104474. static CreateTiledBox(options: {
  104475. pattern?: number;
  104476. width?: number;
  104477. height?: number;
  104478. depth?: number;
  104479. tileSize?: number;
  104480. tileWidth?: number;
  104481. tileHeight?: number;
  104482. alignHorizontal?: number;
  104483. alignVertical?: number;
  104484. faceUV?: Vector4[];
  104485. faceColors?: Color4[];
  104486. sideOrientation?: number;
  104487. }): VertexData;
  104488. /**
  104489. * Creates the VertexData for a tiled plane
  104490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104491. * * pattern a limited pattern arrangement depending on the number
  104492. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  104493. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  104494. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  104495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104496. * * 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)
  104497. * * 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)
  104498. * @returns the VertexData of the tiled plane
  104499. */
  104500. static CreateTiledPlane(options: {
  104501. pattern?: number;
  104502. tileSize?: number;
  104503. tileWidth?: number;
  104504. tileHeight?: number;
  104505. size?: number;
  104506. width?: number;
  104507. height?: number;
  104508. alignHorizontal?: number;
  104509. alignVertical?: number;
  104510. sideOrientation?: number;
  104511. frontUVs?: Vector4;
  104512. backUVs?: Vector4;
  104513. }): VertexData;
  104514. /**
  104515. * Creates the VertexData for an ellipsoid, defaults to a sphere
  104516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104517. * * segments sets the number of horizontal strips optional, default 32
  104518. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  104519. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  104520. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  104521. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  104522. * * 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
  104523. * * 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
  104524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104525. * * 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)
  104526. * * 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)
  104527. * @returns the VertexData of the ellipsoid
  104528. */
  104529. static CreateSphere(options: {
  104530. segments?: number;
  104531. diameter?: number;
  104532. diameterX?: number;
  104533. diameterY?: number;
  104534. diameterZ?: number;
  104535. arc?: number;
  104536. slice?: number;
  104537. sideOrientation?: number;
  104538. frontUVs?: Vector4;
  104539. backUVs?: Vector4;
  104540. }): VertexData;
  104541. /**
  104542. * Creates the VertexData for a cylinder, cone or prism
  104543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104544. * * height sets the height (y direction) of the cylinder, optional, default 2
  104545. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  104546. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  104547. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  104548. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104549. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  104550. * * 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
  104551. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104552. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104553. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  104554. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  104555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104556. * * 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)
  104557. * * 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)
  104558. * @returns the VertexData of the cylinder, cone or prism
  104559. */
  104560. static CreateCylinder(options: {
  104561. height?: number;
  104562. diameterTop?: number;
  104563. diameterBottom?: number;
  104564. diameter?: number;
  104565. tessellation?: number;
  104566. subdivisions?: number;
  104567. arc?: number;
  104568. faceColors?: Color4[];
  104569. faceUV?: Vector4[];
  104570. hasRings?: boolean;
  104571. enclose?: boolean;
  104572. sideOrientation?: number;
  104573. frontUVs?: Vector4;
  104574. backUVs?: Vector4;
  104575. }): VertexData;
  104576. /**
  104577. * Creates the VertexData for a torus
  104578. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104579. * * diameter the diameter of the torus, optional default 1
  104580. * * thickness the diameter of the tube forming the torus, optional default 0.5
  104581. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104583. * * 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)
  104584. * * 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)
  104585. * @returns the VertexData of the torus
  104586. */
  104587. static CreateTorus(options: {
  104588. diameter?: number;
  104589. thickness?: number;
  104590. tessellation?: number;
  104591. sideOrientation?: number;
  104592. frontUVs?: Vector4;
  104593. backUVs?: Vector4;
  104594. }): VertexData;
  104595. /**
  104596. * Creates the VertexData of the LineSystem
  104597. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  104598. * - lines an array of lines, each line being an array of successive Vector3
  104599. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  104600. * @returns the VertexData of the LineSystem
  104601. */
  104602. static CreateLineSystem(options: {
  104603. lines: Vector3[][];
  104604. colors?: Nullable<Color4[][]>;
  104605. }): VertexData;
  104606. /**
  104607. * Create the VertexData for a DashedLines
  104608. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  104609. * - points an array successive Vector3
  104610. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  104611. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  104612. * - dashNb the intended total number of dashes, optional, default 200
  104613. * @returns the VertexData for the DashedLines
  104614. */
  104615. static CreateDashedLines(options: {
  104616. points: Vector3[];
  104617. dashSize?: number;
  104618. gapSize?: number;
  104619. dashNb?: number;
  104620. }): VertexData;
  104621. /**
  104622. * Creates the VertexData for a Ground
  104623. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104624. * - width the width (x direction) of the ground, optional, default 1
  104625. * - height the height (z direction) of the ground, optional, default 1
  104626. * - subdivisions the number of subdivisions per side, optional, default 1
  104627. * @returns the VertexData of the Ground
  104628. */
  104629. static CreateGround(options: {
  104630. width?: number;
  104631. height?: number;
  104632. subdivisions?: number;
  104633. subdivisionsX?: number;
  104634. subdivisionsY?: number;
  104635. }): VertexData;
  104636. /**
  104637. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  104638. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104639. * * xmin the ground minimum X coordinate, optional, default -1
  104640. * * zmin the ground minimum Z coordinate, optional, default -1
  104641. * * xmax the ground maximum X coordinate, optional, default 1
  104642. * * zmax the ground maximum Z coordinate, optional, default 1
  104643. * * 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}
  104644. * * 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}
  104645. * @returns the VertexData of the TiledGround
  104646. */
  104647. static CreateTiledGround(options: {
  104648. xmin: number;
  104649. zmin: number;
  104650. xmax: number;
  104651. zmax: number;
  104652. subdivisions?: {
  104653. w: number;
  104654. h: number;
  104655. };
  104656. precision?: {
  104657. w: number;
  104658. h: number;
  104659. };
  104660. }): VertexData;
  104661. /**
  104662. * Creates the VertexData of the Ground designed from a heightmap
  104663. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  104664. * * width the width (x direction) of the ground
  104665. * * height the height (z direction) of the ground
  104666. * * subdivisions the number of subdivisions per side
  104667. * * minHeight the minimum altitude on the ground, optional, default 0
  104668. * * maxHeight the maximum altitude on the ground, optional default 1
  104669. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  104670. * * buffer the array holding the image color data
  104671. * * bufferWidth the width of image
  104672. * * bufferHeight the height of image
  104673. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  104674. * @returns the VertexData of the Ground designed from a heightmap
  104675. */
  104676. static CreateGroundFromHeightMap(options: {
  104677. width: number;
  104678. height: number;
  104679. subdivisions: number;
  104680. minHeight: number;
  104681. maxHeight: number;
  104682. colorFilter: Color3;
  104683. buffer: Uint8Array;
  104684. bufferWidth: number;
  104685. bufferHeight: number;
  104686. alphaFilter: number;
  104687. }): VertexData;
  104688. /**
  104689. * Creates the VertexData for a Plane
  104690. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  104691. * * size sets the width and height of the plane to the value of size, optional default 1
  104692. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  104693. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  104694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104695. * * 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)
  104696. * * 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)
  104697. * @returns the VertexData of the box
  104698. */
  104699. static CreatePlane(options: {
  104700. size?: number;
  104701. width?: number;
  104702. height?: number;
  104703. sideOrientation?: number;
  104704. frontUVs?: Vector4;
  104705. backUVs?: Vector4;
  104706. }): VertexData;
  104707. /**
  104708. * Creates the VertexData of the Disc or regular Polygon
  104709. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  104710. * * radius the radius of the disc, optional default 0.5
  104711. * * tessellation the number of polygon sides, optional, default 64
  104712. * * 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
  104713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104714. * * 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)
  104715. * * 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)
  104716. * @returns the VertexData of the box
  104717. */
  104718. static CreateDisc(options: {
  104719. radius?: number;
  104720. tessellation?: number;
  104721. arc?: number;
  104722. sideOrientation?: number;
  104723. frontUVs?: Vector4;
  104724. backUVs?: Vector4;
  104725. }): VertexData;
  104726. /**
  104727. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  104728. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  104729. * @param polygon a mesh built from polygonTriangulation.build()
  104730. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104731. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104732. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104733. * @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)
  104734. * @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)
  104735. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  104736. * @returns the VertexData of the Polygon
  104737. */
  104738. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  104739. /**
  104740. * Creates the VertexData of the IcoSphere
  104741. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  104742. * * radius the radius of the IcoSphere, optional default 1
  104743. * * radiusX allows stretching in the x direction, optional, default radius
  104744. * * radiusY allows stretching in the y direction, optional, default radius
  104745. * * radiusZ allows stretching in the z direction, optional, default radius
  104746. * * flat when true creates a flat shaded mesh, optional, default true
  104747. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  104748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104749. * * 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)
  104750. * * 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)
  104751. * @returns the VertexData of the IcoSphere
  104752. */
  104753. static CreateIcoSphere(options: {
  104754. radius?: number;
  104755. radiusX?: number;
  104756. radiusY?: number;
  104757. radiusZ?: number;
  104758. flat?: boolean;
  104759. subdivisions?: number;
  104760. sideOrientation?: number;
  104761. frontUVs?: Vector4;
  104762. backUVs?: Vector4;
  104763. }): VertexData;
  104764. /**
  104765. * Creates the VertexData for a Polyhedron
  104766. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  104767. * * type provided types are:
  104768. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  104769. * * 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)
  104770. * * size the size of the IcoSphere, optional default 1
  104771. * * sizeX allows stretching in the x direction, optional, default size
  104772. * * sizeY allows stretching in the y direction, optional, default size
  104773. * * sizeZ allows stretching in the z direction, optional, default size
  104774. * * 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
  104775. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104776. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104777. * * flat when true creates a flat shaded mesh, optional, default true
  104778. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  104779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104780. * * 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)
  104781. * * 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)
  104782. * @returns the VertexData of the Polyhedron
  104783. */
  104784. static CreatePolyhedron(options: {
  104785. type?: number;
  104786. size?: number;
  104787. sizeX?: number;
  104788. sizeY?: number;
  104789. sizeZ?: number;
  104790. custom?: any;
  104791. faceUV?: Vector4[];
  104792. faceColors?: Color4[];
  104793. flat?: boolean;
  104794. sideOrientation?: number;
  104795. frontUVs?: Vector4;
  104796. backUVs?: Vector4;
  104797. }): VertexData;
  104798. /**
  104799. * Creates the VertexData for a TorusKnot
  104800. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  104801. * * radius the radius of the torus knot, optional, default 2
  104802. * * tube the thickness of the tube, optional, default 0.5
  104803. * * radialSegments the number of sides on each tube segments, optional, default 32
  104804. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  104805. * * p the number of windings around the z axis, optional, default 2
  104806. * * q the number of windings around the x axis, optional, default 3
  104807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104808. * * 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)
  104809. * * 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)
  104810. * @returns the VertexData of the Torus Knot
  104811. */
  104812. static CreateTorusKnot(options: {
  104813. radius?: number;
  104814. tube?: number;
  104815. radialSegments?: number;
  104816. tubularSegments?: number;
  104817. p?: number;
  104818. q?: number;
  104819. sideOrientation?: number;
  104820. frontUVs?: Vector4;
  104821. backUVs?: Vector4;
  104822. }): VertexData;
  104823. /**
  104824. * Compute normals for given positions and indices
  104825. * @param positions an array of vertex positions, [...., x, y, z, ......]
  104826. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  104827. * @param normals an array of vertex normals, [...., x, y, z, ......]
  104828. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  104829. * * facetNormals : optional array of facet normals (vector3)
  104830. * * facetPositions : optional array of facet positions (vector3)
  104831. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  104832. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  104833. * * bInfo : optional bounding info, required for facetPartitioning computation
  104834. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  104835. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  104836. * * useRightHandedSystem: optional boolean to for right handed system computation
  104837. * * depthSort : optional boolean to enable the facet depth sort computation
  104838. * * distanceTo : optional Vector3 to compute the facet depth from this location
  104839. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  104840. */
  104841. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  104842. facetNormals?: any;
  104843. facetPositions?: any;
  104844. facetPartitioning?: any;
  104845. ratio?: number;
  104846. bInfo?: any;
  104847. bbSize?: Vector3;
  104848. subDiv?: any;
  104849. useRightHandedSystem?: boolean;
  104850. depthSort?: boolean;
  104851. distanceTo?: Vector3;
  104852. depthSortedFacets?: any;
  104853. }): void;
  104854. /** @hidden */
  104855. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  104856. /**
  104857. * Applies VertexData created from the imported parameters to the geometry
  104858. * @param parsedVertexData the parsed data from an imported file
  104859. * @param geometry the geometry to apply the VertexData to
  104860. */
  104861. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  104862. }
  104863. }
  104864. declare module BABYLON {
  104865. /**
  104866. * Defines a target to use with MorphTargetManager
  104867. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104868. */
  104869. export class MorphTarget implements IAnimatable {
  104870. /** defines the name of the target */
  104871. name: string;
  104872. /**
  104873. * Gets or sets the list of animations
  104874. */
  104875. animations: Animation[];
  104876. private _scene;
  104877. private _positions;
  104878. private _normals;
  104879. private _tangents;
  104880. private _uvs;
  104881. private _influence;
  104882. private _uniqueId;
  104883. /**
  104884. * Observable raised when the influence changes
  104885. */
  104886. onInfluenceChanged: Observable<boolean>;
  104887. /** @hidden */
  104888. _onDataLayoutChanged: Observable<void>;
  104889. /**
  104890. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  104891. */
  104892. get influence(): number;
  104893. set influence(influence: number);
  104894. /**
  104895. * Gets or sets the id of the morph Target
  104896. */
  104897. id: string;
  104898. private _animationPropertiesOverride;
  104899. /**
  104900. * Gets or sets the animation properties override
  104901. */
  104902. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  104903. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  104904. /**
  104905. * Creates a new MorphTarget
  104906. * @param name defines the name of the target
  104907. * @param influence defines the influence to use
  104908. * @param scene defines the scene the morphtarget belongs to
  104909. */
  104910. constructor(
  104911. /** defines the name of the target */
  104912. name: string, influence?: number, scene?: Nullable<Scene>);
  104913. /**
  104914. * Gets the unique ID of this manager
  104915. */
  104916. get uniqueId(): number;
  104917. /**
  104918. * Gets a boolean defining if the target contains position data
  104919. */
  104920. get hasPositions(): boolean;
  104921. /**
  104922. * Gets a boolean defining if the target contains normal data
  104923. */
  104924. get hasNormals(): boolean;
  104925. /**
  104926. * Gets a boolean defining if the target contains tangent data
  104927. */
  104928. get hasTangents(): boolean;
  104929. /**
  104930. * Gets a boolean defining if the target contains texture coordinates data
  104931. */
  104932. get hasUVs(): boolean;
  104933. /**
  104934. * Affects position data to this target
  104935. * @param data defines the position data to use
  104936. */
  104937. setPositions(data: Nullable<FloatArray>): void;
  104938. /**
  104939. * Gets the position data stored in this target
  104940. * @returns a FloatArray containing the position data (or null if not present)
  104941. */
  104942. getPositions(): Nullable<FloatArray>;
  104943. /**
  104944. * Affects normal data to this target
  104945. * @param data defines the normal data to use
  104946. */
  104947. setNormals(data: Nullable<FloatArray>): void;
  104948. /**
  104949. * Gets the normal data stored in this target
  104950. * @returns a FloatArray containing the normal data (or null if not present)
  104951. */
  104952. getNormals(): Nullable<FloatArray>;
  104953. /**
  104954. * Affects tangent data to this target
  104955. * @param data defines the tangent data to use
  104956. */
  104957. setTangents(data: Nullable<FloatArray>): void;
  104958. /**
  104959. * Gets the tangent data stored in this target
  104960. * @returns a FloatArray containing the tangent data (or null if not present)
  104961. */
  104962. getTangents(): Nullable<FloatArray>;
  104963. /**
  104964. * Affects texture coordinates data to this target
  104965. * @param data defines the texture coordinates data to use
  104966. */
  104967. setUVs(data: Nullable<FloatArray>): void;
  104968. /**
  104969. * Gets the texture coordinates data stored in this target
  104970. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  104971. */
  104972. getUVs(): Nullable<FloatArray>;
  104973. /**
  104974. * Clone the current target
  104975. * @returns a new MorphTarget
  104976. */
  104977. clone(): MorphTarget;
  104978. /**
  104979. * Serializes the current target into a Serialization object
  104980. * @returns the serialized object
  104981. */
  104982. serialize(): any;
  104983. /**
  104984. * Returns the string "MorphTarget"
  104985. * @returns "MorphTarget"
  104986. */
  104987. getClassName(): string;
  104988. /**
  104989. * Creates a new target from serialized data
  104990. * @param serializationObject defines the serialized data to use
  104991. * @returns a new MorphTarget
  104992. */
  104993. static Parse(serializationObject: any): MorphTarget;
  104994. /**
  104995. * Creates a MorphTarget from mesh data
  104996. * @param mesh defines the source mesh
  104997. * @param name defines the name to use for the new target
  104998. * @param influence defines the influence to attach to the target
  104999. * @returns a new MorphTarget
  105000. */
  105001. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105002. }
  105003. }
  105004. declare module BABYLON {
  105005. /**
  105006. * This class is used to deform meshes using morphing between different targets
  105007. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105008. */
  105009. export class MorphTargetManager {
  105010. private _targets;
  105011. private _targetInfluenceChangedObservers;
  105012. private _targetDataLayoutChangedObservers;
  105013. private _activeTargets;
  105014. private _scene;
  105015. private _influences;
  105016. private _supportsNormals;
  105017. private _supportsTangents;
  105018. private _supportsUVs;
  105019. private _vertexCount;
  105020. private _uniqueId;
  105021. private _tempInfluences;
  105022. /**
  105023. * Gets or sets a boolean indicating if normals must be morphed
  105024. */
  105025. enableNormalMorphing: boolean;
  105026. /**
  105027. * Gets or sets a boolean indicating if tangents must be morphed
  105028. */
  105029. enableTangentMorphing: boolean;
  105030. /**
  105031. * Gets or sets a boolean indicating if UV must be morphed
  105032. */
  105033. enableUVMorphing: boolean;
  105034. /**
  105035. * Creates a new MorphTargetManager
  105036. * @param scene defines the current scene
  105037. */
  105038. constructor(scene?: Nullable<Scene>);
  105039. /**
  105040. * Gets the unique ID of this manager
  105041. */
  105042. get uniqueId(): number;
  105043. /**
  105044. * Gets the number of vertices handled by this manager
  105045. */
  105046. get vertexCount(): number;
  105047. /**
  105048. * Gets a boolean indicating if this manager supports morphing of normals
  105049. */
  105050. get supportsNormals(): boolean;
  105051. /**
  105052. * Gets a boolean indicating if this manager supports morphing of tangents
  105053. */
  105054. get supportsTangents(): boolean;
  105055. /**
  105056. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105057. */
  105058. get supportsUVs(): boolean;
  105059. /**
  105060. * Gets the number of targets stored in this manager
  105061. */
  105062. get numTargets(): number;
  105063. /**
  105064. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105065. */
  105066. get numInfluencers(): number;
  105067. /**
  105068. * Gets the list of influences (one per target)
  105069. */
  105070. get influences(): Float32Array;
  105071. /**
  105072. * Gets the active target at specified index. An active target is a target with an influence > 0
  105073. * @param index defines the index to check
  105074. * @returns the requested target
  105075. */
  105076. getActiveTarget(index: number): MorphTarget;
  105077. /**
  105078. * Gets the target at specified index
  105079. * @param index defines the index to check
  105080. * @returns the requested target
  105081. */
  105082. getTarget(index: number): MorphTarget;
  105083. /**
  105084. * Add a new target to this manager
  105085. * @param target defines the target to add
  105086. */
  105087. addTarget(target: MorphTarget): void;
  105088. /**
  105089. * Removes a target from the manager
  105090. * @param target defines the target to remove
  105091. */
  105092. removeTarget(target: MorphTarget): void;
  105093. /**
  105094. * Clone the current manager
  105095. * @returns a new MorphTargetManager
  105096. */
  105097. clone(): MorphTargetManager;
  105098. /**
  105099. * Serializes the current manager into a Serialization object
  105100. * @returns the serialized object
  105101. */
  105102. serialize(): any;
  105103. private _syncActiveTargets;
  105104. /**
  105105. * Syncrhonize the targets with all the meshes using this morph target manager
  105106. */
  105107. synchronize(): void;
  105108. /**
  105109. * Creates a new MorphTargetManager from serialized data
  105110. * @param serializationObject defines the serialized data
  105111. * @param scene defines the hosting scene
  105112. * @returns the new MorphTargetManager
  105113. */
  105114. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105115. }
  105116. }
  105117. declare module BABYLON {
  105118. /**
  105119. * Class used to represent a specific level of detail of a mesh
  105120. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105121. */
  105122. export class MeshLODLevel {
  105123. /** Defines the distance where this level should start being displayed */
  105124. distance: number;
  105125. /** Defines the mesh to use to render this level */
  105126. mesh: Nullable<Mesh>;
  105127. /**
  105128. * Creates a new LOD level
  105129. * @param distance defines the distance where this level should star being displayed
  105130. * @param mesh defines the mesh to use to render this level
  105131. */
  105132. constructor(
  105133. /** Defines the distance where this level should start being displayed */
  105134. distance: number,
  105135. /** Defines the mesh to use to render this level */
  105136. mesh: Nullable<Mesh>);
  105137. }
  105138. }
  105139. declare module BABYLON {
  105140. /**
  105141. * Helper class used to generate a canvas to manipulate images
  105142. */
  105143. export class CanvasGenerator {
  105144. /**
  105145. * Create a new canvas (or offscreen canvas depending on the context)
  105146. * @param width defines the expected width
  105147. * @param height defines the expected height
  105148. * @return a new canvas or offscreen canvas
  105149. */
  105150. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105151. }
  105152. }
  105153. declare module BABYLON {
  105154. /**
  105155. * Mesh representing the gorund
  105156. */
  105157. export class GroundMesh extends Mesh {
  105158. /** If octree should be generated */
  105159. generateOctree: boolean;
  105160. private _heightQuads;
  105161. /** @hidden */
  105162. _subdivisionsX: number;
  105163. /** @hidden */
  105164. _subdivisionsY: number;
  105165. /** @hidden */
  105166. _width: number;
  105167. /** @hidden */
  105168. _height: number;
  105169. /** @hidden */
  105170. _minX: number;
  105171. /** @hidden */
  105172. _maxX: number;
  105173. /** @hidden */
  105174. _minZ: number;
  105175. /** @hidden */
  105176. _maxZ: number;
  105177. constructor(name: string, scene: Scene);
  105178. /**
  105179. * "GroundMesh"
  105180. * @returns "GroundMesh"
  105181. */
  105182. getClassName(): string;
  105183. /**
  105184. * The minimum of x and y subdivisions
  105185. */
  105186. get subdivisions(): number;
  105187. /**
  105188. * X subdivisions
  105189. */
  105190. get subdivisionsX(): number;
  105191. /**
  105192. * Y subdivisions
  105193. */
  105194. get subdivisionsY(): number;
  105195. /**
  105196. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105197. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105198. * @param chunksCount the number of subdivisions for x and y
  105199. * @param octreeBlocksSize (Default: 32)
  105200. */
  105201. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105202. /**
  105203. * Returns a height (y) value in the Worl system :
  105204. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105205. * @param x x coordinate
  105206. * @param z z coordinate
  105207. * @returns the ground y position if (x, z) are outside the ground surface.
  105208. */
  105209. getHeightAtCoordinates(x: number, z: number): number;
  105210. /**
  105211. * Returns a normalized vector (Vector3) orthogonal to the ground
  105212. * at the ground coordinates (x, z) expressed in the World system.
  105213. * @param x x coordinate
  105214. * @param z z coordinate
  105215. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105216. */
  105217. getNormalAtCoordinates(x: number, z: number): Vector3;
  105218. /**
  105219. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105220. * at the ground coordinates (x, z) expressed in the World system.
  105221. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105222. * @param x x coordinate
  105223. * @param z z coordinate
  105224. * @param ref vector to store the result
  105225. * @returns the GroundMesh.
  105226. */
  105227. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105228. /**
  105229. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105230. * if the ground has been updated.
  105231. * This can be used in the render loop.
  105232. * @returns the GroundMesh.
  105233. */
  105234. updateCoordinateHeights(): GroundMesh;
  105235. private _getFacetAt;
  105236. private _initHeightQuads;
  105237. private _computeHeightQuads;
  105238. /**
  105239. * Serializes this ground mesh
  105240. * @param serializationObject object to write serialization to
  105241. */
  105242. serialize(serializationObject: any): void;
  105243. /**
  105244. * Parses a serialized ground mesh
  105245. * @param parsedMesh the serialized mesh
  105246. * @param scene the scene to create the ground mesh in
  105247. * @returns the created ground mesh
  105248. */
  105249. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105250. }
  105251. }
  105252. declare module BABYLON {
  105253. /**
  105254. * Interface for Physics-Joint data
  105255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105256. */
  105257. export interface PhysicsJointData {
  105258. /**
  105259. * The main pivot of the joint
  105260. */
  105261. mainPivot?: Vector3;
  105262. /**
  105263. * The connected pivot of the joint
  105264. */
  105265. connectedPivot?: Vector3;
  105266. /**
  105267. * The main axis of the joint
  105268. */
  105269. mainAxis?: Vector3;
  105270. /**
  105271. * The connected axis of the joint
  105272. */
  105273. connectedAxis?: Vector3;
  105274. /**
  105275. * The collision of the joint
  105276. */
  105277. collision?: boolean;
  105278. /**
  105279. * Native Oimo/Cannon/Energy data
  105280. */
  105281. nativeParams?: any;
  105282. }
  105283. /**
  105284. * This is a holder class for the physics joint created by the physics plugin
  105285. * It holds a set of functions to control the underlying joint
  105286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105287. */
  105288. export class PhysicsJoint {
  105289. /**
  105290. * The type of the physics joint
  105291. */
  105292. type: number;
  105293. /**
  105294. * The data for the physics joint
  105295. */
  105296. jointData: PhysicsJointData;
  105297. private _physicsJoint;
  105298. protected _physicsPlugin: IPhysicsEnginePlugin;
  105299. /**
  105300. * Initializes the physics joint
  105301. * @param type The type of the physics joint
  105302. * @param jointData The data for the physics joint
  105303. */
  105304. constructor(
  105305. /**
  105306. * The type of the physics joint
  105307. */
  105308. type: number,
  105309. /**
  105310. * The data for the physics joint
  105311. */
  105312. jointData: PhysicsJointData);
  105313. /**
  105314. * Gets the physics joint
  105315. */
  105316. get physicsJoint(): any;
  105317. /**
  105318. * Sets the physics joint
  105319. */
  105320. set physicsJoint(newJoint: any);
  105321. /**
  105322. * Sets the physics plugin
  105323. */
  105324. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105325. /**
  105326. * Execute a function that is physics-plugin specific.
  105327. * @param {Function} func the function that will be executed.
  105328. * It accepts two parameters: the physics world and the physics joint
  105329. */
  105330. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105331. /**
  105332. * Distance-Joint type
  105333. */
  105334. static DistanceJoint: number;
  105335. /**
  105336. * Hinge-Joint type
  105337. */
  105338. static HingeJoint: number;
  105339. /**
  105340. * Ball-and-Socket joint type
  105341. */
  105342. static BallAndSocketJoint: number;
  105343. /**
  105344. * Wheel-Joint type
  105345. */
  105346. static WheelJoint: number;
  105347. /**
  105348. * Slider-Joint type
  105349. */
  105350. static SliderJoint: number;
  105351. /**
  105352. * Prismatic-Joint type
  105353. */
  105354. static PrismaticJoint: number;
  105355. /**
  105356. * Universal-Joint type
  105357. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105358. */
  105359. static UniversalJoint: number;
  105360. /**
  105361. * Hinge-Joint 2 type
  105362. */
  105363. static Hinge2Joint: number;
  105364. /**
  105365. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105366. */
  105367. static PointToPointJoint: number;
  105368. /**
  105369. * Spring-Joint type
  105370. */
  105371. static SpringJoint: number;
  105372. /**
  105373. * Lock-Joint type
  105374. */
  105375. static LockJoint: number;
  105376. }
  105377. /**
  105378. * A class representing a physics distance joint
  105379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105380. */
  105381. export class DistanceJoint extends PhysicsJoint {
  105382. /**
  105383. *
  105384. * @param jointData The data for the Distance-Joint
  105385. */
  105386. constructor(jointData: DistanceJointData);
  105387. /**
  105388. * Update the predefined distance.
  105389. * @param maxDistance The maximum preferred distance
  105390. * @param minDistance The minimum preferred distance
  105391. */
  105392. updateDistance(maxDistance: number, minDistance?: number): void;
  105393. }
  105394. /**
  105395. * Represents a Motor-Enabled Joint
  105396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105397. */
  105398. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105399. /**
  105400. * Initializes the Motor-Enabled Joint
  105401. * @param type The type of the joint
  105402. * @param jointData The physica joint data for the joint
  105403. */
  105404. constructor(type: number, jointData: PhysicsJointData);
  105405. /**
  105406. * Set the motor values.
  105407. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105408. * @param force the force to apply
  105409. * @param maxForce max force for this motor.
  105410. */
  105411. setMotor(force?: number, maxForce?: number): void;
  105412. /**
  105413. * Set the motor's limits.
  105414. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105415. * @param upperLimit The upper limit of the motor
  105416. * @param lowerLimit The lower limit of the motor
  105417. */
  105418. setLimit(upperLimit: number, lowerLimit?: number): void;
  105419. }
  105420. /**
  105421. * This class represents a single physics Hinge-Joint
  105422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105423. */
  105424. export class HingeJoint extends MotorEnabledJoint {
  105425. /**
  105426. * Initializes the Hinge-Joint
  105427. * @param jointData The joint data for the Hinge-Joint
  105428. */
  105429. constructor(jointData: PhysicsJointData);
  105430. /**
  105431. * Set the motor values.
  105432. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105433. * @param {number} force the force to apply
  105434. * @param {number} maxForce max force for this motor.
  105435. */
  105436. setMotor(force?: number, maxForce?: number): void;
  105437. /**
  105438. * Set the motor's limits.
  105439. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105440. * @param upperLimit The upper limit of the motor
  105441. * @param lowerLimit The lower limit of the motor
  105442. */
  105443. setLimit(upperLimit: number, lowerLimit?: number): void;
  105444. }
  105445. /**
  105446. * This class represents a dual hinge physics joint (same as wheel joint)
  105447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105448. */
  105449. export class Hinge2Joint extends MotorEnabledJoint {
  105450. /**
  105451. * Initializes the Hinge2-Joint
  105452. * @param jointData The joint data for the Hinge2-Joint
  105453. */
  105454. constructor(jointData: PhysicsJointData);
  105455. /**
  105456. * Set the motor values.
  105457. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105458. * @param {number} targetSpeed the speed the motor is to reach
  105459. * @param {number} maxForce max force for this motor.
  105460. * @param {motorIndex} the motor's index, 0 or 1.
  105461. */
  105462. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  105463. /**
  105464. * Set the motor limits.
  105465. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105466. * @param {number} upperLimit the upper limit
  105467. * @param {number} lowerLimit lower limit
  105468. * @param {motorIndex} the motor's index, 0 or 1.
  105469. */
  105470. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105471. }
  105472. /**
  105473. * Interface for a motor enabled joint
  105474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105475. */
  105476. export interface IMotorEnabledJoint {
  105477. /**
  105478. * Physics joint
  105479. */
  105480. physicsJoint: any;
  105481. /**
  105482. * Sets the motor of the motor-enabled joint
  105483. * @param force The force of the motor
  105484. * @param maxForce The maximum force of the motor
  105485. * @param motorIndex The index of the motor
  105486. */
  105487. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  105488. /**
  105489. * Sets the limit of the motor
  105490. * @param upperLimit The upper limit of the motor
  105491. * @param lowerLimit The lower limit of the motor
  105492. * @param motorIndex The index of the motor
  105493. */
  105494. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105495. }
  105496. /**
  105497. * Joint data for a Distance-Joint
  105498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105499. */
  105500. export interface DistanceJointData extends PhysicsJointData {
  105501. /**
  105502. * Max distance the 2 joint objects can be apart
  105503. */
  105504. maxDistance: number;
  105505. }
  105506. /**
  105507. * Joint data from a spring joint
  105508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105509. */
  105510. export interface SpringJointData extends PhysicsJointData {
  105511. /**
  105512. * Length of the spring
  105513. */
  105514. length: number;
  105515. /**
  105516. * Stiffness of the spring
  105517. */
  105518. stiffness: number;
  105519. /**
  105520. * Damping of the spring
  105521. */
  105522. damping: number;
  105523. /** this callback will be called when applying the force to the impostors. */
  105524. forceApplicationCallback: () => void;
  105525. }
  105526. }
  105527. declare module BABYLON {
  105528. /**
  105529. * Holds the data for the raycast result
  105530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105531. */
  105532. export class PhysicsRaycastResult {
  105533. private _hasHit;
  105534. private _hitDistance;
  105535. private _hitNormalWorld;
  105536. private _hitPointWorld;
  105537. private _rayFromWorld;
  105538. private _rayToWorld;
  105539. /**
  105540. * Gets if there was a hit
  105541. */
  105542. get hasHit(): boolean;
  105543. /**
  105544. * Gets the distance from the hit
  105545. */
  105546. get hitDistance(): number;
  105547. /**
  105548. * Gets the hit normal/direction in the world
  105549. */
  105550. get hitNormalWorld(): Vector3;
  105551. /**
  105552. * Gets the hit point in the world
  105553. */
  105554. get hitPointWorld(): Vector3;
  105555. /**
  105556. * Gets the ray "start point" of the ray in the world
  105557. */
  105558. get rayFromWorld(): Vector3;
  105559. /**
  105560. * Gets the ray "end point" of the ray in the world
  105561. */
  105562. get rayToWorld(): Vector3;
  105563. /**
  105564. * Sets the hit data (normal & point in world space)
  105565. * @param hitNormalWorld defines the normal in world space
  105566. * @param hitPointWorld defines the point in world space
  105567. */
  105568. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  105569. /**
  105570. * Sets the distance from the start point to the hit point
  105571. * @param distance
  105572. */
  105573. setHitDistance(distance: number): void;
  105574. /**
  105575. * Calculates the distance manually
  105576. */
  105577. calculateHitDistance(): void;
  105578. /**
  105579. * Resets all the values to default
  105580. * @param from The from point on world space
  105581. * @param to The to point on world space
  105582. */
  105583. reset(from?: Vector3, to?: Vector3): void;
  105584. }
  105585. /**
  105586. * Interface for the size containing width and height
  105587. */
  105588. interface IXYZ {
  105589. /**
  105590. * X
  105591. */
  105592. x: number;
  105593. /**
  105594. * Y
  105595. */
  105596. y: number;
  105597. /**
  105598. * Z
  105599. */
  105600. z: number;
  105601. }
  105602. }
  105603. declare module BABYLON {
  105604. /**
  105605. * Interface used to describe a physics joint
  105606. */
  105607. export interface PhysicsImpostorJoint {
  105608. /** Defines the main impostor to which the joint is linked */
  105609. mainImpostor: PhysicsImpostor;
  105610. /** Defines the impostor that is connected to the main impostor using this joint */
  105611. connectedImpostor: PhysicsImpostor;
  105612. /** Defines the joint itself */
  105613. joint: PhysicsJoint;
  105614. }
  105615. /** @hidden */
  105616. export interface IPhysicsEnginePlugin {
  105617. world: any;
  105618. name: string;
  105619. setGravity(gravity: Vector3): void;
  105620. setTimeStep(timeStep: number): void;
  105621. getTimeStep(): number;
  105622. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105623. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105624. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105625. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105626. removePhysicsBody(impostor: PhysicsImpostor): void;
  105627. generateJoint(joint: PhysicsImpostorJoint): void;
  105628. removeJoint(joint: PhysicsImpostorJoint): void;
  105629. isSupported(): boolean;
  105630. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105633. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105634. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105635. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105636. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105637. getBodyMass(impostor: PhysicsImpostor): number;
  105638. getBodyFriction(impostor: PhysicsImpostor): number;
  105639. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105640. getBodyRestitution(impostor: PhysicsImpostor): number;
  105641. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105642. getBodyPressure?(impostor: PhysicsImpostor): number;
  105643. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  105644. getBodyStiffness?(impostor: PhysicsImpostor): number;
  105645. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  105646. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  105647. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  105648. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  105649. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  105650. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  105651. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  105652. sleepBody(impostor: PhysicsImpostor): void;
  105653. wakeUpBody(impostor: PhysicsImpostor): void;
  105654. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105655. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105656. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  105657. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105658. getRadius(impostor: PhysicsImpostor): number;
  105659. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105661. dispose(): void;
  105662. }
  105663. /**
  105664. * Interface used to define a physics engine
  105665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105666. */
  105667. export interface IPhysicsEngine {
  105668. /**
  105669. * Gets the gravity vector used by the simulation
  105670. */
  105671. gravity: Vector3;
  105672. /**
  105673. * Sets the gravity vector used by the simulation
  105674. * @param gravity defines the gravity vector to use
  105675. */
  105676. setGravity(gravity: Vector3): void;
  105677. /**
  105678. * Set the time step of the physics engine.
  105679. * Default is 1/60.
  105680. * To slow it down, enter 1/600 for example.
  105681. * To speed it up, 1/30
  105682. * @param newTimeStep the new timestep to apply to this world.
  105683. */
  105684. setTimeStep(newTimeStep: number): void;
  105685. /**
  105686. * Get the time step of the physics engine.
  105687. * @returns the current time step
  105688. */
  105689. getTimeStep(): number;
  105690. /**
  105691. * Set the sub time step of the physics engine.
  105692. * Default is 0 meaning there is no sub steps
  105693. * To increase physics resolution precision, set a small value (like 1 ms)
  105694. * @param subTimeStep defines the new sub timestep used for physics resolution.
  105695. */
  105696. setSubTimeStep(subTimeStep: number): void;
  105697. /**
  105698. * Get the sub time step of the physics engine.
  105699. * @returns the current sub time step
  105700. */
  105701. getSubTimeStep(): number;
  105702. /**
  105703. * Release all resources
  105704. */
  105705. dispose(): void;
  105706. /**
  105707. * Gets the name of the current physics plugin
  105708. * @returns the name of the plugin
  105709. */
  105710. getPhysicsPluginName(): string;
  105711. /**
  105712. * Adding a new impostor for the impostor tracking.
  105713. * This will be done by the impostor itself.
  105714. * @param impostor the impostor to add
  105715. */
  105716. addImpostor(impostor: PhysicsImpostor): void;
  105717. /**
  105718. * Remove an impostor from the engine.
  105719. * This impostor and its mesh will not longer be updated by the physics engine.
  105720. * @param impostor the impostor to remove
  105721. */
  105722. removeImpostor(impostor: PhysicsImpostor): void;
  105723. /**
  105724. * Add a joint to the physics engine
  105725. * @param mainImpostor defines the main impostor to which the joint is added.
  105726. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105727. * @param joint defines the joint that will connect both impostors.
  105728. */
  105729. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105730. /**
  105731. * Removes a joint from the simulation
  105732. * @param mainImpostor defines the impostor used with the joint
  105733. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105734. * @param joint defines the joint to remove
  105735. */
  105736. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105737. /**
  105738. * Gets the current plugin used to run the simulation
  105739. * @returns current plugin
  105740. */
  105741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105742. /**
  105743. * Gets the list of physic impostors
  105744. * @returns an array of PhysicsImpostor
  105745. */
  105746. getImpostors(): Array<PhysicsImpostor>;
  105747. /**
  105748. * Gets the impostor for a physics enabled object
  105749. * @param object defines the object impersonated by the impostor
  105750. * @returns the PhysicsImpostor or null if not found
  105751. */
  105752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105753. /**
  105754. * Gets the impostor for a physics body object
  105755. * @param body defines physics body used by the impostor
  105756. * @returns the PhysicsImpostor or null if not found
  105757. */
  105758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105759. /**
  105760. * Does a raycast in the physics world
  105761. * @param from when should the ray start?
  105762. * @param to when should the ray end?
  105763. * @returns PhysicsRaycastResult
  105764. */
  105765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105766. /**
  105767. * Called by the scene. No need to call it.
  105768. * @param delta defines the timespam between frames
  105769. */
  105770. _step(delta: number): void;
  105771. }
  105772. }
  105773. declare module BABYLON {
  105774. /**
  105775. * The interface for the physics imposter parameters
  105776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105777. */
  105778. export interface PhysicsImpostorParameters {
  105779. /**
  105780. * The mass of the physics imposter
  105781. */
  105782. mass: number;
  105783. /**
  105784. * The friction of the physics imposter
  105785. */
  105786. friction?: number;
  105787. /**
  105788. * The coefficient of restitution of the physics imposter
  105789. */
  105790. restitution?: number;
  105791. /**
  105792. * The native options of the physics imposter
  105793. */
  105794. nativeOptions?: any;
  105795. /**
  105796. * Specifies if the parent should be ignored
  105797. */
  105798. ignoreParent?: boolean;
  105799. /**
  105800. * Specifies if bi-directional transformations should be disabled
  105801. */
  105802. disableBidirectionalTransformation?: boolean;
  105803. /**
  105804. * The pressure inside the physics imposter, soft object only
  105805. */
  105806. pressure?: number;
  105807. /**
  105808. * The stiffness the physics imposter, soft object only
  105809. */
  105810. stiffness?: number;
  105811. /**
  105812. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  105813. */
  105814. velocityIterations?: number;
  105815. /**
  105816. * The number of iterations used in maintaining consistent vertex positions, soft object only
  105817. */
  105818. positionIterations?: number;
  105819. /**
  105820. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  105821. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  105822. * Add to fix multiple points
  105823. */
  105824. fixedPoints?: number;
  105825. /**
  105826. * The collision margin around a soft object
  105827. */
  105828. margin?: number;
  105829. /**
  105830. * The collision margin around a soft object
  105831. */
  105832. damping?: number;
  105833. /**
  105834. * The path for a rope based on an extrusion
  105835. */
  105836. path?: any;
  105837. /**
  105838. * The shape of an extrusion used for a rope based on an extrusion
  105839. */
  105840. shape?: any;
  105841. }
  105842. /**
  105843. * Interface for a physics-enabled object
  105844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105845. */
  105846. export interface IPhysicsEnabledObject {
  105847. /**
  105848. * The position of the physics-enabled object
  105849. */
  105850. position: Vector3;
  105851. /**
  105852. * The rotation of the physics-enabled object
  105853. */
  105854. rotationQuaternion: Nullable<Quaternion>;
  105855. /**
  105856. * The scale of the physics-enabled object
  105857. */
  105858. scaling: Vector3;
  105859. /**
  105860. * The rotation of the physics-enabled object
  105861. */
  105862. rotation?: Vector3;
  105863. /**
  105864. * The parent of the physics-enabled object
  105865. */
  105866. parent?: any;
  105867. /**
  105868. * The bounding info of the physics-enabled object
  105869. * @returns The bounding info of the physics-enabled object
  105870. */
  105871. getBoundingInfo(): BoundingInfo;
  105872. /**
  105873. * Computes the world matrix
  105874. * @param force Specifies if the world matrix should be computed by force
  105875. * @returns A world matrix
  105876. */
  105877. computeWorldMatrix(force: boolean): Matrix;
  105878. /**
  105879. * Gets the world matrix
  105880. * @returns A world matrix
  105881. */
  105882. getWorldMatrix?(): Matrix;
  105883. /**
  105884. * Gets the child meshes
  105885. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  105886. * @returns An array of abstract meshes
  105887. */
  105888. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  105889. /**
  105890. * Gets the vertex data
  105891. * @param kind The type of vertex data
  105892. * @returns A nullable array of numbers, or a float32 array
  105893. */
  105894. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  105895. /**
  105896. * Gets the indices from the mesh
  105897. * @returns A nullable array of index arrays
  105898. */
  105899. getIndices?(): Nullable<IndicesArray>;
  105900. /**
  105901. * Gets the scene from the mesh
  105902. * @returns the indices array or null
  105903. */
  105904. getScene?(): Scene;
  105905. /**
  105906. * Gets the absolute position from the mesh
  105907. * @returns the absolute position
  105908. */
  105909. getAbsolutePosition(): Vector3;
  105910. /**
  105911. * Gets the absolute pivot point from the mesh
  105912. * @returns the absolute pivot point
  105913. */
  105914. getAbsolutePivotPoint(): Vector3;
  105915. /**
  105916. * Rotates the mesh
  105917. * @param axis The axis of rotation
  105918. * @param amount The amount of rotation
  105919. * @param space The space of the rotation
  105920. * @returns The rotation transform node
  105921. */
  105922. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  105923. /**
  105924. * Translates the mesh
  105925. * @param axis The axis of translation
  105926. * @param distance The distance of translation
  105927. * @param space The space of the translation
  105928. * @returns The transform node
  105929. */
  105930. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  105931. /**
  105932. * Sets the absolute position of the mesh
  105933. * @param absolutePosition The absolute position of the mesh
  105934. * @returns The transform node
  105935. */
  105936. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  105937. /**
  105938. * Gets the class name of the mesh
  105939. * @returns The class name
  105940. */
  105941. getClassName(): string;
  105942. }
  105943. /**
  105944. * Represents a physics imposter
  105945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105946. */
  105947. export class PhysicsImpostor {
  105948. /**
  105949. * The physics-enabled object used as the physics imposter
  105950. */
  105951. object: IPhysicsEnabledObject;
  105952. /**
  105953. * The type of the physics imposter
  105954. */
  105955. type: number;
  105956. private _options;
  105957. private _scene?;
  105958. /**
  105959. * The default object size of the imposter
  105960. */
  105961. static DEFAULT_OBJECT_SIZE: Vector3;
  105962. /**
  105963. * The identity quaternion of the imposter
  105964. */
  105965. static IDENTITY_QUATERNION: Quaternion;
  105966. /** @hidden */
  105967. _pluginData: any;
  105968. private _physicsEngine;
  105969. private _physicsBody;
  105970. private _bodyUpdateRequired;
  105971. private _onBeforePhysicsStepCallbacks;
  105972. private _onAfterPhysicsStepCallbacks;
  105973. /** @hidden */
  105974. _onPhysicsCollideCallbacks: Array<{
  105975. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  105976. otherImpostors: Array<PhysicsImpostor>;
  105977. }>;
  105978. private _deltaPosition;
  105979. private _deltaRotation;
  105980. private _deltaRotationConjugated;
  105981. /** @hidden */
  105982. _isFromLine: boolean;
  105983. private _parent;
  105984. private _isDisposed;
  105985. private static _tmpVecs;
  105986. private static _tmpQuat;
  105987. /**
  105988. * Specifies if the physics imposter is disposed
  105989. */
  105990. get isDisposed(): boolean;
  105991. /**
  105992. * Gets the mass of the physics imposter
  105993. */
  105994. get mass(): number;
  105995. set mass(value: number);
  105996. /**
  105997. * Gets the coefficient of friction
  105998. */
  105999. get friction(): number;
  106000. /**
  106001. * Sets the coefficient of friction
  106002. */
  106003. set friction(value: number);
  106004. /**
  106005. * Gets the coefficient of restitution
  106006. */
  106007. get restitution(): number;
  106008. /**
  106009. * Sets the coefficient of restitution
  106010. */
  106011. set restitution(value: number);
  106012. /**
  106013. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106014. */
  106015. get pressure(): number;
  106016. /**
  106017. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106018. */
  106019. set pressure(value: number);
  106020. /**
  106021. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106022. */
  106023. get stiffness(): number;
  106024. /**
  106025. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106026. */
  106027. set stiffness(value: number);
  106028. /**
  106029. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106030. */
  106031. get velocityIterations(): number;
  106032. /**
  106033. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106034. */
  106035. set velocityIterations(value: number);
  106036. /**
  106037. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106038. */
  106039. get positionIterations(): number;
  106040. /**
  106041. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106042. */
  106043. set positionIterations(value: number);
  106044. /**
  106045. * The unique id of the physics imposter
  106046. * set by the physics engine when adding this impostor to the array
  106047. */
  106048. uniqueId: number;
  106049. /**
  106050. * @hidden
  106051. */
  106052. soft: boolean;
  106053. /**
  106054. * @hidden
  106055. */
  106056. segments: number;
  106057. private _joints;
  106058. /**
  106059. * Initializes the physics imposter
  106060. * @param object The physics-enabled object used as the physics imposter
  106061. * @param type The type of the physics imposter
  106062. * @param _options The options for the physics imposter
  106063. * @param _scene The Babylon scene
  106064. */
  106065. constructor(
  106066. /**
  106067. * The physics-enabled object used as the physics imposter
  106068. */
  106069. object: IPhysicsEnabledObject,
  106070. /**
  106071. * The type of the physics imposter
  106072. */
  106073. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106074. /**
  106075. * This function will completly initialize this impostor.
  106076. * It will create a new body - but only if this mesh has no parent.
  106077. * If it has, this impostor will not be used other than to define the impostor
  106078. * of the child mesh.
  106079. * @hidden
  106080. */
  106081. _init(): void;
  106082. private _getPhysicsParent;
  106083. /**
  106084. * Should a new body be generated.
  106085. * @returns boolean specifying if body initialization is required
  106086. */
  106087. isBodyInitRequired(): boolean;
  106088. /**
  106089. * Sets the updated scaling
  106090. * @param updated Specifies if the scaling is updated
  106091. */
  106092. setScalingUpdated(): void;
  106093. /**
  106094. * Force a regeneration of this or the parent's impostor's body.
  106095. * Use under cautious - This will remove all joints already implemented.
  106096. */
  106097. forceUpdate(): void;
  106098. /**
  106099. * Gets the body that holds this impostor. Either its own, or its parent.
  106100. */
  106101. get physicsBody(): any;
  106102. /**
  106103. * Get the parent of the physics imposter
  106104. * @returns Physics imposter or null
  106105. */
  106106. get parent(): Nullable<PhysicsImpostor>;
  106107. /**
  106108. * Sets the parent of the physics imposter
  106109. */
  106110. set parent(value: Nullable<PhysicsImpostor>);
  106111. /**
  106112. * Set the physics body. Used mainly by the physics engine/plugin
  106113. */
  106114. set physicsBody(physicsBody: any);
  106115. /**
  106116. * Resets the update flags
  106117. */
  106118. resetUpdateFlags(): void;
  106119. /**
  106120. * Gets the object extend size
  106121. * @returns the object extend size
  106122. */
  106123. getObjectExtendSize(): Vector3;
  106124. /**
  106125. * Gets the object center
  106126. * @returns The object center
  106127. */
  106128. getObjectCenter(): Vector3;
  106129. /**
  106130. * Get a specific parameter from the options parameters
  106131. * @param paramName The object parameter name
  106132. * @returns The object parameter
  106133. */
  106134. getParam(paramName: string): any;
  106135. /**
  106136. * Sets a specific parameter in the options given to the physics plugin
  106137. * @param paramName The parameter name
  106138. * @param value The value of the parameter
  106139. */
  106140. setParam(paramName: string, value: number): void;
  106141. /**
  106142. * Specifically change the body's mass option. Won't recreate the physics body object
  106143. * @param mass The mass of the physics imposter
  106144. */
  106145. setMass(mass: number): void;
  106146. /**
  106147. * Gets the linear velocity
  106148. * @returns linear velocity or null
  106149. */
  106150. getLinearVelocity(): Nullable<Vector3>;
  106151. /**
  106152. * Sets the linear velocity
  106153. * @param velocity linear velocity or null
  106154. */
  106155. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106156. /**
  106157. * Gets the angular velocity
  106158. * @returns angular velocity or null
  106159. */
  106160. getAngularVelocity(): Nullable<Vector3>;
  106161. /**
  106162. * Sets the angular velocity
  106163. * @param velocity The velocity or null
  106164. */
  106165. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106166. /**
  106167. * Execute a function with the physics plugin native code
  106168. * Provide a function the will have two variables - the world object and the physics body object
  106169. * @param func The function to execute with the physics plugin native code
  106170. */
  106171. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106172. /**
  106173. * Register a function that will be executed before the physics world is stepping forward
  106174. * @param func The function to execute before the physics world is stepped forward
  106175. */
  106176. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106177. /**
  106178. * Unregister a function that will be executed before the physics world is stepping forward
  106179. * @param func The function to execute before the physics world is stepped forward
  106180. */
  106181. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106182. /**
  106183. * Register a function that will be executed after the physics step
  106184. * @param func The function to execute after physics step
  106185. */
  106186. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106187. /**
  106188. * Unregisters a function that will be executed after the physics step
  106189. * @param func The function to execute after physics step
  106190. */
  106191. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106192. /**
  106193. * register a function that will be executed when this impostor collides against a different body
  106194. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106195. * @param func Callback that is executed on collision
  106196. */
  106197. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106198. /**
  106199. * Unregisters the physics imposter on contact
  106200. * @param collideAgainst The physics object to collide against
  106201. * @param func Callback to execute on collision
  106202. */
  106203. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106204. private _tmpQuat;
  106205. private _tmpQuat2;
  106206. /**
  106207. * Get the parent rotation
  106208. * @returns The parent rotation
  106209. */
  106210. getParentsRotation(): Quaternion;
  106211. /**
  106212. * this function is executed by the physics engine.
  106213. */
  106214. beforeStep: () => void;
  106215. /**
  106216. * this function is executed by the physics engine
  106217. */
  106218. afterStep: () => void;
  106219. /**
  106220. * Legacy collision detection event support
  106221. */
  106222. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106223. /**
  106224. * event and body object due to cannon's event-based architecture.
  106225. */
  106226. onCollide: (e: {
  106227. body: any;
  106228. }) => void;
  106229. /**
  106230. * Apply a force
  106231. * @param force The force to apply
  106232. * @param contactPoint The contact point for the force
  106233. * @returns The physics imposter
  106234. */
  106235. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106236. /**
  106237. * Apply an impulse
  106238. * @param force The impulse force
  106239. * @param contactPoint The contact point for the impulse force
  106240. * @returns The physics imposter
  106241. */
  106242. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106243. /**
  106244. * A help function to create a joint
  106245. * @param otherImpostor A physics imposter used to create a joint
  106246. * @param jointType The type of joint
  106247. * @param jointData The data for the joint
  106248. * @returns The physics imposter
  106249. */
  106250. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106251. /**
  106252. * Add a joint to this impostor with a different impostor
  106253. * @param otherImpostor A physics imposter used to add a joint
  106254. * @param joint The joint to add
  106255. * @returns The physics imposter
  106256. */
  106257. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106258. /**
  106259. * Add an anchor to a cloth impostor
  106260. * @param otherImpostor rigid impostor to anchor to
  106261. * @param width ratio across width from 0 to 1
  106262. * @param height ratio up height from 0 to 1
  106263. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106264. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106265. * @returns impostor the soft imposter
  106266. */
  106267. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106268. /**
  106269. * Add a hook to a rope impostor
  106270. * @param otherImpostor rigid impostor to anchor to
  106271. * @param length ratio across rope from 0 to 1
  106272. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106273. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106274. * @returns impostor the rope imposter
  106275. */
  106276. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106277. /**
  106278. * Will keep this body still, in a sleep mode.
  106279. * @returns the physics imposter
  106280. */
  106281. sleep(): PhysicsImpostor;
  106282. /**
  106283. * Wake the body up.
  106284. * @returns The physics imposter
  106285. */
  106286. wakeUp(): PhysicsImpostor;
  106287. /**
  106288. * Clones the physics imposter
  106289. * @param newObject The physics imposter clones to this physics-enabled object
  106290. * @returns A nullable physics imposter
  106291. */
  106292. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106293. /**
  106294. * Disposes the physics imposter
  106295. */
  106296. dispose(): void;
  106297. /**
  106298. * Sets the delta position
  106299. * @param position The delta position amount
  106300. */
  106301. setDeltaPosition(position: Vector3): void;
  106302. /**
  106303. * Sets the delta rotation
  106304. * @param rotation The delta rotation amount
  106305. */
  106306. setDeltaRotation(rotation: Quaternion): void;
  106307. /**
  106308. * Gets the box size of the physics imposter and stores the result in the input parameter
  106309. * @param result Stores the box size
  106310. * @returns The physics imposter
  106311. */
  106312. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106313. /**
  106314. * Gets the radius of the physics imposter
  106315. * @returns Radius of the physics imposter
  106316. */
  106317. getRadius(): number;
  106318. /**
  106319. * Sync a bone with this impostor
  106320. * @param bone The bone to sync to the impostor.
  106321. * @param boneMesh The mesh that the bone is influencing.
  106322. * @param jointPivot The pivot of the joint / bone in local space.
  106323. * @param distToJoint Optional distance from the impostor to the joint.
  106324. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106325. */
  106326. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106327. /**
  106328. * Sync impostor to a bone
  106329. * @param bone The bone that the impostor will be synced to.
  106330. * @param boneMesh The mesh that the bone is influencing.
  106331. * @param jointPivot The pivot of the joint / bone in local space.
  106332. * @param distToJoint Optional distance from the impostor to the joint.
  106333. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106334. * @param boneAxis Optional vector3 axis the bone is aligned with
  106335. */
  106336. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106337. /**
  106338. * No-Imposter type
  106339. */
  106340. static NoImpostor: number;
  106341. /**
  106342. * Sphere-Imposter type
  106343. */
  106344. static SphereImpostor: number;
  106345. /**
  106346. * Box-Imposter type
  106347. */
  106348. static BoxImpostor: number;
  106349. /**
  106350. * Plane-Imposter type
  106351. */
  106352. static PlaneImpostor: number;
  106353. /**
  106354. * Mesh-imposter type
  106355. */
  106356. static MeshImpostor: number;
  106357. /**
  106358. * Capsule-Impostor type (Ammo.js plugin only)
  106359. */
  106360. static CapsuleImpostor: number;
  106361. /**
  106362. * Cylinder-Imposter type
  106363. */
  106364. static CylinderImpostor: number;
  106365. /**
  106366. * Particle-Imposter type
  106367. */
  106368. static ParticleImpostor: number;
  106369. /**
  106370. * Heightmap-Imposter type
  106371. */
  106372. static HeightmapImpostor: number;
  106373. /**
  106374. * ConvexHull-Impostor type (Ammo.js plugin only)
  106375. */
  106376. static ConvexHullImpostor: number;
  106377. /**
  106378. * Custom-Imposter type (Ammo.js plugin only)
  106379. */
  106380. static CustomImpostor: number;
  106381. /**
  106382. * Rope-Imposter type
  106383. */
  106384. static RopeImpostor: number;
  106385. /**
  106386. * Cloth-Imposter type
  106387. */
  106388. static ClothImpostor: number;
  106389. /**
  106390. * Softbody-Imposter type
  106391. */
  106392. static SoftbodyImpostor: number;
  106393. }
  106394. }
  106395. declare module BABYLON {
  106396. /**
  106397. * @hidden
  106398. **/
  106399. export class _CreationDataStorage {
  106400. closePath?: boolean;
  106401. closeArray?: boolean;
  106402. idx: number[];
  106403. dashSize: number;
  106404. gapSize: number;
  106405. path3D: Path3D;
  106406. pathArray: Vector3[][];
  106407. arc: number;
  106408. radius: number;
  106409. cap: number;
  106410. tessellation: number;
  106411. }
  106412. /**
  106413. * @hidden
  106414. **/
  106415. class _InstanceDataStorage {
  106416. visibleInstances: any;
  106417. batchCache: _InstancesBatch;
  106418. instancesBufferSize: number;
  106419. instancesBuffer: Nullable<Buffer>;
  106420. instancesData: Float32Array;
  106421. overridenInstanceCount: number;
  106422. isFrozen: boolean;
  106423. previousBatch: Nullable<_InstancesBatch>;
  106424. hardwareInstancedRendering: boolean;
  106425. sideOrientation: number;
  106426. manualUpdate: boolean;
  106427. }
  106428. /**
  106429. * @hidden
  106430. **/
  106431. export class _InstancesBatch {
  106432. mustReturn: boolean;
  106433. visibleInstances: Nullable<InstancedMesh[]>[];
  106434. renderSelf: boolean[];
  106435. hardwareInstancedRendering: boolean[];
  106436. }
  106437. /**
  106438. * @hidden
  106439. **/
  106440. class _ThinInstanceDataStorage {
  106441. instancesCount: number;
  106442. matrixBuffer: Nullable<Buffer>;
  106443. matrixBufferSize: number;
  106444. matrixData: Nullable<Float32Array>;
  106445. boundingVectors: Array<Vector3>;
  106446. }
  106447. /**
  106448. * Class used to represent renderable models
  106449. */
  106450. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  106451. /**
  106452. * Mesh side orientation : usually the external or front surface
  106453. */
  106454. static readonly FRONTSIDE: number;
  106455. /**
  106456. * Mesh side orientation : usually the internal or back surface
  106457. */
  106458. static readonly BACKSIDE: number;
  106459. /**
  106460. * Mesh side orientation : both internal and external or front and back surfaces
  106461. */
  106462. static readonly DOUBLESIDE: number;
  106463. /**
  106464. * Mesh side orientation : by default, `FRONTSIDE`
  106465. */
  106466. static readonly DEFAULTSIDE: number;
  106467. /**
  106468. * Mesh cap setting : no cap
  106469. */
  106470. static readonly NO_CAP: number;
  106471. /**
  106472. * Mesh cap setting : one cap at the beginning of the mesh
  106473. */
  106474. static readonly CAP_START: number;
  106475. /**
  106476. * Mesh cap setting : one cap at the end of the mesh
  106477. */
  106478. static readonly CAP_END: number;
  106479. /**
  106480. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  106481. */
  106482. static readonly CAP_ALL: number;
  106483. /**
  106484. * Mesh pattern setting : no flip or rotate
  106485. */
  106486. static readonly NO_FLIP: number;
  106487. /**
  106488. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  106489. */
  106490. static readonly FLIP_TILE: number;
  106491. /**
  106492. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  106493. */
  106494. static readonly ROTATE_TILE: number;
  106495. /**
  106496. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  106497. */
  106498. static readonly FLIP_ROW: number;
  106499. /**
  106500. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  106501. */
  106502. static readonly ROTATE_ROW: number;
  106503. /**
  106504. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  106505. */
  106506. static readonly FLIP_N_ROTATE_TILE: number;
  106507. /**
  106508. * Mesh pattern setting : rotate pattern and rotate
  106509. */
  106510. static readonly FLIP_N_ROTATE_ROW: number;
  106511. /**
  106512. * Mesh tile positioning : part tiles same on left/right or top/bottom
  106513. */
  106514. static readonly CENTER: number;
  106515. /**
  106516. * Mesh tile positioning : part tiles on left
  106517. */
  106518. static readonly LEFT: number;
  106519. /**
  106520. * Mesh tile positioning : part tiles on right
  106521. */
  106522. static readonly RIGHT: number;
  106523. /**
  106524. * Mesh tile positioning : part tiles on top
  106525. */
  106526. static readonly TOP: number;
  106527. /**
  106528. * Mesh tile positioning : part tiles on bottom
  106529. */
  106530. static readonly BOTTOM: number;
  106531. /**
  106532. * Gets the default side orientation.
  106533. * @param orientation the orientation to value to attempt to get
  106534. * @returns the default orientation
  106535. * @hidden
  106536. */
  106537. static _GetDefaultSideOrientation(orientation?: number): number;
  106538. private _internalMeshDataInfo;
  106539. get computeBonesUsingShaders(): boolean;
  106540. set computeBonesUsingShaders(value: boolean);
  106541. /**
  106542. * An event triggered before rendering the mesh
  106543. */
  106544. get onBeforeRenderObservable(): Observable<Mesh>;
  106545. /**
  106546. * An event triggered before binding the mesh
  106547. */
  106548. get onBeforeBindObservable(): Observable<Mesh>;
  106549. /**
  106550. * An event triggered after rendering the mesh
  106551. */
  106552. get onAfterRenderObservable(): Observable<Mesh>;
  106553. /**
  106554. * An event triggered before drawing the mesh
  106555. */
  106556. get onBeforeDrawObservable(): Observable<Mesh>;
  106557. private _onBeforeDrawObserver;
  106558. /**
  106559. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  106560. */
  106561. set onBeforeDraw(callback: () => void);
  106562. get hasInstances(): boolean;
  106563. get hasThinInstances(): boolean;
  106564. /**
  106565. * Gets the delay loading state of the mesh (when delay loading is turned on)
  106566. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  106567. */
  106568. delayLoadState: number;
  106569. /**
  106570. * Gets the list of instances created from this mesh
  106571. * it is not supposed to be modified manually.
  106572. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  106573. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106574. */
  106575. instances: InstancedMesh[];
  106576. /**
  106577. * Gets the file containing delay loading data for this mesh
  106578. */
  106579. delayLoadingFile: string;
  106580. /** @hidden */
  106581. _binaryInfo: any;
  106582. /**
  106583. * User defined function used to change how LOD level selection is done
  106584. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106585. */
  106586. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  106587. /**
  106588. * Gets or sets the morph target manager
  106589. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106590. */
  106591. get morphTargetManager(): Nullable<MorphTargetManager>;
  106592. set morphTargetManager(value: Nullable<MorphTargetManager>);
  106593. /** @hidden */
  106594. _creationDataStorage: Nullable<_CreationDataStorage>;
  106595. /** @hidden */
  106596. _geometry: Nullable<Geometry>;
  106597. /** @hidden */
  106598. _delayInfo: Array<string>;
  106599. /** @hidden */
  106600. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  106601. /** @hidden */
  106602. _instanceDataStorage: _InstanceDataStorage;
  106603. /** @hidden */
  106604. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  106605. private _effectiveMaterial;
  106606. /** @hidden */
  106607. _shouldGenerateFlatShading: boolean;
  106608. /** @hidden */
  106609. _originalBuilderSideOrientation: number;
  106610. /**
  106611. * Use this property to change the original side orientation defined at construction time
  106612. */
  106613. overrideMaterialSideOrientation: Nullable<number>;
  106614. /**
  106615. * Gets the source mesh (the one used to clone this one from)
  106616. */
  106617. get source(): Nullable<Mesh>;
  106618. /**
  106619. * Gets or sets a boolean indicating that this mesh does not use index buffer
  106620. */
  106621. get isUnIndexed(): boolean;
  106622. set isUnIndexed(value: boolean);
  106623. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  106624. get worldMatrixInstancedBuffer(): Float32Array;
  106625. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  106626. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  106627. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  106628. /**
  106629. * @constructor
  106630. * @param name The value used by scene.getMeshByName() to do a lookup.
  106631. * @param scene The scene to add this mesh to.
  106632. * @param parent The parent of this mesh, if it has one
  106633. * @param source An optional Mesh from which geometry is shared, cloned.
  106634. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  106635. * When false, achieved by calling a clone(), also passing False.
  106636. * This will make creation of children, recursive.
  106637. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  106638. */
  106639. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  106640. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  106641. doNotInstantiate: boolean;
  106642. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  106643. /**
  106644. * Gets the class name
  106645. * @returns the string "Mesh".
  106646. */
  106647. getClassName(): string;
  106648. /** @hidden */
  106649. get _isMesh(): boolean;
  106650. /**
  106651. * Returns a description of this mesh
  106652. * @param fullDetails define if full details about this mesh must be used
  106653. * @returns a descriptive string representing this mesh
  106654. */
  106655. toString(fullDetails?: boolean): string;
  106656. /** @hidden */
  106657. _unBindEffect(): void;
  106658. /**
  106659. * Gets a boolean indicating if this mesh has LOD
  106660. */
  106661. get hasLODLevels(): boolean;
  106662. /**
  106663. * Gets the list of MeshLODLevel associated with the current mesh
  106664. * @returns an array of MeshLODLevel
  106665. */
  106666. getLODLevels(): MeshLODLevel[];
  106667. private _sortLODLevels;
  106668. /**
  106669. * Add a mesh as LOD level triggered at the given distance.
  106670. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106671. * @param distance The distance from the center of the object to show this level
  106672. * @param mesh The mesh to be added as LOD level (can be null)
  106673. * @return This mesh (for chaining)
  106674. */
  106675. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  106676. /**
  106677. * Returns the LOD level mesh at the passed distance or null if not found.
  106678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106679. * @param distance The distance from the center of the object to show this level
  106680. * @returns a Mesh or `null`
  106681. */
  106682. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  106683. /**
  106684. * Remove a mesh from the LOD array
  106685. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106686. * @param mesh defines the mesh to be removed
  106687. * @return This mesh (for chaining)
  106688. */
  106689. removeLODLevel(mesh: Mesh): Mesh;
  106690. /**
  106691. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  106692. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106693. * @param camera defines the camera to use to compute distance
  106694. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  106695. * @return This mesh (for chaining)
  106696. */
  106697. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  106698. /**
  106699. * Gets the mesh internal Geometry object
  106700. */
  106701. get geometry(): Nullable<Geometry>;
  106702. /**
  106703. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  106704. * @returns the total number of vertices
  106705. */
  106706. getTotalVertices(): number;
  106707. /**
  106708. * Returns the content of an associated vertex buffer
  106709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106710. * - VertexBuffer.PositionKind
  106711. * - VertexBuffer.UVKind
  106712. * - VertexBuffer.UV2Kind
  106713. * - VertexBuffer.UV3Kind
  106714. * - VertexBuffer.UV4Kind
  106715. * - VertexBuffer.UV5Kind
  106716. * - VertexBuffer.UV6Kind
  106717. * - VertexBuffer.ColorKind
  106718. * - VertexBuffer.MatricesIndicesKind
  106719. * - VertexBuffer.MatricesIndicesExtraKind
  106720. * - VertexBuffer.MatricesWeightsKind
  106721. * - VertexBuffer.MatricesWeightsExtraKind
  106722. * @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
  106723. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  106724. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  106725. */
  106726. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106727. /**
  106728. * Returns the mesh VertexBuffer object from the requested `kind`
  106729. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106730. * - VertexBuffer.PositionKind
  106731. * - VertexBuffer.NormalKind
  106732. * - VertexBuffer.UVKind
  106733. * - VertexBuffer.UV2Kind
  106734. * - VertexBuffer.UV3Kind
  106735. * - VertexBuffer.UV4Kind
  106736. * - VertexBuffer.UV5Kind
  106737. * - VertexBuffer.UV6Kind
  106738. * - VertexBuffer.ColorKind
  106739. * - VertexBuffer.MatricesIndicesKind
  106740. * - VertexBuffer.MatricesIndicesExtraKind
  106741. * - VertexBuffer.MatricesWeightsKind
  106742. * - VertexBuffer.MatricesWeightsExtraKind
  106743. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  106744. */
  106745. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106746. /**
  106747. * Tests if a specific vertex buffer is associated with this mesh
  106748. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  106749. * - VertexBuffer.PositionKind
  106750. * - VertexBuffer.NormalKind
  106751. * - VertexBuffer.UVKind
  106752. * - VertexBuffer.UV2Kind
  106753. * - VertexBuffer.UV3Kind
  106754. * - VertexBuffer.UV4Kind
  106755. * - VertexBuffer.UV5Kind
  106756. * - VertexBuffer.UV6Kind
  106757. * - VertexBuffer.ColorKind
  106758. * - VertexBuffer.MatricesIndicesKind
  106759. * - VertexBuffer.MatricesIndicesExtraKind
  106760. * - VertexBuffer.MatricesWeightsKind
  106761. * - VertexBuffer.MatricesWeightsExtraKind
  106762. * @returns a boolean
  106763. */
  106764. isVerticesDataPresent(kind: string): boolean;
  106765. /**
  106766. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  106767. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  106768. * - VertexBuffer.PositionKind
  106769. * - VertexBuffer.UVKind
  106770. * - VertexBuffer.UV2Kind
  106771. * - VertexBuffer.UV3Kind
  106772. * - VertexBuffer.UV4Kind
  106773. * - VertexBuffer.UV5Kind
  106774. * - VertexBuffer.UV6Kind
  106775. * - VertexBuffer.ColorKind
  106776. * - VertexBuffer.MatricesIndicesKind
  106777. * - VertexBuffer.MatricesIndicesExtraKind
  106778. * - VertexBuffer.MatricesWeightsKind
  106779. * - VertexBuffer.MatricesWeightsExtraKind
  106780. * @returns a boolean
  106781. */
  106782. isVertexBufferUpdatable(kind: string): boolean;
  106783. /**
  106784. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  106785. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106786. * - VertexBuffer.PositionKind
  106787. * - VertexBuffer.NormalKind
  106788. * - VertexBuffer.UVKind
  106789. * - VertexBuffer.UV2Kind
  106790. * - VertexBuffer.UV3Kind
  106791. * - VertexBuffer.UV4Kind
  106792. * - VertexBuffer.UV5Kind
  106793. * - VertexBuffer.UV6Kind
  106794. * - VertexBuffer.ColorKind
  106795. * - VertexBuffer.MatricesIndicesKind
  106796. * - VertexBuffer.MatricesIndicesExtraKind
  106797. * - VertexBuffer.MatricesWeightsKind
  106798. * - VertexBuffer.MatricesWeightsExtraKind
  106799. * @returns an array of strings
  106800. */
  106801. getVerticesDataKinds(): string[];
  106802. /**
  106803. * Returns a positive integer : the total number of indices in this mesh geometry.
  106804. * @returns the numner of indices or zero if the mesh has no geometry.
  106805. */
  106806. getTotalIndices(): number;
  106807. /**
  106808. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106809. * @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.
  106810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106811. * @returns the indices array or an empty array if the mesh has no geometry
  106812. */
  106813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106814. get isBlocked(): boolean;
  106815. /**
  106816. * Determine if the current mesh is ready to be rendered
  106817. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  106818. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  106819. * @returns true if all associated assets are ready (material, textures, shaders)
  106820. */
  106821. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  106822. /**
  106823. * 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.
  106824. */
  106825. get areNormalsFrozen(): boolean;
  106826. /**
  106827. * 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.
  106828. * @returns the current mesh
  106829. */
  106830. freezeNormals(): Mesh;
  106831. /**
  106832. * 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
  106833. * @returns the current mesh
  106834. */
  106835. unfreezeNormals(): Mesh;
  106836. /**
  106837. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  106838. */
  106839. set overridenInstanceCount(count: number);
  106840. /** @hidden */
  106841. _preActivate(): Mesh;
  106842. /** @hidden */
  106843. _preActivateForIntermediateRendering(renderId: number): Mesh;
  106844. /** @hidden */
  106845. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  106846. protected _afterComputeWorldMatrix(): void;
  106847. /** @hidden */
  106848. _postActivate(): void;
  106849. /**
  106850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  106851. * This means the mesh underlying bounding box and sphere are recomputed.
  106852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  106853. * @returns the current mesh
  106854. */
  106855. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  106856. /** @hidden */
  106857. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  106858. /**
  106859. * This function will subdivide the mesh into multiple submeshes
  106860. * @param count defines the expected number of submeshes
  106861. */
  106862. subdivide(count: number): void;
  106863. /**
  106864. * Copy a FloatArray into a specific associated vertex buffer
  106865. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106866. * - VertexBuffer.PositionKind
  106867. * - VertexBuffer.UVKind
  106868. * - VertexBuffer.UV2Kind
  106869. * - VertexBuffer.UV3Kind
  106870. * - VertexBuffer.UV4Kind
  106871. * - VertexBuffer.UV5Kind
  106872. * - VertexBuffer.UV6Kind
  106873. * - VertexBuffer.ColorKind
  106874. * - VertexBuffer.MatricesIndicesKind
  106875. * - VertexBuffer.MatricesIndicesExtraKind
  106876. * - VertexBuffer.MatricesWeightsKind
  106877. * - VertexBuffer.MatricesWeightsExtraKind
  106878. * @param data defines the data source
  106879. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  106880. * @param stride defines the data stride size (can be null)
  106881. * @returns the current mesh
  106882. */
  106883. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  106884. /**
  106885. * Delete a vertex buffer associated with this mesh
  106886. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  106887. * - VertexBuffer.PositionKind
  106888. * - VertexBuffer.UVKind
  106889. * - VertexBuffer.UV2Kind
  106890. * - VertexBuffer.UV3Kind
  106891. * - VertexBuffer.UV4Kind
  106892. * - VertexBuffer.UV5Kind
  106893. * - VertexBuffer.UV6Kind
  106894. * - VertexBuffer.ColorKind
  106895. * - VertexBuffer.MatricesIndicesKind
  106896. * - VertexBuffer.MatricesIndicesExtraKind
  106897. * - VertexBuffer.MatricesWeightsKind
  106898. * - VertexBuffer.MatricesWeightsExtraKind
  106899. */
  106900. removeVerticesData(kind: string): void;
  106901. /**
  106902. * Flags an associated vertex buffer as updatable
  106903. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  106904. * - VertexBuffer.PositionKind
  106905. * - VertexBuffer.UVKind
  106906. * - VertexBuffer.UV2Kind
  106907. * - VertexBuffer.UV3Kind
  106908. * - VertexBuffer.UV4Kind
  106909. * - VertexBuffer.UV5Kind
  106910. * - VertexBuffer.UV6Kind
  106911. * - VertexBuffer.ColorKind
  106912. * - VertexBuffer.MatricesIndicesKind
  106913. * - VertexBuffer.MatricesIndicesExtraKind
  106914. * - VertexBuffer.MatricesWeightsKind
  106915. * - VertexBuffer.MatricesWeightsExtraKind
  106916. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  106917. */
  106918. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  106919. /**
  106920. * Sets the mesh global Vertex Buffer
  106921. * @param buffer defines the buffer to use
  106922. * @returns the current mesh
  106923. */
  106924. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  106925. /**
  106926. * Update a specific associated vertex buffer
  106927. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106928. * - VertexBuffer.PositionKind
  106929. * - VertexBuffer.UVKind
  106930. * - VertexBuffer.UV2Kind
  106931. * - VertexBuffer.UV3Kind
  106932. * - VertexBuffer.UV4Kind
  106933. * - VertexBuffer.UV5Kind
  106934. * - VertexBuffer.UV6Kind
  106935. * - VertexBuffer.ColorKind
  106936. * - VertexBuffer.MatricesIndicesKind
  106937. * - VertexBuffer.MatricesIndicesExtraKind
  106938. * - VertexBuffer.MatricesWeightsKind
  106939. * - VertexBuffer.MatricesWeightsExtraKind
  106940. * @param data defines the data source
  106941. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106942. * @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)
  106943. * @returns the current mesh
  106944. */
  106945. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  106946. /**
  106947. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  106948. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  106949. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  106950. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  106951. * @returns the current mesh
  106952. */
  106953. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  106954. /**
  106955. * Creates a un-shared specific occurence of the geometry for the mesh.
  106956. * @returns the current mesh
  106957. */
  106958. makeGeometryUnique(): Mesh;
  106959. /**
  106960. * Set the index buffer of this mesh
  106961. * @param indices defines the source data
  106962. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  106963. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  106964. * @returns the current mesh
  106965. */
  106966. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  106967. /**
  106968. * Update the current index buffer
  106969. * @param indices defines the source data
  106970. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  106971. * @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)
  106972. * @returns the current mesh
  106973. */
  106974. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  106975. /**
  106976. * Invert the geometry to move from a right handed system to a left handed one.
  106977. * @returns the current mesh
  106978. */
  106979. toLeftHanded(): Mesh;
  106980. /** @hidden */
  106981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  106982. /** @hidden */
  106983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  106984. /**
  106985. * Registers for this mesh a javascript function called just before the rendering process
  106986. * @param func defines the function to call before rendering this mesh
  106987. * @returns the current mesh
  106988. */
  106989. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  106990. /**
  106991. * Disposes a previously registered javascript function called before the rendering
  106992. * @param func defines the function to remove
  106993. * @returns the current mesh
  106994. */
  106995. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  106996. /**
  106997. * Registers for this mesh a javascript function called just after the rendering is complete
  106998. * @param func defines the function to call after rendering this mesh
  106999. * @returns the current mesh
  107000. */
  107001. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107002. /**
  107003. * Disposes a previously registered javascript function called after the rendering.
  107004. * @param func defines the function to remove
  107005. * @returns the current mesh
  107006. */
  107007. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107008. /** @hidden */
  107009. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107010. /** @hidden */
  107011. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107012. /** @hidden */
  107013. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107014. /** @hidden */
  107015. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107016. /** @hidden */
  107017. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107018. /** @hidden */
  107019. _rebuild(): void;
  107020. /** @hidden */
  107021. _freeze(): void;
  107022. /** @hidden */
  107023. _unFreeze(): void;
  107024. /**
  107025. * 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
  107026. * @param subMesh defines the subMesh to render
  107027. * @param enableAlphaMode defines if alpha mode can be changed
  107028. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107029. * @returns the current mesh
  107030. */
  107031. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107032. private _onBeforeDraw;
  107033. /**
  107034. * Renormalize the mesh and patch it up if there are no weights
  107035. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107036. * However in the case of zero weights then we set just a single influence to 1.
  107037. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107038. */
  107039. cleanMatrixWeights(): void;
  107040. private normalizeSkinFourWeights;
  107041. private normalizeSkinWeightsAndExtra;
  107042. /**
  107043. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107044. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107045. * the user know there was an issue with importing the mesh
  107046. * @returns a validation object with skinned, valid and report string
  107047. */
  107048. validateSkinning(): {
  107049. skinned: boolean;
  107050. valid: boolean;
  107051. report: string;
  107052. };
  107053. /** @hidden */
  107054. _checkDelayState(): Mesh;
  107055. private _queueLoad;
  107056. /**
  107057. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107058. * A mesh is in the frustum if its bounding box intersects the frustum
  107059. * @param frustumPlanes defines the frustum to test
  107060. * @returns true if the mesh is in the frustum planes
  107061. */
  107062. isInFrustum(frustumPlanes: Plane[]): boolean;
  107063. /**
  107064. * Sets the mesh material by the material or multiMaterial `id` property
  107065. * @param id is a string identifying the material or the multiMaterial
  107066. * @returns the current mesh
  107067. */
  107068. setMaterialByID(id: string): Mesh;
  107069. /**
  107070. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107071. * @returns an array of IAnimatable
  107072. */
  107073. getAnimatables(): IAnimatable[];
  107074. /**
  107075. * Modifies the mesh geometry according to the passed transformation matrix.
  107076. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107077. * The mesh normals are modified using the same transformation.
  107078. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107079. * @param transform defines the transform matrix to use
  107080. * @see https://doc.babylonjs.com/resources/baking_transformations
  107081. * @returns the current mesh
  107082. */
  107083. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107084. /**
  107085. * Modifies the mesh geometry according to its own current World Matrix.
  107086. * The mesh World Matrix is then reset.
  107087. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107088. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107089. * @see https://doc.babylonjs.com/resources/baking_transformations
  107090. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107091. * @returns the current mesh
  107092. */
  107093. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107094. /** @hidden */
  107095. get _positions(): Nullable<Vector3[]>;
  107096. /** @hidden */
  107097. _resetPointsArrayCache(): Mesh;
  107098. /** @hidden */
  107099. _generatePointsArray(): boolean;
  107100. /**
  107101. * Returns a new Mesh object generated from the current mesh properties.
  107102. * This method must not get confused with createInstance()
  107103. * @param name is a string, the name given to the new mesh
  107104. * @param newParent can be any Node object (default `null`)
  107105. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107106. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107107. * @returns a new mesh
  107108. */
  107109. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107110. /**
  107111. * Releases resources associated with this mesh.
  107112. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107113. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107114. */
  107115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107116. /** @hidden */
  107117. _disposeInstanceSpecificData(): void;
  107118. /** @hidden */
  107119. _disposeThinInstanceSpecificData(): void;
  107120. /**
  107121. * Modifies the mesh geometry according to a displacement map.
  107122. * 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.
  107123. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107124. * @param url is a string, the URL from the image file is to be downloaded.
  107125. * @param minHeight is the lower limit of the displacement.
  107126. * @param maxHeight is the upper limit of the displacement.
  107127. * @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.
  107128. * @param uvOffset is an optional vector2 used to offset UV.
  107129. * @param uvScale is an optional vector2 used to scale UV.
  107130. * @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.
  107131. * @returns the Mesh.
  107132. */
  107133. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107134. /**
  107135. * Modifies the mesh geometry according to a displacementMap buffer.
  107136. * 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.
  107137. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107138. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107139. * @param heightMapWidth is the width of the buffer image.
  107140. * @param heightMapHeight is the height of the buffer image.
  107141. * @param minHeight is the lower limit of the displacement.
  107142. * @param maxHeight is the upper limit of the displacement.
  107143. * @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.
  107144. * @param uvOffset is an optional vector2 used to offset UV.
  107145. * @param uvScale is an optional vector2 used to scale UV.
  107146. * @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.
  107147. * @returns the Mesh.
  107148. */
  107149. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107150. /**
  107151. * Modify the mesh to get a flat shading rendering.
  107152. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107153. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107154. * @returns current mesh
  107155. */
  107156. convertToFlatShadedMesh(): Mesh;
  107157. /**
  107158. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107159. * In other words, more vertices, no more indices and a single bigger VBO.
  107160. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107161. * @returns current mesh
  107162. */
  107163. convertToUnIndexedMesh(): Mesh;
  107164. /**
  107165. * Inverses facet orientations.
  107166. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107167. * @param flipNormals will also inverts the normals
  107168. * @returns current mesh
  107169. */
  107170. flipFaces(flipNormals?: boolean): Mesh;
  107171. /**
  107172. * Increase the number of facets and hence vertices in a mesh
  107173. * Vertex normals are interpolated from existing vertex normals
  107174. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107175. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107176. */
  107177. increaseVertices(numberPerEdge: number): void;
  107178. /**
  107179. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107180. * This will undo any application of covertToFlatShadedMesh
  107181. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107182. */
  107183. forceSharedVertices(): void;
  107184. /** @hidden */
  107185. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107186. /** @hidden */
  107187. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107188. /**
  107189. * Creates a new InstancedMesh object from the mesh model.
  107190. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107191. * @param name defines the name of the new instance
  107192. * @returns a new InstancedMesh
  107193. */
  107194. createInstance(name: string): InstancedMesh;
  107195. /**
  107196. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107197. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107198. * @returns the current mesh
  107199. */
  107200. synchronizeInstances(): Mesh;
  107201. /**
  107202. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107203. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107204. * This should be used together with the simplification to avoid disappearing triangles.
  107205. * @param successCallback an optional success callback to be called after the optimization finished.
  107206. * @returns the current mesh
  107207. */
  107208. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107209. /**
  107210. * Serialize current mesh
  107211. * @param serializationObject defines the object which will receive the serialization data
  107212. */
  107213. serialize(serializationObject: any): void;
  107214. /** @hidden */
  107215. _syncGeometryWithMorphTargetManager(): void;
  107216. /** @hidden */
  107217. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107218. /**
  107219. * Returns a new Mesh object parsed from the source provided.
  107220. * @param parsedMesh is the source
  107221. * @param scene defines the hosting scene
  107222. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107223. * @returns a new Mesh
  107224. */
  107225. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107226. /**
  107227. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107229. * @param name defines the name of the mesh to create
  107230. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107231. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107232. * @param closePath creates a seam between the first and the last points of each path of the path array
  107233. * @param offset is taken in account only if the `pathArray` is containing a single path
  107234. * @param scene defines the hosting scene
  107235. * @param updatable defines if the mesh must be flagged as updatable
  107236. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107237. * @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)
  107238. * @returns a new Mesh
  107239. */
  107240. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107241. /**
  107242. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107243. * @param name defines the name of the mesh to create
  107244. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107245. * @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
  107246. * @param scene defines the hosting scene
  107247. * @param updatable defines if the mesh must be flagged as updatable
  107248. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107249. * @returns a new Mesh
  107250. */
  107251. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107252. /**
  107253. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107254. * @param name defines the name of the mesh to create
  107255. * @param size sets the size (float) of each box side (default 1)
  107256. * @param scene defines the hosting scene
  107257. * @param updatable defines if the mesh must be flagged as updatable
  107258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107259. * @returns a new Mesh
  107260. */
  107261. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107262. /**
  107263. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107264. * @param name defines the name of the mesh to create
  107265. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107266. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107267. * @param scene defines the hosting scene
  107268. * @param updatable defines if the mesh must be flagged as updatable
  107269. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107270. * @returns a new Mesh
  107271. */
  107272. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107273. /**
  107274. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107275. * @param name defines the name of the mesh to create
  107276. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107277. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107278. * @param scene defines the hosting scene
  107279. * @returns a new Mesh
  107280. */
  107281. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107282. /**
  107283. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107284. * @param name defines the name of the mesh to create
  107285. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107286. * @param diameterTop set the top cap diameter (floats, default 1)
  107287. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107288. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107289. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107290. * @param scene defines the hosting scene
  107291. * @param updatable defines if the mesh must be flagged as updatable
  107292. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107293. * @returns a new Mesh
  107294. */
  107295. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107296. /**
  107297. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107298. * @param name defines the name of the mesh to create
  107299. * @param diameter sets the diameter size (float) of the torus (default 1)
  107300. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107301. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107302. * @param scene defines the hosting scene
  107303. * @param updatable defines if the mesh must be flagged as updatable
  107304. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107305. * @returns a new Mesh
  107306. */
  107307. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107308. /**
  107309. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107310. * @param name defines the name of the mesh to create
  107311. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107312. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107313. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107314. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107315. * @param p the number of windings on X axis (positive integers, default 2)
  107316. * @param q the number of windings on Y axis (positive integers, default 3)
  107317. * @param scene defines the hosting scene
  107318. * @param updatable defines if the mesh must be flagged as updatable
  107319. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107320. * @returns a new Mesh
  107321. */
  107322. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107323. /**
  107324. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107325. * @param name defines the name of the mesh to create
  107326. * @param points is an array successive Vector3
  107327. * @param scene defines the hosting scene
  107328. * @param updatable defines if the mesh must be flagged as updatable
  107329. * @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).
  107330. * @returns a new Mesh
  107331. */
  107332. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107333. /**
  107334. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107335. * @param name defines the name of the mesh to create
  107336. * @param points is an array successive Vector3
  107337. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107338. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107339. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107340. * @param scene defines the hosting scene
  107341. * @param updatable defines if the mesh must be flagged as updatable
  107342. * @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)
  107343. * @returns a new Mesh
  107344. */
  107345. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107346. /**
  107347. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107348. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107349. * 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.
  107350. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107351. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107352. * Remember you can only change the shape positions, not their number when updating a polygon.
  107353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107354. * @param name defines the name of the mesh to create
  107355. * @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
  107356. * @param scene defines the hosting scene
  107357. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107358. * @param updatable defines if the mesh must be flagged as updatable
  107359. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107360. * @param earcutInjection can be used to inject your own earcut reference
  107361. * @returns a new Mesh
  107362. */
  107363. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107364. /**
  107365. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107367. * @param name defines the name of the mesh to create
  107368. * @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
  107369. * @param depth defines the height of extrusion
  107370. * @param scene defines the hosting scene
  107371. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107372. * @param updatable defines if the mesh must be flagged as updatable
  107373. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107374. * @param earcutInjection can be used to inject your own earcut reference
  107375. * @returns a new Mesh
  107376. */
  107377. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107378. /**
  107379. * Creates an extruded shape mesh.
  107380. * 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
  107381. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107383. * @param name defines the name of the mesh to create
  107384. * @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
  107385. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107386. * @param scale is the value to scale the shape
  107387. * @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
  107388. * @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
  107389. * @param scene defines the hosting scene
  107390. * @param updatable defines if the mesh must be flagged as updatable
  107391. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107392. * @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)
  107393. * @returns a new Mesh
  107394. */
  107395. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107396. /**
  107397. * Creates an custom extruded shape mesh.
  107398. * The custom extrusion is a parametric shape.
  107399. * It has no predefined shape. Its final shape will depend on the input parameters.
  107400. * Please consider using the same method from the MeshBuilder class instead
  107401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107402. * @param name defines the name of the mesh to create
  107403. * @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
  107404. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107405. * @param scaleFunction is a custom Javascript function called on each path point
  107406. * @param rotationFunction is a custom Javascript function called on each path point
  107407. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107408. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107409. * @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
  107410. * @param scene defines the hosting scene
  107411. * @param updatable defines if the mesh must be flagged as updatable
  107412. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107413. * @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)
  107414. * @returns a new Mesh
  107415. */
  107416. 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;
  107417. /**
  107418. * Creates lathe mesh.
  107419. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107420. * Please consider using the same method from the MeshBuilder class instead
  107421. * @param name defines the name of the mesh to create
  107422. * @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
  107423. * @param radius is the radius value of the lathe
  107424. * @param tessellation is the side number of the lathe.
  107425. * @param scene defines the hosting scene
  107426. * @param updatable defines if the mesh must be flagged as updatable
  107427. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107428. * @returns a new Mesh
  107429. */
  107430. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107431. /**
  107432. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107433. * @param name defines the name of the mesh to create
  107434. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107435. * @param scene defines the hosting scene
  107436. * @param updatable defines if the mesh must be flagged as updatable
  107437. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107438. * @returns a new Mesh
  107439. */
  107440. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107441. /**
  107442. * Creates a ground mesh.
  107443. * Please consider using the same method from the MeshBuilder class instead
  107444. * @param name defines the name of the mesh to create
  107445. * @param width set the width of the ground
  107446. * @param height set the height of the ground
  107447. * @param subdivisions sets the number of subdivisions per side
  107448. * @param scene defines the hosting scene
  107449. * @param updatable defines if the mesh must be flagged as updatable
  107450. * @returns a new Mesh
  107451. */
  107452. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  107453. /**
  107454. * Creates a tiled ground mesh.
  107455. * Please consider using the same method from the MeshBuilder class instead
  107456. * @param name defines the name of the mesh to create
  107457. * @param xmin set the ground minimum X coordinate
  107458. * @param zmin set the ground minimum Y coordinate
  107459. * @param xmax set the ground maximum X coordinate
  107460. * @param zmax set the ground maximum Z coordinate
  107461. * @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
  107462. * @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
  107463. * @param scene defines the hosting scene
  107464. * @param updatable defines if the mesh must be flagged as updatable
  107465. * @returns a new Mesh
  107466. */
  107467. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  107468. w: number;
  107469. h: number;
  107470. }, precision: {
  107471. w: number;
  107472. h: number;
  107473. }, scene: Scene, updatable?: boolean): Mesh;
  107474. /**
  107475. * Creates a ground mesh from a height map.
  107476. * Please consider using the same method from the MeshBuilder class instead
  107477. * @see https://doc.babylonjs.com/babylon101/height_map
  107478. * @param name defines the name of the mesh to create
  107479. * @param url sets the URL of the height map image resource
  107480. * @param width set the ground width size
  107481. * @param height set the ground height size
  107482. * @param subdivisions sets the number of subdivision per side
  107483. * @param minHeight is the minimum altitude on the ground
  107484. * @param maxHeight is the maximum altitude on the ground
  107485. * @param scene defines the hosting scene
  107486. * @param updatable defines if the mesh must be flagged as updatable
  107487. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  107488. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107489. * @returns a new Mesh
  107490. */
  107491. 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;
  107492. /**
  107493. * Creates a tube mesh.
  107494. * The tube is a parametric shape.
  107495. * It has no predefined shape. Its final shape will depend on the input parameters.
  107496. * Please consider using the same method from the MeshBuilder class instead
  107497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107498. * @param name defines the name of the mesh to create
  107499. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  107500. * @param radius sets the tube radius size
  107501. * @param tessellation is the number of sides on the tubular surface
  107502. * @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
  107503. * @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
  107504. * @param scene defines the hosting scene
  107505. * @param updatable defines if the mesh must be flagged as updatable
  107506. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107507. * @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)
  107508. * @returns a new Mesh
  107509. */
  107510. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  107511. (i: number, distance: number): number;
  107512. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107513. /**
  107514. * Creates a polyhedron mesh.
  107515. * Please consider using the same method from the MeshBuilder class instead.
  107516. * * 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
  107517. * * The parameter `size` (positive float, default 1) sets the polygon size
  107518. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107519. * * 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`
  107520. * * 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
  107521. * * 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)`)
  107522. * * 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
  107523. * * 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
  107524. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107527. * @param name defines the name of the mesh to create
  107528. * @param options defines the options used to create the mesh
  107529. * @param scene defines the hosting scene
  107530. * @returns a new Mesh
  107531. */
  107532. static CreatePolyhedron(name: string, options: {
  107533. type?: number;
  107534. size?: number;
  107535. sizeX?: number;
  107536. sizeY?: number;
  107537. sizeZ?: number;
  107538. custom?: any;
  107539. faceUV?: Vector4[];
  107540. faceColors?: Color4[];
  107541. updatable?: boolean;
  107542. sideOrientation?: number;
  107543. }, scene: Scene): Mesh;
  107544. /**
  107545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107547. * * 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`)
  107548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107549. * * 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
  107550. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107553. * @param name defines the name of the mesh
  107554. * @param options defines the options used to create the mesh
  107555. * @param scene defines the hosting scene
  107556. * @returns a new Mesh
  107557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107558. */
  107559. static CreateIcoSphere(name: string, options: {
  107560. radius?: number;
  107561. flat?: boolean;
  107562. subdivisions?: number;
  107563. sideOrientation?: number;
  107564. updatable?: boolean;
  107565. }, scene: Scene): Mesh;
  107566. /**
  107567. * Creates a decal mesh.
  107568. * Please consider using the same method from the MeshBuilder class instead.
  107569. * A decal is a mesh usually applied as a model onto the surface of another mesh
  107570. * @param name defines the name of the mesh
  107571. * @param sourceMesh defines the mesh receiving the decal
  107572. * @param position sets the position of the decal in world coordinates
  107573. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  107574. * @param size sets the decal scaling
  107575. * @param angle sets the angle to rotate the decal
  107576. * @returns a new Mesh
  107577. */
  107578. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  107579. /**
  107580. * Prepare internal position array for software CPU skinning
  107581. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  107582. */
  107583. setPositionsForCPUSkinning(): Float32Array;
  107584. /**
  107585. * Prepare internal normal array for software CPU skinning
  107586. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  107587. */
  107588. setNormalsForCPUSkinning(): Float32Array;
  107589. /**
  107590. * Updates the vertex buffer by applying transformation from the bones
  107591. * @param skeleton defines the skeleton to apply to current mesh
  107592. * @returns the current mesh
  107593. */
  107594. applySkeleton(skeleton: Skeleton): Mesh;
  107595. /**
  107596. * 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
  107597. * @param meshes defines the list of meshes to scan
  107598. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  107599. */
  107600. static MinMax(meshes: AbstractMesh[]): {
  107601. min: Vector3;
  107602. max: Vector3;
  107603. };
  107604. /**
  107605. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  107606. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  107607. * @returns a vector3
  107608. */
  107609. static Center(meshesOrMinMaxVector: {
  107610. min: Vector3;
  107611. max: Vector3;
  107612. } | AbstractMesh[]): Vector3;
  107613. /**
  107614. * Merge the array of meshes into a single mesh for performance reasons.
  107615. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  107616. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  107617. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  107618. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  107619. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  107620. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  107621. * @returns a new mesh
  107622. */
  107623. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  107624. /** @hidden */
  107625. addInstance(instance: InstancedMesh): void;
  107626. /** @hidden */
  107627. removeInstance(instance: InstancedMesh): void;
  107628. }
  107629. }
  107630. declare module BABYLON {
  107631. /**
  107632. * This is the base class of all the camera used in the application.
  107633. * @see https://doc.babylonjs.com/features/cameras
  107634. */
  107635. export class Camera extends Node {
  107636. /** @hidden */
  107637. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  107638. /**
  107639. * This is the default projection mode used by the cameras.
  107640. * It helps recreating a feeling of perspective and better appreciate depth.
  107641. * This is the best way to simulate real life cameras.
  107642. */
  107643. static readonly PERSPECTIVE_CAMERA: number;
  107644. /**
  107645. * This helps creating camera with an orthographic mode.
  107646. * 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.
  107647. */
  107648. static readonly ORTHOGRAPHIC_CAMERA: number;
  107649. /**
  107650. * This is the default FOV mode for perspective cameras.
  107651. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  107652. */
  107653. static readonly FOVMODE_VERTICAL_FIXED: number;
  107654. /**
  107655. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  107656. */
  107657. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  107658. /**
  107659. * This specifies ther is no need for a camera rig.
  107660. * Basically only one eye is rendered corresponding to the camera.
  107661. */
  107662. static readonly RIG_MODE_NONE: number;
  107663. /**
  107664. * Simulates a camera Rig with one blue eye and one red eye.
  107665. * This can be use with 3d blue and red glasses.
  107666. */
  107667. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  107668. /**
  107669. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  107670. */
  107671. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  107672. /**
  107673. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  107674. */
  107675. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  107676. /**
  107677. * Defines that both eyes of the camera will be rendered over under each other.
  107678. */
  107679. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  107680. /**
  107681. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  107682. */
  107683. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  107684. /**
  107685. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  107686. */
  107687. static readonly RIG_MODE_VR: number;
  107688. /**
  107689. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  107690. */
  107691. static readonly RIG_MODE_WEBVR: number;
  107692. /**
  107693. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  107694. */
  107695. static readonly RIG_MODE_CUSTOM: number;
  107696. /**
  107697. * Defines if by default attaching controls should prevent the default javascript event to continue.
  107698. */
  107699. static ForceAttachControlToAlwaysPreventDefault: boolean;
  107700. /**
  107701. * Define the input manager associated with the camera.
  107702. */
  107703. inputs: CameraInputsManager<Camera>;
  107704. /** @hidden */
  107705. _position: Vector3;
  107706. /**
  107707. * Define the current local position of the camera in the scene
  107708. */
  107709. get position(): Vector3;
  107710. set position(newPosition: Vector3);
  107711. /**
  107712. * The vector the camera should consider as up.
  107713. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  107714. */
  107715. upVector: Vector3;
  107716. /**
  107717. * Define the current limit on the left side for an orthographic camera
  107718. * In scene unit
  107719. */
  107720. orthoLeft: Nullable<number>;
  107721. /**
  107722. * Define the current limit on the right side for an orthographic camera
  107723. * In scene unit
  107724. */
  107725. orthoRight: Nullable<number>;
  107726. /**
  107727. * Define the current limit on the bottom side for an orthographic camera
  107728. * In scene unit
  107729. */
  107730. orthoBottom: Nullable<number>;
  107731. /**
  107732. * Define the current limit on the top side for an orthographic camera
  107733. * In scene unit
  107734. */
  107735. orthoTop: Nullable<number>;
  107736. /**
  107737. * Field Of View is set in Radians. (default is 0.8)
  107738. */
  107739. fov: number;
  107740. /**
  107741. * Define the minimum distance the camera can see from.
  107742. * This is important to note that the depth buffer are not infinite and the closer it starts
  107743. * the more your scene might encounter depth fighting issue.
  107744. */
  107745. minZ: number;
  107746. /**
  107747. * Define the maximum distance the camera can see to.
  107748. * This is important to note that the depth buffer are not infinite and the further it end
  107749. * the more your scene might encounter depth fighting issue.
  107750. */
  107751. maxZ: number;
  107752. /**
  107753. * Define the default inertia of the camera.
  107754. * This helps giving a smooth feeling to the camera movement.
  107755. */
  107756. inertia: number;
  107757. /**
  107758. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  107759. */
  107760. mode: number;
  107761. /**
  107762. * Define whether the camera is intermediate.
  107763. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  107764. */
  107765. isIntermediate: boolean;
  107766. /**
  107767. * Define the viewport of the camera.
  107768. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  107769. */
  107770. viewport: Viewport;
  107771. /**
  107772. * Restricts the camera to viewing objects with the same layerMask.
  107773. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  107774. */
  107775. layerMask: number;
  107776. /**
  107777. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  107778. */
  107779. fovMode: number;
  107780. /**
  107781. * Rig mode of the camera.
  107782. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  107783. * This is normally controlled byt the camera themselves as internal use.
  107784. */
  107785. cameraRigMode: number;
  107786. /**
  107787. * Defines the distance between both "eyes" in case of a RIG
  107788. */
  107789. interaxialDistance: number;
  107790. /**
  107791. * Defines if stereoscopic rendering is done side by side or over under.
  107792. */
  107793. isStereoscopicSideBySide: boolean;
  107794. /**
  107795. * 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
  107796. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  107797. * else in the scene. (Eg. security camera)
  107798. *
  107799. * 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)
  107800. */
  107801. customRenderTargets: RenderTargetTexture[];
  107802. /**
  107803. * When set, the camera will render to this render target instead of the default canvas
  107804. *
  107805. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  107806. */
  107807. outputRenderTarget: Nullable<RenderTargetTexture>;
  107808. /**
  107809. * Observable triggered when the camera view matrix has changed.
  107810. */
  107811. onViewMatrixChangedObservable: Observable<Camera>;
  107812. /**
  107813. * Observable triggered when the camera Projection matrix has changed.
  107814. */
  107815. onProjectionMatrixChangedObservable: Observable<Camera>;
  107816. /**
  107817. * Observable triggered when the inputs have been processed.
  107818. */
  107819. onAfterCheckInputsObservable: Observable<Camera>;
  107820. /**
  107821. * Observable triggered when reset has been called and applied to the camera.
  107822. */
  107823. onRestoreStateObservable: Observable<Camera>;
  107824. /**
  107825. * Is this camera a part of a rig system?
  107826. */
  107827. isRigCamera: boolean;
  107828. /**
  107829. * If isRigCamera set to true this will be set with the parent camera.
  107830. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  107831. */
  107832. rigParent?: Camera;
  107833. /** @hidden */
  107834. _cameraRigParams: any;
  107835. /** @hidden */
  107836. _rigCameras: Camera[];
  107837. /** @hidden */
  107838. _rigPostProcess: Nullable<PostProcess>;
  107839. protected _webvrViewMatrix: Matrix;
  107840. /** @hidden */
  107841. _skipRendering: boolean;
  107842. /** @hidden */
  107843. _projectionMatrix: Matrix;
  107844. /** @hidden */
  107845. _postProcesses: Nullable<PostProcess>[];
  107846. /** @hidden */
  107847. _activeMeshes: SmartArray<AbstractMesh>;
  107848. protected _globalPosition: Vector3;
  107849. /** @hidden */
  107850. _computedViewMatrix: Matrix;
  107851. private _doNotComputeProjectionMatrix;
  107852. private _transformMatrix;
  107853. private _frustumPlanes;
  107854. private _refreshFrustumPlanes;
  107855. private _storedFov;
  107856. private _stateStored;
  107857. /**
  107858. * Instantiates a new camera object.
  107859. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  107860. * @see https://doc.babylonjs.com/features/cameras
  107861. * @param name Defines the name of the camera in the scene
  107862. * @param position Defines the position of the camera
  107863. * @param scene Defines the scene the camera belongs too
  107864. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  107865. */
  107866. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107867. /**
  107868. * Store current camera state (fov, position, etc..)
  107869. * @returns the camera
  107870. */
  107871. storeState(): Camera;
  107872. /**
  107873. * Restores the camera state values if it has been stored. You must call storeState() first
  107874. */
  107875. protected _restoreStateValues(): boolean;
  107876. /**
  107877. * Restored camera state. You must call storeState() first.
  107878. * @returns true if restored and false otherwise
  107879. */
  107880. restoreState(): boolean;
  107881. /**
  107882. * Gets the class name of the camera.
  107883. * @returns the class name
  107884. */
  107885. getClassName(): string;
  107886. /** @hidden */
  107887. readonly _isCamera: boolean;
  107888. /**
  107889. * Gets a string representation of the camera useful for debug purpose.
  107890. * @param fullDetails Defines that a more verboe level of logging is required
  107891. * @returns the string representation
  107892. */
  107893. toString(fullDetails?: boolean): string;
  107894. /**
  107895. * Gets the current world space position of the camera.
  107896. */
  107897. get globalPosition(): Vector3;
  107898. /**
  107899. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  107900. * @returns the active meshe list
  107901. */
  107902. getActiveMeshes(): SmartArray<AbstractMesh>;
  107903. /**
  107904. * Check whether a mesh is part of the current active mesh list of the camera
  107905. * @param mesh Defines the mesh to check
  107906. * @returns true if active, false otherwise
  107907. */
  107908. isActiveMesh(mesh: Mesh): boolean;
  107909. /**
  107910. * Is this camera ready to be used/rendered
  107911. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  107912. * @return true if the camera is ready
  107913. */
  107914. isReady(completeCheck?: boolean): boolean;
  107915. /** @hidden */
  107916. _initCache(): void;
  107917. /** @hidden */
  107918. _updateCache(ignoreParentClass?: boolean): void;
  107919. /** @hidden */
  107920. _isSynchronized(): boolean;
  107921. /** @hidden */
  107922. _isSynchronizedViewMatrix(): boolean;
  107923. /** @hidden */
  107924. _isSynchronizedProjectionMatrix(): boolean;
  107925. /**
  107926. * Attach the input controls to a specific dom element to get the input from.
  107927. * @param element Defines the element the controls should be listened from
  107928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107929. */
  107930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107931. /**
  107932. * Detach the current controls from the specified dom element.
  107933. * @param element Defines the element to stop listening the inputs from
  107934. */
  107935. detachControl(element: HTMLElement): void;
  107936. /**
  107937. * Update the camera state according to the different inputs gathered during the frame.
  107938. */
  107939. update(): void;
  107940. /** @hidden */
  107941. _checkInputs(): void;
  107942. /** @hidden */
  107943. get rigCameras(): Camera[];
  107944. /**
  107945. * Gets the post process used by the rig cameras
  107946. */
  107947. get rigPostProcess(): Nullable<PostProcess>;
  107948. /**
  107949. * Internal, gets the first post proces.
  107950. * @returns the first post process to be run on this camera.
  107951. */
  107952. _getFirstPostProcess(): Nullable<PostProcess>;
  107953. private _cascadePostProcessesToRigCams;
  107954. /**
  107955. * Attach a post process to the camera.
  107956. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  107957. * @param postProcess The post process to attach to the camera
  107958. * @param insertAt The position of the post process in case several of them are in use in the scene
  107959. * @returns the position the post process has been inserted at
  107960. */
  107961. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  107962. /**
  107963. * Detach a post process to the camera.
  107964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  107965. * @param postProcess The post process to detach from the camera
  107966. */
  107967. detachPostProcess(postProcess: PostProcess): void;
  107968. /**
  107969. * Gets the current world matrix of the camera
  107970. */
  107971. getWorldMatrix(): Matrix;
  107972. /** @hidden */
  107973. _getViewMatrix(): Matrix;
  107974. /**
  107975. * Gets the current view matrix of the camera.
  107976. * @param force forces the camera to recompute the matrix without looking at the cached state
  107977. * @returns the view matrix
  107978. */
  107979. getViewMatrix(force?: boolean): Matrix;
  107980. /**
  107981. * Freeze the projection matrix.
  107982. * It will prevent the cache check of the camera projection compute and can speed up perf
  107983. * if no parameter of the camera are meant to change
  107984. * @param projection Defines manually a projection if necessary
  107985. */
  107986. freezeProjectionMatrix(projection?: Matrix): void;
  107987. /**
  107988. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  107989. */
  107990. unfreezeProjectionMatrix(): void;
  107991. /**
  107992. * Gets the current projection matrix of the camera.
  107993. * @param force forces the camera to recompute the matrix without looking at the cached state
  107994. * @returns the projection matrix
  107995. */
  107996. getProjectionMatrix(force?: boolean): Matrix;
  107997. /**
  107998. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  107999. * @returns a Matrix
  108000. */
  108001. getTransformationMatrix(): Matrix;
  108002. private _updateFrustumPlanes;
  108003. /**
  108004. * Checks if a cullable object (mesh...) is in the camera frustum
  108005. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108006. * @param target The object to check
  108007. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108008. * @returns true if the object is in frustum otherwise false
  108009. */
  108010. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108011. /**
  108012. * Checks if a cullable object (mesh...) is in the camera frustum
  108013. * Unlike isInFrustum this cheks the full bounding box
  108014. * @param target The object to check
  108015. * @returns true if the object is in frustum otherwise false
  108016. */
  108017. isCompletelyInFrustum(target: ICullable): boolean;
  108018. /**
  108019. * Gets a ray in the forward direction from the camera.
  108020. * @param length Defines the length of the ray to create
  108021. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108022. * @param origin Defines the start point of the ray which defaults to the camera position
  108023. * @returns the forward ray
  108024. */
  108025. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108026. /**
  108027. * Releases resources associated with this node.
  108028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108030. */
  108031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108032. /** @hidden */
  108033. _isLeftCamera: boolean;
  108034. /**
  108035. * Gets the left camera of a rig setup in case of Rigged Camera
  108036. */
  108037. get isLeftCamera(): boolean;
  108038. /** @hidden */
  108039. _isRightCamera: boolean;
  108040. /**
  108041. * Gets the right camera of a rig setup in case of Rigged Camera
  108042. */
  108043. get isRightCamera(): boolean;
  108044. /**
  108045. * Gets the left camera of a rig setup in case of Rigged Camera
  108046. */
  108047. get leftCamera(): Nullable<FreeCamera>;
  108048. /**
  108049. * Gets the right camera of a rig setup in case of Rigged Camera
  108050. */
  108051. get rightCamera(): Nullable<FreeCamera>;
  108052. /**
  108053. * Gets the left camera target of a rig setup in case of Rigged Camera
  108054. * @returns the target position
  108055. */
  108056. getLeftTarget(): Nullable<Vector3>;
  108057. /**
  108058. * Gets the right camera target of a rig setup in case of Rigged Camera
  108059. * @returns the target position
  108060. */
  108061. getRightTarget(): Nullable<Vector3>;
  108062. /**
  108063. * @hidden
  108064. */
  108065. setCameraRigMode(mode: number, rigParams: any): void;
  108066. /** @hidden */
  108067. static _setStereoscopicRigMode(camera: Camera): void;
  108068. /** @hidden */
  108069. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108070. /** @hidden */
  108071. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108072. /** @hidden */
  108073. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108074. /** @hidden */
  108075. _getVRProjectionMatrix(): Matrix;
  108076. protected _updateCameraRotationMatrix(): void;
  108077. protected _updateWebVRCameraRotationMatrix(): void;
  108078. /**
  108079. * This function MUST be overwritten by the different WebVR cameras available.
  108080. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108081. * @hidden
  108082. */
  108083. _getWebVRProjectionMatrix(): Matrix;
  108084. /**
  108085. * This function MUST be overwritten by the different WebVR cameras available.
  108086. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108087. * @hidden
  108088. */
  108089. _getWebVRViewMatrix(): Matrix;
  108090. /** @hidden */
  108091. setCameraRigParameter(name: string, value: any): void;
  108092. /**
  108093. * needs to be overridden by children so sub has required properties to be copied
  108094. * @hidden
  108095. */
  108096. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108097. /**
  108098. * May need to be overridden by children
  108099. * @hidden
  108100. */
  108101. _updateRigCameras(): void;
  108102. /** @hidden */
  108103. _setupInputs(): void;
  108104. /**
  108105. * Serialiaze the camera setup to a json represention
  108106. * @returns the JSON representation
  108107. */
  108108. serialize(): any;
  108109. /**
  108110. * Clones the current camera.
  108111. * @param name The cloned camera name
  108112. * @returns the cloned camera
  108113. */
  108114. clone(name: string): Camera;
  108115. /**
  108116. * Gets the direction of the camera relative to a given local axis.
  108117. * @param localAxis Defines the reference axis to provide a relative direction.
  108118. * @return the direction
  108119. */
  108120. getDirection(localAxis: Vector3): Vector3;
  108121. /**
  108122. * Returns the current camera absolute rotation
  108123. */
  108124. get absoluteRotation(): Quaternion;
  108125. /**
  108126. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108127. * @param localAxis Defines the reference axis to provide a relative direction.
  108128. * @param result Defines the vector to store the result in
  108129. */
  108130. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108131. /**
  108132. * Gets a camera constructor for a given camera type
  108133. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108134. * @param name The name of the camera the result will be able to instantiate
  108135. * @param scene The scene the result will construct the camera in
  108136. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108137. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108138. * @returns a factory method to construc the camera
  108139. */
  108140. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108141. /**
  108142. * Compute the world matrix of the camera.
  108143. * @returns the camera world matrix
  108144. */
  108145. computeWorldMatrix(): Matrix;
  108146. /**
  108147. * Parse a JSON and creates the camera from the parsed information
  108148. * @param parsedCamera The JSON to parse
  108149. * @param scene The scene to instantiate the camera in
  108150. * @returns the newly constructed camera
  108151. */
  108152. static Parse(parsedCamera: any, scene: Scene): Camera;
  108153. }
  108154. }
  108155. declare module BABYLON {
  108156. /**
  108157. * Class containing static functions to help procedurally build meshes
  108158. */
  108159. export class DiscBuilder {
  108160. /**
  108161. * Creates a plane polygonal mesh. By default, this is a disc
  108162. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108163. * * 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
  108164. * * 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
  108165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108168. * @param name defines the name of the mesh
  108169. * @param options defines the options used to create the mesh
  108170. * @param scene defines the hosting scene
  108171. * @returns the plane polygonal mesh
  108172. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108173. */
  108174. static CreateDisc(name: string, options: {
  108175. radius?: number;
  108176. tessellation?: number;
  108177. arc?: number;
  108178. updatable?: boolean;
  108179. sideOrientation?: number;
  108180. frontUVs?: Vector4;
  108181. backUVs?: Vector4;
  108182. }, scene?: Nullable<Scene>): Mesh;
  108183. }
  108184. }
  108185. declare module BABYLON {
  108186. /**
  108187. * Options to be used when creating a FresnelParameters.
  108188. */
  108189. export type IFresnelParametersCreationOptions = {
  108190. /**
  108191. * Define the color used on edges (grazing angle)
  108192. */
  108193. leftColor?: Color3;
  108194. /**
  108195. * Define the color used on center
  108196. */
  108197. rightColor?: Color3;
  108198. /**
  108199. * Define bias applied to computed fresnel term
  108200. */
  108201. bias?: number;
  108202. /**
  108203. * Defined the power exponent applied to fresnel term
  108204. */
  108205. power?: number;
  108206. /**
  108207. * Define if the fresnel effect is enable or not.
  108208. */
  108209. isEnabled?: boolean;
  108210. };
  108211. /**
  108212. * Serialized format for FresnelParameters.
  108213. */
  108214. export type IFresnelParametersSerialized = {
  108215. /**
  108216. * Define the color used on edges (grazing angle) [as an array]
  108217. */
  108218. leftColor: number[];
  108219. /**
  108220. * Define the color used on center [as an array]
  108221. */
  108222. rightColor: number[];
  108223. /**
  108224. * Define bias applied to computed fresnel term
  108225. */
  108226. bias: number;
  108227. /**
  108228. * Defined the power exponent applied to fresnel term
  108229. */
  108230. power?: number;
  108231. /**
  108232. * Define if the fresnel effect is enable or not.
  108233. */
  108234. isEnabled: boolean;
  108235. };
  108236. /**
  108237. * This represents all the required information to add a fresnel effect on a material:
  108238. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108239. */
  108240. export class FresnelParameters {
  108241. private _isEnabled;
  108242. /**
  108243. * Define if the fresnel effect is enable or not.
  108244. */
  108245. get isEnabled(): boolean;
  108246. set isEnabled(value: boolean);
  108247. /**
  108248. * Define the color used on edges (grazing angle)
  108249. */
  108250. leftColor: Color3;
  108251. /**
  108252. * Define the color used on center
  108253. */
  108254. rightColor: Color3;
  108255. /**
  108256. * Define bias applied to computed fresnel term
  108257. */
  108258. bias: number;
  108259. /**
  108260. * Defined the power exponent applied to fresnel term
  108261. */
  108262. power: number;
  108263. /**
  108264. * Creates a new FresnelParameters object.
  108265. *
  108266. * @param options provide your own settings to optionally to override defaults
  108267. */
  108268. constructor(options?: IFresnelParametersCreationOptions);
  108269. /**
  108270. * Clones the current fresnel and its valuues
  108271. * @returns a clone fresnel configuration
  108272. */
  108273. clone(): FresnelParameters;
  108274. /**
  108275. * Determines equality between FresnelParameters objects
  108276. * @param otherFresnelParameters defines the second operand
  108277. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108278. */
  108279. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108280. /**
  108281. * Serializes the current fresnel parameters to a JSON representation.
  108282. * @return the JSON serialization
  108283. */
  108284. serialize(): IFresnelParametersSerialized;
  108285. /**
  108286. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108287. * @param parsedFresnelParameters Define the JSON representation
  108288. * @returns the parsed parameters
  108289. */
  108290. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108291. }
  108292. }
  108293. declare module BABYLON {
  108294. /**
  108295. * This groups all the flags used to control the materials channel.
  108296. */
  108297. export class MaterialFlags {
  108298. private static _DiffuseTextureEnabled;
  108299. /**
  108300. * Are diffuse textures enabled in the application.
  108301. */
  108302. static get DiffuseTextureEnabled(): boolean;
  108303. static set DiffuseTextureEnabled(value: boolean);
  108304. private static _DetailTextureEnabled;
  108305. /**
  108306. * Are detail textures enabled in the application.
  108307. */
  108308. static get DetailTextureEnabled(): boolean;
  108309. static set DetailTextureEnabled(value: boolean);
  108310. private static _AmbientTextureEnabled;
  108311. /**
  108312. * Are ambient textures enabled in the application.
  108313. */
  108314. static get AmbientTextureEnabled(): boolean;
  108315. static set AmbientTextureEnabled(value: boolean);
  108316. private static _OpacityTextureEnabled;
  108317. /**
  108318. * Are opacity textures enabled in the application.
  108319. */
  108320. static get OpacityTextureEnabled(): boolean;
  108321. static set OpacityTextureEnabled(value: boolean);
  108322. private static _ReflectionTextureEnabled;
  108323. /**
  108324. * Are reflection textures enabled in the application.
  108325. */
  108326. static get ReflectionTextureEnabled(): boolean;
  108327. static set ReflectionTextureEnabled(value: boolean);
  108328. private static _EmissiveTextureEnabled;
  108329. /**
  108330. * Are emissive textures enabled in the application.
  108331. */
  108332. static get EmissiveTextureEnabled(): boolean;
  108333. static set EmissiveTextureEnabled(value: boolean);
  108334. private static _SpecularTextureEnabled;
  108335. /**
  108336. * Are specular textures enabled in the application.
  108337. */
  108338. static get SpecularTextureEnabled(): boolean;
  108339. static set SpecularTextureEnabled(value: boolean);
  108340. private static _BumpTextureEnabled;
  108341. /**
  108342. * Are bump textures enabled in the application.
  108343. */
  108344. static get BumpTextureEnabled(): boolean;
  108345. static set BumpTextureEnabled(value: boolean);
  108346. private static _LightmapTextureEnabled;
  108347. /**
  108348. * Are lightmap textures enabled in the application.
  108349. */
  108350. static get LightmapTextureEnabled(): boolean;
  108351. static set LightmapTextureEnabled(value: boolean);
  108352. private static _RefractionTextureEnabled;
  108353. /**
  108354. * Are refraction textures enabled in the application.
  108355. */
  108356. static get RefractionTextureEnabled(): boolean;
  108357. static set RefractionTextureEnabled(value: boolean);
  108358. private static _ColorGradingTextureEnabled;
  108359. /**
  108360. * Are color grading textures enabled in the application.
  108361. */
  108362. static get ColorGradingTextureEnabled(): boolean;
  108363. static set ColorGradingTextureEnabled(value: boolean);
  108364. private static _FresnelEnabled;
  108365. /**
  108366. * Are fresnels enabled in the application.
  108367. */
  108368. static get FresnelEnabled(): boolean;
  108369. static set FresnelEnabled(value: boolean);
  108370. private static _ClearCoatTextureEnabled;
  108371. /**
  108372. * Are clear coat textures enabled in the application.
  108373. */
  108374. static get ClearCoatTextureEnabled(): boolean;
  108375. static set ClearCoatTextureEnabled(value: boolean);
  108376. private static _ClearCoatBumpTextureEnabled;
  108377. /**
  108378. * Are clear coat bump textures enabled in the application.
  108379. */
  108380. static get ClearCoatBumpTextureEnabled(): boolean;
  108381. static set ClearCoatBumpTextureEnabled(value: boolean);
  108382. private static _ClearCoatTintTextureEnabled;
  108383. /**
  108384. * Are clear coat tint textures enabled in the application.
  108385. */
  108386. static get ClearCoatTintTextureEnabled(): boolean;
  108387. static set ClearCoatTintTextureEnabled(value: boolean);
  108388. private static _SheenTextureEnabled;
  108389. /**
  108390. * Are sheen textures enabled in the application.
  108391. */
  108392. static get SheenTextureEnabled(): boolean;
  108393. static set SheenTextureEnabled(value: boolean);
  108394. private static _AnisotropicTextureEnabled;
  108395. /**
  108396. * Are anisotropic textures enabled in the application.
  108397. */
  108398. static get AnisotropicTextureEnabled(): boolean;
  108399. static set AnisotropicTextureEnabled(value: boolean);
  108400. private static _ThicknessTextureEnabled;
  108401. /**
  108402. * Are thickness textures enabled in the application.
  108403. */
  108404. static get ThicknessTextureEnabled(): boolean;
  108405. static set ThicknessTextureEnabled(value: boolean);
  108406. }
  108407. }
  108408. declare module BABYLON {
  108409. /** @hidden */
  108410. export var defaultFragmentDeclaration: {
  108411. name: string;
  108412. shader: string;
  108413. };
  108414. }
  108415. declare module BABYLON {
  108416. /** @hidden */
  108417. export var defaultUboDeclaration: {
  108418. name: string;
  108419. shader: string;
  108420. };
  108421. }
  108422. declare module BABYLON {
  108423. /** @hidden */
  108424. export var prePassDeclaration: {
  108425. name: string;
  108426. shader: string;
  108427. };
  108428. }
  108429. declare module BABYLON {
  108430. /** @hidden */
  108431. export var lightFragmentDeclaration: {
  108432. name: string;
  108433. shader: string;
  108434. };
  108435. }
  108436. declare module BABYLON {
  108437. /** @hidden */
  108438. export var lightUboDeclaration: {
  108439. name: string;
  108440. shader: string;
  108441. };
  108442. }
  108443. declare module BABYLON {
  108444. /** @hidden */
  108445. export var lightsFragmentFunctions: {
  108446. name: string;
  108447. shader: string;
  108448. };
  108449. }
  108450. declare module BABYLON {
  108451. /** @hidden */
  108452. export var shadowsFragmentFunctions: {
  108453. name: string;
  108454. shader: string;
  108455. };
  108456. }
  108457. declare module BABYLON {
  108458. /** @hidden */
  108459. export var fresnelFunction: {
  108460. name: string;
  108461. shader: string;
  108462. };
  108463. }
  108464. declare module BABYLON {
  108465. /** @hidden */
  108466. export var bumpFragmentMainFunctions: {
  108467. name: string;
  108468. shader: string;
  108469. };
  108470. }
  108471. declare module BABYLON {
  108472. /** @hidden */
  108473. export var bumpFragmentFunctions: {
  108474. name: string;
  108475. shader: string;
  108476. };
  108477. }
  108478. declare module BABYLON {
  108479. /** @hidden */
  108480. export var logDepthDeclaration: {
  108481. name: string;
  108482. shader: string;
  108483. };
  108484. }
  108485. declare module BABYLON {
  108486. /** @hidden */
  108487. export var bumpFragment: {
  108488. name: string;
  108489. shader: string;
  108490. };
  108491. }
  108492. declare module BABYLON {
  108493. /** @hidden */
  108494. export var depthPrePass: {
  108495. name: string;
  108496. shader: string;
  108497. };
  108498. }
  108499. declare module BABYLON {
  108500. /** @hidden */
  108501. export var lightFragment: {
  108502. name: string;
  108503. shader: string;
  108504. };
  108505. }
  108506. declare module BABYLON {
  108507. /** @hidden */
  108508. export var logDepthFragment: {
  108509. name: string;
  108510. shader: string;
  108511. };
  108512. }
  108513. declare module BABYLON {
  108514. /** @hidden */
  108515. export var defaultPixelShader: {
  108516. name: string;
  108517. shader: string;
  108518. };
  108519. }
  108520. declare module BABYLON {
  108521. /** @hidden */
  108522. export var defaultVertexDeclaration: {
  108523. name: string;
  108524. shader: string;
  108525. };
  108526. }
  108527. declare module BABYLON {
  108528. /** @hidden */
  108529. export var bumpVertexDeclaration: {
  108530. name: string;
  108531. shader: string;
  108532. };
  108533. }
  108534. declare module BABYLON {
  108535. /** @hidden */
  108536. export var bumpVertex: {
  108537. name: string;
  108538. shader: string;
  108539. };
  108540. }
  108541. declare module BABYLON {
  108542. /** @hidden */
  108543. export var fogVertex: {
  108544. name: string;
  108545. shader: string;
  108546. };
  108547. }
  108548. declare module BABYLON {
  108549. /** @hidden */
  108550. export var shadowsVertex: {
  108551. name: string;
  108552. shader: string;
  108553. };
  108554. }
  108555. declare module BABYLON {
  108556. /** @hidden */
  108557. export var pointCloudVertex: {
  108558. name: string;
  108559. shader: string;
  108560. };
  108561. }
  108562. declare module BABYLON {
  108563. /** @hidden */
  108564. export var logDepthVertex: {
  108565. name: string;
  108566. shader: string;
  108567. };
  108568. }
  108569. declare module BABYLON {
  108570. /** @hidden */
  108571. export var defaultVertexShader: {
  108572. name: string;
  108573. shader: string;
  108574. };
  108575. }
  108576. declare module BABYLON {
  108577. /**
  108578. * @hidden
  108579. */
  108580. export interface IMaterialDetailMapDefines {
  108581. DETAIL: boolean;
  108582. DETAILDIRECTUV: number;
  108583. DETAIL_NORMALBLENDMETHOD: number;
  108584. /** @hidden */
  108585. _areTexturesDirty: boolean;
  108586. }
  108587. /**
  108588. * Define the code related to the detail map parameters of a material
  108589. *
  108590. * Inspired from:
  108591. * 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
  108592. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  108593. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  108594. */
  108595. export class DetailMapConfiguration {
  108596. private _texture;
  108597. /**
  108598. * The detail texture of the material.
  108599. */
  108600. texture: Nullable<BaseTexture>;
  108601. /**
  108602. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  108603. * Bigger values mean stronger blending
  108604. */
  108605. diffuseBlendLevel: number;
  108606. /**
  108607. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  108608. * Bigger values mean stronger blending. Only used with PBR materials
  108609. */
  108610. roughnessBlendLevel: number;
  108611. /**
  108612. * Defines how strong the bump effect from the detail map is
  108613. * Bigger values mean stronger effect
  108614. */
  108615. bumpLevel: number;
  108616. private _normalBlendMethod;
  108617. /**
  108618. * The method used to blend the bump and detail normals together
  108619. */
  108620. normalBlendMethod: number;
  108621. private _isEnabled;
  108622. /**
  108623. * Enable or disable the detail map on this material
  108624. */
  108625. isEnabled: boolean;
  108626. /** @hidden */
  108627. private _internalMarkAllSubMeshesAsTexturesDirty;
  108628. /** @hidden */
  108629. _markAllSubMeshesAsTexturesDirty(): void;
  108630. /**
  108631. * Instantiate a new detail map
  108632. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108633. */
  108634. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108635. /**
  108636. * Gets whether the submesh is ready to be used or not.
  108637. * @param defines the list of "defines" to update.
  108638. * @param scene defines the scene the material belongs to.
  108639. * @returns - boolean indicating that the submesh is ready or not.
  108640. */
  108641. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  108642. /**
  108643. * Update the defines for detail map usage
  108644. * @param defines the list of "defines" to update.
  108645. * @param scene defines the scene the material belongs to.
  108646. */
  108647. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  108648. /**
  108649. * Binds the material data.
  108650. * @param uniformBuffer defines the Uniform buffer to fill in.
  108651. * @param scene defines the scene the material belongs to.
  108652. * @param isFrozen defines whether the material is frozen or not.
  108653. */
  108654. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108655. /**
  108656. * Checks to see if a texture is used in the material.
  108657. * @param texture - Base texture to use.
  108658. * @returns - Boolean specifying if a texture is used in the material.
  108659. */
  108660. hasTexture(texture: BaseTexture): boolean;
  108661. /**
  108662. * Returns an array of the actively used textures.
  108663. * @param activeTextures Array of BaseTextures
  108664. */
  108665. getActiveTextures(activeTextures: BaseTexture[]): void;
  108666. /**
  108667. * Returns the animatable textures.
  108668. * @param animatables Array of animatable textures.
  108669. */
  108670. getAnimatables(animatables: IAnimatable[]): void;
  108671. /**
  108672. * Disposes the resources of the material.
  108673. * @param forceDisposeTextures - Forces the disposal of all textures.
  108674. */
  108675. dispose(forceDisposeTextures?: boolean): void;
  108676. /**
  108677. * Get the current class name useful for serialization or dynamic coding.
  108678. * @returns "DetailMap"
  108679. */
  108680. getClassName(): string;
  108681. /**
  108682. * Add the required uniforms to the current list.
  108683. * @param uniforms defines the current uniform list.
  108684. */
  108685. static AddUniforms(uniforms: string[]): void;
  108686. /**
  108687. * Add the required samplers to the current list.
  108688. * @param samplers defines the current sampler list.
  108689. */
  108690. static AddSamplers(samplers: string[]): void;
  108691. /**
  108692. * Add the required uniforms to the current buffer.
  108693. * @param uniformBuffer defines the current uniform buffer.
  108694. */
  108695. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108696. /**
  108697. * Makes a duplicate of the current instance into another one.
  108698. * @param detailMap define the instance where to copy the info
  108699. */
  108700. copyTo(detailMap: DetailMapConfiguration): void;
  108701. /**
  108702. * Serializes this detail map instance
  108703. * @returns - An object with the serialized instance.
  108704. */
  108705. serialize(): any;
  108706. /**
  108707. * Parses a detail map setting from a serialized object.
  108708. * @param source - Serialized object.
  108709. * @param scene Defines the scene we are parsing for
  108710. * @param rootUrl Defines the rootUrl to load from
  108711. */
  108712. parse(source: any, scene: Scene, rootUrl: string): void;
  108713. }
  108714. }
  108715. declare module BABYLON {
  108716. /** @hidden */
  108717. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  108718. MAINUV1: boolean;
  108719. MAINUV2: boolean;
  108720. DIFFUSE: boolean;
  108721. DIFFUSEDIRECTUV: number;
  108722. DETAIL: boolean;
  108723. DETAILDIRECTUV: number;
  108724. DETAIL_NORMALBLENDMETHOD: number;
  108725. AMBIENT: boolean;
  108726. AMBIENTDIRECTUV: number;
  108727. OPACITY: boolean;
  108728. OPACITYDIRECTUV: number;
  108729. OPACITYRGB: boolean;
  108730. REFLECTION: boolean;
  108731. EMISSIVE: boolean;
  108732. EMISSIVEDIRECTUV: number;
  108733. SPECULAR: boolean;
  108734. SPECULARDIRECTUV: number;
  108735. BUMP: boolean;
  108736. BUMPDIRECTUV: number;
  108737. PARALLAX: boolean;
  108738. PARALLAXOCCLUSION: boolean;
  108739. SPECULAROVERALPHA: boolean;
  108740. CLIPPLANE: boolean;
  108741. CLIPPLANE2: boolean;
  108742. CLIPPLANE3: boolean;
  108743. CLIPPLANE4: boolean;
  108744. CLIPPLANE5: boolean;
  108745. CLIPPLANE6: boolean;
  108746. ALPHATEST: boolean;
  108747. DEPTHPREPASS: boolean;
  108748. ALPHAFROMDIFFUSE: boolean;
  108749. POINTSIZE: boolean;
  108750. FOG: boolean;
  108751. SPECULARTERM: boolean;
  108752. DIFFUSEFRESNEL: boolean;
  108753. OPACITYFRESNEL: boolean;
  108754. REFLECTIONFRESNEL: boolean;
  108755. REFRACTIONFRESNEL: boolean;
  108756. EMISSIVEFRESNEL: boolean;
  108757. FRESNEL: boolean;
  108758. NORMAL: boolean;
  108759. UV1: boolean;
  108760. UV2: boolean;
  108761. VERTEXCOLOR: boolean;
  108762. VERTEXALPHA: boolean;
  108763. NUM_BONE_INFLUENCERS: number;
  108764. BonesPerMesh: number;
  108765. BONETEXTURE: boolean;
  108766. INSTANCES: boolean;
  108767. THIN_INSTANCES: boolean;
  108768. GLOSSINESS: boolean;
  108769. ROUGHNESS: boolean;
  108770. EMISSIVEASILLUMINATION: boolean;
  108771. LINKEMISSIVEWITHDIFFUSE: boolean;
  108772. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108773. LIGHTMAP: boolean;
  108774. LIGHTMAPDIRECTUV: number;
  108775. OBJECTSPACE_NORMALMAP: boolean;
  108776. USELIGHTMAPASSHADOWMAP: boolean;
  108777. REFLECTIONMAP_3D: boolean;
  108778. REFLECTIONMAP_SPHERICAL: boolean;
  108779. REFLECTIONMAP_PLANAR: boolean;
  108780. REFLECTIONMAP_CUBIC: boolean;
  108781. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108782. REFLECTIONMAP_PROJECTION: boolean;
  108783. REFLECTIONMAP_SKYBOX: boolean;
  108784. REFLECTIONMAP_EXPLICIT: boolean;
  108785. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108786. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108787. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108788. INVERTCUBICMAP: boolean;
  108789. LOGARITHMICDEPTH: boolean;
  108790. REFRACTION: boolean;
  108791. REFRACTIONMAP_3D: boolean;
  108792. REFLECTIONOVERALPHA: boolean;
  108793. TWOSIDEDLIGHTING: boolean;
  108794. SHADOWFLOAT: boolean;
  108795. MORPHTARGETS: boolean;
  108796. MORPHTARGETS_NORMAL: boolean;
  108797. MORPHTARGETS_TANGENT: boolean;
  108798. MORPHTARGETS_UV: boolean;
  108799. NUM_MORPH_INFLUENCERS: number;
  108800. NONUNIFORMSCALING: boolean;
  108801. PREMULTIPLYALPHA: boolean;
  108802. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  108803. ALPHABLEND: boolean;
  108804. PREPASS: boolean;
  108805. SCENE_MRT_COUNT: number;
  108806. RGBDLIGHTMAP: boolean;
  108807. RGBDREFLECTION: boolean;
  108808. RGBDREFRACTION: boolean;
  108809. IMAGEPROCESSING: boolean;
  108810. VIGNETTE: boolean;
  108811. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108812. VIGNETTEBLENDMODEOPAQUE: boolean;
  108813. TONEMAPPING: boolean;
  108814. TONEMAPPING_ACES: boolean;
  108815. CONTRAST: boolean;
  108816. COLORCURVES: boolean;
  108817. COLORGRADING: boolean;
  108818. COLORGRADING3D: boolean;
  108819. SAMPLER3DGREENDEPTH: boolean;
  108820. SAMPLER3DBGRMAP: boolean;
  108821. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108822. MULTIVIEW: boolean;
  108823. /**
  108824. * If the reflection texture on this material is in linear color space
  108825. * @hidden
  108826. */
  108827. IS_REFLECTION_LINEAR: boolean;
  108828. /**
  108829. * If the refraction texture on this material is in linear color space
  108830. * @hidden
  108831. */
  108832. IS_REFRACTION_LINEAR: boolean;
  108833. EXPOSURE: boolean;
  108834. constructor();
  108835. setReflectionMode(modeToEnable: string): void;
  108836. }
  108837. /**
  108838. * This is the default material used in Babylon. It is the best trade off between quality
  108839. * and performances.
  108840. * @see https://doc.babylonjs.com/babylon101/materials
  108841. */
  108842. export class StandardMaterial extends PushMaterial {
  108843. private _diffuseTexture;
  108844. /**
  108845. * The basic texture of the material as viewed under a light.
  108846. */
  108847. diffuseTexture: Nullable<BaseTexture>;
  108848. private _ambientTexture;
  108849. /**
  108850. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108851. */
  108852. ambientTexture: Nullable<BaseTexture>;
  108853. private _opacityTexture;
  108854. /**
  108855. * Define the transparency of the material from a texture.
  108856. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108857. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108858. */
  108859. opacityTexture: Nullable<BaseTexture>;
  108860. private _reflectionTexture;
  108861. /**
  108862. * Define the texture used to display the reflection.
  108863. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108864. */
  108865. reflectionTexture: Nullable<BaseTexture>;
  108866. private _emissiveTexture;
  108867. /**
  108868. * Define texture of the material as if self lit.
  108869. * This will be mixed in the final result even in the absence of light.
  108870. */
  108871. emissiveTexture: Nullable<BaseTexture>;
  108872. private _specularTexture;
  108873. /**
  108874. * Define how the color and intensity of the highlight given by the light in the material.
  108875. */
  108876. specularTexture: Nullable<BaseTexture>;
  108877. private _bumpTexture;
  108878. /**
  108879. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108880. * 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.
  108881. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  108882. */
  108883. bumpTexture: Nullable<BaseTexture>;
  108884. private _lightmapTexture;
  108885. /**
  108886. * Complex lighting can be computationally expensive to compute at runtime.
  108887. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108888. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  108889. */
  108890. lightmapTexture: Nullable<BaseTexture>;
  108891. private _refractionTexture;
  108892. /**
  108893. * Define the texture used to display the refraction.
  108894. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108895. */
  108896. refractionTexture: Nullable<BaseTexture>;
  108897. /**
  108898. * The color of the material lit by the environmental background lighting.
  108899. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108900. */
  108901. ambientColor: Color3;
  108902. /**
  108903. * The basic color of the material as viewed under a light.
  108904. */
  108905. diffuseColor: Color3;
  108906. /**
  108907. * Define how the color and intensity of the highlight given by the light in the material.
  108908. */
  108909. specularColor: Color3;
  108910. /**
  108911. * Define the color of the material as if self lit.
  108912. * This will be mixed in the final result even in the absence of light.
  108913. */
  108914. emissiveColor: Color3;
  108915. /**
  108916. * Defines how sharp are the highlights in the material.
  108917. * The bigger the value the sharper giving a more glossy feeling to the result.
  108918. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108919. */
  108920. specularPower: number;
  108921. private _useAlphaFromDiffuseTexture;
  108922. /**
  108923. * Does the transparency come from the diffuse texture alpha channel.
  108924. */
  108925. useAlphaFromDiffuseTexture: boolean;
  108926. private _useEmissiveAsIllumination;
  108927. /**
  108928. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108929. */
  108930. useEmissiveAsIllumination: boolean;
  108931. private _linkEmissiveWithDiffuse;
  108932. /**
  108933. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108934. * the emissive level when the final color is close to one.
  108935. */
  108936. linkEmissiveWithDiffuse: boolean;
  108937. private _useSpecularOverAlpha;
  108938. /**
  108939. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108940. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108941. */
  108942. useSpecularOverAlpha: boolean;
  108943. private _useReflectionOverAlpha;
  108944. /**
  108945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108947. */
  108948. useReflectionOverAlpha: boolean;
  108949. private _disableLighting;
  108950. /**
  108951. * Does lights from the scene impacts this material.
  108952. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108953. */
  108954. disableLighting: boolean;
  108955. private _useObjectSpaceNormalMap;
  108956. /**
  108957. * Allows using an object space normal map (instead of tangent space).
  108958. */
  108959. useObjectSpaceNormalMap: boolean;
  108960. private _useParallax;
  108961. /**
  108962. * Is parallax enabled or not.
  108963. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  108964. */
  108965. useParallax: boolean;
  108966. private _useParallaxOcclusion;
  108967. /**
  108968. * Is parallax occlusion enabled or not.
  108969. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108970. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  108971. */
  108972. useParallaxOcclusion: boolean;
  108973. /**
  108974. * 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.
  108975. */
  108976. parallaxScaleBias: number;
  108977. private _roughness;
  108978. /**
  108979. * Helps to define how blurry the reflections should appears in the material.
  108980. */
  108981. roughness: number;
  108982. /**
  108983. * In case of refraction, define the value of the index of refraction.
  108984. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108985. */
  108986. indexOfRefraction: number;
  108987. /**
  108988. * Invert the refraction texture alongside the y axis.
  108989. * It can be useful with procedural textures or probe for instance.
  108990. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108991. */
  108992. invertRefractionY: boolean;
  108993. /**
  108994. * Defines the alpha limits in alpha test mode.
  108995. */
  108996. alphaCutOff: number;
  108997. private _useLightmapAsShadowmap;
  108998. /**
  108999. * In case of light mapping, define whether the map contains light or shadow informations.
  109000. */
  109001. useLightmapAsShadowmap: boolean;
  109002. private _diffuseFresnelParameters;
  109003. /**
  109004. * Define the diffuse fresnel parameters of the material.
  109005. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109006. */
  109007. diffuseFresnelParameters: FresnelParameters;
  109008. private _opacityFresnelParameters;
  109009. /**
  109010. * Define the opacity fresnel parameters of the material.
  109011. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109012. */
  109013. opacityFresnelParameters: FresnelParameters;
  109014. private _reflectionFresnelParameters;
  109015. /**
  109016. * Define the reflection fresnel parameters of the material.
  109017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109018. */
  109019. reflectionFresnelParameters: FresnelParameters;
  109020. private _refractionFresnelParameters;
  109021. /**
  109022. * Define the refraction fresnel parameters of the material.
  109023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109024. */
  109025. refractionFresnelParameters: FresnelParameters;
  109026. private _emissiveFresnelParameters;
  109027. /**
  109028. * Define the emissive fresnel parameters of the material.
  109029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109030. */
  109031. emissiveFresnelParameters: FresnelParameters;
  109032. private _useReflectionFresnelFromSpecular;
  109033. /**
  109034. * If true automatically deducts the fresnels values from the material specularity.
  109035. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109036. */
  109037. useReflectionFresnelFromSpecular: boolean;
  109038. private _useGlossinessFromSpecularMapAlpha;
  109039. /**
  109040. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109041. */
  109042. useGlossinessFromSpecularMapAlpha: boolean;
  109043. private _maxSimultaneousLights;
  109044. /**
  109045. * Defines the maximum number of lights that can be used in the material
  109046. */
  109047. maxSimultaneousLights: number;
  109048. private _invertNormalMapX;
  109049. /**
  109050. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109051. */
  109052. invertNormalMapX: boolean;
  109053. private _invertNormalMapY;
  109054. /**
  109055. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109056. */
  109057. invertNormalMapY: boolean;
  109058. private _twoSidedLighting;
  109059. /**
  109060. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109061. */
  109062. twoSidedLighting: boolean;
  109063. /**
  109064. * Default configuration related to image processing available in the standard Material.
  109065. */
  109066. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109067. /**
  109068. * Gets the image processing configuration used either in this material.
  109069. */
  109070. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109071. /**
  109072. * Sets the Default image processing configuration used either in the this material.
  109073. *
  109074. * If sets to null, the scene one is in use.
  109075. */
  109076. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109077. /**
  109078. * Keep track of the image processing observer to allow dispose and replace.
  109079. */
  109080. private _imageProcessingObserver;
  109081. /**
  109082. * Attaches a new image processing configuration to the Standard Material.
  109083. * @param configuration
  109084. */
  109085. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109086. /**
  109087. * Gets wether the color curves effect is enabled.
  109088. */
  109089. get cameraColorCurvesEnabled(): boolean;
  109090. /**
  109091. * Sets wether the color curves effect is enabled.
  109092. */
  109093. set cameraColorCurvesEnabled(value: boolean);
  109094. /**
  109095. * Gets wether the color grading effect is enabled.
  109096. */
  109097. get cameraColorGradingEnabled(): boolean;
  109098. /**
  109099. * Gets wether the color grading effect is enabled.
  109100. */
  109101. set cameraColorGradingEnabled(value: boolean);
  109102. /**
  109103. * Gets wether tonemapping is enabled or not.
  109104. */
  109105. get cameraToneMappingEnabled(): boolean;
  109106. /**
  109107. * Sets wether tonemapping is enabled or not
  109108. */
  109109. set cameraToneMappingEnabled(value: boolean);
  109110. /**
  109111. * The camera exposure used on this material.
  109112. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109113. * This corresponds to a photographic exposure.
  109114. */
  109115. get cameraExposure(): number;
  109116. /**
  109117. * The camera exposure used on this material.
  109118. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109119. * This corresponds to a photographic exposure.
  109120. */
  109121. set cameraExposure(value: number);
  109122. /**
  109123. * Gets The camera contrast used on this material.
  109124. */
  109125. get cameraContrast(): number;
  109126. /**
  109127. * Sets The camera contrast used on this material.
  109128. */
  109129. set cameraContrast(value: number);
  109130. /**
  109131. * Gets the Color Grading 2D Lookup Texture.
  109132. */
  109133. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109134. /**
  109135. * Sets the Color Grading 2D Lookup Texture.
  109136. */
  109137. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109138. /**
  109139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109141. * 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;
  109142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109143. */
  109144. get cameraColorCurves(): Nullable<ColorCurves>;
  109145. /**
  109146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109148. * 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;
  109149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109150. */
  109151. set cameraColorCurves(value: Nullable<ColorCurves>);
  109152. /**
  109153. * Can this material render to several textures at once
  109154. */
  109155. get canRenderToMRT(): boolean;
  109156. /**
  109157. * Defines the detail map parameters for the material.
  109158. */
  109159. readonly detailMap: DetailMapConfiguration;
  109160. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109161. protected _worldViewProjectionMatrix: Matrix;
  109162. protected _globalAmbientColor: Color3;
  109163. protected _useLogarithmicDepth: boolean;
  109164. protected _rebuildInParallel: boolean;
  109165. /**
  109166. * Instantiates a new standard material.
  109167. * This is the default material used in Babylon. It is the best trade off between quality
  109168. * and performances.
  109169. * @see https://doc.babylonjs.com/babylon101/materials
  109170. * @param name Define the name of the material in the scene
  109171. * @param scene Define the scene the material belong to
  109172. */
  109173. constructor(name: string, scene: Scene);
  109174. /**
  109175. * Gets a boolean indicating that current material needs to register RTT
  109176. */
  109177. get hasRenderTargetTextures(): boolean;
  109178. /**
  109179. * Gets the current class name of the material e.g. "StandardMaterial"
  109180. * Mainly use in serialization.
  109181. * @returns the class name
  109182. */
  109183. getClassName(): string;
  109184. /**
  109185. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109186. * You can try switching to logarithmic depth.
  109187. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109188. */
  109189. get useLogarithmicDepth(): boolean;
  109190. set useLogarithmicDepth(value: boolean);
  109191. /**
  109192. * Specifies if the material will require alpha blending
  109193. * @returns a boolean specifying if alpha blending is needed
  109194. */
  109195. needAlphaBlending(): boolean;
  109196. /**
  109197. * Specifies if this material should be rendered in alpha test mode
  109198. * @returns a boolean specifying if an alpha test is needed.
  109199. */
  109200. needAlphaTesting(): boolean;
  109201. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109202. /**
  109203. * Get the texture used for alpha test purpose.
  109204. * @returns the diffuse texture in case of the standard material.
  109205. */
  109206. getAlphaTestTexture(): Nullable<BaseTexture>;
  109207. /**
  109208. * Get if the submesh is ready to be used and all its information available.
  109209. * Child classes can use it to update shaders
  109210. * @param mesh defines the mesh to check
  109211. * @param subMesh defines which submesh to check
  109212. * @param useInstances specifies that instances should be used
  109213. * @returns a boolean indicating that the submesh is ready or not
  109214. */
  109215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109216. /**
  109217. * Builds the material UBO layouts.
  109218. * Used internally during the effect preparation.
  109219. */
  109220. buildUniformLayout(): void;
  109221. /**
  109222. * Unbinds the material from the mesh
  109223. */
  109224. unbind(): void;
  109225. /**
  109226. * Binds the submesh to this material by preparing the effect and shader to draw
  109227. * @param world defines the world transformation matrix
  109228. * @param mesh defines the mesh containing the submesh
  109229. * @param subMesh defines the submesh to bind the material to
  109230. */
  109231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109232. /**
  109233. * Get the list of animatables in the material.
  109234. * @returns the list of animatables object used in the material
  109235. */
  109236. getAnimatables(): IAnimatable[];
  109237. /**
  109238. * Gets the active textures from the material
  109239. * @returns an array of textures
  109240. */
  109241. getActiveTextures(): BaseTexture[];
  109242. /**
  109243. * Specifies if the material uses a texture
  109244. * @param texture defines the texture to check against the material
  109245. * @returns a boolean specifying if the material uses the texture
  109246. */
  109247. hasTexture(texture: BaseTexture): boolean;
  109248. /**
  109249. * Disposes the material
  109250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109252. */
  109253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109254. /**
  109255. * Makes a duplicate of the material, and gives it a new name
  109256. * @param name defines the new name for the duplicated material
  109257. * @returns the cloned material
  109258. */
  109259. clone(name: string): StandardMaterial;
  109260. /**
  109261. * Serializes this material in a JSON representation
  109262. * @returns the serialized material object
  109263. */
  109264. serialize(): any;
  109265. /**
  109266. * Creates a standard material from parsed material data
  109267. * @param source defines the JSON representation of the material
  109268. * @param scene defines the hosting scene
  109269. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109270. * @returns a new standard material
  109271. */
  109272. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109273. /**
  109274. * Are diffuse textures enabled in the application.
  109275. */
  109276. static get DiffuseTextureEnabled(): boolean;
  109277. static set DiffuseTextureEnabled(value: boolean);
  109278. /**
  109279. * Are detail textures enabled in the application.
  109280. */
  109281. static get DetailTextureEnabled(): boolean;
  109282. static set DetailTextureEnabled(value: boolean);
  109283. /**
  109284. * Are ambient textures enabled in the application.
  109285. */
  109286. static get AmbientTextureEnabled(): boolean;
  109287. static set AmbientTextureEnabled(value: boolean);
  109288. /**
  109289. * Are opacity textures enabled in the application.
  109290. */
  109291. static get OpacityTextureEnabled(): boolean;
  109292. static set OpacityTextureEnabled(value: boolean);
  109293. /**
  109294. * Are reflection textures enabled in the application.
  109295. */
  109296. static get ReflectionTextureEnabled(): boolean;
  109297. static set ReflectionTextureEnabled(value: boolean);
  109298. /**
  109299. * Are emissive textures enabled in the application.
  109300. */
  109301. static get EmissiveTextureEnabled(): boolean;
  109302. static set EmissiveTextureEnabled(value: boolean);
  109303. /**
  109304. * Are specular textures enabled in the application.
  109305. */
  109306. static get SpecularTextureEnabled(): boolean;
  109307. static set SpecularTextureEnabled(value: boolean);
  109308. /**
  109309. * Are bump textures enabled in the application.
  109310. */
  109311. static get BumpTextureEnabled(): boolean;
  109312. static set BumpTextureEnabled(value: boolean);
  109313. /**
  109314. * Are lightmap textures enabled in the application.
  109315. */
  109316. static get LightmapTextureEnabled(): boolean;
  109317. static set LightmapTextureEnabled(value: boolean);
  109318. /**
  109319. * Are refraction textures enabled in the application.
  109320. */
  109321. static get RefractionTextureEnabled(): boolean;
  109322. static set RefractionTextureEnabled(value: boolean);
  109323. /**
  109324. * Are color grading textures enabled in the application.
  109325. */
  109326. static get ColorGradingTextureEnabled(): boolean;
  109327. static set ColorGradingTextureEnabled(value: boolean);
  109328. /**
  109329. * Are fresnels enabled in the application.
  109330. */
  109331. static get FresnelEnabled(): boolean;
  109332. static set FresnelEnabled(value: boolean);
  109333. }
  109334. }
  109335. declare module BABYLON {
  109336. /**
  109337. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109338. *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.
  109339. * The SPS is also a particle system. It provides some methods to manage the particles.
  109340. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109341. *
  109342. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109343. */
  109344. export class SolidParticleSystem implements IDisposable {
  109345. /**
  109346. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109347. * Example : var p = SPS.particles[i];
  109348. */
  109349. particles: SolidParticle[];
  109350. /**
  109351. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109352. */
  109353. nbParticles: number;
  109354. /**
  109355. * If the particles must ever face the camera (default false). Useful for planar particles.
  109356. */
  109357. billboard: boolean;
  109358. /**
  109359. * Recompute normals when adding a shape
  109360. */
  109361. recomputeNormals: boolean;
  109362. /**
  109363. * This a counter ofr your own usage. It's not set by any SPS functions.
  109364. */
  109365. counter: number;
  109366. /**
  109367. * The SPS name. This name is also given to the underlying mesh.
  109368. */
  109369. name: string;
  109370. /**
  109371. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109372. */
  109373. mesh: Mesh;
  109374. /**
  109375. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109376. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109377. */
  109378. vars: any;
  109379. /**
  109380. * This array is populated when the SPS is set as 'pickable'.
  109381. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109382. * Each element of this array is an object `{idx: int, faceId: int}`.
  109383. * `idx` is the picked particle index in the `SPS.particles` array
  109384. * `faceId` is the picked face index counted within this particle.
  109385. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109386. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109387. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109388. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109389. */
  109390. pickedParticles: {
  109391. idx: number;
  109392. faceId: number;
  109393. }[];
  109394. /**
  109395. * This array is populated when the SPS is set as 'pickable'
  109396. * Each key of this array is a submesh index.
  109397. * Each element of this array is a second array defined like this :
  109398. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109399. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109400. * `idx` is the picked particle index in the `SPS.particles` array
  109401. * `faceId` is the picked face index counted within this particle.
  109402. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109403. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109404. */
  109405. pickedBySubMesh: {
  109406. idx: number;
  109407. faceId: number;
  109408. }[][];
  109409. /**
  109410. * This array is populated when `enableDepthSort` is set to true.
  109411. * Each element of this array is an instance of the class DepthSortedParticle.
  109412. */
  109413. depthSortedParticles: DepthSortedParticle[];
  109414. /**
  109415. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109416. * @hidden
  109417. */
  109418. _bSphereOnly: boolean;
  109419. /**
  109420. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109421. * @hidden
  109422. */
  109423. _bSphereRadiusFactor: number;
  109424. private _scene;
  109425. private _positions;
  109426. private _indices;
  109427. private _normals;
  109428. private _colors;
  109429. private _uvs;
  109430. private _indices32;
  109431. private _positions32;
  109432. private _normals32;
  109433. private _fixedNormal32;
  109434. private _colors32;
  109435. private _uvs32;
  109436. private _index;
  109437. private _updatable;
  109438. private _pickable;
  109439. private _isVisibilityBoxLocked;
  109440. private _alwaysVisible;
  109441. private _depthSort;
  109442. private _expandable;
  109443. private _shapeCounter;
  109444. private _copy;
  109445. private _color;
  109446. private _computeParticleColor;
  109447. private _computeParticleTexture;
  109448. private _computeParticleRotation;
  109449. private _computeParticleVertex;
  109450. private _computeBoundingBox;
  109451. private _depthSortParticles;
  109452. private _camera;
  109453. private _mustUnrotateFixedNormals;
  109454. private _particlesIntersect;
  109455. private _needs32Bits;
  109456. private _isNotBuilt;
  109457. private _lastParticleId;
  109458. private _idxOfId;
  109459. private _multimaterialEnabled;
  109460. private _useModelMaterial;
  109461. private _indicesByMaterial;
  109462. private _materialIndexes;
  109463. private _depthSortFunction;
  109464. private _materialSortFunction;
  109465. private _materials;
  109466. private _multimaterial;
  109467. private _materialIndexesById;
  109468. private _defaultMaterial;
  109469. private _autoUpdateSubMeshes;
  109470. private _tmpVertex;
  109471. /**
  109472. * Creates a SPS (Solid Particle System) object.
  109473. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109474. * @param scene (Scene) is the scene in which the SPS is added.
  109475. * @param options defines the options of the sps e.g.
  109476. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109477. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109478. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109479. * * 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.
  109480. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  109481. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  109482. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109483. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109484. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109485. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109486. */
  109487. constructor(name: string, scene: Scene, options?: {
  109488. updatable?: boolean;
  109489. isPickable?: boolean;
  109490. enableDepthSort?: boolean;
  109491. particleIntersection?: boolean;
  109492. boundingSphereOnly?: boolean;
  109493. bSphereRadiusFactor?: number;
  109494. expandable?: boolean;
  109495. useModelMaterial?: boolean;
  109496. enableMultiMaterial?: boolean;
  109497. });
  109498. /**
  109499. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109500. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109501. * @returns the created mesh
  109502. */
  109503. buildMesh(): Mesh;
  109504. /**
  109505. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109506. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109507. * Thus the particles generated from `digest()` have their property `position` set yet.
  109508. * @param mesh ( Mesh ) is the mesh to be digested
  109509. * @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
  109510. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109511. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109512. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109513. * @returns the current SPS
  109514. */
  109515. digest(mesh: Mesh, options?: {
  109516. facetNb?: number;
  109517. number?: number;
  109518. delta?: number;
  109519. storage?: [];
  109520. }): SolidParticleSystem;
  109521. /**
  109522. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109523. * @hidden
  109524. */
  109525. private _unrotateFixedNormals;
  109526. /**
  109527. * Resets the temporary working copy particle
  109528. * @hidden
  109529. */
  109530. private _resetCopy;
  109531. /**
  109532. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  109533. * @param p the current index in the positions array to be updated
  109534. * @param ind the current index in the indices array
  109535. * @param shape a Vector3 array, the shape geometry
  109536. * @param positions the positions array to be updated
  109537. * @param meshInd the shape indices array
  109538. * @param indices the indices array to be updated
  109539. * @param meshUV the shape uv array
  109540. * @param uvs the uv array to be updated
  109541. * @param meshCol the shape color array
  109542. * @param colors the color array to be updated
  109543. * @param meshNor the shape normals array
  109544. * @param normals the normals array to be updated
  109545. * @param idx the particle index
  109546. * @param idxInShape the particle index in its shape
  109547. * @param options the addShape() method passed options
  109548. * @model the particle model
  109549. * @hidden
  109550. */
  109551. private _meshBuilder;
  109552. /**
  109553. * Returns a shape Vector3 array from positions float array
  109554. * @param positions float array
  109555. * @returns a vector3 array
  109556. * @hidden
  109557. */
  109558. private _posToShape;
  109559. /**
  109560. * Returns a shapeUV array from a float uvs (array deep copy)
  109561. * @param uvs as a float array
  109562. * @returns a shapeUV array
  109563. * @hidden
  109564. */
  109565. private _uvsToShapeUV;
  109566. /**
  109567. * Adds a new particle object in the particles array
  109568. * @param idx particle index in particles array
  109569. * @param id particle id
  109570. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  109571. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  109572. * @param model particle ModelShape object
  109573. * @param shapeId model shape identifier
  109574. * @param idxInShape index of the particle in the current model
  109575. * @param bInfo model bounding info object
  109576. * @param storage target storage array, if any
  109577. * @hidden
  109578. */
  109579. private _addParticle;
  109580. /**
  109581. * Adds some particles to the SPS from the model shape. Returns the shape id.
  109582. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  109583. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  109584. * @param nb (positive integer) the number of particles to be created from this model
  109585. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  109586. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  109587. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109588. * @returns the number of shapes in the system
  109589. */
  109590. addShape(mesh: Mesh, nb: number, options?: {
  109591. positionFunction?: any;
  109592. vertexFunction?: any;
  109593. storage?: [];
  109594. }): number;
  109595. /**
  109596. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  109597. * @hidden
  109598. */
  109599. private _rebuildParticle;
  109600. /**
  109601. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109602. * @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.
  109603. * @returns the SPS.
  109604. */
  109605. rebuildMesh(reset?: boolean): SolidParticleSystem;
  109606. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  109607. * Returns an array with the removed particles.
  109608. * 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.
  109609. * The SPS can't be empty so at least one particle needs to remain in place.
  109610. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  109611. * @param start index of the first particle to remove
  109612. * @param end index of the last particle to remove (included)
  109613. * @returns an array populated with the removed particles
  109614. */
  109615. removeParticles(start: number, end: number): SolidParticle[];
  109616. /**
  109617. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  109618. * @param solidParticleArray an array populated with Solid Particles objects
  109619. * @returns the SPS
  109620. */
  109621. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  109622. /**
  109623. * Creates a new particle and modifies the SPS mesh geometry :
  109624. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  109625. * - calls _addParticle() to populate the particle array
  109626. * factorized code from addShape() and insertParticlesFromArray()
  109627. * @param idx particle index in the particles array
  109628. * @param i particle index in its shape
  109629. * @param modelShape particle ModelShape object
  109630. * @param shape shape vertex array
  109631. * @param meshInd shape indices array
  109632. * @param meshUV shape uv array
  109633. * @param meshCol shape color array
  109634. * @param meshNor shape normals array
  109635. * @param bbInfo shape bounding info
  109636. * @param storage target particle storage
  109637. * @options addShape() passed options
  109638. * @hidden
  109639. */
  109640. private _insertNewParticle;
  109641. /**
  109642. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  109643. * This method calls `updateParticle()` for each particle of the SPS.
  109644. * For an animated SPS, it is usually called within the render loop.
  109645. * 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.
  109646. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  109647. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  109648. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  109649. * @returns the SPS.
  109650. */
  109651. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  109652. /**
  109653. * Disposes the SPS.
  109654. */
  109655. dispose(): void;
  109656. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  109657. * idx is the particle index in the SPS
  109658. * faceId is the picked face index counted within this particle.
  109659. * Returns null if the pickInfo can't identify a picked particle.
  109660. * @param pickingInfo (PickingInfo object)
  109661. * @returns {idx: number, faceId: number} or null
  109662. */
  109663. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  109664. idx: number;
  109665. faceId: number;
  109666. }>;
  109667. /**
  109668. * Returns a SolidParticle object from its identifier : particle.id
  109669. * @param id (integer) the particle Id
  109670. * @returns the searched particle or null if not found in the SPS.
  109671. */
  109672. getParticleById(id: number): Nullable<SolidParticle>;
  109673. /**
  109674. * Returns a new array populated with the particles having the passed shapeId.
  109675. * @param shapeId (integer) the shape identifier
  109676. * @returns a new solid particle array
  109677. */
  109678. getParticlesByShapeId(shapeId: number): SolidParticle[];
  109679. /**
  109680. * Populates the passed array "ref" with the particles having the passed shapeId.
  109681. * @param shapeId the shape identifier
  109682. * @returns the SPS
  109683. * @param ref
  109684. */
  109685. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  109686. /**
  109687. * Computes the required SubMeshes according the materials assigned to the particles.
  109688. * @returns the solid particle system.
  109689. * Does nothing if called before the SPS mesh is built.
  109690. */
  109691. computeSubMeshes(): SolidParticleSystem;
  109692. /**
  109693. * Sorts the solid particles by material when MultiMaterial is enabled.
  109694. * Updates the indices32 array.
  109695. * Updates the indicesByMaterial array.
  109696. * Updates the mesh indices array.
  109697. * @returns the SPS
  109698. * @hidden
  109699. */
  109700. private _sortParticlesByMaterial;
  109701. /**
  109702. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  109703. * @hidden
  109704. */
  109705. private _setMaterialIndexesById;
  109706. /**
  109707. * Returns an array with unique values of Materials from the passed array
  109708. * @param array the material array to be checked and filtered
  109709. * @hidden
  109710. */
  109711. private _filterUniqueMaterialId;
  109712. /**
  109713. * Sets a new Standard Material as _defaultMaterial if not already set.
  109714. * @hidden
  109715. */
  109716. private _setDefaultMaterial;
  109717. /**
  109718. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  109719. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109720. * @returns the SPS.
  109721. */
  109722. refreshVisibleSize(): SolidParticleSystem;
  109723. /**
  109724. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  109725. * @param size the size (float) of the visibility box
  109726. * note : this doesn't lock the SPS mesh bounding box.
  109727. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109728. */
  109729. setVisibilityBox(size: number): void;
  109730. /**
  109731. * Gets whether the SPS as always visible or not
  109732. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109733. */
  109734. get isAlwaysVisible(): boolean;
  109735. /**
  109736. * Sets the SPS as always visible or not
  109737. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109738. */
  109739. set isAlwaysVisible(val: boolean);
  109740. /**
  109741. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109742. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109743. */
  109744. set isVisibilityBoxLocked(val: boolean);
  109745. /**
  109746. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109747. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109748. */
  109749. get isVisibilityBoxLocked(): boolean;
  109750. /**
  109751. * Tells to `setParticles()` to compute the particle rotations or not.
  109752. * Default value : true. The SPS is faster when it's set to false.
  109753. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109754. */
  109755. set computeParticleRotation(val: boolean);
  109756. /**
  109757. * Tells to `setParticles()` to compute the particle colors or not.
  109758. * Default value : true. The SPS is faster when it's set to false.
  109759. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109760. */
  109761. set computeParticleColor(val: boolean);
  109762. set computeParticleTexture(val: boolean);
  109763. /**
  109764. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  109765. * Default value : false. The SPS is faster when it's set to false.
  109766. * Note : the particle custom vertex positions aren't stored values.
  109767. */
  109768. set computeParticleVertex(val: boolean);
  109769. /**
  109770. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  109771. */
  109772. set computeBoundingBox(val: boolean);
  109773. /**
  109774. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  109775. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109776. * Default : `true`
  109777. */
  109778. set depthSortParticles(val: boolean);
  109779. /**
  109780. * Gets if `setParticles()` computes the particle rotations or not.
  109781. * Default value : true. The SPS is faster when it's set to false.
  109782. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109783. */
  109784. get computeParticleRotation(): boolean;
  109785. /**
  109786. * Gets if `setParticles()` computes the particle colors or not.
  109787. * Default value : true. The SPS is faster when it's set to false.
  109788. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109789. */
  109790. get computeParticleColor(): boolean;
  109791. /**
  109792. * Gets if `setParticles()` computes the particle textures or not.
  109793. * Default value : true. The SPS is faster when it's set to false.
  109794. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  109795. */
  109796. get computeParticleTexture(): boolean;
  109797. /**
  109798. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  109799. * Default value : false. The SPS is faster when it's set to false.
  109800. * Note : the particle custom vertex positions aren't stored values.
  109801. */
  109802. get computeParticleVertex(): boolean;
  109803. /**
  109804. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  109805. */
  109806. get computeBoundingBox(): boolean;
  109807. /**
  109808. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  109809. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109810. * Default : `true`
  109811. */
  109812. get depthSortParticles(): boolean;
  109813. /**
  109814. * Gets if the SPS is created as expandable at construction time.
  109815. * Default : `false`
  109816. */
  109817. get expandable(): boolean;
  109818. /**
  109819. * Gets if the SPS supports the Multi Materials
  109820. */
  109821. get multimaterialEnabled(): boolean;
  109822. /**
  109823. * Gets if the SPS uses the model materials for its own multimaterial.
  109824. */
  109825. get useModelMaterial(): boolean;
  109826. /**
  109827. * The SPS used material array.
  109828. */
  109829. get materials(): Material[];
  109830. /**
  109831. * Sets the SPS MultiMaterial from the passed materials.
  109832. * Note : the passed array is internally copied and not used then by reference.
  109833. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  109834. */
  109835. setMultiMaterial(materials: Material[]): void;
  109836. /**
  109837. * The SPS computed multimaterial object
  109838. */
  109839. get multimaterial(): MultiMaterial;
  109840. set multimaterial(mm: MultiMaterial);
  109841. /**
  109842. * If the subMeshes must be updated on the next call to setParticles()
  109843. */
  109844. get autoUpdateSubMeshes(): boolean;
  109845. set autoUpdateSubMeshes(val: boolean);
  109846. /**
  109847. * This function does nothing. It may be overwritten to set all the particle first values.
  109848. * The SPS doesn't call this function, you may have to call it by your own.
  109849. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109850. */
  109851. initParticles(): void;
  109852. /**
  109853. * This function does nothing. It may be overwritten to recycle a particle.
  109854. * The SPS doesn't call this function, you may have to call it by your own.
  109855. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109856. * @param particle The particle to recycle
  109857. * @returns the recycled particle
  109858. */
  109859. recycleParticle(particle: SolidParticle): SolidParticle;
  109860. /**
  109861. * Updates a particle : this function should be overwritten by the user.
  109862. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  109863. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109864. * @example : just set a particle position or velocity and recycle conditions
  109865. * @param particle The particle to update
  109866. * @returns the updated particle
  109867. */
  109868. updateParticle(particle: SolidParticle): SolidParticle;
  109869. /**
  109870. * Updates a vertex of a particle : it can be overwritten by the user.
  109871. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  109872. * @param particle the current particle
  109873. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  109874. * @param pt the index of the current vertex in the particle shape
  109875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  109876. * @example : just set a vertex particle position or color
  109877. * @returns the sps
  109878. */
  109879. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  109880. /**
  109881. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  109882. * This does nothing and may be overwritten by the user.
  109883. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109885. * @param update the boolean update value actually passed to setParticles()
  109886. */
  109887. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  109888. /**
  109889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  109890. * This will be passed three parameters.
  109891. * This does nothing and may be overwritten by the user.
  109892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109894. * @param update the boolean update value actually passed to setParticles()
  109895. */
  109896. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  109897. }
  109898. }
  109899. declare module BABYLON {
  109900. /**
  109901. * Represents one particle of a solid particle system.
  109902. */
  109903. export class SolidParticle {
  109904. /**
  109905. * particle global index
  109906. */
  109907. idx: number;
  109908. /**
  109909. * particle identifier
  109910. */
  109911. id: number;
  109912. /**
  109913. * The color of the particle
  109914. */
  109915. color: Nullable<Color4>;
  109916. /**
  109917. * The world space position of the particle.
  109918. */
  109919. position: Vector3;
  109920. /**
  109921. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  109922. */
  109923. rotation: Vector3;
  109924. /**
  109925. * The world space rotation quaternion of the particle.
  109926. */
  109927. rotationQuaternion: Nullable<Quaternion>;
  109928. /**
  109929. * The scaling of the particle.
  109930. */
  109931. scaling: Vector3;
  109932. /**
  109933. * The uvs of the particle.
  109934. */
  109935. uvs: Vector4;
  109936. /**
  109937. * The current speed of the particle.
  109938. */
  109939. velocity: Vector3;
  109940. /**
  109941. * The pivot point in the particle local space.
  109942. */
  109943. pivot: Vector3;
  109944. /**
  109945. * Must the particle be translated from its pivot point in its local space ?
  109946. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  109947. * Default : false
  109948. */
  109949. translateFromPivot: boolean;
  109950. /**
  109951. * Is the particle active or not ?
  109952. */
  109953. alive: boolean;
  109954. /**
  109955. * Is the particle visible or not ?
  109956. */
  109957. isVisible: boolean;
  109958. /**
  109959. * Index of this particle in the global "positions" array (Internal use)
  109960. * @hidden
  109961. */
  109962. _pos: number;
  109963. /**
  109964. * @hidden Index of this particle in the global "indices" array (Internal use)
  109965. */
  109966. _ind: number;
  109967. /**
  109968. * @hidden ModelShape of this particle (Internal use)
  109969. */
  109970. _model: ModelShape;
  109971. /**
  109972. * ModelShape id of this particle
  109973. */
  109974. shapeId: number;
  109975. /**
  109976. * Index of the particle in its shape id
  109977. */
  109978. idxInShape: number;
  109979. /**
  109980. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  109981. */
  109982. _modelBoundingInfo: BoundingInfo;
  109983. /**
  109984. * @hidden Particle BoundingInfo object (Internal use)
  109985. */
  109986. _boundingInfo: BoundingInfo;
  109987. /**
  109988. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  109989. */
  109990. _sps: SolidParticleSystem;
  109991. /**
  109992. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  109993. */
  109994. _stillInvisible: boolean;
  109995. /**
  109996. * @hidden Last computed particle rotation matrix
  109997. */
  109998. _rotationMatrix: number[];
  109999. /**
  110000. * Parent particle Id, if any.
  110001. * Default null.
  110002. */
  110003. parentId: Nullable<number>;
  110004. /**
  110005. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110006. */
  110007. materialIndex: Nullable<number>;
  110008. /**
  110009. * Custom object or properties.
  110010. */
  110011. props: Nullable<any>;
  110012. /**
  110013. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110014. * The possible values are :
  110015. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110016. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110017. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110019. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110020. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110021. * */
  110022. cullingStrategy: number;
  110023. /**
  110024. * @hidden Internal global position in the SPS.
  110025. */
  110026. _globalPosition: Vector3;
  110027. /**
  110028. * Creates a Solid Particle object.
  110029. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110030. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110031. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110032. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110033. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110034. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110035. * @param shapeId (integer) is the model shape identifier in the SPS.
  110036. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110037. * @param sps defines the sps it is associated to
  110038. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110039. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110040. */
  110041. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110042. /**
  110043. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110044. * @param target the particle target
  110045. * @returns the current particle
  110046. */
  110047. copyToRef(target: SolidParticle): SolidParticle;
  110048. /**
  110049. * Legacy support, changed scale to scaling
  110050. */
  110051. get scale(): Vector3;
  110052. /**
  110053. * Legacy support, changed scale to scaling
  110054. */
  110055. set scale(scale: Vector3);
  110056. /**
  110057. * Legacy support, changed quaternion to rotationQuaternion
  110058. */
  110059. get quaternion(): Nullable<Quaternion>;
  110060. /**
  110061. * Legacy support, changed quaternion to rotationQuaternion
  110062. */
  110063. set quaternion(q: Nullable<Quaternion>);
  110064. /**
  110065. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110066. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110067. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110068. * @returns true if it intersects
  110069. */
  110070. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110071. /**
  110072. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110073. * A particle is in the frustum if its bounding box intersects the frustum
  110074. * @param frustumPlanes defines the frustum to test
  110075. * @returns true if the particle is in the frustum planes
  110076. */
  110077. isInFrustum(frustumPlanes: Plane[]): boolean;
  110078. /**
  110079. * get the rotation matrix of the particle
  110080. * @hidden
  110081. */
  110082. getRotationMatrix(m: Matrix): void;
  110083. }
  110084. /**
  110085. * Represents the shape of the model used by one particle of a solid particle system.
  110086. * SPS internal tool, don't use it manually.
  110087. */
  110088. export class ModelShape {
  110089. /**
  110090. * The shape id
  110091. * @hidden
  110092. */
  110093. shapeID: number;
  110094. /**
  110095. * flat array of model positions (internal use)
  110096. * @hidden
  110097. */
  110098. _shape: Vector3[];
  110099. /**
  110100. * flat array of model UVs (internal use)
  110101. * @hidden
  110102. */
  110103. _shapeUV: number[];
  110104. /**
  110105. * color array of the model
  110106. * @hidden
  110107. */
  110108. _shapeColors: number[];
  110109. /**
  110110. * indices array of the model
  110111. * @hidden
  110112. */
  110113. _indices: number[];
  110114. /**
  110115. * normals array of the model
  110116. * @hidden
  110117. */
  110118. _normals: number[];
  110119. /**
  110120. * length of the shape in the model indices array (internal use)
  110121. * @hidden
  110122. */
  110123. _indicesLength: number;
  110124. /**
  110125. * Custom position function (internal use)
  110126. * @hidden
  110127. */
  110128. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110129. /**
  110130. * Custom vertex function (internal use)
  110131. * @hidden
  110132. */
  110133. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110134. /**
  110135. * Model material (internal use)
  110136. * @hidden
  110137. */
  110138. _material: Nullable<Material>;
  110139. /**
  110140. * 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.
  110141. * SPS internal tool, don't use it manually.
  110142. * @hidden
  110143. */
  110144. 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>);
  110145. }
  110146. /**
  110147. * Represents a Depth Sorted Particle in the solid particle system.
  110148. * @hidden
  110149. */
  110150. export class DepthSortedParticle {
  110151. /**
  110152. * Particle index
  110153. */
  110154. idx: number;
  110155. /**
  110156. * Index of the particle in the "indices" array
  110157. */
  110158. ind: number;
  110159. /**
  110160. * Length of the particle shape in the "indices" array
  110161. */
  110162. indicesLength: number;
  110163. /**
  110164. * Squared distance from the particle to the camera
  110165. */
  110166. sqDistance: number;
  110167. /**
  110168. * Material index when used with MultiMaterials
  110169. */
  110170. materialIndex: number;
  110171. /**
  110172. * Creates a new sorted particle
  110173. * @param materialIndex
  110174. */
  110175. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110176. }
  110177. /**
  110178. * Represents a solid particle vertex
  110179. */
  110180. export class SolidParticleVertex {
  110181. /**
  110182. * Vertex position
  110183. */
  110184. position: Vector3;
  110185. /**
  110186. * Vertex color
  110187. */
  110188. color: Color4;
  110189. /**
  110190. * Vertex UV
  110191. */
  110192. uv: Vector2;
  110193. /**
  110194. * Creates a new solid particle vertex
  110195. */
  110196. constructor();
  110197. /** Vertex x coordinate */
  110198. get x(): number;
  110199. set x(val: number);
  110200. /** Vertex y coordinate */
  110201. get y(): number;
  110202. set y(val: number);
  110203. /** Vertex z coordinate */
  110204. get z(): number;
  110205. set z(val: number);
  110206. }
  110207. }
  110208. declare module BABYLON {
  110209. /**
  110210. * @hidden
  110211. */
  110212. export class _MeshCollisionData {
  110213. _checkCollisions: boolean;
  110214. _collisionMask: number;
  110215. _collisionGroup: number;
  110216. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110217. _collider: Nullable<Collider>;
  110218. _oldPositionForCollisions: Vector3;
  110219. _diffPositionForCollisions: Vector3;
  110220. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110221. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110222. }
  110223. }
  110224. declare module BABYLON {
  110225. /** @hidden */
  110226. class _FacetDataStorage {
  110227. facetPositions: Vector3[];
  110228. facetNormals: Vector3[];
  110229. facetPartitioning: number[][];
  110230. facetNb: number;
  110231. partitioningSubdivisions: number;
  110232. partitioningBBoxRatio: number;
  110233. facetDataEnabled: boolean;
  110234. facetParameters: any;
  110235. bbSize: Vector3;
  110236. subDiv: {
  110237. max: number;
  110238. X: number;
  110239. Y: number;
  110240. Z: number;
  110241. };
  110242. facetDepthSort: boolean;
  110243. facetDepthSortEnabled: boolean;
  110244. depthSortedIndices: IndicesArray;
  110245. depthSortedFacets: {
  110246. ind: number;
  110247. sqDistance: number;
  110248. }[];
  110249. facetDepthSortFunction: (f1: {
  110250. ind: number;
  110251. sqDistance: number;
  110252. }, f2: {
  110253. ind: number;
  110254. sqDistance: number;
  110255. }) => number;
  110256. facetDepthSortFrom: Vector3;
  110257. facetDepthSortOrigin: Vector3;
  110258. invertedMatrix: Matrix;
  110259. }
  110260. /**
  110261. * @hidden
  110262. **/
  110263. class _InternalAbstractMeshDataInfo {
  110264. _hasVertexAlpha: boolean;
  110265. _useVertexColors: boolean;
  110266. _numBoneInfluencers: number;
  110267. _applyFog: boolean;
  110268. _receiveShadows: boolean;
  110269. _facetData: _FacetDataStorage;
  110270. _visibility: number;
  110271. _skeleton: Nullable<Skeleton>;
  110272. _layerMask: number;
  110273. _computeBonesUsingShaders: boolean;
  110274. _isActive: boolean;
  110275. _onlyForInstances: boolean;
  110276. _isActiveIntermediate: boolean;
  110277. _onlyForInstancesIntermediate: boolean;
  110278. _actAsRegularMesh: boolean;
  110279. }
  110280. /**
  110281. * Class used to store all common mesh properties
  110282. */
  110283. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110284. /** No occlusion */
  110285. static OCCLUSION_TYPE_NONE: number;
  110286. /** Occlusion set to optimisitic */
  110287. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110288. /** Occlusion set to strict */
  110289. static OCCLUSION_TYPE_STRICT: number;
  110290. /** Use an accurante occlusion algorithm */
  110291. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110292. /** Use a conservative occlusion algorithm */
  110293. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110294. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110295. * Test order :
  110296. * Is the bounding sphere outside the frustum ?
  110297. * If not, are the bounding box vertices outside the frustum ?
  110298. * It not, then the cullable object is in the frustum.
  110299. */
  110300. static readonly CULLINGSTRATEGY_STANDARD: number;
  110301. /** Culling strategy : Bounding Sphere Only.
  110302. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110303. * It's also less accurate than the standard because some not visible objects can still be selected.
  110304. * Test : is the bounding sphere outside the frustum ?
  110305. * If not, then the cullable object is in the frustum.
  110306. */
  110307. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110308. /** Culling strategy : Optimistic Inclusion.
  110309. * This in an inclusion test first, then the standard exclusion test.
  110310. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110311. * 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.
  110312. * Anyway, it's as accurate as the standard strategy.
  110313. * Test :
  110314. * Is the cullable object bounding sphere center in the frustum ?
  110315. * If not, apply the default culling strategy.
  110316. */
  110317. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110318. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110319. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110320. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110321. * 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.
  110322. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110323. * Test :
  110324. * Is the cullable object bounding sphere center in the frustum ?
  110325. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110326. */
  110327. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110328. /**
  110329. * No billboard
  110330. */
  110331. static get BILLBOARDMODE_NONE(): number;
  110332. /** Billboard on X axis */
  110333. static get BILLBOARDMODE_X(): number;
  110334. /** Billboard on Y axis */
  110335. static get BILLBOARDMODE_Y(): number;
  110336. /** Billboard on Z axis */
  110337. static get BILLBOARDMODE_Z(): number;
  110338. /** Billboard on all axes */
  110339. static get BILLBOARDMODE_ALL(): number;
  110340. /** Billboard on using position instead of orientation */
  110341. static get BILLBOARDMODE_USE_POSITION(): number;
  110342. /** @hidden */
  110343. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110344. /**
  110345. * The culling strategy to use to check whether the mesh must be rendered or not.
  110346. * This value can be changed at any time and will be used on the next render mesh selection.
  110347. * The possible values are :
  110348. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110349. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110350. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110352. * Please read each static variable documentation to get details about the culling process.
  110353. * */
  110354. cullingStrategy: number;
  110355. /**
  110356. * Gets the number of facets in the mesh
  110357. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110358. */
  110359. get facetNb(): number;
  110360. /**
  110361. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110362. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110363. */
  110364. get partitioningSubdivisions(): number;
  110365. set partitioningSubdivisions(nb: number);
  110366. /**
  110367. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110368. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110369. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110370. */
  110371. get partitioningBBoxRatio(): number;
  110372. set partitioningBBoxRatio(ratio: number);
  110373. /**
  110374. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110375. * Works only for updatable meshes.
  110376. * Doesn't work with multi-materials
  110377. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110378. */
  110379. get mustDepthSortFacets(): boolean;
  110380. set mustDepthSortFacets(sort: boolean);
  110381. /**
  110382. * The location (Vector3) where the facet depth sort must be computed from.
  110383. * By default, the active camera position.
  110384. * Used only when facet depth sort is enabled
  110385. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110386. */
  110387. get facetDepthSortFrom(): Vector3;
  110388. set facetDepthSortFrom(location: Vector3);
  110389. /**
  110390. * gets a boolean indicating if facetData is enabled
  110391. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110392. */
  110393. get isFacetDataEnabled(): boolean;
  110394. /** @hidden */
  110395. _updateNonUniformScalingState(value: boolean): boolean;
  110396. /**
  110397. * An event triggered when this mesh collides with another one
  110398. */
  110399. onCollideObservable: Observable<AbstractMesh>;
  110400. /** Set a function to call when this mesh collides with another one */
  110401. set onCollide(callback: () => void);
  110402. /**
  110403. * An event triggered when the collision's position changes
  110404. */
  110405. onCollisionPositionChangeObservable: Observable<Vector3>;
  110406. /** Set a function to call when the collision's position changes */
  110407. set onCollisionPositionChange(callback: () => void);
  110408. /**
  110409. * An event triggered when material is changed
  110410. */
  110411. onMaterialChangedObservable: Observable<AbstractMesh>;
  110412. /**
  110413. * Gets or sets the orientation for POV movement & rotation
  110414. */
  110415. definedFacingForward: boolean;
  110416. /** @hidden */
  110417. _occlusionQuery: Nullable<WebGLQuery>;
  110418. /** @hidden */
  110419. _renderingGroup: Nullable<RenderingGroup>;
  110420. /**
  110421. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110422. */
  110423. get visibility(): number;
  110424. /**
  110425. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110426. */
  110427. set visibility(value: number);
  110428. /** Gets or sets the alpha index used to sort transparent meshes
  110429. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110430. */
  110431. alphaIndex: number;
  110432. /**
  110433. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  110434. */
  110435. isVisible: boolean;
  110436. /**
  110437. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  110438. */
  110439. isPickable: boolean;
  110440. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  110441. showSubMeshesBoundingBox: boolean;
  110442. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  110443. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110444. */
  110445. isBlocker: boolean;
  110446. /**
  110447. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  110448. */
  110449. enablePointerMoveEvents: boolean;
  110450. /**
  110451. * Specifies the rendering group id for this mesh (0 by default)
  110452. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  110453. */
  110454. renderingGroupId: number;
  110455. private _material;
  110456. /** Gets or sets current material */
  110457. get material(): Nullable<Material>;
  110458. set material(value: Nullable<Material>);
  110459. /**
  110460. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  110461. * @see https://doc.babylonjs.com/babylon101/shadows
  110462. */
  110463. get receiveShadows(): boolean;
  110464. set receiveShadows(value: boolean);
  110465. /** Defines color to use when rendering outline */
  110466. outlineColor: Color3;
  110467. /** Define width to use when rendering outline */
  110468. outlineWidth: number;
  110469. /** Defines color to use when rendering overlay */
  110470. overlayColor: Color3;
  110471. /** Defines alpha to use when rendering overlay */
  110472. overlayAlpha: number;
  110473. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  110474. get hasVertexAlpha(): boolean;
  110475. set hasVertexAlpha(value: boolean);
  110476. /** 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) */
  110477. get useVertexColors(): boolean;
  110478. set useVertexColors(value: boolean);
  110479. /**
  110480. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  110481. */
  110482. get computeBonesUsingShaders(): boolean;
  110483. set computeBonesUsingShaders(value: boolean);
  110484. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  110485. get numBoneInfluencers(): number;
  110486. set numBoneInfluencers(value: number);
  110487. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  110488. get applyFog(): boolean;
  110489. set applyFog(value: boolean);
  110490. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  110491. useOctreeForRenderingSelection: boolean;
  110492. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  110493. useOctreeForPicking: boolean;
  110494. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  110495. useOctreeForCollisions: boolean;
  110496. /**
  110497. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  110498. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  110499. */
  110500. get layerMask(): number;
  110501. set layerMask(value: number);
  110502. /**
  110503. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  110504. */
  110505. alwaysSelectAsActiveMesh: boolean;
  110506. /**
  110507. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  110508. */
  110509. doNotSyncBoundingInfo: boolean;
  110510. /**
  110511. * Gets or sets the current action manager
  110512. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110513. */
  110514. actionManager: Nullable<AbstractActionManager>;
  110515. private _meshCollisionData;
  110516. /**
  110517. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  110518. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110519. */
  110520. ellipsoid: Vector3;
  110521. /**
  110522. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  110523. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110524. */
  110525. ellipsoidOffset: Vector3;
  110526. /**
  110527. * Gets or sets a collision mask used to mask collisions (default is -1).
  110528. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110529. */
  110530. get collisionMask(): number;
  110531. set collisionMask(mask: number);
  110532. /**
  110533. * Gets or sets the current collision group mask (-1 by default).
  110534. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110535. */
  110536. get collisionGroup(): number;
  110537. set collisionGroup(mask: number);
  110538. /**
  110539. * Gets or sets current surrounding meshes (null by default).
  110540. *
  110541. * By default collision detection is tested against every mesh in the scene.
  110542. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  110543. * meshes will be tested for the collision.
  110544. *
  110545. * Note: if set to an empty array no collision will happen when this mesh is moved.
  110546. */
  110547. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  110548. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  110549. /**
  110550. * Defines edge width used when edgesRenderer is enabled
  110551. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110552. */
  110553. edgesWidth: number;
  110554. /**
  110555. * Defines edge color used when edgesRenderer is enabled
  110556. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110557. */
  110558. edgesColor: Color4;
  110559. /** @hidden */
  110560. _edgesRenderer: Nullable<IEdgesRenderer>;
  110561. /** @hidden */
  110562. _masterMesh: Nullable<AbstractMesh>;
  110563. /** @hidden */
  110564. _boundingInfo: Nullable<BoundingInfo>;
  110565. /** @hidden */
  110566. _renderId: number;
  110567. /**
  110568. * Gets or sets the list of subMeshes
  110569. * @see https://doc.babylonjs.com/how_to/multi_materials
  110570. */
  110571. subMeshes: SubMesh[];
  110572. /** @hidden */
  110573. _intersectionsInProgress: AbstractMesh[];
  110574. /** @hidden */
  110575. _unIndexed: boolean;
  110576. /** @hidden */
  110577. _lightSources: Light[];
  110578. /** Gets the list of lights affecting that mesh */
  110579. get lightSources(): Light[];
  110580. /** @hidden */
  110581. get _positions(): Nullable<Vector3[]>;
  110582. /** @hidden */
  110583. _waitingData: {
  110584. lods: Nullable<any>;
  110585. actions: Nullable<any>;
  110586. freezeWorldMatrix: Nullable<boolean>;
  110587. };
  110588. /** @hidden */
  110589. _bonesTransformMatrices: Nullable<Float32Array>;
  110590. /** @hidden */
  110591. _transformMatrixTexture: Nullable<RawTexture>;
  110592. /**
  110593. * Gets or sets a skeleton to apply skining transformations
  110594. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110595. */
  110596. set skeleton(value: Nullable<Skeleton>);
  110597. get skeleton(): Nullable<Skeleton>;
  110598. /**
  110599. * An event triggered when the mesh is rebuilt.
  110600. */
  110601. onRebuildObservable: Observable<AbstractMesh>;
  110602. /**
  110603. * Creates a new AbstractMesh
  110604. * @param name defines the name of the mesh
  110605. * @param scene defines the hosting scene
  110606. */
  110607. constructor(name: string, scene?: Nullable<Scene>);
  110608. /**
  110609. * Returns the string "AbstractMesh"
  110610. * @returns "AbstractMesh"
  110611. */
  110612. getClassName(): string;
  110613. /**
  110614. * Gets a string representation of the current mesh
  110615. * @param fullDetails defines a boolean indicating if full details must be included
  110616. * @returns a string representation of the current mesh
  110617. */
  110618. toString(fullDetails?: boolean): string;
  110619. /**
  110620. * @hidden
  110621. */
  110622. protected _getEffectiveParent(): Nullable<Node>;
  110623. /** @hidden */
  110624. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110625. /** @hidden */
  110626. _rebuild(): void;
  110627. /** @hidden */
  110628. _resyncLightSources(): void;
  110629. /** @hidden */
  110630. _resyncLightSource(light: Light): void;
  110631. /** @hidden */
  110632. _unBindEffect(): void;
  110633. /** @hidden */
  110634. _removeLightSource(light: Light, dispose: boolean): void;
  110635. private _markSubMeshesAsDirty;
  110636. /** @hidden */
  110637. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  110638. /** @hidden */
  110639. _markSubMeshesAsAttributesDirty(): void;
  110640. /** @hidden */
  110641. _markSubMeshesAsMiscDirty(): void;
  110642. /**
  110643. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  110644. */
  110645. get scaling(): Vector3;
  110646. set scaling(newScaling: Vector3);
  110647. /**
  110648. * Returns true if the mesh is blocked. Implemented by child classes
  110649. */
  110650. get isBlocked(): boolean;
  110651. /**
  110652. * Returns the mesh itself by default. Implemented by child classes
  110653. * @param camera defines the camera to use to pick the right LOD level
  110654. * @returns the currentAbstractMesh
  110655. */
  110656. getLOD(camera: Camera): Nullable<AbstractMesh>;
  110657. /**
  110658. * Returns 0 by default. Implemented by child classes
  110659. * @returns an integer
  110660. */
  110661. getTotalVertices(): number;
  110662. /**
  110663. * Returns a positive integer : the total number of indices in this mesh geometry.
  110664. * @returns the numner of indices or zero if the mesh has no geometry.
  110665. */
  110666. getTotalIndices(): number;
  110667. /**
  110668. * Returns null by default. Implemented by child classes
  110669. * @returns null
  110670. */
  110671. getIndices(): Nullable<IndicesArray>;
  110672. /**
  110673. * Returns the array of the requested vertex data kind. Implemented by child classes
  110674. * @param kind defines the vertex data kind to use
  110675. * @returns null
  110676. */
  110677. getVerticesData(kind: string): Nullable<FloatArray>;
  110678. /**
  110679. * Sets the vertex data of the mesh geometry for the requested `kind`.
  110680. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  110681. * Note that a new underlying VertexBuffer object is created each call.
  110682. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  110683. * @param kind defines vertex data kind:
  110684. * * VertexBuffer.PositionKind
  110685. * * VertexBuffer.UVKind
  110686. * * VertexBuffer.UV2Kind
  110687. * * VertexBuffer.UV3Kind
  110688. * * VertexBuffer.UV4Kind
  110689. * * VertexBuffer.UV5Kind
  110690. * * VertexBuffer.UV6Kind
  110691. * * VertexBuffer.ColorKind
  110692. * * VertexBuffer.MatricesIndicesKind
  110693. * * VertexBuffer.MatricesIndicesExtraKind
  110694. * * VertexBuffer.MatricesWeightsKind
  110695. * * VertexBuffer.MatricesWeightsExtraKind
  110696. * @param data defines the data source
  110697. * @param updatable defines if the data must be flagged as updatable (or static)
  110698. * @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
  110699. * @returns the current mesh
  110700. */
  110701. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  110702. /**
  110703. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  110704. * If the mesh has no geometry, it is simply returned as it is.
  110705. * @param kind defines vertex data kind:
  110706. * * VertexBuffer.PositionKind
  110707. * * VertexBuffer.UVKind
  110708. * * VertexBuffer.UV2Kind
  110709. * * VertexBuffer.UV3Kind
  110710. * * VertexBuffer.UV4Kind
  110711. * * VertexBuffer.UV5Kind
  110712. * * VertexBuffer.UV6Kind
  110713. * * VertexBuffer.ColorKind
  110714. * * VertexBuffer.MatricesIndicesKind
  110715. * * VertexBuffer.MatricesIndicesExtraKind
  110716. * * VertexBuffer.MatricesWeightsKind
  110717. * * VertexBuffer.MatricesWeightsExtraKind
  110718. * @param data defines the data source
  110719. * @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
  110720. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  110721. * @returns the current mesh
  110722. */
  110723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  110724. /**
  110725. * Sets the mesh indices,
  110726. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  110727. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  110728. * @param totalVertices Defines the total number of vertices
  110729. * @returns the current mesh
  110730. */
  110731. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  110732. /**
  110733. * Gets a boolean indicating if specific vertex data is present
  110734. * @param kind defines the vertex data kind to use
  110735. * @returns true is data kind is present
  110736. */
  110737. isVerticesDataPresent(kind: string): boolean;
  110738. /**
  110739. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  110740. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  110741. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  110742. * @returns a BoundingInfo
  110743. */
  110744. getBoundingInfo(): BoundingInfo;
  110745. /**
  110746. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  110747. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  110748. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  110749. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  110750. * @returns the current mesh
  110751. */
  110752. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  110753. /**
  110754. * Overwrite the current bounding info
  110755. * @param boundingInfo defines the new bounding info
  110756. * @returns the current mesh
  110757. */
  110758. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  110759. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  110760. get useBones(): boolean;
  110761. /** @hidden */
  110762. _preActivate(): void;
  110763. /** @hidden */
  110764. _preActivateForIntermediateRendering(renderId: number): void;
  110765. /** @hidden */
  110766. _activate(renderId: number, intermediateRendering: boolean): boolean;
  110767. /** @hidden */
  110768. _postActivate(): void;
  110769. /** @hidden */
  110770. _freeze(): void;
  110771. /** @hidden */
  110772. _unFreeze(): void;
  110773. /**
  110774. * Gets the current world matrix
  110775. * @returns a Matrix
  110776. */
  110777. getWorldMatrix(): Matrix;
  110778. /** @hidden */
  110779. _getWorldMatrixDeterminant(): number;
  110780. /**
  110781. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  110782. */
  110783. get isAnInstance(): boolean;
  110784. /**
  110785. * Gets a boolean indicating if this mesh has instances
  110786. */
  110787. get hasInstances(): boolean;
  110788. /**
  110789. * Gets a boolean indicating if this mesh has thin instances
  110790. */
  110791. get hasThinInstances(): boolean;
  110792. /**
  110793. * Perform relative position change from the point of view of behind the front of the mesh.
  110794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  110795. * Supports definition of mesh facing forward or backward
  110796. * @param amountRight defines the distance on the right axis
  110797. * @param amountUp defines the distance on the up axis
  110798. * @param amountForward defines the distance on the forward axis
  110799. * @returns the current mesh
  110800. */
  110801. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  110802. /**
  110803. * Calculate relative position change from the point of view of behind the front of the mesh.
  110804. * This is performed taking into account the meshes current rotation, so you do not have to care.
  110805. * Supports definition of mesh facing forward or backward
  110806. * @param amountRight defines the distance on the right axis
  110807. * @param amountUp defines the distance on the up axis
  110808. * @param amountForward defines the distance on the forward axis
  110809. * @returns the new displacement vector
  110810. */
  110811. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  110812. /**
  110813. * Perform relative rotation change from the point of view of behind the front of the mesh.
  110814. * Supports definition of mesh facing forward or backward
  110815. * @param flipBack defines the flip
  110816. * @param twirlClockwise defines the twirl
  110817. * @param tiltRight defines the tilt
  110818. * @returns the current mesh
  110819. */
  110820. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  110821. /**
  110822. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  110823. * Supports definition of mesh facing forward or backward.
  110824. * @param flipBack defines the flip
  110825. * @param twirlClockwise defines the twirl
  110826. * @param tiltRight defines the tilt
  110827. * @returns the new rotation vector
  110828. */
  110829. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  110830. /**
  110831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  110832. * This means the mesh underlying bounding box and sphere are recomputed.
  110833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  110834. * @returns the current mesh
  110835. */
  110836. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  110837. /** @hidden */
  110838. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  110839. /** @hidden */
  110840. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  110841. /** @hidden */
  110842. _updateBoundingInfo(): AbstractMesh;
  110843. /** @hidden */
  110844. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  110845. /** @hidden */
  110846. protected _afterComputeWorldMatrix(): void;
  110847. /** @hidden */
  110848. get _effectiveMesh(): AbstractMesh;
  110849. /**
  110850. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  110851. * A mesh is in the frustum if its bounding box intersects the frustum
  110852. * @param frustumPlanes defines the frustum to test
  110853. * @returns true if the mesh is in the frustum planes
  110854. */
  110855. isInFrustum(frustumPlanes: Plane[]): boolean;
  110856. /**
  110857. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  110858. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  110859. * @param frustumPlanes defines the frustum to test
  110860. * @returns true if the mesh is completely in the frustum planes
  110861. */
  110862. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110863. /**
  110864. * True if the mesh intersects another mesh or a SolidParticle object
  110865. * @param mesh defines a target mesh or SolidParticle to test
  110866. * @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)
  110867. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  110868. * @returns true if there is an intersection
  110869. */
  110870. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  110871. /**
  110872. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  110873. * @param point defines the point to test
  110874. * @returns true if there is an intersection
  110875. */
  110876. intersectsPoint(point: Vector3): boolean;
  110877. /**
  110878. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  110879. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110880. */
  110881. get checkCollisions(): boolean;
  110882. set checkCollisions(collisionEnabled: boolean);
  110883. /**
  110884. * Gets Collider object used to compute collisions (not physics)
  110885. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110886. */
  110887. get collider(): Nullable<Collider>;
  110888. /**
  110889. * Move the mesh using collision engine
  110890. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110891. * @param displacement defines the requested displacement vector
  110892. * @returns the current mesh
  110893. */
  110894. moveWithCollisions(displacement: Vector3): AbstractMesh;
  110895. private _onCollisionPositionChange;
  110896. /** @hidden */
  110897. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  110898. /** @hidden */
  110899. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  110900. /** @hidden */
  110901. _checkCollision(collider: Collider): AbstractMesh;
  110902. /** @hidden */
  110903. _generatePointsArray(): boolean;
  110904. /**
  110905. * Checks if the passed Ray intersects with the mesh
  110906. * @param ray defines the ray to use
  110907. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  110908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110909. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  110910. * @returns the picking info
  110911. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  110912. */
  110913. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  110914. /**
  110915. * Clones the current mesh
  110916. * @param name defines the mesh name
  110917. * @param newParent defines the new mesh parent
  110918. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  110919. * @returns the new mesh
  110920. */
  110921. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  110922. /**
  110923. * Disposes all the submeshes of the current meshnp
  110924. * @returns the current mesh
  110925. */
  110926. releaseSubMeshes(): AbstractMesh;
  110927. /**
  110928. * Releases resources associated with this abstract mesh.
  110929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110931. */
  110932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110933. /**
  110934. * Adds the passed mesh as a child to the current mesh
  110935. * @param mesh defines the child mesh
  110936. * @returns the current mesh
  110937. */
  110938. addChild(mesh: AbstractMesh): AbstractMesh;
  110939. /**
  110940. * Removes the passed mesh from the current mesh children list
  110941. * @param mesh defines the child mesh
  110942. * @returns the current mesh
  110943. */
  110944. removeChild(mesh: AbstractMesh): AbstractMesh;
  110945. /** @hidden */
  110946. private _initFacetData;
  110947. /**
  110948. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  110949. * This method can be called within the render loop.
  110950. * 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
  110951. * @returns the current mesh
  110952. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110953. */
  110954. updateFacetData(): AbstractMesh;
  110955. /**
  110956. * Returns the facetLocalNormals array.
  110957. * The normals are expressed in the mesh local spac
  110958. * @returns an array of Vector3
  110959. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110960. */
  110961. getFacetLocalNormals(): Vector3[];
  110962. /**
  110963. * Returns the facetLocalPositions array.
  110964. * The facet positions are expressed in the mesh local space
  110965. * @returns an array of Vector3
  110966. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110967. */
  110968. getFacetLocalPositions(): Vector3[];
  110969. /**
  110970. * Returns the facetLocalPartioning array
  110971. * @returns an array of array of numbers
  110972. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110973. */
  110974. getFacetLocalPartitioning(): number[][];
  110975. /**
  110976. * Returns the i-th facet position in the world system.
  110977. * This method allocates a new Vector3 per call
  110978. * @param i defines the facet index
  110979. * @returns a new Vector3
  110980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110981. */
  110982. getFacetPosition(i: number): Vector3;
  110983. /**
  110984. * Sets the reference Vector3 with the i-th facet position in the world system
  110985. * @param i defines the facet index
  110986. * @param ref defines the target vector
  110987. * @returns the current mesh
  110988. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110989. */
  110990. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  110991. /**
  110992. * Returns the i-th facet normal in the world system.
  110993. * This method allocates a new Vector3 per call
  110994. * @param i defines the facet index
  110995. * @returns a new Vector3
  110996. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110997. */
  110998. getFacetNormal(i: number): Vector3;
  110999. /**
  111000. * Sets the reference Vector3 with the i-th facet normal in the world system
  111001. * @param i defines the facet index
  111002. * @param ref defines the target vector
  111003. * @returns the current mesh
  111004. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111005. */
  111006. getFacetNormalToRef(i: number, ref: Vector3): this;
  111007. /**
  111008. * 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)
  111009. * @param x defines x coordinate
  111010. * @param y defines y coordinate
  111011. * @param z defines z coordinate
  111012. * @returns the array of facet indexes
  111013. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111014. */
  111015. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111016. /**
  111017. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111018. * @param projected sets as the (x,y,z) world projection on the facet
  111019. * @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
  111020. * @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
  111021. * @param x defines x coordinate
  111022. * @param y defines y coordinate
  111023. * @param z defines z coordinate
  111024. * @returns the face index if found (or null instead)
  111025. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111026. */
  111027. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111028. /**
  111029. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111030. * @param projected sets as the (x,y,z) local projection on the facet
  111031. * @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
  111032. * @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
  111033. * @param x defines x coordinate
  111034. * @param y defines y coordinate
  111035. * @param z defines z coordinate
  111036. * @returns the face index if found (or null instead)
  111037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111038. */
  111039. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111040. /**
  111041. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111042. * @returns the parameters
  111043. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111044. */
  111045. getFacetDataParameters(): any;
  111046. /**
  111047. * Disables the feature FacetData and frees the related memory
  111048. * @returns the current mesh
  111049. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111050. */
  111051. disableFacetData(): AbstractMesh;
  111052. /**
  111053. * Updates the AbstractMesh indices array
  111054. * @param indices defines the data source
  111055. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111056. * @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)
  111057. * @returns the current mesh
  111058. */
  111059. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111060. /**
  111061. * Creates new normals data for the mesh
  111062. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111063. * @returns the current mesh
  111064. */
  111065. createNormals(updatable: boolean): AbstractMesh;
  111066. /**
  111067. * Align the mesh with a normal
  111068. * @param normal defines the normal to use
  111069. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111070. * @returns the current mesh
  111071. */
  111072. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111073. /** @hidden */
  111074. _checkOcclusionQuery(): boolean;
  111075. /**
  111076. * Disables the mesh edge rendering mode
  111077. * @returns the currentAbstractMesh
  111078. */
  111079. disableEdgesRendering(): AbstractMesh;
  111080. /**
  111081. * Enables the edge rendering mode on the mesh.
  111082. * This mode makes the mesh edges visible
  111083. * @param epsilon defines the maximal distance between two angles to detect a face
  111084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111085. * @returns the currentAbstractMesh
  111086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111087. */
  111088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111089. /**
  111090. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111091. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111092. */
  111093. getConnectedParticleSystems(): IParticleSystem[];
  111094. }
  111095. }
  111096. declare module BABYLON {
  111097. /**
  111098. * Interface used to define ActionEvent
  111099. */
  111100. export interface IActionEvent {
  111101. /** The mesh or sprite that triggered the action */
  111102. source: any;
  111103. /** The X mouse cursor position at the time of the event */
  111104. pointerX: number;
  111105. /** The Y mouse cursor position at the time of the event */
  111106. pointerY: number;
  111107. /** The mesh that is currently pointed at (can be null) */
  111108. meshUnderPointer: Nullable<AbstractMesh>;
  111109. /** the original (browser) event that triggered the ActionEvent */
  111110. sourceEvent?: any;
  111111. /** additional data for the event */
  111112. additionalData?: any;
  111113. }
  111114. /**
  111115. * ActionEvent is the event being sent when an action is triggered.
  111116. */
  111117. export class ActionEvent implements IActionEvent {
  111118. /** The mesh or sprite that triggered the action */
  111119. source: any;
  111120. /** The X mouse cursor position at the time of the event */
  111121. pointerX: number;
  111122. /** The Y mouse cursor position at the time of the event */
  111123. pointerY: number;
  111124. /** The mesh that is currently pointed at (can be null) */
  111125. meshUnderPointer: Nullable<AbstractMesh>;
  111126. /** the original (browser) event that triggered the ActionEvent */
  111127. sourceEvent?: any;
  111128. /** additional data for the event */
  111129. additionalData?: any;
  111130. /**
  111131. * Creates a new ActionEvent
  111132. * @param source The mesh or sprite that triggered the action
  111133. * @param pointerX The X mouse cursor position at the time of the event
  111134. * @param pointerY The Y mouse cursor position at the time of the event
  111135. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111136. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111137. * @param additionalData additional data for the event
  111138. */
  111139. constructor(
  111140. /** The mesh or sprite that triggered the action */
  111141. source: any,
  111142. /** The X mouse cursor position at the time of the event */
  111143. pointerX: number,
  111144. /** The Y mouse cursor position at the time of the event */
  111145. pointerY: number,
  111146. /** The mesh that is currently pointed at (can be null) */
  111147. meshUnderPointer: Nullable<AbstractMesh>,
  111148. /** the original (browser) event that triggered the ActionEvent */
  111149. sourceEvent?: any,
  111150. /** additional data for the event */
  111151. additionalData?: any);
  111152. /**
  111153. * Helper function to auto-create an ActionEvent from a source mesh.
  111154. * @param source The source mesh that triggered the event
  111155. * @param evt The original (browser) event
  111156. * @param additionalData additional data for the event
  111157. * @returns the new ActionEvent
  111158. */
  111159. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111160. /**
  111161. * Helper function to auto-create an ActionEvent from a source sprite
  111162. * @param source The source sprite that triggered the event
  111163. * @param scene Scene associated with the sprite
  111164. * @param evt The original (browser) event
  111165. * @param additionalData additional data for the event
  111166. * @returns the new ActionEvent
  111167. */
  111168. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111169. /**
  111170. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111171. * @param scene the scene where the event occurred
  111172. * @param evt The original (browser) event
  111173. * @returns the new ActionEvent
  111174. */
  111175. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111176. /**
  111177. * Helper function to auto-create an ActionEvent from a primitive
  111178. * @param prim defines the target primitive
  111179. * @param pointerPos defines the pointer position
  111180. * @param evt The original (browser) event
  111181. * @param additionalData additional data for the event
  111182. * @returns the new ActionEvent
  111183. */
  111184. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111185. }
  111186. }
  111187. declare module BABYLON {
  111188. /**
  111189. * Abstract class used to decouple action Manager from scene and meshes.
  111190. * Do not instantiate.
  111191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111192. */
  111193. export abstract class AbstractActionManager implements IDisposable {
  111194. /** Gets the list of active triggers */
  111195. static Triggers: {
  111196. [key: string]: number;
  111197. };
  111198. /** Gets the cursor to use when hovering items */
  111199. hoverCursor: string;
  111200. /** Gets the list of actions */
  111201. actions: IAction[];
  111202. /**
  111203. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111204. */
  111205. isRecursive: boolean;
  111206. /**
  111207. * Releases all associated resources
  111208. */
  111209. abstract dispose(): void;
  111210. /**
  111211. * Does this action manager has pointer triggers
  111212. */
  111213. abstract get hasPointerTriggers(): boolean;
  111214. /**
  111215. * Does this action manager has pick triggers
  111216. */
  111217. abstract get hasPickTriggers(): boolean;
  111218. /**
  111219. * Process a specific trigger
  111220. * @param trigger defines the trigger to process
  111221. * @param evt defines the event details to be processed
  111222. */
  111223. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111224. /**
  111225. * Does this action manager handles actions of any of the given triggers
  111226. * @param triggers defines the triggers to be tested
  111227. * @return a boolean indicating whether one (or more) of the triggers is handled
  111228. */
  111229. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111230. /**
  111231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111232. * speed.
  111233. * @param triggerA defines the trigger to be tested
  111234. * @param triggerB defines the trigger to be tested
  111235. * @return a boolean indicating whether one (or more) of the triggers is handled
  111236. */
  111237. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111238. /**
  111239. * Does this action manager handles actions of a given trigger
  111240. * @param trigger defines the trigger to be tested
  111241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111242. * @return whether the trigger is handled
  111243. */
  111244. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111245. /**
  111246. * Serialize this manager to a JSON object
  111247. * @param name defines the property name to store this manager
  111248. * @returns a JSON representation of this manager
  111249. */
  111250. abstract serialize(name: string): any;
  111251. /**
  111252. * Registers an action to this action manager
  111253. * @param action defines the action to be registered
  111254. * @return the action amended (prepared) after registration
  111255. */
  111256. abstract registerAction(action: IAction): Nullable<IAction>;
  111257. /**
  111258. * Unregisters an action to this action manager
  111259. * @param action defines the action to be unregistered
  111260. * @return a boolean indicating whether the action has been unregistered
  111261. */
  111262. abstract unregisterAction(action: IAction): Boolean;
  111263. /**
  111264. * Does exist one action manager with at least one trigger
  111265. **/
  111266. static get HasTriggers(): boolean;
  111267. /**
  111268. * Does exist one action manager with at least one pick trigger
  111269. **/
  111270. static get HasPickTriggers(): boolean;
  111271. /**
  111272. * Does exist one action manager that handles actions of a given trigger
  111273. * @param trigger defines the trigger to be tested
  111274. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111275. **/
  111276. static HasSpecificTrigger(trigger: number): boolean;
  111277. }
  111278. }
  111279. declare module BABYLON {
  111280. /**
  111281. * Defines how a node can be built from a string name.
  111282. */
  111283. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111284. /**
  111285. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111286. */
  111287. export class Node implements IBehaviorAware<Node> {
  111288. /** @hidden */
  111289. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111290. private static _NodeConstructors;
  111291. /**
  111292. * Add a new node constructor
  111293. * @param type defines the type name of the node to construct
  111294. * @param constructorFunc defines the constructor function
  111295. */
  111296. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111297. /**
  111298. * Returns a node constructor based on type name
  111299. * @param type defines the type name
  111300. * @param name defines the new node name
  111301. * @param scene defines the hosting scene
  111302. * @param options defines optional options to transmit to constructors
  111303. * @returns the new constructor or null
  111304. */
  111305. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111306. /**
  111307. * Gets or sets the name of the node
  111308. */
  111309. name: string;
  111310. /**
  111311. * Gets or sets the id of the node
  111312. */
  111313. id: string;
  111314. /**
  111315. * Gets or sets the unique id of the node
  111316. */
  111317. uniqueId: number;
  111318. /**
  111319. * Gets or sets a string used to store user defined state for the node
  111320. */
  111321. state: string;
  111322. /**
  111323. * Gets or sets an object used to store user defined information for the node
  111324. */
  111325. metadata: any;
  111326. /**
  111327. * For internal use only. Please do not use.
  111328. */
  111329. reservedDataStore: any;
  111330. /**
  111331. * List of inspectable custom properties (used by the Inspector)
  111332. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111333. */
  111334. inspectableCustomProperties: IInspectable[];
  111335. private _doNotSerialize;
  111336. /**
  111337. * Gets or sets a boolean used to define if the node must be serialized
  111338. */
  111339. get doNotSerialize(): boolean;
  111340. set doNotSerialize(value: boolean);
  111341. /** @hidden */
  111342. _isDisposed: boolean;
  111343. /**
  111344. * Gets a list of Animations associated with the node
  111345. */
  111346. animations: Animation[];
  111347. protected _ranges: {
  111348. [name: string]: Nullable<AnimationRange>;
  111349. };
  111350. /**
  111351. * Callback raised when the node is ready to be used
  111352. */
  111353. onReady: Nullable<(node: Node) => void>;
  111354. private _isEnabled;
  111355. private _isParentEnabled;
  111356. private _isReady;
  111357. /** @hidden */
  111358. _currentRenderId: number;
  111359. private _parentUpdateId;
  111360. /** @hidden */
  111361. _childUpdateId: number;
  111362. /** @hidden */
  111363. _waitingParentId: Nullable<string>;
  111364. /** @hidden */
  111365. _scene: Scene;
  111366. /** @hidden */
  111367. _cache: any;
  111368. private _parentNode;
  111369. private _children;
  111370. /** @hidden */
  111371. _worldMatrix: Matrix;
  111372. /** @hidden */
  111373. _worldMatrixDeterminant: number;
  111374. /** @hidden */
  111375. _worldMatrixDeterminantIsDirty: boolean;
  111376. /** @hidden */
  111377. private _sceneRootNodesIndex;
  111378. /**
  111379. * Gets a boolean indicating if the node has been disposed
  111380. * @returns true if the node was disposed
  111381. */
  111382. isDisposed(): boolean;
  111383. /**
  111384. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111385. * @see https://doc.babylonjs.com/how_to/parenting
  111386. */
  111387. set parent(parent: Nullable<Node>);
  111388. get parent(): Nullable<Node>;
  111389. /** @hidden */
  111390. _addToSceneRootNodes(): void;
  111391. /** @hidden */
  111392. _removeFromSceneRootNodes(): void;
  111393. private _animationPropertiesOverride;
  111394. /**
  111395. * Gets or sets the animation properties override
  111396. */
  111397. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111398. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111399. /**
  111400. * Gets a string idenfifying the name of the class
  111401. * @returns "Node" string
  111402. */
  111403. getClassName(): string;
  111404. /** @hidden */
  111405. readonly _isNode: boolean;
  111406. /**
  111407. * An event triggered when the mesh is disposed
  111408. */
  111409. onDisposeObservable: Observable<Node>;
  111410. private _onDisposeObserver;
  111411. /**
  111412. * Sets a callback that will be raised when the node will be disposed
  111413. */
  111414. set onDispose(callback: () => void);
  111415. /**
  111416. * Creates a new Node
  111417. * @param name the name and id to be given to this node
  111418. * @param scene the scene this node will be added to
  111419. */
  111420. constructor(name: string, scene?: Nullable<Scene>);
  111421. /**
  111422. * Gets the scene of the node
  111423. * @returns a scene
  111424. */
  111425. getScene(): Scene;
  111426. /**
  111427. * Gets the engine of the node
  111428. * @returns a Engine
  111429. */
  111430. getEngine(): Engine;
  111431. private _behaviors;
  111432. /**
  111433. * Attach a behavior to the node
  111434. * @see https://doc.babylonjs.com/features/behaviour
  111435. * @param behavior defines the behavior to attach
  111436. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  111437. * @returns the current Node
  111438. */
  111439. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  111440. /**
  111441. * Remove an attached behavior
  111442. * @see https://doc.babylonjs.com/features/behaviour
  111443. * @param behavior defines the behavior to attach
  111444. * @returns the current Node
  111445. */
  111446. removeBehavior(behavior: Behavior<Node>): Node;
  111447. /**
  111448. * Gets the list of attached behaviors
  111449. * @see https://doc.babylonjs.com/features/behaviour
  111450. */
  111451. get behaviors(): Behavior<Node>[];
  111452. /**
  111453. * Gets an attached behavior by name
  111454. * @param name defines the name of the behavior to look for
  111455. * @see https://doc.babylonjs.com/features/behaviour
  111456. * @returns null if behavior was not found else the requested behavior
  111457. */
  111458. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  111459. /**
  111460. * Returns the latest update of the World matrix
  111461. * @returns a Matrix
  111462. */
  111463. getWorldMatrix(): Matrix;
  111464. /** @hidden */
  111465. _getWorldMatrixDeterminant(): number;
  111466. /**
  111467. * Returns directly the latest state of the mesh World matrix.
  111468. * A Matrix is returned.
  111469. */
  111470. get worldMatrixFromCache(): Matrix;
  111471. /** @hidden */
  111472. _initCache(): void;
  111473. /** @hidden */
  111474. updateCache(force?: boolean): void;
  111475. /** @hidden */
  111476. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111477. /** @hidden */
  111478. _updateCache(ignoreParentClass?: boolean): void;
  111479. /** @hidden */
  111480. _isSynchronized(): boolean;
  111481. /** @hidden */
  111482. _markSyncedWithParent(): void;
  111483. /** @hidden */
  111484. isSynchronizedWithParent(): boolean;
  111485. /** @hidden */
  111486. isSynchronized(): boolean;
  111487. /**
  111488. * Is this node ready to be used/rendered
  111489. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  111490. * @return true if the node is ready
  111491. */
  111492. isReady(completeCheck?: boolean): boolean;
  111493. /**
  111494. * Is this node enabled?
  111495. * 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
  111496. * @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
  111497. * @return whether this node (and its parent) is enabled
  111498. */
  111499. isEnabled(checkAncestors?: boolean): boolean;
  111500. /** @hidden */
  111501. protected _syncParentEnabledState(): void;
  111502. /**
  111503. * Set the enabled state of this node
  111504. * @param value defines the new enabled state
  111505. */
  111506. setEnabled(value: boolean): void;
  111507. /**
  111508. * Is this node a descendant of the given node?
  111509. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  111510. * @param ancestor defines the parent node to inspect
  111511. * @returns a boolean indicating if this node is a descendant of the given node
  111512. */
  111513. isDescendantOf(ancestor: Node): boolean;
  111514. /** @hidden */
  111515. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  111516. /**
  111517. * Will return all nodes that have this node as ascendant
  111518. * @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
  111519. * @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
  111520. * @return all children nodes of all types
  111521. */
  111522. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  111523. /**
  111524. * Get all child-meshes of this node
  111525. * @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)
  111526. * @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
  111527. * @returns an array of AbstractMesh
  111528. */
  111529. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  111530. /**
  111531. * Get all direct children of this node
  111532. * @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
  111533. * @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)
  111534. * @returns an array of Node
  111535. */
  111536. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  111537. /** @hidden */
  111538. _setReady(state: boolean): void;
  111539. /**
  111540. * Get an animation by name
  111541. * @param name defines the name of the animation to look for
  111542. * @returns null if not found else the requested animation
  111543. */
  111544. getAnimationByName(name: string): Nullable<Animation>;
  111545. /**
  111546. * Creates an animation range for this node
  111547. * @param name defines the name of the range
  111548. * @param from defines the starting key
  111549. * @param to defines the end key
  111550. */
  111551. createAnimationRange(name: string, from: number, to: number): void;
  111552. /**
  111553. * Delete a specific animation range
  111554. * @param name defines the name of the range to delete
  111555. * @param deleteFrames defines if animation frames from the range must be deleted as well
  111556. */
  111557. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111558. /**
  111559. * Get an animation range by name
  111560. * @param name defines the name of the animation range to look for
  111561. * @returns null if not found else the requested animation range
  111562. */
  111563. getAnimationRange(name: string): Nullable<AnimationRange>;
  111564. /**
  111565. * Gets the list of all animation ranges defined on this node
  111566. * @returns an array
  111567. */
  111568. getAnimationRanges(): Nullable<AnimationRange>[];
  111569. /**
  111570. * Will start the animation sequence
  111571. * @param name defines the range frames for animation sequence
  111572. * @param loop defines if the animation should loop (false by default)
  111573. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  111574. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  111575. * @returns the object created for this animation. If range does not exist, it will return null
  111576. */
  111577. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111578. /**
  111579. * Serialize animation ranges into a JSON compatible object
  111580. * @returns serialization object
  111581. */
  111582. serializeAnimationRanges(): any;
  111583. /**
  111584. * Computes the world matrix of the node
  111585. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111586. * @returns the world matrix
  111587. */
  111588. computeWorldMatrix(force?: boolean): Matrix;
  111589. /**
  111590. * Releases resources associated with this node.
  111591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111593. */
  111594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111595. /**
  111596. * Parse animation range data from a serialization object and store them into a given node
  111597. * @param node defines where to store the animation ranges
  111598. * @param parsedNode defines the serialization object to read data from
  111599. * @param scene defines the hosting scene
  111600. */
  111601. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  111602. /**
  111603. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  111604. * @param includeDescendants Include bounding info from descendants as well (true by default)
  111605. * @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
  111606. * @returns the new bounding vectors
  111607. */
  111608. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  111609. min: Vector3;
  111610. max: Vector3;
  111611. };
  111612. }
  111613. }
  111614. declare module BABYLON {
  111615. /**
  111616. * @hidden
  111617. */
  111618. export class _IAnimationState {
  111619. key: number;
  111620. repeatCount: number;
  111621. workValue?: any;
  111622. loopMode?: number;
  111623. offsetValue?: any;
  111624. highLimitValue?: any;
  111625. }
  111626. /**
  111627. * Class used to store any kind of animation
  111628. */
  111629. export class Animation {
  111630. /**Name of the animation */
  111631. name: string;
  111632. /**Property to animate */
  111633. targetProperty: string;
  111634. /**The frames per second of the animation */
  111635. framePerSecond: number;
  111636. /**The data type of the animation */
  111637. dataType: number;
  111638. /**The loop mode of the animation */
  111639. loopMode?: number | undefined;
  111640. /**Specifies if blending should be enabled */
  111641. enableBlending?: boolean | undefined;
  111642. /**
  111643. * Use matrix interpolation instead of using direct key value when animating matrices
  111644. */
  111645. static AllowMatricesInterpolation: boolean;
  111646. /**
  111647. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  111648. */
  111649. static AllowMatrixDecomposeForInterpolation: boolean;
  111650. /** Define the Url to load snippets */
  111651. static SnippetUrl: string;
  111652. /** Snippet ID if the animation was created from the snippet server */
  111653. snippetId: string;
  111654. /**
  111655. * Stores the key frames of the animation
  111656. */
  111657. private _keys;
  111658. /**
  111659. * Stores the easing function of the animation
  111660. */
  111661. private _easingFunction;
  111662. /**
  111663. * @hidden Internal use only
  111664. */
  111665. _runtimeAnimations: RuntimeAnimation[];
  111666. /**
  111667. * The set of event that will be linked to this animation
  111668. */
  111669. private _events;
  111670. /**
  111671. * Stores an array of target property paths
  111672. */
  111673. targetPropertyPath: string[];
  111674. /**
  111675. * Stores the blending speed of the animation
  111676. */
  111677. blendingSpeed: number;
  111678. /**
  111679. * Stores the animation ranges for the animation
  111680. */
  111681. private _ranges;
  111682. /**
  111683. * @hidden Internal use
  111684. */
  111685. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  111686. /**
  111687. * Sets up an animation
  111688. * @param property The property to animate
  111689. * @param animationType The animation type to apply
  111690. * @param framePerSecond The frames per second of the animation
  111691. * @param easingFunction The easing function used in the animation
  111692. * @returns The created animation
  111693. */
  111694. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  111695. /**
  111696. * Create and start an animation on a node
  111697. * @param name defines the name of the global animation that will be run on all nodes
  111698. * @param node defines the root node where the animation will take place
  111699. * @param targetProperty defines property to animate
  111700. * @param framePerSecond defines the number of frame per second yo use
  111701. * @param totalFrame defines the number of frames in total
  111702. * @param from defines the initial value
  111703. * @param to defines the final value
  111704. * @param loopMode defines which loop mode you want to use (off by default)
  111705. * @param easingFunction defines the easing function to use (linear by default)
  111706. * @param onAnimationEnd defines the callback to call when animation end
  111707. * @returns the animatable created for this animation
  111708. */
  111709. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  111710. /**
  111711. * Create and start an animation on a node and its descendants
  111712. * @param name defines the name of the global animation that will be run on all nodes
  111713. * @param node defines the root node where the animation will take place
  111714. * @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
  111715. * @param targetProperty defines property to animate
  111716. * @param framePerSecond defines the number of frame per second to use
  111717. * @param totalFrame defines the number of frames in total
  111718. * @param from defines the initial value
  111719. * @param to defines the final value
  111720. * @param loopMode defines which loop mode you want to use (off by default)
  111721. * @param easingFunction defines the easing function to use (linear by default)
  111722. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  111723. * @returns the list of animatables created for all nodes
  111724. * @example https://www.babylonjs-playground.com/#MH0VLI
  111725. */
  111726. 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[]>;
  111727. /**
  111728. * Creates a new animation, merges it with the existing animations and starts it
  111729. * @param name Name of the animation
  111730. * @param node Node which contains the scene that begins the animations
  111731. * @param targetProperty Specifies which property to animate
  111732. * @param framePerSecond The frames per second of the animation
  111733. * @param totalFrame The total number of frames
  111734. * @param from The frame at the beginning of the animation
  111735. * @param to The frame at the end of the animation
  111736. * @param loopMode Specifies the loop mode of the animation
  111737. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  111738. * @param onAnimationEnd Callback to run once the animation is complete
  111739. * @returns Nullable animation
  111740. */
  111741. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  111742. /**
  111743. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111744. * @param sourceAnimation defines the Animation containing keyframes to convert
  111745. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111746. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  111747. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  111748. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  111749. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  111750. */
  111751. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  111752. /**
  111753. * Transition property of an host to the target Value
  111754. * @param property The property to transition
  111755. * @param targetValue The target Value of the property
  111756. * @param host The object where the property to animate belongs
  111757. * @param scene Scene used to run the animation
  111758. * @param frameRate Framerate (in frame/s) to use
  111759. * @param transition The transition type we want to use
  111760. * @param duration The duration of the animation, in milliseconds
  111761. * @param onAnimationEnd Callback trigger at the end of the animation
  111762. * @returns Nullable animation
  111763. */
  111764. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  111765. /**
  111766. * Return the array of runtime animations currently using this animation
  111767. */
  111768. get runtimeAnimations(): RuntimeAnimation[];
  111769. /**
  111770. * Specifies if any of the runtime animations are currently running
  111771. */
  111772. get hasRunningRuntimeAnimations(): boolean;
  111773. /**
  111774. * Initializes the animation
  111775. * @param name Name of the animation
  111776. * @param targetProperty Property to animate
  111777. * @param framePerSecond The frames per second of the animation
  111778. * @param dataType The data type of the animation
  111779. * @param loopMode The loop mode of the animation
  111780. * @param enableBlending Specifies if blending should be enabled
  111781. */
  111782. constructor(
  111783. /**Name of the animation */
  111784. name: string,
  111785. /**Property to animate */
  111786. targetProperty: string,
  111787. /**The frames per second of the animation */
  111788. framePerSecond: number,
  111789. /**The data type of the animation */
  111790. dataType: number,
  111791. /**The loop mode of the animation */
  111792. loopMode?: number | undefined,
  111793. /**Specifies if blending should be enabled */
  111794. enableBlending?: boolean | undefined);
  111795. /**
  111796. * Converts the animation to a string
  111797. * @param fullDetails support for multiple levels of logging within scene loading
  111798. * @returns String form of the animation
  111799. */
  111800. toString(fullDetails?: boolean): string;
  111801. /**
  111802. * Add an event to this animation
  111803. * @param event Event to add
  111804. */
  111805. addEvent(event: AnimationEvent): void;
  111806. /**
  111807. * Remove all events found at the given frame
  111808. * @param frame The frame to remove events from
  111809. */
  111810. removeEvents(frame: number): void;
  111811. /**
  111812. * Retrieves all the events from the animation
  111813. * @returns Events from the animation
  111814. */
  111815. getEvents(): AnimationEvent[];
  111816. /**
  111817. * Creates an animation range
  111818. * @param name Name of the animation range
  111819. * @param from Starting frame of the animation range
  111820. * @param to Ending frame of the animation
  111821. */
  111822. createRange(name: string, from: number, to: number): void;
  111823. /**
  111824. * Deletes an animation range by name
  111825. * @param name Name of the animation range to delete
  111826. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  111827. */
  111828. deleteRange(name: string, deleteFrames?: boolean): void;
  111829. /**
  111830. * Gets the animation range by name, or null if not defined
  111831. * @param name Name of the animation range
  111832. * @returns Nullable animation range
  111833. */
  111834. getRange(name: string): Nullable<AnimationRange>;
  111835. /**
  111836. * Gets the key frames from the animation
  111837. * @returns The key frames of the animation
  111838. */
  111839. getKeys(): Array<IAnimationKey>;
  111840. /**
  111841. * Gets the highest frame rate of the animation
  111842. * @returns Highest frame rate of the animation
  111843. */
  111844. getHighestFrame(): number;
  111845. /**
  111846. * Gets the easing function of the animation
  111847. * @returns Easing function of the animation
  111848. */
  111849. getEasingFunction(): IEasingFunction;
  111850. /**
  111851. * Sets the easing function of the animation
  111852. * @param easingFunction A custom mathematical formula for animation
  111853. */
  111854. setEasingFunction(easingFunction: EasingFunction): void;
  111855. /**
  111856. * Interpolates a scalar linearly
  111857. * @param startValue Start value of the animation curve
  111858. * @param endValue End value of the animation curve
  111859. * @param gradient Scalar amount to interpolate
  111860. * @returns Interpolated scalar value
  111861. */
  111862. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  111863. /**
  111864. * Interpolates a scalar cubically
  111865. * @param startValue Start value of the animation curve
  111866. * @param outTangent End tangent of the animation
  111867. * @param endValue End value of the animation curve
  111868. * @param inTangent Start tangent of the animation curve
  111869. * @param gradient Scalar amount to interpolate
  111870. * @returns Interpolated scalar value
  111871. */
  111872. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  111873. /**
  111874. * Interpolates a quaternion using a spherical linear interpolation
  111875. * @param startValue Start value of the animation curve
  111876. * @param endValue End value of the animation curve
  111877. * @param gradient Scalar amount to interpolate
  111878. * @returns Interpolated quaternion value
  111879. */
  111880. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  111881. /**
  111882. * Interpolates a quaternion cubically
  111883. * @param startValue Start value of the animation curve
  111884. * @param outTangent End tangent of the animation curve
  111885. * @param endValue End value of the animation curve
  111886. * @param inTangent Start tangent of the animation curve
  111887. * @param gradient Scalar amount to interpolate
  111888. * @returns Interpolated quaternion value
  111889. */
  111890. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  111891. /**
  111892. * Interpolates a Vector3 linearl
  111893. * @param startValue Start value of the animation curve
  111894. * @param endValue End value of the animation curve
  111895. * @param gradient Scalar amount to interpolate
  111896. * @returns Interpolated scalar value
  111897. */
  111898. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  111899. /**
  111900. * Interpolates a Vector3 cubically
  111901. * @param startValue Start value of the animation curve
  111902. * @param outTangent End tangent of the animation
  111903. * @param endValue End value of the animation curve
  111904. * @param inTangent Start tangent of the animation curve
  111905. * @param gradient Scalar amount to interpolate
  111906. * @returns InterpolatedVector3 value
  111907. */
  111908. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  111909. /**
  111910. * Interpolates a Vector2 linearly
  111911. * @param startValue Start value of the animation curve
  111912. * @param endValue End value of the animation curve
  111913. * @param gradient Scalar amount to interpolate
  111914. * @returns Interpolated Vector2 value
  111915. */
  111916. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  111917. /**
  111918. * Interpolates a Vector2 cubically
  111919. * @param startValue Start value of the animation curve
  111920. * @param outTangent End tangent of the animation
  111921. * @param endValue End value of the animation curve
  111922. * @param inTangent Start tangent of the animation curve
  111923. * @param gradient Scalar amount to interpolate
  111924. * @returns Interpolated Vector2 value
  111925. */
  111926. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  111927. /**
  111928. * Interpolates a size linearly
  111929. * @param startValue Start value of the animation curve
  111930. * @param endValue End value of the animation curve
  111931. * @param gradient Scalar amount to interpolate
  111932. * @returns Interpolated Size value
  111933. */
  111934. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  111935. /**
  111936. * Interpolates a Color3 linearly
  111937. * @param startValue Start value of the animation curve
  111938. * @param endValue End value of the animation curve
  111939. * @param gradient Scalar amount to interpolate
  111940. * @returns Interpolated Color3 value
  111941. */
  111942. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  111943. /**
  111944. * Interpolates a Color4 linearly
  111945. * @param startValue Start value of the animation curve
  111946. * @param endValue End value of the animation curve
  111947. * @param gradient Scalar amount to interpolate
  111948. * @returns Interpolated Color3 value
  111949. */
  111950. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  111951. /**
  111952. * @hidden Internal use only
  111953. */
  111954. _getKeyValue(value: any): any;
  111955. /**
  111956. * @hidden Internal use only
  111957. */
  111958. _interpolate(currentFrame: number, state: _IAnimationState): any;
  111959. /**
  111960. * Defines the function to use to interpolate matrices
  111961. * @param startValue defines the start matrix
  111962. * @param endValue defines the end matrix
  111963. * @param gradient defines the gradient between both matrices
  111964. * @param result defines an optional target matrix where to store the interpolation
  111965. * @returns the interpolated matrix
  111966. */
  111967. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  111968. /**
  111969. * Makes a copy of the animation
  111970. * @returns Cloned animation
  111971. */
  111972. clone(): Animation;
  111973. /**
  111974. * Sets the key frames of the animation
  111975. * @param values The animation key frames to set
  111976. */
  111977. setKeys(values: Array<IAnimationKey>): void;
  111978. /**
  111979. * Serializes the animation to an object
  111980. * @returns Serialized object
  111981. */
  111982. serialize(): any;
  111983. /**
  111984. * Float animation type
  111985. */
  111986. static readonly ANIMATIONTYPE_FLOAT: number;
  111987. /**
  111988. * Vector3 animation type
  111989. */
  111990. static readonly ANIMATIONTYPE_VECTOR3: number;
  111991. /**
  111992. * Quaternion animation type
  111993. */
  111994. static readonly ANIMATIONTYPE_QUATERNION: number;
  111995. /**
  111996. * Matrix animation type
  111997. */
  111998. static readonly ANIMATIONTYPE_MATRIX: number;
  111999. /**
  112000. * Color3 animation type
  112001. */
  112002. static readonly ANIMATIONTYPE_COLOR3: number;
  112003. /**
  112004. * Color3 animation type
  112005. */
  112006. static readonly ANIMATIONTYPE_COLOR4: number;
  112007. /**
  112008. * Vector2 animation type
  112009. */
  112010. static readonly ANIMATIONTYPE_VECTOR2: number;
  112011. /**
  112012. * Size animation type
  112013. */
  112014. static readonly ANIMATIONTYPE_SIZE: number;
  112015. /**
  112016. * Relative Loop Mode
  112017. */
  112018. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112019. /**
  112020. * Cycle Loop Mode
  112021. */
  112022. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112023. /**
  112024. * Constant Loop Mode
  112025. */
  112026. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112027. /** @hidden */
  112028. static _UniversalLerp(left: any, right: any, amount: number): any;
  112029. /**
  112030. * Parses an animation object and creates an animation
  112031. * @param parsedAnimation Parsed animation object
  112032. * @returns Animation object
  112033. */
  112034. static Parse(parsedAnimation: any): Animation;
  112035. /**
  112036. * Appends the serialized animations from the source animations
  112037. * @param source Source containing the animations
  112038. * @param destination Target to store the animations
  112039. */
  112040. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112041. /**
  112042. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112043. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112044. * @param url defines the url to load from
  112045. * @returns a promise that will resolve to the new animation or an array of animations
  112046. */
  112047. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112048. /**
  112049. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112050. * @param snippetId defines the snippet to load
  112051. * @returns a promise that will resolve to the new animation or a new array of animations
  112052. */
  112053. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112054. }
  112055. }
  112056. declare module BABYLON {
  112057. /**
  112058. * Interface containing an array of animations
  112059. */
  112060. export interface IAnimatable {
  112061. /**
  112062. * Array of animations
  112063. */
  112064. animations: Nullable<Array<Animation>>;
  112065. }
  112066. }
  112067. declare module BABYLON {
  112068. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112069. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112070. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112071. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112072. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112073. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112074. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112075. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112076. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112077. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112078. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112079. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112080. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112081. /**
  112082. * Decorator used to define property that can be serialized as reference to a camera
  112083. * @param sourceName defines the name of the property to decorate
  112084. */
  112085. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112086. /**
  112087. * Class used to help serialization objects
  112088. */
  112089. export class SerializationHelper {
  112090. /** @hidden */
  112091. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112092. /** @hidden */
  112093. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112094. /** @hidden */
  112095. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112096. /** @hidden */
  112097. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112098. /**
  112099. * Appends the serialized animations from the source animations
  112100. * @param source Source containing the animations
  112101. * @param destination Target to store the animations
  112102. */
  112103. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112104. /**
  112105. * Static function used to serialized a specific entity
  112106. * @param entity defines the entity to serialize
  112107. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112108. * @returns a JSON compatible object representing the serialization of the entity
  112109. */
  112110. static Serialize<T>(entity: T, serializationObject?: any): any;
  112111. /**
  112112. * Creates a new entity from a serialization data object
  112113. * @param creationFunction defines a function used to instanciated the new entity
  112114. * @param source defines the source serialization data
  112115. * @param scene defines the hosting scene
  112116. * @param rootUrl defines the root url for resources
  112117. * @returns a new entity
  112118. */
  112119. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112120. /**
  112121. * Clones an object
  112122. * @param creationFunction defines the function used to instanciate the new object
  112123. * @param source defines the source object
  112124. * @returns the cloned object
  112125. */
  112126. static Clone<T>(creationFunction: () => T, source: T): T;
  112127. /**
  112128. * Instanciates a new object based on a source one (some data will be shared between both object)
  112129. * @param creationFunction defines the function used to instanciate the new object
  112130. * @param source defines the source object
  112131. * @returns the new object
  112132. */
  112133. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112134. }
  112135. }
  112136. declare module BABYLON {
  112137. /**
  112138. * Base class of all the textures in babylon.
  112139. * It groups all the common properties the materials, post process, lights... might need
  112140. * in order to make a correct use of the texture.
  112141. */
  112142. export class BaseTexture implements IAnimatable {
  112143. /**
  112144. * Default anisotropic filtering level for the application.
  112145. * It is set to 4 as a good tradeoff between perf and quality.
  112146. */
  112147. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112148. /**
  112149. * Gets or sets the unique id of the texture
  112150. */
  112151. uniqueId: number;
  112152. /**
  112153. * Define the name of the texture.
  112154. */
  112155. name: string;
  112156. /**
  112157. * Gets or sets an object used to store user defined information.
  112158. */
  112159. metadata: any;
  112160. /**
  112161. * For internal use only. Please do not use.
  112162. */
  112163. reservedDataStore: any;
  112164. private _hasAlpha;
  112165. /**
  112166. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112167. */
  112168. set hasAlpha(value: boolean);
  112169. get hasAlpha(): boolean;
  112170. /**
  112171. * Defines if the alpha value should be determined via the rgb values.
  112172. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112173. */
  112174. getAlphaFromRGB: boolean;
  112175. /**
  112176. * Intensity or strength of the texture.
  112177. * It is commonly used by materials to fine tune the intensity of the texture
  112178. */
  112179. level: number;
  112180. /**
  112181. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112182. * This is part of the texture as textures usually maps to one uv set.
  112183. */
  112184. coordinatesIndex: number;
  112185. private _coordinatesMode;
  112186. /**
  112187. * How a texture is mapped.
  112188. *
  112189. * | Value | Type | Description |
  112190. * | ----- | ----------------------------------- | ----------- |
  112191. * | 0 | EXPLICIT_MODE | |
  112192. * | 1 | SPHERICAL_MODE | |
  112193. * | 2 | PLANAR_MODE | |
  112194. * | 3 | CUBIC_MODE | |
  112195. * | 4 | PROJECTION_MODE | |
  112196. * | 5 | SKYBOX_MODE | |
  112197. * | 6 | INVCUBIC_MODE | |
  112198. * | 7 | EQUIRECTANGULAR_MODE | |
  112199. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112200. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112201. */
  112202. set coordinatesMode(value: number);
  112203. get coordinatesMode(): number;
  112204. /**
  112205. * | Value | Type | Description |
  112206. * | ----- | ------------------ | ----------- |
  112207. * | 0 | CLAMP_ADDRESSMODE | |
  112208. * | 1 | WRAP_ADDRESSMODE | |
  112209. * | 2 | MIRROR_ADDRESSMODE | |
  112210. */
  112211. wrapU: number;
  112212. /**
  112213. * | Value | Type | Description |
  112214. * | ----- | ------------------ | ----------- |
  112215. * | 0 | CLAMP_ADDRESSMODE | |
  112216. * | 1 | WRAP_ADDRESSMODE | |
  112217. * | 2 | MIRROR_ADDRESSMODE | |
  112218. */
  112219. wrapV: number;
  112220. /**
  112221. * | Value | Type | Description |
  112222. * | ----- | ------------------ | ----------- |
  112223. * | 0 | CLAMP_ADDRESSMODE | |
  112224. * | 1 | WRAP_ADDRESSMODE | |
  112225. * | 2 | MIRROR_ADDRESSMODE | |
  112226. */
  112227. wrapR: number;
  112228. /**
  112229. * With compliant hardware and browser (supporting anisotropic filtering)
  112230. * this defines the level of anisotropic filtering in the texture.
  112231. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112232. */
  112233. anisotropicFilteringLevel: number;
  112234. /**
  112235. * Define if the texture is a cube texture or if false a 2d texture.
  112236. */
  112237. get isCube(): boolean;
  112238. set isCube(value: boolean);
  112239. /**
  112240. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112241. */
  112242. get is3D(): boolean;
  112243. set is3D(value: boolean);
  112244. /**
  112245. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112246. */
  112247. get is2DArray(): boolean;
  112248. set is2DArray(value: boolean);
  112249. /**
  112250. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112251. * HDR texture are usually stored in linear space.
  112252. * This only impacts the PBR and Background materials
  112253. */
  112254. gammaSpace: boolean;
  112255. /**
  112256. * Gets or sets whether or not the texture contains RGBD data.
  112257. */
  112258. get isRGBD(): boolean;
  112259. set isRGBD(value: boolean);
  112260. /**
  112261. * Is Z inverted in the texture (useful in a cube texture).
  112262. */
  112263. invertZ: boolean;
  112264. /**
  112265. * Are mip maps generated for this texture or not.
  112266. */
  112267. get noMipmap(): boolean;
  112268. /**
  112269. * @hidden
  112270. */
  112271. lodLevelInAlpha: boolean;
  112272. /**
  112273. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112274. */
  112275. get lodGenerationOffset(): number;
  112276. set lodGenerationOffset(value: number);
  112277. /**
  112278. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112279. */
  112280. get lodGenerationScale(): number;
  112281. set lodGenerationScale(value: number);
  112282. /**
  112283. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112284. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112285. * average roughness values.
  112286. */
  112287. get linearSpecularLOD(): boolean;
  112288. set linearSpecularLOD(value: boolean);
  112289. /**
  112290. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112291. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112292. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112293. */
  112294. get irradianceTexture(): Nullable<BaseTexture>;
  112295. set irradianceTexture(value: Nullable<BaseTexture>);
  112296. /**
  112297. * Define if the texture is a render target.
  112298. */
  112299. isRenderTarget: boolean;
  112300. /**
  112301. * Define the unique id of the texture in the scene.
  112302. */
  112303. get uid(): string;
  112304. /** @hidden */
  112305. _prefiltered: boolean;
  112306. /**
  112307. * Return a string representation of the texture.
  112308. * @returns the texture as a string
  112309. */
  112310. toString(): string;
  112311. /**
  112312. * Get the class name of the texture.
  112313. * @returns "BaseTexture"
  112314. */
  112315. getClassName(): string;
  112316. /**
  112317. * Define the list of animation attached to the texture.
  112318. */
  112319. animations: Animation[];
  112320. /**
  112321. * An event triggered when the texture is disposed.
  112322. */
  112323. onDisposeObservable: Observable<BaseTexture>;
  112324. private _onDisposeObserver;
  112325. /**
  112326. * Callback triggered when the texture has been disposed.
  112327. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112328. */
  112329. set onDispose(callback: () => void);
  112330. /**
  112331. * Define the current state of the loading sequence when in delayed load mode.
  112332. */
  112333. delayLoadState: number;
  112334. private _scene;
  112335. private _engine;
  112336. /** @hidden */
  112337. _texture: Nullable<InternalTexture>;
  112338. private _uid;
  112339. /**
  112340. * Define if the texture is preventinga material to render or not.
  112341. * If not and the texture is not ready, the engine will use a default black texture instead.
  112342. */
  112343. get isBlocking(): boolean;
  112344. /**
  112345. * Instantiates a new BaseTexture.
  112346. * Base class of all the textures in babylon.
  112347. * It groups all the common properties the materials, post process, lights... might need
  112348. * in order to make a correct use of the texture.
  112349. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112350. */
  112351. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112352. /**
  112353. * Get the scene the texture belongs to.
  112354. * @returns the scene or null if undefined
  112355. */
  112356. getScene(): Nullable<Scene>;
  112357. /** @hidden */
  112358. protected _getEngine(): Nullable<ThinEngine>;
  112359. /**
  112360. * Get the texture transform matrix used to offset tile the texture for istance.
  112361. * @returns the transformation matrix
  112362. */
  112363. getTextureMatrix(): Matrix;
  112364. /**
  112365. * Get the texture reflection matrix used to rotate/transform the reflection.
  112366. * @returns the reflection matrix
  112367. */
  112368. getReflectionTextureMatrix(): Matrix;
  112369. /**
  112370. * Get the underlying lower level texture from Babylon.
  112371. * @returns the insternal texture
  112372. */
  112373. getInternalTexture(): Nullable<InternalTexture>;
  112374. /**
  112375. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112376. * @returns true if ready or not blocking
  112377. */
  112378. isReadyOrNotBlocking(): boolean;
  112379. /**
  112380. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112381. * @returns true if fully ready
  112382. */
  112383. isReady(): boolean;
  112384. private _cachedSize;
  112385. /**
  112386. * Get the size of the texture.
  112387. * @returns the texture size.
  112388. */
  112389. getSize(): ISize;
  112390. /**
  112391. * Get the base size of the texture.
  112392. * It can be different from the size if the texture has been resized for POT for instance
  112393. * @returns the base size
  112394. */
  112395. getBaseSize(): ISize;
  112396. /**
  112397. * Update the sampling mode of the texture.
  112398. * Default is Trilinear mode.
  112399. *
  112400. * | Value | Type | Description |
  112401. * | ----- | ------------------ | ----------- |
  112402. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112403. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112404. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112405. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112406. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112407. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112408. * | 7 | NEAREST_LINEAR | |
  112409. * | 8 | NEAREST_NEAREST | |
  112410. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112411. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112412. * | 11 | LINEAR_LINEAR | |
  112413. * | 12 | LINEAR_NEAREST | |
  112414. *
  112415. * > _mag_: magnification filter (close to the viewer)
  112416. * > _min_: minification filter (far from the viewer)
  112417. * > _mip_: filter used between mip map levels
  112418. *@param samplingMode Define the new sampling mode of the texture
  112419. */
  112420. updateSamplingMode(samplingMode: number): void;
  112421. /**
  112422. * Scales the texture if is `canRescale()`
  112423. * @param ratio the resize factor we want to use to rescale
  112424. */
  112425. scale(ratio: number): void;
  112426. /**
  112427. * Get if the texture can rescale.
  112428. */
  112429. get canRescale(): boolean;
  112430. /** @hidden */
  112431. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  112432. /** @hidden */
  112433. _rebuild(): void;
  112434. /**
  112435. * Triggers the load sequence in delayed load mode.
  112436. */
  112437. delayLoad(): void;
  112438. /**
  112439. * Clones the texture.
  112440. * @returns the cloned texture
  112441. */
  112442. clone(): Nullable<BaseTexture>;
  112443. /**
  112444. * Get the texture underlying type (INT, FLOAT...)
  112445. */
  112446. get textureType(): number;
  112447. /**
  112448. * Get the texture underlying format (RGB, RGBA...)
  112449. */
  112450. get textureFormat(): number;
  112451. /**
  112452. * Indicates that textures need to be re-calculated for all materials
  112453. */
  112454. protected _markAllSubMeshesAsTexturesDirty(): void;
  112455. /**
  112456. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  112457. * This will returns an RGBA array buffer containing either in values (0-255) or
  112458. * float values (0-1) depending of the underlying buffer type.
  112459. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  112460. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  112461. * @param buffer defines a user defined buffer to fill with data (can be null)
  112462. * @returns The Array buffer containing the pixels data.
  112463. */
  112464. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  112465. /**
  112466. * Release and destroy the underlying lower level texture aka internalTexture.
  112467. */
  112468. releaseInternalTexture(): void;
  112469. /** @hidden */
  112470. get _lodTextureHigh(): Nullable<BaseTexture>;
  112471. /** @hidden */
  112472. get _lodTextureMid(): Nullable<BaseTexture>;
  112473. /** @hidden */
  112474. get _lodTextureLow(): Nullable<BaseTexture>;
  112475. /**
  112476. * Dispose the texture and release its associated resources.
  112477. */
  112478. dispose(): void;
  112479. /**
  112480. * Serialize the texture into a JSON representation that can be parsed later on.
  112481. * @returns the JSON representation of the texture
  112482. */
  112483. serialize(): any;
  112484. /**
  112485. * Helper function to be called back once a list of texture contains only ready textures.
  112486. * @param textures Define the list of textures to wait for
  112487. * @param callback Define the callback triggered once the entire list will be ready
  112488. */
  112489. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  112490. private static _isScene;
  112491. }
  112492. }
  112493. declare module BABYLON {
  112494. /**
  112495. * Options to be used when creating an effect.
  112496. */
  112497. export interface IEffectCreationOptions {
  112498. /**
  112499. * Atrributes that will be used in the shader.
  112500. */
  112501. attributes: string[];
  112502. /**
  112503. * Uniform varible names that will be set in the shader.
  112504. */
  112505. uniformsNames: string[];
  112506. /**
  112507. * Uniform buffer variable names that will be set in the shader.
  112508. */
  112509. uniformBuffersNames: string[];
  112510. /**
  112511. * Sampler texture variable names that will be set in the shader.
  112512. */
  112513. samplers: string[];
  112514. /**
  112515. * Define statements that will be set in the shader.
  112516. */
  112517. defines: any;
  112518. /**
  112519. * Possible fallbacks for this effect to improve performance when needed.
  112520. */
  112521. fallbacks: Nullable<IEffectFallbacks>;
  112522. /**
  112523. * Callback that will be called when the shader is compiled.
  112524. */
  112525. onCompiled: Nullable<(effect: Effect) => void>;
  112526. /**
  112527. * Callback that will be called if an error occurs during shader compilation.
  112528. */
  112529. onError: Nullable<(effect: Effect, errors: string) => void>;
  112530. /**
  112531. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112532. */
  112533. indexParameters?: any;
  112534. /**
  112535. * Max number of lights that can be used in the shader.
  112536. */
  112537. maxSimultaneousLights?: number;
  112538. /**
  112539. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  112540. */
  112541. transformFeedbackVaryings?: Nullable<string[]>;
  112542. /**
  112543. * 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
  112544. */
  112545. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  112546. /**
  112547. * Is this effect rendering to several color attachments ?
  112548. */
  112549. multiTarget?: boolean;
  112550. }
  112551. /**
  112552. * Effect containing vertex and fragment shader that can be executed on an object.
  112553. */
  112554. export class Effect implements IDisposable {
  112555. /**
  112556. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112557. */
  112558. static ShadersRepository: string;
  112559. /**
  112560. * Enable logging of the shader code when a compilation error occurs
  112561. */
  112562. static LogShaderCodeOnCompilationError: boolean;
  112563. /**
  112564. * Name of the effect.
  112565. */
  112566. name: any;
  112567. /**
  112568. * String container all the define statements that should be set on the shader.
  112569. */
  112570. defines: string;
  112571. /**
  112572. * Callback that will be called when the shader is compiled.
  112573. */
  112574. onCompiled: Nullable<(effect: Effect) => void>;
  112575. /**
  112576. * Callback that will be called if an error occurs during shader compilation.
  112577. */
  112578. onError: Nullable<(effect: Effect, errors: string) => void>;
  112579. /**
  112580. * Callback that will be called when effect is bound.
  112581. */
  112582. onBind: Nullable<(effect: Effect) => void>;
  112583. /**
  112584. * Unique ID of the effect.
  112585. */
  112586. uniqueId: number;
  112587. /**
  112588. * Observable that will be called when the shader is compiled.
  112589. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  112590. */
  112591. onCompileObservable: Observable<Effect>;
  112592. /**
  112593. * Observable that will be called if an error occurs during shader compilation.
  112594. */
  112595. onErrorObservable: Observable<Effect>;
  112596. /** @hidden */
  112597. _onBindObservable: Nullable<Observable<Effect>>;
  112598. /**
  112599. * @hidden
  112600. * Specifies if the effect was previously ready
  112601. */
  112602. _wasPreviouslyReady: boolean;
  112603. /**
  112604. * Observable that will be called when effect is bound.
  112605. */
  112606. get onBindObservable(): Observable<Effect>;
  112607. /** @hidden */
  112608. _bonesComputationForcedToCPU: boolean;
  112609. /** @hidden */
  112610. _multiTarget: boolean;
  112611. private static _uniqueIdSeed;
  112612. private _engine;
  112613. private _uniformBuffersNames;
  112614. private _uniformBuffersNamesList;
  112615. private _uniformsNames;
  112616. private _samplerList;
  112617. private _samplers;
  112618. private _isReady;
  112619. private _compilationError;
  112620. private _allFallbacksProcessed;
  112621. private _attributesNames;
  112622. private _attributes;
  112623. private _attributeLocationByName;
  112624. private _uniforms;
  112625. /**
  112626. * Key for the effect.
  112627. * @hidden
  112628. */
  112629. _key: string;
  112630. private _indexParameters;
  112631. private _fallbacks;
  112632. private _vertexSourceCode;
  112633. private _fragmentSourceCode;
  112634. private _vertexSourceCodeOverride;
  112635. private _fragmentSourceCodeOverride;
  112636. private _transformFeedbackVaryings;
  112637. /**
  112638. * Compiled shader to webGL program.
  112639. * @hidden
  112640. */
  112641. _pipelineContext: Nullable<IPipelineContext>;
  112642. private _valueCache;
  112643. private static _baseCache;
  112644. /**
  112645. * Instantiates an effect.
  112646. * An effect can be used to create/manage/execute vertex and fragment shaders.
  112647. * @param baseName Name of the effect.
  112648. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  112649. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  112650. * @param samplers List of sampler variables that will be passed to the shader.
  112651. * @param engine Engine to be used to render the effect
  112652. * @param defines Define statements to be added to the shader.
  112653. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  112654. * @param onCompiled Callback that will be called when the shader is compiled.
  112655. * @param onError Callback that will be called if an error occurs during shader compilation.
  112656. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112657. */
  112658. 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);
  112659. private _useFinalCode;
  112660. /**
  112661. * Unique key for this effect
  112662. */
  112663. get key(): string;
  112664. /**
  112665. * If the effect has been compiled and prepared.
  112666. * @returns if the effect is compiled and prepared.
  112667. */
  112668. isReady(): boolean;
  112669. private _isReadyInternal;
  112670. /**
  112671. * The engine the effect was initialized with.
  112672. * @returns the engine.
  112673. */
  112674. getEngine(): Engine;
  112675. /**
  112676. * The pipeline context for this effect
  112677. * @returns the associated pipeline context
  112678. */
  112679. getPipelineContext(): Nullable<IPipelineContext>;
  112680. /**
  112681. * The set of names of attribute variables for the shader.
  112682. * @returns An array of attribute names.
  112683. */
  112684. getAttributesNames(): string[];
  112685. /**
  112686. * Returns the attribute at the given index.
  112687. * @param index The index of the attribute.
  112688. * @returns The location of the attribute.
  112689. */
  112690. getAttributeLocation(index: number): number;
  112691. /**
  112692. * Returns the attribute based on the name of the variable.
  112693. * @param name of the attribute to look up.
  112694. * @returns the attribute location.
  112695. */
  112696. getAttributeLocationByName(name: string): number;
  112697. /**
  112698. * The number of attributes.
  112699. * @returns the numnber of attributes.
  112700. */
  112701. getAttributesCount(): number;
  112702. /**
  112703. * Gets the index of a uniform variable.
  112704. * @param uniformName of the uniform to look up.
  112705. * @returns the index.
  112706. */
  112707. getUniformIndex(uniformName: string): number;
  112708. /**
  112709. * Returns the attribute based on the name of the variable.
  112710. * @param uniformName of the uniform to look up.
  112711. * @returns the location of the uniform.
  112712. */
  112713. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  112714. /**
  112715. * Returns an array of sampler variable names
  112716. * @returns The array of sampler variable names.
  112717. */
  112718. getSamplers(): string[];
  112719. /**
  112720. * Returns an array of uniform variable names
  112721. * @returns The array of uniform variable names.
  112722. */
  112723. getUniformNames(): string[];
  112724. /**
  112725. * Returns an array of uniform buffer variable names
  112726. * @returns The array of uniform buffer variable names.
  112727. */
  112728. getUniformBuffersNames(): string[];
  112729. /**
  112730. * Returns the index parameters used to create the effect
  112731. * @returns The index parameters object
  112732. */
  112733. getIndexParameters(): any;
  112734. /**
  112735. * The error from the last compilation.
  112736. * @returns the error string.
  112737. */
  112738. getCompilationError(): string;
  112739. /**
  112740. * Gets a boolean indicating that all fallbacks were used during compilation
  112741. * @returns true if all fallbacks were used
  112742. */
  112743. allFallbacksProcessed(): boolean;
  112744. /**
  112745. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  112746. * @param func The callback to be used.
  112747. */
  112748. executeWhenCompiled(func: (effect: Effect) => void): void;
  112749. private _checkIsReady;
  112750. private _loadShader;
  112751. /**
  112752. * Gets the vertex shader source code of this effect
  112753. */
  112754. get vertexSourceCode(): string;
  112755. /**
  112756. * Gets the fragment shader source code of this effect
  112757. */
  112758. get fragmentSourceCode(): string;
  112759. /**
  112760. * Recompiles the webGL program
  112761. * @param vertexSourceCode The source code for the vertex shader.
  112762. * @param fragmentSourceCode The source code for the fragment shader.
  112763. * @param onCompiled Callback called when completed.
  112764. * @param onError Callback called on error.
  112765. * @hidden
  112766. */
  112767. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  112768. /**
  112769. * Prepares the effect
  112770. * @hidden
  112771. */
  112772. _prepareEffect(): void;
  112773. private _getShaderCodeAndErrorLine;
  112774. private _processCompilationErrors;
  112775. /**
  112776. * Checks if the effect is supported. (Must be called after compilation)
  112777. */
  112778. get isSupported(): boolean;
  112779. /**
  112780. * Binds a texture to the engine to be used as output of the shader.
  112781. * @param channel Name of the output variable.
  112782. * @param texture Texture to bind.
  112783. * @hidden
  112784. */
  112785. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  112786. /**
  112787. * Sets a texture on the engine to be used in the shader.
  112788. * @param channel Name of the sampler variable.
  112789. * @param texture Texture to set.
  112790. */
  112791. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  112792. /**
  112793. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  112794. * @param channel Name of the sampler variable.
  112795. * @param texture Texture to set.
  112796. */
  112797. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  112798. /**
  112799. * Sets an array of textures on the engine to be used in the shader.
  112800. * @param channel Name of the variable.
  112801. * @param textures Textures to set.
  112802. */
  112803. setTextureArray(channel: string, textures: BaseTexture[]): void;
  112804. /**
  112805. * 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)
  112806. * @param channel Name of the sampler variable.
  112807. * @param postProcess Post process to get the input texture from.
  112808. */
  112809. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  112810. /**
  112811. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  112812. * 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)
  112813. * @param channel Name of the sampler variable.
  112814. * @param postProcess Post process to get the output texture from.
  112815. */
  112816. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  112817. /** @hidden */
  112818. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  112819. /** @hidden */
  112820. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  112821. /** @hidden */
  112822. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  112823. /** @hidden */
  112824. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  112825. /**
  112826. * Binds a buffer to a uniform.
  112827. * @param buffer Buffer to bind.
  112828. * @param name Name of the uniform variable to bind to.
  112829. */
  112830. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  112831. /**
  112832. * Binds block to a uniform.
  112833. * @param blockName Name of the block to bind.
  112834. * @param index Index to bind.
  112835. */
  112836. bindUniformBlock(blockName: string, index: number): void;
  112837. /**
  112838. * Sets an interger value on a uniform variable.
  112839. * @param uniformName Name of the variable.
  112840. * @param value Value to be set.
  112841. * @returns this effect.
  112842. */
  112843. setInt(uniformName: string, value: number): Effect;
  112844. /**
  112845. * Sets an int array on a uniform variable.
  112846. * @param uniformName Name of the variable.
  112847. * @param array array to be set.
  112848. * @returns this effect.
  112849. */
  112850. setIntArray(uniformName: string, array: Int32Array): Effect;
  112851. /**
  112852. * 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)
  112853. * @param uniformName Name of the variable.
  112854. * @param array array to be set.
  112855. * @returns this effect.
  112856. */
  112857. setIntArray2(uniformName: string, array: Int32Array): Effect;
  112858. /**
  112859. * 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)
  112860. * @param uniformName Name of the variable.
  112861. * @param array array to be set.
  112862. * @returns this effect.
  112863. */
  112864. setIntArray3(uniformName: string, array: Int32Array): Effect;
  112865. /**
  112866. * 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)
  112867. * @param uniformName Name of the variable.
  112868. * @param array array to be set.
  112869. * @returns this effect.
  112870. */
  112871. setIntArray4(uniformName: string, array: Int32Array): Effect;
  112872. /**
  112873. * Sets an float array on a uniform variable.
  112874. * @param uniformName Name of the variable.
  112875. * @param array array to be set.
  112876. * @returns this effect.
  112877. */
  112878. setFloatArray(uniformName: string, array: Float32Array): Effect;
  112879. /**
  112880. * 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)
  112881. * @param uniformName Name of the variable.
  112882. * @param array array to be set.
  112883. * @returns this effect.
  112884. */
  112885. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  112886. /**
  112887. * 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)
  112888. * @param uniformName Name of the variable.
  112889. * @param array array to be set.
  112890. * @returns this effect.
  112891. */
  112892. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  112893. /**
  112894. * 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)
  112895. * @param uniformName Name of the variable.
  112896. * @param array array to be set.
  112897. * @returns this effect.
  112898. */
  112899. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  112900. /**
  112901. * Sets an array on a uniform variable.
  112902. * @param uniformName Name of the variable.
  112903. * @param array array to be set.
  112904. * @returns this effect.
  112905. */
  112906. setArray(uniformName: string, array: number[]): Effect;
  112907. /**
  112908. * 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)
  112909. * @param uniformName Name of the variable.
  112910. * @param array array to be set.
  112911. * @returns this effect.
  112912. */
  112913. setArray2(uniformName: string, array: number[]): Effect;
  112914. /**
  112915. * 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)
  112916. * @param uniformName Name of the variable.
  112917. * @param array array to be set.
  112918. * @returns this effect.
  112919. */
  112920. setArray3(uniformName: string, array: number[]): Effect;
  112921. /**
  112922. * 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)
  112923. * @param uniformName Name of the variable.
  112924. * @param array array to be set.
  112925. * @returns this effect.
  112926. */
  112927. setArray4(uniformName: string, array: number[]): Effect;
  112928. /**
  112929. * Sets matrices on a uniform variable.
  112930. * @param uniformName Name of the variable.
  112931. * @param matrices matrices to be set.
  112932. * @returns this effect.
  112933. */
  112934. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  112935. /**
  112936. * Sets matrix on a uniform variable.
  112937. * @param uniformName Name of the variable.
  112938. * @param matrix matrix to be set.
  112939. * @returns this effect.
  112940. */
  112941. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  112942. /**
  112943. * 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)
  112944. * @param uniformName Name of the variable.
  112945. * @param matrix matrix to be set.
  112946. * @returns this effect.
  112947. */
  112948. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  112949. /**
  112950. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  112951. * @param uniformName Name of the variable.
  112952. * @param matrix matrix to be set.
  112953. * @returns this effect.
  112954. */
  112955. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  112956. /**
  112957. * Sets a float on a uniform variable.
  112958. * @param uniformName Name of the variable.
  112959. * @param value value to be set.
  112960. * @returns this effect.
  112961. */
  112962. setFloat(uniformName: string, value: number): Effect;
  112963. /**
  112964. * Sets a boolean on a uniform variable.
  112965. * @param uniformName Name of the variable.
  112966. * @param bool value to be set.
  112967. * @returns this effect.
  112968. */
  112969. setBool(uniformName: string, bool: boolean): Effect;
  112970. /**
  112971. * Sets a Vector2 on a uniform variable.
  112972. * @param uniformName Name of the variable.
  112973. * @param vector2 vector2 to be set.
  112974. * @returns this effect.
  112975. */
  112976. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  112977. /**
  112978. * Sets a float2 on a uniform variable.
  112979. * @param uniformName Name of the variable.
  112980. * @param x First float in float2.
  112981. * @param y Second float in float2.
  112982. * @returns this effect.
  112983. */
  112984. setFloat2(uniformName: string, x: number, y: number): Effect;
  112985. /**
  112986. * Sets a Vector3 on a uniform variable.
  112987. * @param uniformName Name of the variable.
  112988. * @param vector3 Value to be set.
  112989. * @returns this effect.
  112990. */
  112991. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  112992. /**
  112993. * Sets a float3 on a uniform variable.
  112994. * @param uniformName Name of the variable.
  112995. * @param x First float in float3.
  112996. * @param y Second float in float3.
  112997. * @param z Third float in float3.
  112998. * @returns this effect.
  112999. */
  113000. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113001. /**
  113002. * Sets a Vector4 on a uniform variable.
  113003. * @param uniformName Name of the variable.
  113004. * @param vector4 Value to be set.
  113005. * @returns this effect.
  113006. */
  113007. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113008. /**
  113009. * Sets a float4 on a uniform variable.
  113010. * @param uniformName Name of the variable.
  113011. * @param x First float in float4.
  113012. * @param y Second float in float4.
  113013. * @param z Third float in float4.
  113014. * @param w Fourth float in float4.
  113015. * @returns this effect.
  113016. */
  113017. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113018. /**
  113019. * Sets a Color3 on a uniform variable.
  113020. * @param uniformName Name of the variable.
  113021. * @param color3 Value to be set.
  113022. * @returns this effect.
  113023. */
  113024. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113025. /**
  113026. * Sets a Color4 on a uniform variable.
  113027. * @param uniformName Name of the variable.
  113028. * @param color3 Value to be set.
  113029. * @param alpha Alpha value to be set.
  113030. * @returns this effect.
  113031. */
  113032. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113033. /**
  113034. * Sets a Color4 on a uniform variable
  113035. * @param uniformName defines the name of the variable
  113036. * @param color4 defines the value to be set
  113037. * @returns this effect.
  113038. */
  113039. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113040. /** Release all associated resources */
  113041. dispose(): void;
  113042. /**
  113043. * This function will add a new shader to the shader store
  113044. * @param name the name of the shader
  113045. * @param pixelShader optional pixel shader content
  113046. * @param vertexShader optional vertex shader content
  113047. */
  113048. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113049. /**
  113050. * Store of each shader (The can be looked up using effect.key)
  113051. */
  113052. static ShadersStore: {
  113053. [key: string]: string;
  113054. };
  113055. /**
  113056. * Store of each included file for a shader (The can be looked up using effect.key)
  113057. */
  113058. static IncludesShadersStore: {
  113059. [key: string]: string;
  113060. };
  113061. /**
  113062. * Resets the cache of effects.
  113063. */
  113064. static ResetCache(): void;
  113065. }
  113066. }
  113067. declare module BABYLON {
  113068. /**
  113069. * Interface used to describe the capabilities of the engine relatively to the current browser
  113070. */
  113071. export interface EngineCapabilities {
  113072. /** Maximum textures units per fragment shader */
  113073. maxTexturesImageUnits: number;
  113074. /** Maximum texture units per vertex shader */
  113075. maxVertexTextureImageUnits: number;
  113076. /** Maximum textures units in the entire pipeline */
  113077. maxCombinedTexturesImageUnits: number;
  113078. /** Maximum texture size */
  113079. maxTextureSize: number;
  113080. /** Maximum texture samples */
  113081. maxSamples?: number;
  113082. /** Maximum cube texture size */
  113083. maxCubemapTextureSize: number;
  113084. /** Maximum render texture size */
  113085. maxRenderTextureSize: number;
  113086. /** Maximum number of vertex attributes */
  113087. maxVertexAttribs: number;
  113088. /** Maximum number of varyings */
  113089. maxVaryingVectors: number;
  113090. /** Maximum number of uniforms per vertex shader */
  113091. maxVertexUniformVectors: number;
  113092. /** Maximum number of uniforms per fragment shader */
  113093. maxFragmentUniformVectors: number;
  113094. /** Defines if standard derivates (dx/dy) are supported */
  113095. standardDerivatives: boolean;
  113096. /** Defines if s3tc texture compression is supported */
  113097. s3tc?: WEBGL_compressed_texture_s3tc;
  113098. /** Defines if pvrtc texture compression is supported */
  113099. pvrtc: any;
  113100. /** Defines if etc1 texture compression is supported */
  113101. etc1: any;
  113102. /** Defines if etc2 texture compression is supported */
  113103. etc2: any;
  113104. /** Defines if astc texture compression is supported */
  113105. astc: any;
  113106. /** Defines if float textures are supported */
  113107. textureFloat: boolean;
  113108. /** Defines if vertex array objects are supported */
  113109. vertexArrayObject: boolean;
  113110. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113111. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113112. /** Gets the maximum level of anisotropy supported */
  113113. maxAnisotropy: number;
  113114. /** Defines if instancing is supported */
  113115. instancedArrays: boolean;
  113116. /** Defines if 32 bits indices are supported */
  113117. uintIndices: boolean;
  113118. /** Defines if high precision shaders are supported */
  113119. highPrecisionShaderSupported: boolean;
  113120. /** Defines if depth reading in the fragment shader is supported */
  113121. fragmentDepthSupported: boolean;
  113122. /** Defines if float texture linear filtering is supported*/
  113123. textureFloatLinearFiltering: boolean;
  113124. /** Defines if rendering to float textures is supported */
  113125. textureFloatRender: boolean;
  113126. /** Defines if half float textures are supported*/
  113127. textureHalfFloat: boolean;
  113128. /** Defines if half float texture linear filtering is supported*/
  113129. textureHalfFloatLinearFiltering: boolean;
  113130. /** Defines if rendering to half float textures is supported */
  113131. textureHalfFloatRender: boolean;
  113132. /** Defines if textureLOD shader command is supported */
  113133. textureLOD: boolean;
  113134. /** Defines if draw buffers extension is supported */
  113135. drawBuffersExtension: boolean;
  113136. /** Defines if depth textures are supported */
  113137. depthTextureExtension: boolean;
  113138. /** Defines if float color buffer are supported */
  113139. colorBufferFloat: boolean;
  113140. /** Gets disjoint timer query extension (null if not supported) */
  113141. timerQuery?: EXT_disjoint_timer_query;
  113142. /** Defines if timestamp can be used with timer query */
  113143. canUseTimestampForTimerQuery: boolean;
  113144. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113145. multiview?: any;
  113146. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113147. oculusMultiview?: any;
  113148. /** Function used to let the system compiles shaders in background */
  113149. parallelShaderCompile?: {
  113150. COMPLETION_STATUS_KHR: number;
  113151. };
  113152. /** Max number of texture samples for MSAA */
  113153. maxMSAASamples: number;
  113154. /** Defines if the blend min max extension is supported */
  113155. blendMinMax: boolean;
  113156. }
  113157. }
  113158. declare module BABYLON {
  113159. /**
  113160. * @hidden
  113161. **/
  113162. export class DepthCullingState {
  113163. private _isDepthTestDirty;
  113164. private _isDepthMaskDirty;
  113165. private _isDepthFuncDirty;
  113166. private _isCullFaceDirty;
  113167. private _isCullDirty;
  113168. private _isZOffsetDirty;
  113169. private _isFrontFaceDirty;
  113170. private _depthTest;
  113171. private _depthMask;
  113172. private _depthFunc;
  113173. private _cull;
  113174. private _cullFace;
  113175. private _zOffset;
  113176. private _frontFace;
  113177. /**
  113178. * Initializes the state.
  113179. */
  113180. constructor();
  113181. get isDirty(): boolean;
  113182. get zOffset(): number;
  113183. set zOffset(value: number);
  113184. get cullFace(): Nullable<number>;
  113185. set cullFace(value: Nullable<number>);
  113186. get cull(): Nullable<boolean>;
  113187. set cull(value: Nullable<boolean>);
  113188. get depthFunc(): Nullable<number>;
  113189. set depthFunc(value: Nullable<number>);
  113190. get depthMask(): boolean;
  113191. set depthMask(value: boolean);
  113192. get depthTest(): boolean;
  113193. set depthTest(value: boolean);
  113194. get frontFace(): Nullable<number>;
  113195. set frontFace(value: Nullable<number>);
  113196. reset(): void;
  113197. apply(gl: WebGLRenderingContext): void;
  113198. }
  113199. }
  113200. declare module BABYLON {
  113201. /**
  113202. * @hidden
  113203. **/
  113204. export class StencilState {
  113205. /** 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 */
  113206. static readonly ALWAYS: number;
  113207. /** Passed to stencilOperation to specify that stencil value must be kept */
  113208. static readonly KEEP: number;
  113209. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113210. static readonly REPLACE: number;
  113211. private _isStencilTestDirty;
  113212. private _isStencilMaskDirty;
  113213. private _isStencilFuncDirty;
  113214. private _isStencilOpDirty;
  113215. private _stencilTest;
  113216. private _stencilMask;
  113217. private _stencilFunc;
  113218. private _stencilFuncRef;
  113219. private _stencilFuncMask;
  113220. private _stencilOpStencilFail;
  113221. private _stencilOpDepthFail;
  113222. private _stencilOpStencilDepthPass;
  113223. get isDirty(): boolean;
  113224. get stencilFunc(): number;
  113225. set stencilFunc(value: number);
  113226. get stencilFuncRef(): number;
  113227. set stencilFuncRef(value: number);
  113228. get stencilFuncMask(): number;
  113229. set stencilFuncMask(value: number);
  113230. get stencilOpStencilFail(): number;
  113231. set stencilOpStencilFail(value: number);
  113232. get stencilOpDepthFail(): number;
  113233. set stencilOpDepthFail(value: number);
  113234. get stencilOpStencilDepthPass(): number;
  113235. set stencilOpStencilDepthPass(value: number);
  113236. get stencilMask(): number;
  113237. set stencilMask(value: number);
  113238. get stencilTest(): boolean;
  113239. set stencilTest(value: boolean);
  113240. constructor();
  113241. reset(): void;
  113242. apply(gl: WebGLRenderingContext): void;
  113243. }
  113244. }
  113245. declare module BABYLON {
  113246. /**
  113247. * @hidden
  113248. **/
  113249. export class AlphaState {
  113250. private _isAlphaBlendDirty;
  113251. private _isBlendFunctionParametersDirty;
  113252. private _isBlendEquationParametersDirty;
  113253. private _isBlendConstantsDirty;
  113254. private _alphaBlend;
  113255. private _blendFunctionParameters;
  113256. private _blendEquationParameters;
  113257. private _blendConstants;
  113258. /**
  113259. * Initializes the state.
  113260. */
  113261. constructor();
  113262. get isDirty(): boolean;
  113263. get alphaBlend(): boolean;
  113264. set alphaBlend(value: boolean);
  113265. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113266. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113267. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113268. reset(): void;
  113269. apply(gl: WebGLRenderingContext): void;
  113270. }
  113271. }
  113272. declare module BABYLON {
  113273. /** @hidden */
  113274. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113275. attributeProcessor(attribute: string): string;
  113276. varyingProcessor(varying: string, isFragment: boolean): string;
  113277. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113278. }
  113279. }
  113280. declare module BABYLON {
  113281. /**
  113282. * Interface for attribute information associated with buffer instanciation
  113283. */
  113284. export interface InstancingAttributeInfo {
  113285. /**
  113286. * Name of the GLSL attribute
  113287. * if attribute index is not specified, this is used to retrieve the index from the effect
  113288. */
  113289. attributeName: string;
  113290. /**
  113291. * Index/offset of the attribute in the vertex shader
  113292. * if not specified, this will be computes from the name.
  113293. */
  113294. index?: number;
  113295. /**
  113296. * size of the attribute, 1, 2, 3 or 4
  113297. */
  113298. attributeSize: number;
  113299. /**
  113300. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113301. */
  113302. offset: number;
  113303. /**
  113304. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113305. * default to 1
  113306. */
  113307. divisor?: number;
  113308. /**
  113309. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113310. * default is FLOAT
  113311. */
  113312. attributeType?: number;
  113313. /**
  113314. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113315. */
  113316. normalized?: boolean;
  113317. }
  113318. }
  113319. declare module BABYLON {
  113320. interface ThinEngine {
  113321. /**
  113322. * Update a video texture
  113323. * @param texture defines the texture to update
  113324. * @param video defines the video element to use
  113325. * @param invertY defines if data must be stored with Y axis inverted
  113326. */
  113327. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113328. }
  113329. }
  113330. declare module BABYLON {
  113331. interface ThinEngine {
  113332. /**
  113333. * Creates a dynamic texture
  113334. * @param width defines the width of the texture
  113335. * @param height defines the height of the texture
  113336. * @param generateMipMaps defines if the engine should generate the mip levels
  113337. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113338. * @returns the dynamic texture inside an InternalTexture
  113339. */
  113340. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113341. /**
  113342. * Update the content of a dynamic texture
  113343. * @param texture defines the texture to update
  113344. * @param canvas defines the canvas containing the source
  113345. * @param invertY defines if data must be stored with Y axis inverted
  113346. * @param premulAlpha defines if alpha is stored as premultiplied
  113347. * @param format defines the format of the data
  113348. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113349. */
  113350. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113351. }
  113352. }
  113353. declare module BABYLON {
  113354. /**
  113355. * Settings for finer control over video usage
  113356. */
  113357. export interface VideoTextureSettings {
  113358. /**
  113359. * Applies `autoplay` to video, if specified
  113360. */
  113361. autoPlay?: boolean;
  113362. /**
  113363. * Applies `loop` to video, if specified
  113364. */
  113365. loop?: boolean;
  113366. /**
  113367. * Automatically updates internal texture from video at every frame in the render loop
  113368. */
  113369. autoUpdateTexture: boolean;
  113370. /**
  113371. * Image src displayed during the video loading or until the user interacts with the video.
  113372. */
  113373. poster?: string;
  113374. }
  113375. /**
  113376. * If you want to display a video in your scene, this is the special texture for that.
  113377. * This special texture works similar to other textures, with the exception of a few parameters.
  113378. * @see https://doc.babylonjs.com/how_to/video_texture
  113379. */
  113380. export class VideoTexture extends Texture {
  113381. /**
  113382. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113383. */
  113384. readonly autoUpdateTexture: boolean;
  113385. /**
  113386. * The video instance used by the texture internally
  113387. */
  113388. readonly video: HTMLVideoElement;
  113389. private _onUserActionRequestedObservable;
  113390. /**
  113391. * Event triggerd when a dom action is required by the user to play the video.
  113392. * This happens due to recent changes in browser policies preventing video to auto start.
  113393. */
  113394. get onUserActionRequestedObservable(): Observable<Texture>;
  113395. private _generateMipMaps;
  113396. private _stillImageCaptured;
  113397. private _displayingPosterTexture;
  113398. private _settings;
  113399. private _createInternalTextureOnEvent;
  113400. private _frameId;
  113401. private _currentSrc;
  113402. /**
  113403. * Creates a video texture.
  113404. * If you want to display a video in your scene, this is the special texture for that.
  113405. * This special texture works similar to other textures, with the exception of a few parameters.
  113406. * @see https://doc.babylonjs.com/how_to/video_texture
  113407. * @param name optional name, will detect from video source, if not defined
  113408. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113409. * @param scene is obviously the current scene.
  113410. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113411. * @param invertY is false by default but can be used to invert video on Y axis
  113412. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113413. * @param settings allows finer control over video usage
  113414. */
  113415. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113416. private _getName;
  113417. private _getVideo;
  113418. private _createInternalTexture;
  113419. private reset;
  113420. /**
  113421. * @hidden Internal method to initiate `update`.
  113422. */
  113423. _rebuild(): void;
  113424. /**
  113425. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113426. */
  113427. update(): void;
  113428. /**
  113429. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  113430. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  113431. */
  113432. updateTexture(isVisible: boolean): void;
  113433. protected _updateInternalTexture: () => void;
  113434. /**
  113435. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  113436. * @param url New url.
  113437. */
  113438. updateURL(url: string): void;
  113439. /**
  113440. * Clones the texture.
  113441. * @returns the cloned texture
  113442. */
  113443. clone(): VideoTexture;
  113444. /**
  113445. * Dispose the texture and release its associated resources.
  113446. */
  113447. dispose(): void;
  113448. /**
  113449. * Creates a video texture straight from a stream.
  113450. * @param scene Define the scene the texture should be created in
  113451. * @param stream Define the stream the texture should be created from
  113452. * @returns The created video texture as a promise
  113453. */
  113454. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  113455. /**
  113456. * Creates a video texture straight from your WebCam video feed.
  113457. * @param scene Define the scene the texture should be created in
  113458. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113459. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113460. * @returns The created video texture as a promise
  113461. */
  113462. static CreateFromWebCamAsync(scene: Scene, constraints: {
  113463. minWidth: number;
  113464. maxWidth: number;
  113465. minHeight: number;
  113466. maxHeight: number;
  113467. deviceId: string;
  113468. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  113469. /**
  113470. * Creates a video texture straight from your WebCam video feed.
  113471. * @param scene Define the scene the texture should be created in
  113472. * @param onReady Define a callback to triggered once the texture will be ready
  113473. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113474. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113475. */
  113476. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  113477. minWidth: number;
  113478. maxWidth: number;
  113479. minHeight: number;
  113480. maxHeight: number;
  113481. deviceId: string;
  113482. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  113483. }
  113484. }
  113485. declare module BABYLON {
  113486. /**
  113487. * Defines the interface used by objects working like Scene
  113488. * @hidden
  113489. */
  113490. export interface ISceneLike {
  113491. _addPendingData(data: any): void;
  113492. _removePendingData(data: any): void;
  113493. offlineProvider: IOfflineProvider;
  113494. }
  113495. /** Interface defining initialization parameters for Engine class */
  113496. export interface EngineOptions extends WebGLContextAttributes {
  113497. /**
  113498. * Defines if the engine should no exceed a specified device ratio
  113499. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  113500. */
  113501. limitDeviceRatio?: number;
  113502. /**
  113503. * Defines if webvr should be enabled automatically
  113504. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113505. */
  113506. autoEnableWebVR?: boolean;
  113507. /**
  113508. * Defines if webgl2 should be turned off even if supported
  113509. * @see https://doc.babylonjs.com/features/webgl2
  113510. */
  113511. disableWebGL2Support?: boolean;
  113512. /**
  113513. * Defines if webaudio should be initialized as well
  113514. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113515. */
  113516. audioEngine?: boolean;
  113517. /**
  113518. * Defines if animations should run using a deterministic lock step
  113519. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113520. */
  113521. deterministicLockstep?: boolean;
  113522. /** Defines the maximum steps to use with deterministic lock step mode */
  113523. lockstepMaxSteps?: number;
  113524. /** Defines the seconds between each deterministic lock step */
  113525. timeStep?: number;
  113526. /**
  113527. * Defines that engine should ignore context lost events
  113528. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  113529. */
  113530. doNotHandleContextLost?: boolean;
  113531. /**
  113532. * Defines that engine should ignore modifying touch action attribute and style
  113533. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  113534. */
  113535. doNotHandleTouchAction?: boolean;
  113536. /**
  113537. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  113538. */
  113539. useHighPrecisionFloats?: boolean;
  113540. /**
  113541. * Make the canvas XR Compatible for XR sessions
  113542. */
  113543. xrCompatible?: boolean;
  113544. /**
  113545. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  113546. */
  113547. useHighPrecisionMatrix?: boolean;
  113548. }
  113549. /**
  113550. * The base engine class (root of all engines)
  113551. */
  113552. export class ThinEngine {
  113553. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  113554. static ExceptionList: ({
  113555. key: string;
  113556. capture: string;
  113557. captureConstraint: number;
  113558. targets: string[];
  113559. } | {
  113560. key: string;
  113561. capture: null;
  113562. captureConstraint: null;
  113563. targets: string[];
  113564. })[];
  113565. /** @hidden */
  113566. static _TextureLoaders: IInternalTextureLoader[];
  113567. /**
  113568. * Returns the current npm package of the sdk
  113569. */
  113570. static get NpmPackage(): string;
  113571. /**
  113572. * Returns the current version of the framework
  113573. */
  113574. static get Version(): string;
  113575. /**
  113576. * Returns a string describing the current engine
  113577. */
  113578. get description(): string;
  113579. /**
  113580. * Gets or sets the epsilon value used by collision engine
  113581. */
  113582. static CollisionsEpsilon: number;
  113583. /**
  113584. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113585. */
  113586. static get ShadersRepository(): string;
  113587. static set ShadersRepository(value: string);
  113588. /** @hidden */
  113589. _shaderProcessor: IShaderProcessor;
  113590. /**
  113591. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  113592. */
  113593. forcePOTTextures: boolean;
  113594. /**
  113595. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  113596. */
  113597. isFullscreen: boolean;
  113598. /**
  113599. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  113600. */
  113601. cullBackFaces: boolean;
  113602. /**
  113603. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  113604. */
  113605. renderEvenInBackground: boolean;
  113606. /**
  113607. * Gets or sets a boolean indicating that cache can be kept between frames
  113608. */
  113609. preventCacheWipeBetweenFrames: boolean;
  113610. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  113611. validateShaderPrograms: boolean;
  113612. /**
  113613. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  113614. * This can provide greater z depth for distant objects.
  113615. */
  113616. useReverseDepthBuffer: boolean;
  113617. /**
  113618. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  113619. */
  113620. disableUniformBuffers: boolean;
  113621. /** @hidden */
  113622. _uniformBuffers: UniformBuffer[];
  113623. /**
  113624. * Gets a boolean indicating that the engine supports uniform buffers
  113625. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  113626. */
  113627. get supportsUniformBuffers(): boolean;
  113628. /** @hidden */
  113629. _gl: WebGLRenderingContext;
  113630. /** @hidden */
  113631. _webGLVersion: number;
  113632. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  113633. protected _windowIsBackground: boolean;
  113634. protected _creationOptions: EngineOptions;
  113635. protected _highPrecisionShadersAllowed: boolean;
  113636. /** @hidden */
  113637. get _shouldUseHighPrecisionShader(): boolean;
  113638. /**
  113639. * Gets a boolean indicating that only power of 2 textures are supported
  113640. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  113641. */
  113642. get needPOTTextures(): boolean;
  113643. /** @hidden */
  113644. _badOS: boolean;
  113645. /** @hidden */
  113646. _badDesktopOS: boolean;
  113647. private _hardwareScalingLevel;
  113648. /** @hidden */
  113649. _caps: EngineCapabilities;
  113650. private _isStencilEnable;
  113651. private _glVersion;
  113652. private _glRenderer;
  113653. private _glVendor;
  113654. /** @hidden */
  113655. _videoTextureSupported: boolean;
  113656. protected _renderingQueueLaunched: boolean;
  113657. protected _activeRenderLoops: (() => void)[];
  113658. /**
  113659. * Observable signaled when a context lost event is raised
  113660. */
  113661. onContextLostObservable: Observable<ThinEngine>;
  113662. /**
  113663. * Observable signaled when a context restored event is raised
  113664. */
  113665. onContextRestoredObservable: Observable<ThinEngine>;
  113666. private _onContextLost;
  113667. private _onContextRestored;
  113668. protected _contextWasLost: boolean;
  113669. /** @hidden */
  113670. _doNotHandleContextLost: boolean;
  113671. /**
  113672. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  113673. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  113674. */
  113675. get doNotHandleContextLost(): boolean;
  113676. set doNotHandleContextLost(value: boolean);
  113677. /**
  113678. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  113679. */
  113680. disableVertexArrayObjects: boolean;
  113681. /** @hidden */
  113682. protected _colorWrite: boolean;
  113683. /** @hidden */
  113684. protected _colorWriteChanged: boolean;
  113685. /** @hidden */
  113686. protected _depthCullingState: DepthCullingState;
  113687. /** @hidden */
  113688. protected _stencilState: StencilState;
  113689. /** @hidden */
  113690. _alphaState: AlphaState;
  113691. /** @hidden */
  113692. _alphaMode: number;
  113693. /** @hidden */
  113694. _alphaEquation: number;
  113695. /** @hidden */
  113696. _internalTexturesCache: InternalTexture[];
  113697. /** @hidden */
  113698. protected _activeChannel: number;
  113699. private _currentTextureChannel;
  113700. /** @hidden */
  113701. protected _boundTexturesCache: {
  113702. [key: string]: Nullable<InternalTexture>;
  113703. };
  113704. /** @hidden */
  113705. protected _currentEffect: Nullable<Effect>;
  113706. /** @hidden */
  113707. protected _currentProgram: Nullable<WebGLProgram>;
  113708. private _compiledEffects;
  113709. private _vertexAttribArraysEnabled;
  113710. /** @hidden */
  113711. protected _cachedViewport: Nullable<IViewportLike>;
  113712. private _cachedVertexArrayObject;
  113713. /** @hidden */
  113714. protected _cachedVertexBuffers: any;
  113715. /** @hidden */
  113716. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  113717. /** @hidden */
  113718. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  113719. /** @hidden */
  113720. _currentRenderTarget: Nullable<InternalTexture>;
  113721. private _uintIndicesCurrentlySet;
  113722. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  113723. /** @hidden */
  113724. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  113725. /** @hidden */
  113726. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  113727. private _currentBufferPointers;
  113728. private _currentInstanceLocations;
  113729. private _currentInstanceBuffers;
  113730. private _textureUnits;
  113731. /** @hidden */
  113732. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113733. /** @hidden */
  113734. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113735. /** @hidden */
  113736. _boundRenderFunction: any;
  113737. private _vaoRecordInProgress;
  113738. private _mustWipeVertexAttributes;
  113739. private _emptyTexture;
  113740. private _emptyCubeTexture;
  113741. private _emptyTexture3D;
  113742. private _emptyTexture2DArray;
  113743. /** @hidden */
  113744. _frameHandler: number;
  113745. private _nextFreeTextureSlots;
  113746. private _maxSimultaneousTextures;
  113747. private _activeRequests;
  113748. /** @hidden */
  113749. _transformTextureUrl: Nullable<(url: string) => string>;
  113750. protected get _supportsHardwareTextureRescaling(): boolean;
  113751. private _framebufferDimensionsObject;
  113752. /**
  113753. * sets the object from which width and height will be taken from when getting render width and height
  113754. * Will fallback to the gl object
  113755. * @param dimensions the framebuffer width and height that will be used.
  113756. */
  113757. set framebufferDimensionsObject(dimensions: Nullable<{
  113758. framebufferWidth: number;
  113759. framebufferHeight: number;
  113760. }>);
  113761. /**
  113762. * Gets the current viewport
  113763. */
  113764. get currentViewport(): Nullable<IViewportLike>;
  113765. /**
  113766. * Gets the default empty texture
  113767. */
  113768. get emptyTexture(): InternalTexture;
  113769. /**
  113770. * Gets the default empty 3D texture
  113771. */
  113772. get emptyTexture3D(): InternalTexture;
  113773. /**
  113774. * Gets the default empty 2D array texture
  113775. */
  113776. get emptyTexture2DArray(): InternalTexture;
  113777. /**
  113778. * Gets the default empty cube texture
  113779. */
  113780. get emptyCubeTexture(): InternalTexture;
  113781. /**
  113782. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  113783. */
  113784. readonly premultipliedAlpha: boolean;
  113785. /**
  113786. * Observable event triggered before each texture is initialized
  113787. */
  113788. onBeforeTextureInitObservable: Observable<Texture>;
  113789. /**
  113790. * Creates a new engine
  113791. * @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
  113792. * @param antialias defines enable antialiasing (default: false)
  113793. * @param options defines further options to be sent to the getContext() function
  113794. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113795. */
  113796. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113797. private _rebuildInternalTextures;
  113798. private _rebuildEffects;
  113799. /**
  113800. * Gets a boolean indicating if all created effects are ready
  113801. * @returns true if all effects are ready
  113802. */
  113803. areAllEffectsReady(): boolean;
  113804. protected _rebuildBuffers(): void;
  113805. protected _initGLContext(): void;
  113806. /**
  113807. * Gets version of the current webGL context
  113808. */
  113809. get webGLVersion(): number;
  113810. /**
  113811. * Gets a string idenfifying the name of the class
  113812. * @returns "Engine" string
  113813. */
  113814. getClassName(): string;
  113815. /**
  113816. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  113817. */
  113818. get isStencilEnable(): boolean;
  113819. /** @hidden */
  113820. _prepareWorkingCanvas(): void;
  113821. /**
  113822. * Reset the texture cache to empty state
  113823. */
  113824. resetTextureCache(): void;
  113825. /**
  113826. * Gets an object containing information about the current webGL context
  113827. * @returns an object containing the vender, the renderer and the version of the current webGL context
  113828. */
  113829. getGlInfo(): {
  113830. vendor: string;
  113831. renderer: string;
  113832. version: string;
  113833. };
  113834. /**
  113835. * Defines the hardware scaling level.
  113836. * By default the hardware scaling level is computed from the window device ratio.
  113837. * 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.
  113838. * @param level defines the level to use
  113839. */
  113840. setHardwareScalingLevel(level: number): void;
  113841. /**
  113842. * Gets the current hardware scaling level.
  113843. * By default the hardware scaling level is computed from the window device ratio.
  113844. * 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.
  113845. * @returns a number indicating the current hardware scaling level
  113846. */
  113847. getHardwareScalingLevel(): number;
  113848. /**
  113849. * Gets the list of loaded textures
  113850. * @returns an array containing all loaded textures
  113851. */
  113852. getLoadedTexturesCache(): InternalTexture[];
  113853. /**
  113854. * Gets the object containing all engine capabilities
  113855. * @returns the EngineCapabilities object
  113856. */
  113857. getCaps(): EngineCapabilities;
  113858. /**
  113859. * stop executing a render loop function and remove it from the execution array
  113860. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  113861. */
  113862. stopRenderLoop(renderFunction?: () => void): void;
  113863. /** @hidden */
  113864. _renderLoop(): void;
  113865. /**
  113866. * Gets the HTML canvas attached with the current webGL context
  113867. * @returns a HTML canvas
  113868. */
  113869. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  113870. /**
  113871. * Gets host window
  113872. * @returns the host window object
  113873. */
  113874. getHostWindow(): Nullable<Window>;
  113875. /**
  113876. * Gets the current render width
  113877. * @param useScreen defines if screen size must be used (or the current render target if any)
  113878. * @returns a number defining the current render width
  113879. */
  113880. getRenderWidth(useScreen?: boolean): number;
  113881. /**
  113882. * Gets the current render height
  113883. * @param useScreen defines if screen size must be used (or the current render target if any)
  113884. * @returns a number defining the current render height
  113885. */
  113886. getRenderHeight(useScreen?: boolean): number;
  113887. /**
  113888. * Can be used to override the current requestAnimationFrame requester.
  113889. * @hidden
  113890. */
  113891. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113892. /**
  113893. * Register and execute a render loop. The engine can have more than one render function
  113894. * @param renderFunction defines the function to continuously execute
  113895. */
  113896. runRenderLoop(renderFunction: () => void): void;
  113897. /**
  113898. * Clear the current render buffer or the current render target (if any is set up)
  113899. * @param color defines the color to use
  113900. * @param backBuffer defines if the back buffer must be cleared
  113901. * @param depth defines if the depth buffer must be cleared
  113902. * @param stencil defines if the stencil buffer must be cleared
  113903. */
  113904. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113905. private _viewportCached;
  113906. /** @hidden */
  113907. _viewport(x: number, y: number, width: number, height: number): void;
  113908. /**
  113909. * Set the WebGL's viewport
  113910. * @param viewport defines the viewport element to be used
  113911. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113912. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113913. */
  113914. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113915. /**
  113916. * Begin a new frame
  113917. */
  113918. beginFrame(): void;
  113919. /**
  113920. * Enf the current frame
  113921. */
  113922. endFrame(): void;
  113923. /**
  113924. * Resize the view according to the canvas' size
  113925. */
  113926. resize(): void;
  113927. /**
  113928. * Force a specific size of the canvas
  113929. * @param width defines the new canvas' width
  113930. * @param height defines the new canvas' height
  113931. * @returns true if the size was changed
  113932. */
  113933. setSize(width: number, height: number): boolean;
  113934. /**
  113935. * Binds the frame buffer to the specified texture.
  113936. * @param texture The texture to render to or null for the default canvas
  113937. * @param faceIndex The face of the texture to render to in case of cube texture
  113938. * @param requiredWidth The width of the target to render to
  113939. * @param requiredHeight The height of the target to render to
  113940. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113941. * @param lodLevel defines the lod level to bind to the frame buffer
  113942. * @param layer defines the 2d array index to bind to frame buffer to
  113943. */
  113944. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  113945. /** @hidden */
  113946. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113947. /**
  113948. * Unbind the current render target texture from the webGL context
  113949. * @param texture defines the render target texture to unbind
  113950. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113951. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113952. */
  113953. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113954. /**
  113955. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  113956. */
  113957. flushFramebuffer(): void;
  113958. /**
  113959. * Unbind the current render target and bind the default framebuffer
  113960. */
  113961. restoreDefaultFramebuffer(): void;
  113962. /** @hidden */
  113963. protected _resetVertexBufferBinding(): void;
  113964. /**
  113965. * Creates a vertex buffer
  113966. * @param data the data for the vertex buffer
  113967. * @returns the new WebGL static buffer
  113968. */
  113969. createVertexBuffer(data: DataArray): DataBuffer;
  113970. private _createVertexBuffer;
  113971. /**
  113972. * Creates a dynamic vertex buffer
  113973. * @param data the data for the dynamic vertex buffer
  113974. * @returns the new WebGL dynamic buffer
  113975. */
  113976. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113977. protected _resetIndexBufferBinding(): void;
  113978. /**
  113979. * Creates a new index buffer
  113980. * @param indices defines the content of the index buffer
  113981. * @param updatable defines if the index buffer must be updatable
  113982. * @returns a new webGL buffer
  113983. */
  113984. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  113985. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  113986. /**
  113987. * Bind a webGL buffer to the webGL context
  113988. * @param buffer defines the buffer to bind
  113989. */
  113990. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  113991. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  113992. private bindBuffer;
  113993. /**
  113994. * update the bound buffer with the given data
  113995. * @param data defines the data to update
  113996. */
  113997. updateArrayBuffer(data: Float32Array): void;
  113998. private _vertexAttribPointer;
  113999. /** @hidden */
  114000. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114001. private _bindVertexBuffersAttributes;
  114002. /**
  114003. * Records a vertex array object
  114004. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114005. * @param vertexBuffers defines the list of vertex buffers to store
  114006. * @param indexBuffer defines the index buffer to store
  114007. * @param effect defines the effect to store
  114008. * @returns the new vertex array object
  114009. */
  114010. recordVertexArrayObject(vertexBuffers: {
  114011. [key: string]: VertexBuffer;
  114012. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114013. /**
  114014. * Bind a specific vertex array object
  114015. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114016. * @param vertexArrayObject defines the vertex array object to bind
  114017. * @param indexBuffer defines the index buffer to bind
  114018. */
  114019. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114020. /**
  114021. * Bind webGl buffers directly to the webGL context
  114022. * @param vertexBuffer defines the vertex buffer to bind
  114023. * @param indexBuffer defines the index buffer to bind
  114024. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114025. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114026. * @param effect defines the effect associated with the vertex buffer
  114027. */
  114028. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114029. private _unbindVertexArrayObject;
  114030. /**
  114031. * Bind a list of vertex buffers to the webGL context
  114032. * @param vertexBuffers defines the list of vertex buffers to bind
  114033. * @param indexBuffer defines the index buffer to bind
  114034. * @param effect defines the effect associated with the vertex buffers
  114035. */
  114036. bindBuffers(vertexBuffers: {
  114037. [key: string]: Nullable<VertexBuffer>;
  114038. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114039. /**
  114040. * Unbind all instance attributes
  114041. */
  114042. unbindInstanceAttributes(): void;
  114043. /**
  114044. * Release and free the memory of a vertex array object
  114045. * @param vao defines the vertex array object to delete
  114046. */
  114047. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114048. /** @hidden */
  114049. _releaseBuffer(buffer: DataBuffer): boolean;
  114050. protected _deleteBuffer(buffer: DataBuffer): void;
  114051. /**
  114052. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114053. * @param instancesBuffer defines the webGL buffer to update and bind
  114054. * @param data defines the data to store in the buffer
  114055. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114056. */
  114057. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114058. /**
  114059. * Bind the content of a webGL buffer used with instantiation
  114060. * @param instancesBuffer defines the webGL buffer to bind
  114061. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114062. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114063. */
  114064. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114065. /**
  114066. * Disable the instance attribute corresponding to the name in parameter
  114067. * @param name defines the name of the attribute to disable
  114068. */
  114069. disableInstanceAttributeByName(name: string): void;
  114070. /**
  114071. * Disable the instance attribute corresponding to the location in parameter
  114072. * @param attributeLocation defines the attribute location of the attribute to disable
  114073. */
  114074. disableInstanceAttribute(attributeLocation: number): void;
  114075. /**
  114076. * Disable the attribute corresponding to the location in parameter
  114077. * @param attributeLocation defines the attribute location of the attribute to disable
  114078. */
  114079. disableAttributeByIndex(attributeLocation: number): void;
  114080. /**
  114081. * Send a draw order
  114082. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114083. * @param indexStart defines the starting index
  114084. * @param indexCount defines the number of index to draw
  114085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114086. */
  114087. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114088. /**
  114089. * Draw a list of points
  114090. * @param verticesStart defines the index of first vertex to draw
  114091. * @param verticesCount defines the count of vertices to draw
  114092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114093. */
  114094. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114095. /**
  114096. * Draw a list of unindexed primitives
  114097. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114098. * @param verticesStart defines the index of first vertex to draw
  114099. * @param verticesCount defines the count of vertices to draw
  114100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114101. */
  114102. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114103. /**
  114104. * Draw a list of indexed primitives
  114105. * @param fillMode defines the primitive to use
  114106. * @param indexStart defines the starting index
  114107. * @param indexCount defines the number of index to draw
  114108. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114109. */
  114110. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114111. /**
  114112. * Draw a list of unindexed primitives
  114113. * @param fillMode defines the primitive to use
  114114. * @param verticesStart defines the index of first vertex to draw
  114115. * @param verticesCount defines the count of vertices to draw
  114116. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114117. */
  114118. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114119. private _drawMode;
  114120. /** @hidden */
  114121. protected _reportDrawCall(): void;
  114122. /** @hidden */
  114123. _releaseEffect(effect: Effect): void;
  114124. /** @hidden */
  114125. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114126. /**
  114127. * Create a new effect (used to store vertex/fragment shaders)
  114128. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114129. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114130. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114131. * @param samplers defines an array of string used to represent textures
  114132. * @param defines defines the string containing the defines to use to compile the shaders
  114133. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114134. * @param onCompiled defines a function to call when the effect creation is successful
  114135. * @param onError defines a function to call when the effect creation has failed
  114136. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114137. * @returns the new Effect
  114138. */
  114139. 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;
  114140. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114141. private _compileShader;
  114142. private _compileRawShader;
  114143. /** @hidden */
  114144. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114145. /**
  114146. * Directly creates a webGL program
  114147. * @param pipelineContext defines the pipeline context to attach to
  114148. * @param vertexCode defines the vertex shader code to use
  114149. * @param fragmentCode defines the fragment shader code to use
  114150. * @param context defines the webGL context to use (if not set, the current one will be used)
  114151. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114152. * @returns the new webGL program
  114153. */
  114154. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114155. /**
  114156. * Creates a webGL program
  114157. * @param pipelineContext defines the pipeline context to attach to
  114158. * @param vertexCode defines the vertex shader code to use
  114159. * @param fragmentCode defines the fragment shader code to use
  114160. * @param defines defines the string containing the defines to use to compile the shaders
  114161. * @param context defines the webGL context to use (if not set, the current one will be used)
  114162. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114163. * @returns the new webGL program
  114164. */
  114165. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114166. /**
  114167. * Creates a new pipeline context
  114168. * @returns the new pipeline
  114169. */
  114170. createPipelineContext(): IPipelineContext;
  114171. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114172. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114173. /** @hidden */
  114174. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114175. /** @hidden */
  114176. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114177. /** @hidden */
  114178. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114179. /**
  114180. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114181. * @param pipelineContext defines the pipeline context to use
  114182. * @param uniformsNames defines the list of uniform names
  114183. * @returns an array of webGL uniform locations
  114184. */
  114185. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114186. /**
  114187. * Gets the lsit of active attributes for a given webGL program
  114188. * @param pipelineContext defines the pipeline context to use
  114189. * @param attributesNames defines the list of attribute names to get
  114190. * @returns an array of indices indicating the offset of each attribute
  114191. */
  114192. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114193. /**
  114194. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114195. * @param effect defines the effect to activate
  114196. */
  114197. enableEffect(effect: Nullable<Effect>): void;
  114198. /**
  114199. * Set the value of an uniform to a number (int)
  114200. * @param uniform defines the webGL uniform location where to store the value
  114201. * @param value defines the int number to store
  114202. */
  114203. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114204. /**
  114205. * Set the value of an uniform to an array of int32
  114206. * @param uniform defines the webGL uniform location where to store the value
  114207. * @param array defines the array of int32 to store
  114208. */
  114209. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114210. /**
  114211. * Set the value of an uniform to an array of int32 (stored as vec2)
  114212. * @param uniform defines the webGL uniform location where to store the value
  114213. * @param array defines the array of int32 to store
  114214. */
  114215. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114216. /**
  114217. * Set the value of an uniform to an array of int32 (stored as vec3)
  114218. * @param uniform defines the webGL uniform location where to store the value
  114219. * @param array defines the array of int32 to store
  114220. */
  114221. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114222. /**
  114223. * Set the value of an uniform to an array of int32 (stored as vec4)
  114224. * @param uniform defines the webGL uniform location where to store the value
  114225. * @param array defines the array of int32 to store
  114226. */
  114227. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114228. /**
  114229. * Set the value of an uniform to an array of number
  114230. * @param uniform defines the webGL uniform location where to store the value
  114231. * @param array defines the array of number to store
  114232. */
  114233. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114234. /**
  114235. * Set the value of an uniform to an array of number (stored as vec2)
  114236. * @param uniform defines the webGL uniform location where to store the value
  114237. * @param array defines the array of number to store
  114238. */
  114239. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114240. /**
  114241. * Set the value of an uniform to an array of number (stored as vec3)
  114242. * @param uniform defines the webGL uniform location where to store the value
  114243. * @param array defines the array of number to store
  114244. */
  114245. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114246. /**
  114247. * Set the value of an uniform to an array of number (stored as vec4)
  114248. * @param uniform defines the webGL uniform location where to store the value
  114249. * @param array defines the array of number to store
  114250. */
  114251. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114252. /**
  114253. * Set the value of an uniform to an array of float32 (stored as matrices)
  114254. * @param uniform defines the webGL uniform location where to store the value
  114255. * @param matrices defines the array of float32 to store
  114256. */
  114257. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114258. /**
  114259. * Set the value of an uniform to a matrix (3x3)
  114260. * @param uniform defines the webGL uniform location where to store the value
  114261. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114262. */
  114263. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114264. /**
  114265. * Set the value of an uniform to a matrix (2x2)
  114266. * @param uniform defines the webGL uniform location where to store the value
  114267. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114268. */
  114269. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114270. /**
  114271. * Set the value of an uniform to a number (float)
  114272. * @param uniform defines the webGL uniform location where to store the value
  114273. * @param value defines the float number to store
  114274. */
  114275. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114276. /**
  114277. * Set the value of an uniform to a vec2
  114278. * @param uniform defines the webGL uniform location where to store the value
  114279. * @param x defines the 1st component of the value
  114280. * @param y defines the 2nd component of the value
  114281. */
  114282. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114283. /**
  114284. * Set the value of an uniform to a vec3
  114285. * @param uniform defines the webGL uniform location where to store the value
  114286. * @param x defines the 1st component of the value
  114287. * @param y defines the 2nd component of the value
  114288. * @param z defines the 3rd component of the value
  114289. */
  114290. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114291. /**
  114292. * Set the value of an uniform to a vec4
  114293. * @param uniform defines the webGL uniform location where to store the value
  114294. * @param x defines the 1st component of the value
  114295. * @param y defines the 2nd component of the value
  114296. * @param z defines the 3rd component of the value
  114297. * @param w defines the 4th component of the value
  114298. */
  114299. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114300. /**
  114301. * Apply all cached states (depth, culling, stencil and alpha)
  114302. */
  114303. applyStates(): void;
  114304. /**
  114305. * Enable or disable color writing
  114306. * @param enable defines the state to set
  114307. */
  114308. setColorWrite(enable: boolean): void;
  114309. /**
  114310. * Gets a boolean indicating if color writing is enabled
  114311. * @returns the current color writing state
  114312. */
  114313. getColorWrite(): boolean;
  114314. /**
  114315. * Gets the depth culling state manager
  114316. */
  114317. get depthCullingState(): DepthCullingState;
  114318. /**
  114319. * Gets the alpha state manager
  114320. */
  114321. get alphaState(): AlphaState;
  114322. /**
  114323. * Gets the stencil state manager
  114324. */
  114325. get stencilState(): StencilState;
  114326. /**
  114327. * Clears the list of texture accessible through engine.
  114328. * This can help preventing texture load conflict due to name collision.
  114329. */
  114330. clearInternalTexturesCache(): void;
  114331. /**
  114332. * Force the entire cache to be cleared
  114333. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114334. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114335. */
  114336. wipeCaches(bruteForce?: boolean): void;
  114337. /** @hidden */
  114338. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114339. min: number;
  114340. mag: number;
  114341. };
  114342. /** @hidden */
  114343. _createTexture(): WebGLTexture;
  114344. /**
  114345. * Usually called from Texture.ts.
  114346. * Passed information to create a WebGLTexture
  114347. * @param url defines a value which contains one of the following:
  114348. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114349. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114350. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114351. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114352. * @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)
  114353. * @param scene needed for loading to the correct scene
  114354. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114355. * @param onLoad optional callback to be called upon successful completion
  114356. * @param onError optional callback to be called upon failure
  114357. * @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
  114358. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114359. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114360. * @param forcedExtension defines the extension to use to pick the right loader
  114361. * @param mimeType defines an optional mime type
  114362. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114363. */
  114364. 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): InternalTexture;
  114365. /**
  114366. * Loads an image as an HTMLImageElement.
  114367. * @param input url string, ArrayBuffer, or Blob to load
  114368. * @param onLoad callback called when the image successfully loads
  114369. * @param onError callback called when the image fails to load
  114370. * @param offlineProvider offline provider for caching
  114371. * @param mimeType optional mime type
  114372. * @returns the HTMLImageElement of the loaded image
  114373. * @hidden
  114374. */
  114375. 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>;
  114376. /**
  114377. * @hidden
  114378. */
  114379. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114380. private _unpackFlipYCached;
  114381. /**
  114382. * In case you are sharing the context with other applications, it might
  114383. * be interested to not cache the unpack flip y state to ensure a consistent
  114384. * value would be set.
  114385. */
  114386. enableUnpackFlipYCached: boolean;
  114387. /** @hidden */
  114388. _unpackFlipY(value: boolean): void;
  114389. /** @hidden */
  114390. _getUnpackAlignement(): number;
  114391. private _getTextureTarget;
  114392. /**
  114393. * Update the sampling mode of a given texture
  114394. * @param samplingMode defines the required sampling mode
  114395. * @param texture defines the texture to update
  114396. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114397. */
  114398. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114399. /**
  114400. * Update the sampling mode of a given texture
  114401. * @param texture defines the texture to update
  114402. * @param wrapU defines the texture wrap mode of the u coordinates
  114403. * @param wrapV defines the texture wrap mode of the v coordinates
  114404. * @param wrapR defines the texture wrap mode of the r coordinates
  114405. */
  114406. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114407. /** @hidden */
  114408. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114409. width: number;
  114410. height: number;
  114411. layers?: number;
  114412. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114413. /** @hidden */
  114414. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114415. /** @hidden */
  114416. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114417. /**
  114418. * Update a portion of an internal texture
  114419. * @param texture defines the texture to update
  114420. * @param imageData defines the data to store into the texture
  114421. * @param xOffset defines the x coordinates of the update rectangle
  114422. * @param yOffset defines the y coordinates of the update rectangle
  114423. * @param width defines the width of the update rectangle
  114424. * @param height defines the height of the update rectangle
  114425. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114426. * @param lod defines the lod level to update (0 by default)
  114427. */
  114428. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114429. /** @hidden */
  114430. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114431. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  114432. private _prepareWebGLTexture;
  114433. /** @hidden */
  114434. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  114435. private _getDepthStencilBuffer;
  114436. /** @hidden */
  114437. _releaseFramebufferObjects(texture: InternalTexture): void;
  114438. /** @hidden */
  114439. _releaseTexture(texture: InternalTexture): void;
  114440. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114441. protected _setProgram(program: WebGLProgram): void;
  114442. protected _boundUniforms: {
  114443. [key: number]: WebGLUniformLocation;
  114444. };
  114445. /**
  114446. * Binds an effect to the webGL context
  114447. * @param effect defines the effect to bind
  114448. */
  114449. bindSamplers(effect: Effect): void;
  114450. private _activateCurrentTexture;
  114451. /** @hidden */
  114452. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  114453. /** @hidden */
  114454. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  114455. /**
  114456. * Unbind all textures from the webGL context
  114457. */
  114458. unbindAllTextures(): void;
  114459. /**
  114460. * Sets a texture to the according uniform.
  114461. * @param channel The texture channel
  114462. * @param uniform The uniform to set
  114463. * @param texture The texture to apply
  114464. */
  114465. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  114466. private _bindSamplerUniformToChannel;
  114467. private _getTextureWrapMode;
  114468. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114469. /**
  114470. * Sets an array of texture to the webGL context
  114471. * @param channel defines the channel where the texture array must be set
  114472. * @param uniform defines the associated uniform location
  114473. * @param textures defines the array of textures to bind
  114474. */
  114475. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  114476. /** @hidden */
  114477. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  114478. private _setTextureParameterFloat;
  114479. private _setTextureParameterInteger;
  114480. /**
  114481. * Unbind all vertex attributes from the webGL context
  114482. */
  114483. unbindAllAttributes(): void;
  114484. /**
  114485. * 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
  114486. */
  114487. releaseEffects(): void;
  114488. /**
  114489. * Dispose and release all associated resources
  114490. */
  114491. dispose(): void;
  114492. /**
  114493. * Attach a new callback raised when context lost event is fired
  114494. * @param callback defines the callback to call
  114495. */
  114496. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114497. /**
  114498. * Attach a new callback raised when context restored event is fired
  114499. * @param callback defines the callback to call
  114500. */
  114501. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114502. /**
  114503. * Get the current error code of the webGL context
  114504. * @returns the error code
  114505. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114506. */
  114507. getError(): number;
  114508. private _canRenderToFloatFramebuffer;
  114509. private _canRenderToHalfFloatFramebuffer;
  114510. private _canRenderToFramebuffer;
  114511. /** @hidden */
  114512. _getWebGLTextureType(type: number): number;
  114513. /** @hidden */
  114514. _getInternalFormat(format: number): number;
  114515. /** @hidden */
  114516. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  114517. /** @hidden */
  114518. _getRGBAMultiSampleBufferFormat(type: number): number;
  114519. /** @hidden */
  114520. _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;
  114521. /**
  114522. * Loads a file from a url
  114523. * @param url url to load
  114524. * @param onSuccess callback called when the file successfully loads
  114525. * @param onProgress callback called while file is loading (if the server supports this mode)
  114526. * @param offlineProvider defines the offline provider for caching
  114527. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114528. * @param onError callback called when the file fails to load
  114529. * @returns a file request object
  114530. * @hidden
  114531. */
  114532. 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;
  114533. /**
  114534. * Reads pixels from the current frame buffer. Please note that this function can be slow
  114535. * @param x defines the x coordinate of the rectangle where pixels must be read
  114536. * @param y defines the y coordinate of the rectangle where pixels must be read
  114537. * @param width defines the width of the rectangle where pixels must be read
  114538. * @param height defines the height of the rectangle where pixels must be read
  114539. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  114540. * @returns a Uint8Array containing RGBA colors
  114541. */
  114542. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  114543. private static _isSupported;
  114544. /**
  114545. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  114546. * @returns true if the engine can be created
  114547. * @ignorenaming
  114548. */
  114549. static isSupported(): boolean;
  114550. /**
  114551. * Find the next highest power of two.
  114552. * @param x Number to start search from.
  114553. * @return Next highest power of two.
  114554. */
  114555. static CeilingPOT(x: number): number;
  114556. /**
  114557. * Find the next lowest power of two.
  114558. * @param x Number to start search from.
  114559. * @return Next lowest power of two.
  114560. */
  114561. static FloorPOT(x: number): number;
  114562. /**
  114563. * Find the nearest power of two.
  114564. * @param x Number to start search from.
  114565. * @return Next nearest power of two.
  114566. */
  114567. static NearestPOT(x: number): number;
  114568. /**
  114569. * Get the closest exponent of two
  114570. * @param value defines the value to approximate
  114571. * @param max defines the maximum value to return
  114572. * @param mode defines how to define the closest value
  114573. * @returns closest exponent of two of the given value
  114574. */
  114575. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  114576. /**
  114577. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  114578. * @param func - the function to be called
  114579. * @param requester - the object that will request the next frame. Falls back to window.
  114580. * @returns frame number
  114581. */
  114582. static QueueNewFrame(func: () => void, requester?: any): number;
  114583. /**
  114584. * Gets host document
  114585. * @returns the host document object
  114586. */
  114587. getHostDocument(): Nullable<Document>;
  114588. }
  114589. }
  114590. declare module BABYLON {
  114591. /**
  114592. * Class representing spherical harmonics coefficients to the 3rd degree
  114593. */
  114594. export class SphericalHarmonics {
  114595. /**
  114596. * Defines whether or not the harmonics have been prescaled for rendering.
  114597. */
  114598. preScaled: boolean;
  114599. /**
  114600. * The l0,0 coefficients of the spherical harmonics
  114601. */
  114602. l00: Vector3;
  114603. /**
  114604. * The l1,-1 coefficients of the spherical harmonics
  114605. */
  114606. l1_1: Vector3;
  114607. /**
  114608. * The l1,0 coefficients of the spherical harmonics
  114609. */
  114610. l10: Vector3;
  114611. /**
  114612. * The l1,1 coefficients of the spherical harmonics
  114613. */
  114614. l11: Vector3;
  114615. /**
  114616. * The l2,-2 coefficients of the spherical harmonics
  114617. */
  114618. l2_2: Vector3;
  114619. /**
  114620. * The l2,-1 coefficients of the spherical harmonics
  114621. */
  114622. l2_1: Vector3;
  114623. /**
  114624. * The l2,0 coefficients of the spherical harmonics
  114625. */
  114626. l20: Vector3;
  114627. /**
  114628. * The l2,1 coefficients of the spherical harmonics
  114629. */
  114630. l21: Vector3;
  114631. /**
  114632. * The l2,2 coefficients of the spherical harmonics
  114633. */
  114634. l22: Vector3;
  114635. /**
  114636. * Adds a light to the spherical harmonics
  114637. * @param direction the direction of the light
  114638. * @param color the color of the light
  114639. * @param deltaSolidAngle the delta solid angle of the light
  114640. */
  114641. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  114642. /**
  114643. * Scales the spherical harmonics by the given amount
  114644. * @param scale the amount to scale
  114645. */
  114646. scaleInPlace(scale: number): void;
  114647. /**
  114648. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  114649. *
  114650. * ```
  114651. * E_lm = A_l * L_lm
  114652. * ```
  114653. *
  114654. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  114655. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  114656. * the scaling factors are given in equation 9.
  114657. */
  114658. convertIncidentRadianceToIrradiance(): void;
  114659. /**
  114660. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  114661. *
  114662. * ```
  114663. * L = (1/pi) * E * rho
  114664. * ```
  114665. *
  114666. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  114667. */
  114668. convertIrradianceToLambertianRadiance(): void;
  114669. /**
  114670. * Integrates the reconstruction coefficients directly in to the SH preventing further
  114671. * required operations at run time.
  114672. *
  114673. * This is simply done by scaling back the SH with Ylm constants parameter.
  114674. * The trigonometric part being applied by the shader at run time.
  114675. */
  114676. preScaleForRendering(): void;
  114677. /**
  114678. * Constructs a spherical harmonics from an array.
  114679. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  114680. * @returns the spherical harmonics
  114681. */
  114682. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  114683. /**
  114684. * Gets the spherical harmonics from polynomial
  114685. * @param polynomial the spherical polynomial
  114686. * @returns the spherical harmonics
  114687. */
  114688. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  114689. }
  114690. /**
  114691. * Class representing spherical polynomial coefficients to the 3rd degree
  114692. */
  114693. export class SphericalPolynomial {
  114694. private _harmonics;
  114695. /**
  114696. * The spherical harmonics used to create the polynomials.
  114697. */
  114698. get preScaledHarmonics(): SphericalHarmonics;
  114699. /**
  114700. * The x coefficients of the spherical polynomial
  114701. */
  114702. x: Vector3;
  114703. /**
  114704. * The y coefficients of the spherical polynomial
  114705. */
  114706. y: Vector3;
  114707. /**
  114708. * The z coefficients of the spherical polynomial
  114709. */
  114710. z: Vector3;
  114711. /**
  114712. * The xx coefficients of the spherical polynomial
  114713. */
  114714. xx: Vector3;
  114715. /**
  114716. * The yy coefficients of the spherical polynomial
  114717. */
  114718. yy: Vector3;
  114719. /**
  114720. * The zz coefficients of the spherical polynomial
  114721. */
  114722. zz: Vector3;
  114723. /**
  114724. * The xy coefficients of the spherical polynomial
  114725. */
  114726. xy: Vector3;
  114727. /**
  114728. * The yz coefficients of the spherical polynomial
  114729. */
  114730. yz: Vector3;
  114731. /**
  114732. * The zx coefficients of the spherical polynomial
  114733. */
  114734. zx: Vector3;
  114735. /**
  114736. * Adds an ambient color to the spherical polynomial
  114737. * @param color the color to add
  114738. */
  114739. addAmbient(color: Color3): void;
  114740. /**
  114741. * Scales the spherical polynomial by the given amount
  114742. * @param scale the amount to scale
  114743. */
  114744. scaleInPlace(scale: number): void;
  114745. /**
  114746. * Gets the spherical polynomial from harmonics
  114747. * @param harmonics the spherical harmonics
  114748. * @returns the spherical polynomial
  114749. */
  114750. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  114751. /**
  114752. * Constructs a spherical polynomial from an array.
  114753. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  114754. * @returns the spherical polynomial
  114755. */
  114756. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  114757. }
  114758. }
  114759. declare module BABYLON {
  114760. /**
  114761. * Defines the source of the internal texture
  114762. */
  114763. export enum InternalTextureSource {
  114764. /**
  114765. * The source of the texture data is unknown
  114766. */
  114767. Unknown = 0,
  114768. /**
  114769. * Texture data comes from an URL
  114770. */
  114771. Url = 1,
  114772. /**
  114773. * Texture data is only used for temporary storage
  114774. */
  114775. Temp = 2,
  114776. /**
  114777. * Texture data comes from raw data (ArrayBuffer)
  114778. */
  114779. Raw = 3,
  114780. /**
  114781. * Texture content is dynamic (video or dynamic texture)
  114782. */
  114783. Dynamic = 4,
  114784. /**
  114785. * Texture content is generated by rendering to it
  114786. */
  114787. RenderTarget = 5,
  114788. /**
  114789. * Texture content is part of a multi render target process
  114790. */
  114791. MultiRenderTarget = 6,
  114792. /**
  114793. * Texture data comes from a cube data file
  114794. */
  114795. Cube = 7,
  114796. /**
  114797. * Texture data comes from a raw cube data
  114798. */
  114799. CubeRaw = 8,
  114800. /**
  114801. * Texture data come from a prefiltered cube data file
  114802. */
  114803. CubePrefiltered = 9,
  114804. /**
  114805. * Texture content is raw 3D data
  114806. */
  114807. Raw3D = 10,
  114808. /**
  114809. * Texture content is raw 2D array data
  114810. */
  114811. Raw2DArray = 11,
  114812. /**
  114813. * Texture content is a depth texture
  114814. */
  114815. Depth = 12,
  114816. /**
  114817. * Texture data comes from a raw cube data encoded with RGBD
  114818. */
  114819. CubeRawRGBD = 13
  114820. }
  114821. /**
  114822. * Class used to store data associated with WebGL texture data for the engine
  114823. * This class should not be used directly
  114824. */
  114825. export class InternalTexture {
  114826. /** @hidden */
  114827. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  114828. /**
  114829. * Defines if the texture is ready
  114830. */
  114831. isReady: boolean;
  114832. /**
  114833. * Defines if the texture is a cube texture
  114834. */
  114835. isCube: boolean;
  114836. /**
  114837. * Defines if the texture contains 3D data
  114838. */
  114839. is3D: boolean;
  114840. /**
  114841. * Defines if the texture contains 2D array data
  114842. */
  114843. is2DArray: boolean;
  114844. /**
  114845. * Defines if the texture contains multiview data
  114846. */
  114847. isMultiview: boolean;
  114848. /**
  114849. * Gets the URL used to load this texture
  114850. */
  114851. url: string;
  114852. /**
  114853. * Gets the sampling mode of the texture
  114854. */
  114855. samplingMode: number;
  114856. /**
  114857. * Gets a boolean indicating if the texture needs mipmaps generation
  114858. */
  114859. generateMipMaps: boolean;
  114860. /**
  114861. * Gets the number of samples used by the texture (WebGL2+ only)
  114862. */
  114863. samples: number;
  114864. /**
  114865. * Gets the type of the texture (int, float...)
  114866. */
  114867. type: number;
  114868. /**
  114869. * Gets the format of the texture (RGB, RGBA...)
  114870. */
  114871. format: number;
  114872. /**
  114873. * Observable called when the texture is loaded
  114874. */
  114875. onLoadedObservable: Observable<InternalTexture>;
  114876. /**
  114877. * Gets the width of the texture
  114878. */
  114879. width: number;
  114880. /**
  114881. * Gets the height of the texture
  114882. */
  114883. height: number;
  114884. /**
  114885. * Gets the depth of the texture
  114886. */
  114887. depth: number;
  114888. /**
  114889. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  114890. */
  114891. baseWidth: number;
  114892. /**
  114893. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  114894. */
  114895. baseHeight: number;
  114896. /**
  114897. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  114898. */
  114899. baseDepth: number;
  114900. /**
  114901. * Gets a boolean indicating if the texture is inverted on Y axis
  114902. */
  114903. invertY: boolean;
  114904. /** @hidden */
  114905. _invertVScale: boolean;
  114906. /** @hidden */
  114907. _associatedChannel: number;
  114908. /** @hidden */
  114909. _source: InternalTextureSource;
  114910. /** @hidden */
  114911. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  114912. /** @hidden */
  114913. _bufferView: Nullable<ArrayBufferView>;
  114914. /** @hidden */
  114915. _bufferViewArray: Nullable<ArrayBufferView[]>;
  114916. /** @hidden */
  114917. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  114918. /** @hidden */
  114919. _size: number;
  114920. /** @hidden */
  114921. _extension: string;
  114922. /** @hidden */
  114923. _files: Nullable<string[]>;
  114924. /** @hidden */
  114925. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114926. /** @hidden */
  114927. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114928. /** @hidden */
  114929. _framebuffer: Nullable<WebGLFramebuffer>;
  114930. /** @hidden */
  114931. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  114932. /** @hidden */
  114933. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  114934. /** @hidden */
  114935. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  114936. /** @hidden */
  114937. _attachments: Nullable<number[]>;
  114938. /** @hidden */
  114939. _textureArray: Nullable<InternalTexture[]>;
  114940. /** @hidden */
  114941. _cachedCoordinatesMode: Nullable<number>;
  114942. /** @hidden */
  114943. _cachedWrapU: Nullable<number>;
  114944. /** @hidden */
  114945. _cachedWrapV: Nullable<number>;
  114946. /** @hidden */
  114947. _cachedWrapR: Nullable<number>;
  114948. /** @hidden */
  114949. _cachedAnisotropicFilteringLevel: Nullable<number>;
  114950. /** @hidden */
  114951. _isDisabled: boolean;
  114952. /** @hidden */
  114953. _compression: Nullable<string>;
  114954. /** @hidden */
  114955. _generateStencilBuffer: boolean;
  114956. /** @hidden */
  114957. _generateDepthBuffer: boolean;
  114958. /** @hidden */
  114959. _comparisonFunction: number;
  114960. /** @hidden */
  114961. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  114962. /** @hidden */
  114963. _lodGenerationScale: number;
  114964. /** @hidden */
  114965. _lodGenerationOffset: number;
  114966. /** @hidden */
  114967. _depthStencilTexture: Nullable<InternalTexture>;
  114968. /** @hidden */
  114969. _colorTextureArray: Nullable<WebGLTexture>;
  114970. /** @hidden */
  114971. _depthStencilTextureArray: Nullable<WebGLTexture>;
  114972. /** @hidden */
  114973. _lodTextureHigh: Nullable<BaseTexture>;
  114974. /** @hidden */
  114975. _lodTextureMid: Nullable<BaseTexture>;
  114976. /** @hidden */
  114977. _lodTextureLow: Nullable<BaseTexture>;
  114978. /** @hidden */
  114979. _isRGBD: boolean;
  114980. /** @hidden */
  114981. _linearSpecularLOD: boolean;
  114982. /** @hidden */
  114983. _irradianceTexture: Nullable<BaseTexture>;
  114984. /** @hidden */
  114985. _webGLTexture: Nullable<WebGLTexture>;
  114986. /** @hidden */
  114987. _references: number;
  114988. private _engine;
  114989. /**
  114990. * Gets the Engine the texture belongs to.
  114991. * @returns The babylon engine
  114992. */
  114993. getEngine(): ThinEngine;
  114994. /**
  114995. * Gets the data source type of the texture
  114996. */
  114997. get source(): InternalTextureSource;
  114998. /**
  114999. * Creates a new InternalTexture
  115000. * @param engine defines the engine to use
  115001. * @param source defines the type of data that will be used
  115002. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115003. */
  115004. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115005. /**
  115006. * Increments the number of references (ie. the number of Texture that point to it)
  115007. */
  115008. incrementReferences(): void;
  115009. /**
  115010. * Change the size of the texture (not the size of the content)
  115011. * @param width defines the new width
  115012. * @param height defines the new height
  115013. * @param depth defines the new depth (1 by default)
  115014. */
  115015. updateSize(width: int, height: int, depth?: int): void;
  115016. /** @hidden */
  115017. _rebuild(): void;
  115018. /** @hidden */
  115019. _swapAndDie(target: InternalTexture): void;
  115020. /**
  115021. * Dispose the current allocated resources
  115022. */
  115023. dispose(): void;
  115024. }
  115025. }
  115026. declare module BABYLON {
  115027. /**
  115028. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115030. */
  115031. export class Analyser {
  115032. /**
  115033. * Gets or sets the smoothing
  115034. * @ignorenaming
  115035. */
  115036. SMOOTHING: number;
  115037. /**
  115038. * Gets or sets the FFT table size
  115039. * @ignorenaming
  115040. */
  115041. FFT_SIZE: number;
  115042. /**
  115043. * Gets or sets the bar graph amplitude
  115044. * @ignorenaming
  115045. */
  115046. BARGRAPHAMPLITUDE: number;
  115047. /**
  115048. * Gets or sets the position of the debug canvas
  115049. * @ignorenaming
  115050. */
  115051. DEBUGCANVASPOS: {
  115052. x: number;
  115053. y: number;
  115054. };
  115055. /**
  115056. * Gets or sets the debug canvas size
  115057. * @ignorenaming
  115058. */
  115059. DEBUGCANVASSIZE: {
  115060. width: number;
  115061. height: number;
  115062. };
  115063. private _byteFreqs;
  115064. private _byteTime;
  115065. private _floatFreqs;
  115066. private _webAudioAnalyser;
  115067. private _debugCanvas;
  115068. private _debugCanvasContext;
  115069. private _scene;
  115070. private _registerFunc;
  115071. private _audioEngine;
  115072. /**
  115073. * Creates a new analyser
  115074. * @param scene defines hosting scene
  115075. */
  115076. constructor(scene: Scene);
  115077. /**
  115078. * Get the number of data values you will have to play with for the visualization
  115079. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115080. * @returns a number
  115081. */
  115082. getFrequencyBinCount(): number;
  115083. /**
  115084. * Gets the current frequency data as a byte array
  115085. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115086. * @returns a Uint8Array
  115087. */
  115088. getByteFrequencyData(): Uint8Array;
  115089. /**
  115090. * Gets the current waveform as a byte array
  115091. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115092. * @returns a Uint8Array
  115093. */
  115094. getByteTimeDomainData(): Uint8Array;
  115095. /**
  115096. * Gets the current frequency data as a float array
  115097. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115098. * @returns a Float32Array
  115099. */
  115100. getFloatFrequencyData(): Float32Array;
  115101. /**
  115102. * Renders the debug canvas
  115103. */
  115104. drawDebugCanvas(): void;
  115105. /**
  115106. * Stops rendering the debug canvas and removes it
  115107. */
  115108. stopDebugCanvas(): void;
  115109. /**
  115110. * Connects two audio nodes
  115111. * @param inputAudioNode defines first node to connect
  115112. * @param outputAudioNode defines second node to connect
  115113. */
  115114. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115115. /**
  115116. * Releases all associated resources
  115117. */
  115118. dispose(): void;
  115119. }
  115120. }
  115121. declare module BABYLON {
  115122. /**
  115123. * This represents an audio engine and it is responsible
  115124. * to play, synchronize and analyse sounds throughout the application.
  115125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115126. */
  115127. export interface IAudioEngine extends IDisposable {
  115128. /**
  115129. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115130. */
  115131. readonly canUseWebAudio: boolean;
  115132. /**
  115133. * Gets the current AudioContext if available.
  115134. */
  115135. readonly audioContext: Nullable<AudioContext>;
  115136. /**
  115137. * The master gain node defines the global audio volume of your audio engine.
  115138. */
  115139. readonly masterGain: GainNode;
  115140. /**
  115141. * Gets whether or not mp3 are supported by your browser.
  115142. */
  115143. readonly isMP3supported: boolean;
  115144. /**
  115145. * Gets whether or not ogg are supported by your browser.
  115146. */
  115147. readonly isOGGsupported: boolean;
  115148. /**
  115149. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115150. * @ignoreNaming
  115151. */
  115152. WarnedWebAudioUnsupported: boolean;
  115153. /**
  115154. * Defines if the audio engine relies on a custom unlocked button.
  115155. * In this case, the embedded button will not be displayed.
  115156. */
  115157. useCustomUnlockedButton: boolean;
  115158. /**
  115159. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115160. */
  115161. readonly unlocked: boolean;
  115162. /**
  115163. * Event raised when audio has been unlocked on the browser.
  115164. */
  115165. onAudioUnlockedObservable: Observable<AudioEngine>;
  115166. /**
  115167. * Event raised when audio has been locked on the browser.
  115168. */
  115169. onAudioLockedObservable: Observable<AudioEngine>;
  115170. /**
  115171. * Flags the audio engine in Locked state.
  115172. * This happens due to new browser policies preventing audio to autoplay.
  115173. */
  115174. lock(): void;
  115175. /**
  115176. * Unlocks the audio engine once a user action has been done on the dom.
  115177. * This is helpful to resume play once browser policies have been satisfied.
  115178. */
  115179. unlock(): void;
  115180. /**
  115181. * Gets the global volume sets on the master gain.
  115182. * @returns the global volume if set or -1 otherwise
  115183. */
  115184. getGlobalVolume(): number;
  115185. /**
  115186. * Sets the global volume of your experience (sets on the master gain).
  115187. * @param newVolume Defines the new global volume of the application
  115188. */
  115189. setGlobalVolume(newVolume: number): void;
  115190. /**
  115191. * Connect the audio engine to an audio analyser allowing some amazing
  115192. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115194. * @param analyser The analyser to connect to the engine
  115195. */
  115196. connectToAnalyser(analyser: Analyser): void;
  115197. }
  115198. /**
  115199. * This represents the default audio engine used in babylon.
  115200. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115202. */
  115203. export class AudioEngine implements IAudioEngine {
  115204. private _audioContext;
  115205. private _audioContextInitialized;
  115206. private _muteButton;
  115207. private _hostElement;
  115208. /**
  115209. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115210. */
  115211. canUseWebAudio: boolean;
  115212. /**
  115213. * The master gain node defines the global audio volume of your audio engine.
  115214. */
  115215. masterGain: GainNode;
  115216. /**
  115217. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115218. * @ignoreNaming
  115219. */
  115220. WarnedWebAudioUnsupported: boolean;
  115221. /**
  115222. * Gets whether or not mp3 are supported by your browser.
  115223. */
  115224. isMP3supported: boolean;
  115225. /**
  115226. * Gets whether or not ogg are supported by your browser.
  115227. */
  115228. isOGGsupported: boolean;
  115229. /**
  115230. * Gets whether audio has been unlocked on the device.
  115231. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115232. * a user interaction has happened.
  115233. */
  115234. unlocked: boolean;
  115235. /**
  115236. * Defines if the audio engine relies on a custom unlocked button.
  115237. * In this case, the embedded button will not be displayed.
  115238. */
  115239. useCustomUnlockedButton: boolean;
  115240. /**
  115241. * Event raised when audio has been unlocked on the browser.
  115242. */
  115243. onAudioUnlockedObservable: Observable<AudioEngine>;
  115244. /**
  115245. * Event raised when audio has been locked on the browser.
  115246. */
  115247. onAudioLockedObservable: Observable<AudioEngine>;
  115248. /**
  115249. * Gets the current AudioContext if available.
  115250. */
  115251. get audioContext(): Nullable<AudioContext>;
  115252. private _connectedAnalyser;
  115253. /**
  115254. * Instantiates a new audio engine.
  115255. *
  115256. * There should be only one per page as some browsers restrict the number
  115257. * of audio contexts you can create.
  115258. * @param hostElement defines the host element where to display the mute icon if necessary
  115259. */
  115260. constructor(hostElement?: Nullable<HTMLElement>);
  115261. /**
  115262. * Flags the audio engine in Locked state.
  115263. * This happens due to new browser policies preventing audio to autoplay.
  115264. */
  115265. lock(): void;
  115266. /**
  115267. * Unlocks the audio engine once a user action has been done on the dom.
  115268. * This is helpful to resume play once browser policies have been satisfied.
  115269. */
  115270. unlock(): void;
  115271. private _resumeAudioContext;
  115272. private _initializeAudioContext;
  115273. private _tryToRun;
  115274. private _triggerRunningState;
  115275. private _triggerSuspendedState;
  115276. private _displayMuteButton;
  115277. private _moveButtonToTopLeft;
  115278. private _onResize;
  115279. private _hideMuteButton;
  115280. /**
  115281. * Destroy and release the resources associated with the audio ccontext.
  115282. */
  115283. dispose(): void;
  115284. /**
  115285. * Gets the global volume sets on the master gain.
  115286. * @returns the global volume if set or -1 otherwise
  115287. */
  115288. getGlobalVolume(): number;
  115289. /**
  115290. * Sets the global volume of your experience (sets on the master gain).
  115291. * @param newVolume Defines the new global volume of the application
  115292. */
  115293. setGlobalVolume(newVolume: number): void;
  115294. /**
  115295. * Connect the audio engine to an audio analyser allowing some amazing
  115296. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115298. * @param analyser The analyser to connect to the engine
  115299. */
  115300. connectToAnalyser(analyser: Analyser): void;
  115301. }
  115302. }
  115303. declare module BABYLON {
  115304. /**
  115305. * Interface used to present a loading screen while loading a scene
  115306. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115307. */
  115308. export interface ILoadingScreen {
  115309. /**
  115310. * Function called to display the loading screen
  115311. */
  115312. displayLoadingUI: () => void;
  115313. /**
  115314. * Function called to hide the loading screen
  115315. */
  115316. hideLoadingUI: () => void;
  115317. /**
  115318. * Gets or sets the color to use for the background
  115319. */
  115320. loadingUIBackgroundColor: string;
  115321. /**
  115322. * Gets or sets the text to display while loading
  115323. */
  115324. loadingUIText: string;
  115325. }
  115326. /**
  115327. * Class used for the default loading screen
  115328. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115329. */
  115330. export class DefaultLoadingScreen implements ILoadingScreen {
  115331. private _renderingCanvas;
  115332. private _loadingText;
  115333. private _loadingDivBackgroundColor;
  115334. private _loadingDiv;
  115335. private _loadingTextDiv;
  115336. /** Gets or sets the logo url to use for the default loading screen */
  115337. static DefaultLogoUrl: string;
  115338. /** Gets or sets the spinner url to use for the default loading screen */
  115339. static DefaultSpinnerUrl: string;
  115340. /**
  115341. * Creates a new default loading screen
  115342. * @param _renderingCanvas defines the canvas used to render the scene
  115343. * @param _loadingText defines the default text to display
  115344. * @param _loadingDivBackgroundColor defines the default background color
  115345. */
  115346. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115347. /**
  115348. * Function called to display the loading screen
  115349. */
  115350. displayLoadingUI(): void;
  115351. /**
  115352. * Function called to hide the loading screen
  115353. */
  115354. hideLoadingUI(): void;
  115355. /**
  115356. * Gets or sets the text to display while loading
  115357. */
  115358. set loadingUIText(text: string);
  115359. get loadingUIText(): string;
  115360. /**
  115361. * Gets or sets the color to use for the background
  115362. */
  115363. get loadingUIBackgroundColor(): string;
  115364. set loadingUIBackgroundColor(color: string);
  115365. private _resizeLoadingUI;
  115366. }
  115367. }
  115368. declare module BABYLON {
  115369. /**
  115370. * Interface for any object that can request an animation frame
  115371. */
  115372. export interface ICustomAnimationFrameRequester {
  115373. /**
  115374. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115375. */
  115376. renderFunction?: Function;
  115377. /**
  115378. * Called to request the next frame to render to
  115379. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115380. */
  115381. requestAnimationFrame: Function;
  115382. /**
  115383. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115384. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115385. */
  115386. requestID?: number;
  115387. }
  115388. }
  115389. declare module BABYLON {
  115390. /**
  115391. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115392. */
  115393. export class PerformanceMonitor {
  115394. private _enabled;
  115395. private _rollingFrameTime;
  115396. private _lastFrameTimeMs;
  115397. /**
  115398. * constructor
  115399. * @param frameSampleSize The number of samples required to saturate the sliding window
  115400. */
  115401. constructor(frameSampleSize?: number);
  115402. /**
  115403. * Samples current frame
  115404. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115405. */
  115406. sampleFrame(timeMs?: number): void;
  115407. /**
  115408. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115409. */
  115410. get averageFrameTime(): number;
  115411. /**
  115412. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115413. */
  115414. get averageFrameTimeVariance(): number;
  115415. /**
  115416. * Returns the frame time of the most recent frame
  115417. */
  115418. get instantaneousFrameTime(): number;
  115419. /**
  115420. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115421. */
  115422. get averageFPS(): number;
  115423. /**
  115424. * Returns the average framerate in frames per second using the most recent frame time
  115425. */
  115426. get instantaneousFPS(): number;
  115427. /**
  115428. * Returns true if enough samples have been taken to completely fill the sliding window
  115429. */
  115430. get isSaturated(): boolean;
  115431. /**
  115432. * Enables contributions to the sliding window sample set
  115433. */
  115434. enable(): void;
  115435. /**
  115436. * Disables contributions to the sliding window sample set
  115437. * Samples will not be interpolated over the disabled period
  115438. */
  115439. disable(): void;
  115440. /**
  115441. * Returns true if sampling is enabled
  115442. */
  115443. get isEnabled(): boolean;
  115444. /**
  115445. * Resets performance monitor
  115446. */
  115447. reset(): void;
  115448. }
  115449. /**
  115450. * RollingAverage
  115451. *
  115452. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  115453. */
  115454. export class RollingAverage {
  115455. /**
  115456. * Current average
  115457. */
  115458. average: number;
  115459. /**
  115460. * Current variance
  115461. */
  115462. variance: number;
  115463. protected _samples: Array<number>;
  115464. protected _sampleCount: number;
  115465. protected _pos: number;
  115466. protected _m2: number;
  115467. /**
  115468. * constructor
  115469. * @param length The number of samples required to saturate the sliding window
  115470. */
  115471. constructor(length: number);
  115472. /**
  115473. * Adds a sample to the sample set
  115474. * @param v The sample value
  115475. */
  115476. add(v: number): void;
  115477. /**
  115478. * Returns previously added values or null if outside of history or outside the sliding window domain
  115479. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  115480. * @return Value previously recorded with add() or null if outside of range
  115481. */
  115482. history(i: number): number;
  115483. /**
  115484. * Returns true if enough samples have been taken to completely fill the sliding window
  115485. * @return true if sample-set saturated
  115486. */
  115487. isSaturated(): boolean;
  115488. /**
  115489. * Resets the rolling average (equivalent to 0 samples taken so far)
  115490. */
  115491. reset(): void;
  115492. /**
  115493. * Wraps a value around the sample range boundaries
  115494. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  115495. * @return Wrapped position in sample range
  115496. */
  115497. protected _wrapPosition(i: number): number;
  115498. }
  115499. }
  115500. declare module BABYLON {
  115501. /**
  115502. * This class is used to track a performance counter which is number based.
  115503. * The user has access to many properties which give statistics of different nature.
  115504. *
  115505. * The implementer can track two kinds of Performance Counter: time and count.
  115506. * 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.
  115507. * 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.
  115508. */
  115509. export class PerfCounter {
  115510. /**
  115511. * Gets or sets a global boolean to turn on and off all the counters
  115512. */
  115513. static Enabled: boolean;
  115514. /**
  115515. * Returns the smallest value ever
  115516. */
  115517. get min(): number;
  115518. /**
  115519. * Returns the biggest value ever
  115520. */
  115521. get max(): number;
  115522. /**
  115523. * Returns the average value since the performance counter is running
  115524. */
  115525. get average(): number;
  115526. /**
  115527. * Returns the average value of the last second the counter was monitored
  115528. */
  115529. get lastSecAverage(): number;
  115530. /**
  115531. * Returns the current value
  115532. */
  115533. get current(): number;
  115534. /**
  115535. * Gets the accumulated total
  115536. */
  115537. get total(): number;
  115538. /**
  115539. * Gets the total value count
  115540. */
  115541. get count(): number;
  115542. /**
  115543. * Creates a new counter
  115544. */
  115545. constructor();
  115546. /**
  115547. * Call this method to start monitoring a new frame.
  115548. * 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.
  115549. */
  115550. fetchNewFrame(): void;
  115551. /**
  115552. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  115553. * @param newCount the count value to add to the monitored count
  115554. * @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.
  115555. */
  115556. addCount(newCount: number, fetchResult: boolean): void;
  115557. /**
  115558. * Start monitoring this performance counter
  115559. */
  115560. beginMonitoring(): void;
  115561. /**
  115562. * Compute the time lapsed since the previous beginMonitoring() call.
  115563. * @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
  115564. */
  115565. endMonitoring(newFrame?: boolean): void;
  115566. private _fetchResult;
  115567. private _startMonitoringTime;
  115568. private _min;
  115569. private _max;
  115570. private _average;
  115571. private _current;
  115572. private _totalValueCount;
  115573. private _totalAccumulated;
  115574. private _lastSecAverage;
  115575. private _lastSecAccumulated;
  115576. private _lastSecTime;
  115577. private _lastSecValueCount;
  115578. }
  115579. }
  115580. declare module BABYLON {
  115581. interface ThinEngine {
  115582. /**
  115583. * Sets alpha constants used by some alpha blending modes
  115584. * @param r defines the red component
  115585. * @param g defines the green component
  115586. * @param b defines the blue component
  115587. * @param a defines the alpha component
  115588. */
  115589. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115590. /**
  115591. * Sets the current alpha mode
  115592. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  115593. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115594. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115595. */
  115596. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115597. /**
  115598. * Gets the current alpha mode
  115599. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115600. * @returns the current alpha mode
  115601. */
  115602. getAlphaMode(): number;
  115603. /**
  115604. * Sets the current alpha equation
  115605. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  115606. */
  115607. setAlphaEquation(equation: number): void;
  115608. /**
  115609. * Gets the current alpha equation.
  115610. * @returns the current alpha equation
  115611. */
  115612. getAlphaEquation(): number;
  115613. }
  115614. }
  115615. declare module BABYLON {
  115616. interface ThinEngine {
  115617. /** @hidden */
  115618. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  115619. }
  115620. }
  115621. declare module BABYLON {
  115622. /**
  115623. * Defines the interface used by display changed events
  115624. */
  115625. export interface IDisplayChangedEventArgs {
  115626. /** Gets the vrDisplay object (if any) */
  115627. vrDisplay: Nullable<any>;
  115628. /** Gets a boolean indicating if webVR is supported */
  115629. vrSupported: boolean;
  115630. }
  115631. /**
  115632. * Defines the interface used by objects containing a viewport (like a camera)
  115633. */
  115634. interface IViewportOwnerLike {
  115635. /**
  115636. * Gets or sets the viewport
  115637. */
  115638. viewport: IViewportLike;
  115639. }
  115640. /**
  115641. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  115642. */
  115643. export class Engine extends ThinEngine {
  115644. /** Defines that alpha blending is disabled */
  115645. static readonly ALPHA_DISABLE: number;
  115646. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  115647. static readonly ALPHA_ADD: number;
  115648. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  115649. static readonly ALPHA_COMBINE: number;
  115650. /** Defines that alpha blending to DEST - SRC * DEST */
  115651. static readonly ALPHA_SUBTRACT: number;
  115652. /** Defines that alpha blending to SRC * DEST */
  115653. static readonly ALPHA_MULTIPLY: number;
  115654. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  115655. static readonly ALPHA_MAXIMIZED: number;
  115656. /** Defines that alpha blending to SRC + DEST */
  115657. static readonly ALPHA_ONEONE: number;
  115658. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  115659. static readonly ALPHA_PREMULTIPLIED: number;
  115660. /**
  115661. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  115662. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  115663. */
  115664. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  115665. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  115666. static readonly ALPHA_INTERPOLATE: number;
  115667. /**
  115668. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  115669. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  115670. */
  115671. static readonly ALPHA_SCREENMODE: number;
  115672. /** Defines that the ressource is not delayed*/
  115673. static readonly DELAYLOADSTATE_NONE: number;
  115674. /** Defines that the ressource was successfully delay loaded */
  115675. static readonly DELAYLOADSTATE_LOADED: number;
  115676. /** Defines that the ressource is currently delay loading */
  115677. static readonly DELAYLOADSTATE_LOADING: number;
  115678. /** Defines that the ressource is delayed and has not started loading */
  115679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  115680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  115681. static readonly NEVER: number;
  115682. /** 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 */
  115683. static readonly ALWAYS: number;
  115684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  115685. static readonly LESS: number;
  115686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  115687. static readonly EQUAL: number;
  115688. /** 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 */
  115689. static readonly LEQUAL: number;
  115690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  115691. static readonly GREATER: number;
  115692. /** 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 */
  115693. static readonly GEQUAL: number;
  115694. /** 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 */
  115695. static readonly NOTEQUAL: number;
  115696. /** Passed to stencilOperation to specify that stencil value must be kept */
  115697. static readonly KEEP: number;
  115698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115699. static readonly REPLACE: number;
  115700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  115701. static readonly INCR: number;
  115702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  115703. static readonly DECR: number;
  115704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  115705. static readonly INVERT: number;
  115706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  115707. static readonly INCR_WRAP: number;
  115708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  115709. static readonly DECR_WRAP: number;
  115710. /** Texture is not repeating outside of 0..1 UVs */
  115711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  115712. /** Texture is repeating outside of 0..1 UVs */
  115713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  115714. /** Texture is repeating and mirrored */
  115715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  115716. /** ALPHA */
  115717. static readonly TEXTUREFORMAT_ALPHA: number;
  115718. /** LUMINANCE */
  115719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  115720. /** LUMINANCE_ALPHA */
  115721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  115722. /** RGB */
  115723. static readonly TEXTUREFORMAT_RGB: number;
  115724. /** RGBA */
  115725. static readonly TEXTUREFORMAT_RGBA: number;
  115726. /** RED */
  115727. static readonly TEXTUREFORMAT_RED: number;
  115728. /** RED (2nd reference) */
  115729. static readonly TEXTUREFORMAT_R: number;
  115730. /** RG */
  115731. static readonly TEXTUREFORMAT_RG: number;
  115732. /** RED_INTEGER */
  115733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  115734. /** RED_INTEGER (2nd reference) */
  115735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  115736. /** RG_INTEGER */
  115737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  115738. /** RGB_INTEGER */
  115739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  115740. /** RGBA_INTEGER */
  115741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  115742. /** UNSIGNED_BYTE */
  115743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  115744. /** UNSIGNED_BYTE (2nd reference) */
  115745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  115746. /** FLOAT */
  115747. static readonly TEXTURETYPE_FLOAT: number;
  115748. /** HALF_FLOAT */
  115749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  115750. /** BYTE */
  115751. static readonly TEXTURETYPE_BYTE: number;
  115752. /** SHORT */
  115753. static readonly TEXTURETYPE_SHORT: number;
  115754. /** UNSIGNED_SHORT */
  115755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  115756. /** INT */
  115757. static readonly TEXTURETYPE_INT: number;
  115758. /** UNSIGNED_INT */
  115759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  115760. /** UNSIGNED_SHORT_4_4_4_4 */
  115761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  115762. /** UNSIGNED_SHORT_5_5_5_1 */
  115763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  115764. /** UNSIGNED_SHORT_5_6_5 */
  115765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  115766. /** UNSIGNED_INT_2_10_10_10_REV */
  115767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  115768. /** UNSIGNED_INT_24_8 */
  115769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  115770. /** UNSIGNED_INT_10F_11F_11F_REV */
  115771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  115772. /** UNSIGNED_INT_5_9_9_9_REV */
  115773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  115774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  115775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115776. /** nearest is mag = nearest and min = nearest and mip = linear */
  115777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  115778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  115779. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  115780. /** Trilinear is mag = linear and min = linear and mip = linear */
  115781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  115782. /** nearest is mag = nearest and min = nearest and mip = linear */
  115783. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  115784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  115785. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  115786. /** Trilinear is mag = linear and min = linear and mip = linear */
  115787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  115788. /** mag = nearest and min = nearest and mip = nearest */
  115789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  115790. /** mag = nearest and min = linear and mip = nearest */
  115791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  115792. /** mag = nearest and min = linear and mip = linear */
  115793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  115794. /** mag = nearest and min = linear and mip = none */
  115795. static readonly TEXTURE_NEAREST_LINEAR: number;
  115796. /** mag = nearest and min = nearest and mip = none */
  115797. static readonly TEXTURE_NEAREST_NEAREST: number;
  115798. /** mag = linear and min = nearest and mip = nearest */
  115799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  115800. /** mag = linear and min = nearest and mip = linear */
  115801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  115802. /** mag = linear and min = linear and mip = none */
  115803. static readonly TEXTURE_LINEAR_LINEAR: number;
  115804. /** mag = linear and min = nearest and mip = none */
  115805. static readonly TEXTURE_LINEAR_NEAREST: number;
  115806. /** Explicit coordinates mode */
  115807. static readonly TEXTURE_EXPLICIT_MODE: number;
  115808. /** Spherical coordinates mode */
  115809. static readonly TEXTURE_SPHERICAL_MODE: number;
  115810. /** Planar coordinates mode */
  115811. static readonly TEXTURE_PLANAR_MODE: number;
  115812. /** Cubic coordinates mode */
  115813. static readonly TEXTURE_CUBIC_MODE: number;
  115814. /** Projection coordinates mode */
  115815. static readonly TEXTURE_PROJECTION_MODE: number;
  115816. /** Skybox coordinates mode */
  115817. static readonly TEXTURE_SKYBOX_MODE: number;
  115818. /** Inverse Cubic coordinates mode */
  115819. static readonly TEXTURE_INVCUBIC_MODE: number;
  115820. /** Equirectangular coordinates mode */
  115821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  115822. /** Equirectangular Fixed coordinates mode */
  115823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  115824. /** Equirectangular Fixed Mirrored coordinates mode */
  115825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  115826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  115827. static readonly SCALEMODE_FLOOR: number;
  115828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  115829. static readonly SCALEMODE_NEAREST: number;
  115830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  115831. static readonly SCALEMODE_CEILING: number;
  115832. /**
  115833. * Returns the current npm package of the sdk
  115834. */
  115835. static get NpmPackage(): string;
  115836. /**
  115837. * Returns the current version of the framework
  115838. */
  115839. static get Version(): string;
  115840. /** Gets the list of created engines */
  115841. static get Instances(): Engine[];
  115842. /**
  115843. * Gets the latest created engine
  115844. */
  115845. static get LastCreatedEngine(): Nullable<Engine>;
  115846. /**
  115847. * Gets the latest created scene
  115848. */
  115849. static get LastCreatedScene(): Nullable<Scene>;
  115850. /**
  115851. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  115852. * @param flag defines which part of the materials must be marked as dirty
  115853. * @param predicate defines a predicate used to filter which materials should be affected
  115854. */
  115855. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  115856. /**
  115857. * Method called to create the default loading screen.
  115858. * This can be overriden in your own app.
  115859. * @param canvas The rendering canvas element
  115860. * @returns The loading screen
  115861. */
  115862. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  115863. /**
  115864. * Method called to create the default rescale post process on each engine.
  115865. */
  115866. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  115867. /**
  115868. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  115869. **/
  115870. enableOfflineSupport: boolean;
  115871. /**
  115872. * 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)
  115873. **/
  115874. disableManifestCheck: boolean;
  115875. /**
  115876. * Gets the list of created scenes
  115877. */
  115878. scenes: Scene[];
  115879. /**
  115880. * Event raised when a new scene is created
  115881. */
  115882. onNewSceneAddedObservable: Observable<Scene>;
  115883. /**
  115884. * Gets the list of created postprocesses
  115885. */
  115886. postProcesses: PostProcess[];
  115887. /**
  115888. * Gets a boolean indicating if the pointer is currently locked
  115889. */
  115890. isPointerLock: boolean;
  115891. /**
  115892. * Observable event triggered each time the rendering canvas is resized
  115893. */
  115894. onResizeObservable: Observable<Engine>;
  115895. /**
  115896. * Observable event triggered each time the canvas loses focus
  115897. */
  115898. onCanvasBlurObservable: Observable<Engine>;
  115899. /**
  115900. * Observable event triggered each time the canvas gains focus
  115901. */
  115902. onCanvasFocusObservable: Observable<Engine>;
  115903. /**
  115904. * Observable event triggered each time the canvas receives pointerout event
  115905. */
  115906. onCanvasPointerOutObservable: Observable<PointerEvent>;
  115907. /**
  115908. * Observable raised when the engine begins a new frame
  115909. */
  115910. onBeginFrameObservable: Observable<Engine>;
  115911. /**
  115912. * If set, will be used to request the next animation frame for the render loop
  115913. */
  115914. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  115915. /**
  115916. * Observable raised when the engine ends the current frame
  115917. */
  115918. onEndFrameObservable: Observable<Engine>;
  115919. /**
  115920. * Observable raised when the engine is about to compile a shader
  115921. */
  115922. onBeforeShaderCompilationObservable: Observable<Engine>;
  115923. /**
  115924. * Observable raised when the engine has jsut compiled a shader
  115925. */
  115926. onAfterShaderCompilationObservable: Observable<Engine>;
  115927. /**
  115928. * Gets the audio engine
  115929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115930. * @ignorenaming
  115931. */
  115932. static audioEngine: IAudioEngine;
  115933. /**
  115934. * Default AudioEngine factory responsible of creating the Audio Engine.
  115935. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  115936. */
  115937. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  115938. /**
  115939. * Default offline support factory responsible of creating a tool used to store data locally.
  115940. * By default, this will create a Database object if the workload has been embedded.
  115941. */
  115942. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  115943. private _loadingScreen;
  115944. private _pointerLockRequested;
  115945. private _rescalePostProcess;
  115946. private _deterministicLockstep;
  115947. private _lockstepMaxSteps;
  115948. private _timeStep;
  115949. protected get _supportsHardwareTextureRescaling(): boolean;
  115950. private _fps;
  115951. private _deltaTime;
  115952. /** @hidden */
  115953. _drawCalls: PerfCounter;
  115954. /** 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 */
  115955. canvasTabIndex: number;
  115956. /**
  115957. * Turn this value on if you want to pause FPS computation when in background
  115958. */
  115959. disablePerformanceMonitorInBackground: boolean;
  115960. private _performanceMonitor;
  115961. /**
  115962. * Gets the performance monitor attached to this engine
  115963. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115964. */
  115965. get performanceMonitor(): PerformanceMonitor;
  115966. private _onFocus;
  115967. private _onBlur;
  115968. private _onCanvasPointerOut;
  115969. private _onCanvasBlur;
  115970. private _onCanvasFocus;
  115971. private _onFullscreenChange;
  115972. private _onPointerLockChange;
  115973. /**
  115974. * Gets the HTML element used to attach event listeners
  115975. * @returns a HTML element
  115976. */
  115977. getInputElement(): Nullable<HTMLElement>;
  115978. /**
  115979. * Creates a new engine
  115980. * @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
  115981. * @param antialias defines enable antialiasing (default: false)
  115982. * @param options defines further options to be sent to the getContext() function
  115983. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115984. */
  115985. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115986. /**
  115987. * Gets current aspect ratio
  115988. * @param viewportOwner defines the camera to use to get the aspect ratio
  115989. * @param useScreen defines if screen size must be used (or the current render target if any)
  115990. * @returns a number defining the aspect ratio
  115991. */
  115992. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  115993. /**
  115994. * Gets current screen aspect ratio
  115995. * @returns a number defining the aspect ratio
  115996. */
  115997. getScreenAspectRatio(): number;
  115998. /**
  115999. * Gets the client rect of the HTML canvas attached with the current webGL context
  116000. * @returns a client rectanglee
  116001. */
  116002. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116003. /**
  116004. * Gets the client rect of the HTML element used for events
  116005. * @returns a client rectanglee
  116006. */
  116007. getInputElementClientRect(): Nullable<ClientRect>;
  116008. /**
  116009. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116010. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116011. * @returns true if engine is in deterministic lock step mode
  116012. */
  116013. isDeterministicLockStep(): boolean;
  116014. /**
  116015. * Gets the max steps when engine is running in deterministic lock step
  116016. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116017. * @returns the max steps
  116018. */
  116019. getLockstepMaxSteps(): number;
  116020. /**
  116021. * Returns the time in ms between steps when using deterministic lock step.
  116022. * @returns time step in (ms)
  116023. */
  116024. getTimeStep(): number;
  116025. /**
  116026. * Force the mipmap generation for the given render target texture
  116027. * @param texture defines the render target texture to use
  116028. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116029. */
  116030. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116031. /** States */
  116032. /**
  116033. * Set various states to the webGL context
  116034. * @param culling defines backface culling state
  116035. * @param zOffset defines the value to apply to zOffset (0 by default)
  116036. * @param force defines if states must be applied even if cache is up to date
  116037. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116038. */
  116039. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116040. /**
  116041. * Set the z offset to apply to current rendering
  116042. * @param value defines the offset to apply
  116043. */
  116044. setZOffset(value: number): void;
  116045. /**
  116046. * Gets the current value of the zOffset
  116047. * @returns the current zOffset state
  116048. */
  116049. getZOffset(): number;
  116050. /**
  116051. * Enable or disable depth buffering
  116052. * @param enable defines the state to set
  116053. */
  116054. setDepthBuffer(enable: boolean): void;
  116055. /**
  116056. * Gets a boolean indicating if depth writing is enabled
  116057. * @returns the current depth writing state
  116058. */
  116059. getDepthWrite(): boolean;
  116060. /**
  116061. * Enable or disable depth writing
  116062. * @param enable defines the state to set
  116063. */
  116064. setDepthWrite(enable: boolean): void;
  116065. /**
  116066. * Gets a boolean indicating if stencil buffer is enabled
  116067. * @returns the current stencil buffer state
  116068. */
  116069. getStencilBuffer(): boolean;
  116070. /**
  116071. * Enable or disable the stencil buffer
  116072. * @param enable defines if the stencil buffer must be enabled or disabled
  116073. */
  116074. setStencilBuffer(enable: boolean): void;
  116075. /**
  116076. * Gets the current stencil mask
  116077. * @returns a number defining the new stencil mask to use
  116078. */
  116079. getStencilMask(): number;
  116080. /**
  116081. * Sets the current stencil mask
  116082. * @param mask defines the new stencil mask to use
  116083. */
  116084. setStencilMask(mask: number): void;
  116085. /**
  116086. * Gets the current stencil function
  116087. * @returns a number defining the stencil function to use
  116088. */
  116089. getStencilFunction(): number;
  116090. /**
  116091. * Gets the current stencil reference value
  116092. * @returns a number defining the stencil reference value to use
  116093. */
  116094. getStencilFunctionReference(): number;
  116095. /**
  116096. * Gets the current stencil mask
  116097. * @returns a number defining the stencil mask to use
  116098. */
  116099. getStencilFunctionMask(): number;
  116100. /**
  116101. * Sets the current stencil function
  116102. * @param stencilFunc defines the new stencil function to use
  116103. */
  116104. setStencilFunction(stencilFunc: number): void;
  116105. /**
  116106. * Sets the current stencil reference
  116107. * @param reference defines the new stencil reference to use
  116108. */
  116109. setStencilFunctionReference(reference: number): void;
  116110. /**
  116111. * Sets the current stencil mask
  116112. * @param mask defines the new stencil mask to use
  116113. */
  116114. setStencilFunctionMask(mask: number): void;
  116115. /**
  116116. * Gets the current stencil operation when stencil fails
  116117. * @returns a number defining stencil operation to use when stencil fails
  116118. */
  116119. getStencilOperationFail(): number;
  116120. /**
  116121. * Gets the current stencil operation when depth fails
  116122. * @returns a number defining stencil operation to use when depth fails
  116123. */
  116124. getStencilOperationDepthFail(): number;
  116125. /**
  116126. * Gets the current stencil operation when stencil passes
  116127. * @returns a number defining stencil operation to use when stencil passes
  116128. */
  116129. getStencilOperationPass(): number;
  116130. /**
  116131. * Sets the stencil operation to use when stencil fails
  116132. * @param operation defines the stencil operation to use when stencil fails
  116133. */
  116134. setStencilOperationFail(operation: number): void;
  116135. /**
  116136. * Sets the stencil operation to use when depth fails
  116137. * @param operation defines the stencil operation to use when depth fails
  116138. */
  116139. setStencilOperationDepthFail(operation: number): void;
  116140. /**
  116141. * Sets the stencil operation to use when stencil passes
  116142. * @param operation defines the stencil operation to use when stencil passes
  116143. */
  116144. setStencilOperationPass(operation: number): void;
  116145. /**
  116146. * Sets a boolean indicating if the dithering state is enabled or disabled
  116147. * @param value defines the dithering state
  116148. */
  116149. setDitheringState(value: boolean): void;
  116150. /**
  116151. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116152. * @param value defines the rasterizer state
  116153. */
  116154. setRasterizerState(value: boolean): void;
  116155. /**
  116156. * Gets the current depth function
  116157. * @returns a number defining the depth function
  116158. */
  116159. getDepthFunction(): Nullable<number>;
  116160. /**
  116161. * Sets the current depth function
  116162. * @param depthFunc defines the function to use
  116163. */
  116164. setDepthFunction(depthFunc: number): void;
  116165. /**
  116166. * Sets the current depth function to GREATER
  116167. */
  116168. setDepthFunctionToGreater(): void;
  116169. /**
  116170. * Sets the current depth function to GEQUAL
  116171. */
  116172. setDepthFunctionToGreaterOrEqual(): void;
  116173. /**
  116174. * Sets the current depth function to LESS
  116175. */
  116176. setDepthFunctionToLess(): void;
  116177. /**
  116178. * Sets the current depth function to LEQUAL
  116179. */
  116180. setDepthFunctionToLessOrEqual(): void;
  116181. private _cachedStencilBuffer;
  116182. private _cachedStencilFunction;
  116183. private _cachedStencilMask;
  116184. private _cachedStencilOperationPass;
  116185. private _cachedStencilOperationFail;
  116186. private _cachedStencilOperationDepthFail;
  116187. private _cachedStencilReference;
  116188. /**
  116189. * Caches the the state of the stencil buffer
  116190. */
  116191. cacheStencilState(): void;
  116192. /**
  116193. * Restores the state of the stencil buffer
  116194. */
  116195. restoreStencilState(): void;
  116196. /**
  116197. * Directly set the WebGL Viewport
  116198. * @param x defines the x coordinate of the viewport (in screen space)
  116199. * @param y defines the y coordinate of the viewport (in screen space)
  116200. * @param width defines the width of the viewport (in screen space)
  116201. * @param height defines the height of the viewport (in screen space)
  116202. * @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
  116203. */
  116204. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116205. /**
  116206. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116207. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116208. * @param y defines the y-coordinate of the corner of the clear rectangle
  116209. * @param width defines the width of the clear rectangle
  116210. * @param height defines the height of the clear rectangle
  116211. * @param clearColor defines the clear color
  116212. */
  116213. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116214. /**
  116215. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116216. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116217. * @param y defines the y-coordinate of the corner of the clear rectangle
  116218. * @param width defines the width of the clear rectangle
  116219. * @param height defines the height of the clear rectangle
  116220. */
  116221. enableScissor(x: number, y: number, width: number, height: number): void;
  116222. /**
  116223. * Disable previously set scissor test rectangle
  116224. */
  116225. disableScissor(): void;
  116226. protected _reportDrawCall(): void;
  116227. /**
  116228. * Initializes a webVR display and starts listening to display change events
  116229. * The onVRDisplayChangedObservable will be notified upon these changes
  116230. * @returns The onVRDisplayChangedObservable
  116231. */
  116232. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116233. /** @hidden */
  116234. _prepareVRComponent(): void;
  116235. /** @hidden */
  116236. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116237. /** @hidden */
  116238. _submitVRFrame(): void;
  116239. /**
  116240. * Call this function to leave webVR mode
  116241. * Will do nothing if webVR is not supported or if there is no webVR device
  116242. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116243. */
  116244. disableVR(): void;
  116245. /**
  116246. * Gets a boolean indicating that the system is in VR mode and is presenting
  116247. * @returns true if VR mode is engaged
  116248. */
  116249. isVRPresenting(): boolean;
  116250. /** @hidden */
  116251. _requestVRFrame(): void;
  116252. /** @hidden */
  116253. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116254. /**
  116255. * Gets the source code of the vertex shader associated with a specific webGL program
  116256. * @param program defines the program to use
  116257. * @returns a string containing the source code of the vertex shader associated with the program
  116258. */
  116259. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116260. /**
  116261. * Gets the source code of the fragment shader associated with a specific webGL program
  116262. * @param program defines the program to use
  116263. * @returns a string containing the source code of the fragment shader associated with the program
  116264. */
  116265. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116266. /**
  116267. * Sets a depth stencil texture from a render target to the according uniform.
  116268. * @param channel The texture channel
  116269. * @param uniform The uniform to set
  116270. * @param texture The render target texture containing the depth stencil texture to apply
  116271. */
  116272. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116273. /**
  116274. * Sets a texture to the webGL context from a postprocess
  116275. * @param channel defines the channel to use
  116276. * @param postProcess defines the source postprocess
  116277. */
  116278. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116279. /**
  116280. * Binds the output of the passed in post process to the texture channel specified
  116281. * @param channel The channel the texture should be bound to
  116282. * @param postProcess The post process which's output should be bound
  116283. */
  116284. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116285. protected _rebuildBuffers(): void;
  116286. /** @hidden */
  116287. _renderFrame(): void;
  116288. _renderLoop(): void;
  116289. /** @hidden */
  116290. _renderViews(): boolean;
  116291. /**
  116292. * Toggle full screen mode
  116293. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116294. */
  116295. switchFullscreen(requestPointerLock: boolean): void;
  116296. /**
  116297. * Enters full screen mode
  116298. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116299. */
  116300. enterFullscreen(requestPointerLock: boolean): void;
  116301. /**
  116302. * Exits full screen mode
  116303. */
  116304. exitFullscreen(): void;
  116305. /**
  116306. * Enters Pointerlock mode
  116307. */
  116308. enterPointerlock(): void;
  116309. /**
  116310. * Exits Pointerlock mode
  116311. */
  116312. exitPointerlock(): void;
  116313. /**
  116314. * Begin a new frame
  116315. */
  116316. beginFrame(): void;
  116317. /**
  116318. * Enf the current frame
  116319. */
  116320. endFrame(): void;
  116321. resize(): void;
  116322. /**
  116323. * Force a specific size of the canvas
  116324. * @param width defines the new canvas' width
  116325. * @param height defines the new canvas' height
  116326. * @returns true if the size was changed
  116327. */
  116328. setSize(width: number, height: number): boolean;
  116329. /**
  116330. * Updates a dynamic vertex buffer.
  116331. * @param vertexBuffer the vertex buffer to update
  116332. * @param data the data used to update the vertex buffer
  116333. * @param byteOffset the byte offset of the data
  116334. * @param byteLength the byte length of the data
  116335. */
  116336. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116337. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116338. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116339. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116340. _releaseTexture(texture: InternalTexture): void;
  116341. /**
  116342. * @hidden
  116343. * Rescales a texture
  116344. * @param source input texutre
  116345. * @param destination destination texture
  116346. * @param scene scene to use to render the resize
  116347. * @param internalFormat format to use when resizing
  116348. * @param onComplete callback to be called when resize has completed
  116349. */
  116350. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116351. /**
  116352. * Gets the current framerate
  116353. * @returns a number representing the framerate
  116354. */
  116355. getFps(): number;
  116356. /**
  116357. * Gets the time spent between current and previous frame
  116358. * @returns a number representing the delta time in ms
  116359. */
  116360. getDeltaTime(): number;
  116361. private _measureFps;
  116362. /** @hidden */
  116363. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116364. /**
  116365. * Update a dynamic index buffer
  116366. * @param indexBuffer defines the target index buffer
  116367. * @param indices defines the data to update
  116368. * @param offset defines the offset in the target index buffer where update should start
  116369. */
  116370. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116371. /**
  116372. * Updates the sample count of a render target texture
  116373. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116374. * @param texture defines the texture to update
  116375. * @param samples defines the sample count to set
  116376. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116377. */
  116378. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116379. /**
  116380. * Updates a depth texture Comparison Mode and Function.
  116381. * If the comparison Function is equal to 0, the mode will be set to none.
  116382. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116383. * @param texture The texture to set the comparison function for
  116384. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116385. */
  116386. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116387. /**
  116388. * Creates a webGL buffer to use with instanciation
  116389. * @param capacity defines the size of the buffer
  116390. * @returns the webGL buffer
  116391. */
  116392. createInstancesBuffer(capacity: number): DataBuffer;
  116393. /**
  116394. * Delete a webGL buffer used with instanciation
  116395. * @param buffer defines the webGL buffer to delete
  116396. */
  116397. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116398. private _clientWaitAsync;
  116399. /** @hidden */
  116400. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116401. dispose(): void;
  116402. private _disableTouchAction;
  116403. /**
  116404. * Display the loading screen
  116405. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116406. */
  116407. displayLoadingUI(): void;
  116408. /**
  116409. * Hide the loading screen
  116410. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116411. */
  116412. hideLoadingUI(): void;
  116413. /**
  116414. * Gets the current loading screen object
  116415. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116416. */
  116417. get loadingScreen(): ILoadingScreen;
  116418. /**
  116419. * Sets the current loading screen object
  116420. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116421. */
  116422. set loadingScreen(loadingScreen: ILoadingScreen);
  116423. /**
  116424. * Sets the current loading screen text
  116425. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116426. */
  116427. set loadingUIText(text: string);
  116428. /**
  116429. * Sets the current loading screen background color
  116430. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116431. */
  116432. set loadingUIBackgroundColor(color: string);
  116433. /** Pointerlock and fullscreen */
  116434. /**
  116435. * Ask the browser to promote the current element to pointerlock mode
  116436. * @param element defines the DOM element to promote
  116437. */
  116438. static _RequestPointerlock(element: HTMLElement): void;
  116439. /**
  116440. * Asks the browser to exit pointerlock mode
  116441. */
  116442. static _ExitPointerlock(): void;
  116443. /**
  116444. * Ask the browser to promote the current element to fullscreen rendering mode
  116445. * @param element defines the DOM element to promote
  116446. */
  116447. static _RequestFullscreen(element: HTMLElement): void;
  116448. /**
  116449. * Asks the browser to exit fullscreen mode
  116450. */
  116451. static _ExitFullscreen(): void;
  116452. }
  116453. }
  116454. declare module BABYLON {
  116455. /**
  116456. * The engine store class is responsible to hold all the instances of Engine and Scene created
  116457. * during the life time of the application.
  116458. */
  116459. export class EngineStore {
  116460. /** Gets the list of created engines */
  116461. static Instances: Engine[];
  116462. /** @hidden */
  116463. static _LastCreatedScene: Nullable<Scene>;
  116464. /**
  116465. * Gets the latest created engine
  116466. */
  116467. static get LastCreatedEngine(): Nullable<Engine>;
  116468. /**
  116469. * Gets the latest created scene
  116470. */
  116471. static get LastCreatedScene(): Nullable<Scene>;
  116472. /**
  116473. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116474. * @ignorenaming
  116475. */
  116476. static UseFallbackTexture: boolean;
  116477. /**
  116478. * Texture content used if a texture cannot loaded
  116479. * @ignorenaming
  116480. */
  116481. static FallbackTexture: string;
  116482. }
  116483. }
  116484. declare module BABYLON {
  116485. /**
  116486. * Helper class that provides a small promise polyfill
  116487. */
  116488. export class PromisePolyfill {
  116489. /**
  116490. * Static function used to check if the polyfill is required
  116491. * If this is the case then the function will inject the polyfill to window.Promise
  116492. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  116493. */
  116494. static Apply(force?: boolean): void;
  116495. }
  116496. }
  116497. declare module BABYLON {
  116498. /**
  116499. * Interface for screenshot methods with describe argument called `size` as object with options
  116500. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  116501. */
  116502. export interface IScreenshotSize {
  116503. /**
  116504. * number in pixels for canvas height
  116505. */
  116506. height?: number;
  116507. /**
  116508. * multiplier allowing render at a higher or lower resolution
  116509. * If value is defined then height and width will be ignored and taken from camera
  116510. */
  116511. precision?: number;
  116512. /**
  116513. * number in pixels for canvas width
  116514. */
  116515. width?: number;
  116516. }
  116517. }
  116518. declare module BABYLON {
  116519. interface IColor4Like {
  116520. r: float;
  116521. g: float;
  116522. b: float;
  116523. a: float;
  116524. }
  116525. /**
  116526. * Class containing a set of static utilities functions
  116527. */
  116528. export class Tools {
  116529. /**
  116530. * Gets or sets the base URL to use to load assets
  116531. */
  116532. static get BaseUrl(): string;
  116533. static set BaseUrl(value: string);
  116534. /**
  116535. * Enable/Disable Custom HTTP Request Headers globally.
  116536. * default = false
  116537. * @see CustomRequestHeaders
  116538. */
  116539. static UseCustomRequestHeaders: boolean;
  116540. /**
  116541. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  116542. * i.e. when loading files, where the server/service expects an Authorization header
  116543. */
  116544. static CustomRequestHeaders: {
  116545. [key: string]: string;
  116546. };
  116547. /**
  116548. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  116549. */
  116550. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  116551. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  116552. /**
  116553. * Default behaviour for cors in the application.
  116554. * It can be a string if the expected behavior is identical in the entire app.
  116555. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  116556. */
  116557. static get CorsBehavior(): string | ((url: string | string[]) => string);
  116558. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  116559. /**
  116560. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116561. * @ignorenaming
  116562. */
  116563. static get UseFallbackTexture(): boolean;
  116564. static set UseFallbackTexture(value: boolean);
  116565. /**
  116566. * Use this object to register external classes like custom textures or material
  116567. * to allow the laoders to instantiate them
  116568. */
  116569. static get RegisteredExternalClasses(): {
  116570. [key: string]: Object;
  116571. };
  116572. static set RegisteredExternalClasses(classes: {
  116573. [key: string]: Object;
  116574. });
  116575. /**
  116576. * Texture content used if a texture cannot loaded
  116577. * @ignorenaming
  116578. */
  116579. static get fallbackTexture(): string;
  116580. static set fallbackTexture(value: string);
  116581. /**
  116582. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  116583. * @param u defines the coordinate on X axis
  116584. * @param v defines the coordinate on Y axis
  116585. * @param width defines the width of the source data
  116586. * @param height defines the height of the source data
  116587. * @param pixels defines the source byte array
  116588. * @param color defines the output color
  116589. */
  116590. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  116591. /**
  116592. * Interpolates between a and b via alpha
  116593. * @param a The lower value (returned when alpha = 0)
  116594. * @param b The upper value (returned when alpha = 1)
  116595. * @param alpha The interpolation-factor
  116596. * @return The mixed value
  116597. */
  116598. static Mix(a: number, b: number, alpha: number): number;
  116599. /**
  116600. * Tries to instantiate a new object from a given class name
  116601. * @param className defines the class name to instantiate
  116602. * @returns the new object or null if the system was not able to do the instantiation
  116603. */
  116604. static Instantiate(className: string): any;
  116605. /**
  116606. * Provides a slice function that will work even on IE
  116607. * @param data defines the array to slice
  116608. * @param start defines the start of the data (optional)
  116609. * @param end defines the end of the data (optional)
  116610. * @returns the new sliced array
  116611. */
  116612. static Slice<T>(data: T, start?: number, end?: number): T;
  116613. /**
  116614. * Polyfill for setImmediate
  116615. * @param action defines the action to execute after the current execution block
  116616. */
  116617. static SetImmediate(action: () => void): void;
  116618. /**
  116619. * Function indicating if a number is an exponent of 2
  116620. * @param value defines the value to test
  116621. * @returns true if the value is an exponent of 2
  116622. */
  116623. static IsExponentOfTwo(value: number): boolean;
  116624. private static _tmpFloatArray;
  116625. /**
  116626. * Returns the nearest 32-bit single precision float representation of a Number
  116627. * @param value A Number. If the parameter is of a different type, it will get converted
  116628. * to a number or to NaN if it cannot be converted
  116629. * @returns number
  116630. */
  116631. static FloatRound(value: number): number;
  116632. /**
  116633. * Extracts the filename from a path
  116634. * @param path defines the path to use
  116635. * @returns the filename
  116636. */
  116637. static GetFilename(path: string): string;
  116638. /**
  116639. * Extracts the "folder" part of a path (everything before the filename).
  116640. * @param uri The URI to extract the info from
  116641. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  116642. * @returns The "folder" part of the path
  116643. */
  116644. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  116645. /**
  116646. * Extracts text content from a DOM element hierarchy
  116647. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  116648. */
  116649. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  116650. /**
  116651. * Convert an angle in radians to degrees
  116652. * @param angle defines the angle to convert
  116653. * @returns the angle in degrees
  116654. */
  116655. static ToDegrees(angle: number): number;
  116656. /**
  116657. * Convert an angle in degrees to radians
  116658. * @param angle defines the angle to convert
  116659. * @returns the angle in radians
  116660. */
  116661. static ToRadians(angle: number): number;
  116662. /**
  116663. * Returns an array if obj is not an array
  116664. * @param obj defines the object to evaluate as an array
  116665. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  116666. * @returns either obj directly if obj is an array or a new array containing obj
  116667. */
  116668. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  116669. /**
  116670. * Gets the pointer prefix to use
  116671. * @param engine defines the engine we are finding the prefix for
  116672. * @returns "pointer" if touch is enabled. Else returns "mouse"
  116673. */
  116674. static GetPointerPrefix(engine: Engine): string;
  116675. /**
  116676. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  116677. * @param url define the url we are trying
  116678. * @param element define the dom element where to configure the cors policy
  116679. */
  116680. static SetCorsBehavior(url: string | string[], element: {
  116681. crossOrigin: string | null;
  116682. }): void;
  116683. /**
  116684. * Removes unwanted characters from an url
  116685. * @param url defines the url to clean
  116686. * @returns the cleaned url
  116687. */
  116688. static CleanUrl(url: string): string;
  116689. /**
  116690. * Gets or sets a function used to pre-process url before using them to load assets
  116691. */
  116692. static get PreprocessUrl(): (url: string) => string;
  116693. static set PreprocessUrl(processor: (url: string) => string);
  116694. /**
  116695. * Loads an image as an HTMLImageElement.
  116696. * @param input url string, ArrayBuffer, or Blob to load
  116697. * @param onLoad callback called when the image successfully loads
  116698. * @param onError callback called when the image fails to load
  116699. * @param offlineProvider offline provider for caching
  116700. * @param mimeType optional mime type
  116701. * @returns the HTMLImageElement of the loaded image
  116702. */
  116703. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  116704. /**
  116705. * Loads a file from a url
  116706. * @param url url string, ArrayBuffer, or Blob to load
  116707. * @param onSuccess callback called when the file successfully loads
  116708. * @param onProgress callback called while file is loading (if the server supports this mode)
  116709. * @param offlineProvider defines the offline provider for caching
  116710. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116711. * @param onError callback called when the file fails to load
  116712. * @returns a file request object
  116713. */
  116714. 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;
  116715. /**
  116716. * Loads a file from a url
  116717. * @param url the file url to load
  116718. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116719. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  116720. */
  116721. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  116722. /**
  116723. * Load a script (identified by an url). When the url returns, the
  116724. * content of this file is added into a new script element, attached to the DOM (body element)
  116725. * @param scriptUrl defines the url of the script to laod
  116726. * @param onSuccess defines the callback called when the script is loaded
  116727. * @param onError defines the callback to call if an error occurs
  116728. * @param scriptId defines the id of the script element
  116729. */
  116730. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  116731. /**
  116732. * Load an asynchronous script (identified by an url). When the url returns, the
  116733. * content of this file is added into a new script element, attached to the DOM (body element)
  116734. * @param scriptUrl defines the url of the script to laod
  116735. * @param scriptId defines the id of the script element
  116736. * @returns a promise request object
  116737. */
  116738. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  116739. /**
  116740. * Loads a file from a blob
  116741. * @param fileToLoad defines the blob to use
  116742. * @param callback defines the callback to call when data is loaded
  116743. * @param progressCallback defines the callback to call during loading process
  116744. * @returns a file request object
  116745. */
  116746. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  116747. /**
  116748. * Reads a file from a File object
  116749. * @param file defines the file to load
  116750. * @param onSuccess defines the callback to call when data is loaded
  116751. * @param onProgress defines the callback to call during loading process
  116752. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116753. * @param onError defines the callback to call when an error occurs
  116754. * @returns a file request object
  116755. */
  116756. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  116757. /**
  116758. * Creates a data url from a given string content
  116759. * @param content defines the content to convert
  116760. * @returns the new data url link
  116761. */
  116762. static FileAsURL(content: string): string;
  116763. /**
  116764. * Format the given number to a specific decimal format
  116765. * @param value defines the number to format
  116766. * @param decimals defines the number of decimals to use
  116767. * @returns the formatted string
  116768. */
  116769. static Format(value: number, decimals?: number): string;
  116770. /**
  116771. * Tries to copy an object by duplicating every property
  116772. * @param source defines the source object
  116773. * @param destination defines the target object
  116774. * @param doNotCopyList defines a list of properties to avoid
  116775. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  116776. */
  116777. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  116778. /**
  116779. * Gets a boolean indicating if the given object has no own property
  116780. * @param obj defines the object to test
  116781. * @returns true if object has no own property
  116782. */
  116783. static IsEmpty(obj: any): boolean;
  116784. /**
  116785. * Function used to register events at window level
  116786. * @param windowElement defines the Window object to use
  116787. * @param events defines the events to register
  116788. */
  116789. static RegisterTopRootEvents(windowElement: Window, events: {
  116790. name: string;
  116791. handler: Nullable<(e: FocusEvent) => any>;
  116792. }[]): void;
  116793. /**
  116794. * Function used to unregister events from window level
  116795. * @param windowElement defines the Window object to use
  116796. * @param events defines the events to unregister
  116797. */
  116798. static UnregisterTopRootEvents(windowElement: Window, events: {
  116799. name: string;
  116800. handler: Nullable<(e: FocusEvent) => any>;
  116801. }[]): void;
  116802. /**
  116803. * @ignore
  116804. */
  116805. static _ScreenshotCanvas: HTMLCanvasElement;
  116806. /**
  116807. * Dumps the current bound framebuffer
  116808. * @param width defines the rendering width
  116809. * @param height defines the rendering height
  116810. * @param engine defines the hosting engine
  116811. * @param successCallback defines the callback triggered once the data are available
  116812. * @param mimeType defines the mime type of the result
  116813. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  116814. */
  116815. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  116816. /**
  116817. * Converts the canvas data to blob.
  116818. * This acts as a polyfill for browsers not supporting the to blob function.
  116819. * @param canvas Defines the canvas to extract the data from
  116820. * @param successCallback Defines the callback triggered once the data are available
  116821. * @param mimeType Defines the mime type of the result
  116822. */
  116823. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  116824. /**
  116825. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  116826. * @param successCallback defines the callback triggered once the data are available
  116827. * @param mimeType defines the mime type of the result
  116828. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  116829. */
  116830. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  116831. /**
  116832. * Downloads a blob in the browser
  116833. * @param blob defines the blob to download
  116834. * @param fileName defines the name of the downloaded file
  116835. */
  116836. static Download(blob: Blob, fileName: string): void;
  116837. /**
  116838. * Captures a screenshot of the current rendering
  116839. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116840. * @param engine defines the rendering engine
  116841. * @param camera defines the source camera
  116842. * @param size This parameter can be set to a single number or to an object with the
  116843. * following (optional) properties: precision, width, height. If a single number is passed,
  116844. * it will be used for both width and height. If an object is passed, the screenshot size
  116845. * will be derived from the parameters. The precision property is a multiplier allowing
  116846. * rendering at a higher or lower resolution
  116847. * @param successCallback defines the callback receives a single parameter which contains the
  116848. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116849. * src parameter of an <img> to display it
  116850. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116851. * Check your browser for supported MIME types
  116852. */
  116853. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  116854. /**
  116855. * Captures a screenshot of the current rendering
  116856. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116857. * @param engine defines the rendering engine
  116858. * @param camera defines the source camera
  116859. * @param size This parameter can be set to a single number or to an object with the
  116860. * following (optional) properties: precision, width, height. If a single number is passed,
  116861. * it will be used for both width and height. If an object is passed, the screenshot size
  116862. * will be derived from the parameters. The precision property is a multiplier allowing
  116863. * rendering at a higher or lower resolution
  116864. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116865. * Check your browser for supported MIME types
  116866. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116867. * to the src parameter of an <img> to display it
  116868. */
  116869. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  116870. /**
  116871. * Generates an image screenshot from the specified camera.
  116872. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116873. * @param engine The engine to use for rendering
  116874. * @param camera The camera to use for rendering
  116875. * @param size This parameter can be set to a single number or to an object with the
  116876. * following (optional) properties: precision, width, height. If a single number is passed,
  116877. * it will be used for both width and height. If an object is passed, the screenshot size
  116878. * will be derived from the parameters. The precision property is a multiplier allowing
  116879. * rendering at a higher or lower resolution
  116880. * @param successCallback The callback receives a single parameter which contains the
  116881. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116882. * src parameter of an <img> to display it
  116883. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116884. * Check your browser for supported MIME types
  116885. * @param samples Texture samples (default: 1)
  116886. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116887. * @param fileName A name for for the downloaded file.
  116888. */
  116889. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116890. /**
  116891. * Generates an image screenshot from the specified camera.
  116892. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116893. * @param engine The engine to use for rendering
  116894. * @param camera The camera to use for rendering
  116895. * @param size This parameter can be set to a single number or to an object with the
  116896. * following (optional) properties: precision, width, height. If a single number is passed,
  116897. * it will be used for both width and height. If an object is passed, the screenshot size
  116898. * will be derived from the parameters. The precision property is a multiplier allowing
  116899. * rendering at a higher or lower resolution
  116900. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116901. * Check your browser for supported MIME types
  116902. * @param samples Texture samples (default: 1)
  116903. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116904. * @param fileName A name for for the downloaded file.
  116905. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116906. * to the src parameter of an <img> to display it
  116907. */
  116908. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  116909. /**
  116910. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  116911. * Be aware Math.random() could cause collisions, but:
  116912. * "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"
  116913. * @returns a pseudo random id
  116914. */
  116915. static RandomId(): string;
  116916. /**
  116917. * Test if the given uri is a base64 string
  116918. * @param uri The uri to test
  116919. * @return True if the uri is a base64 string or false otherwise
  116920. */
  116921. static IsBase64(uri: string): boolean;
  116922. /**
  116923. * Decode the given base64 uri.
  116924. * @param uri The uri to decode
  116925. * @return The decoded base64 data.
  116926. */
  116927. static DecodeBase64(uri: string): ArrayBuffer;
  116928. /**
  116929. * Gets the absolute url.
  116930. * @param url the input url
  116931. * @return the absolute url
  116932. */
  116933. static GetAbsoluteUrl(url: string): string;
  116934. /**
  116935. * No log
  116936. */
  116937. static readonly NoneLogLevel: number;
  116938. /**
  116939. * Only message logs
  116940. */
  116941. static readonly MessageLogLevel: number;
  116942. /**
  116943. * Only warning logs
  116944. */
  116945. static readonly WarningLogLevel: number;
  116946. /**
  116947. * Only error logs
  116948. */
  116949. static readonly ErrorLogLevel: number;
  116950. /**
  116951. * All logs
  116952. */
  116953. static readonly AllLogLevel: number;
  116954. /**
  116955. * Gets a value indicating the number of loading errors
  116956. * @ignorenaming
  116957. */
  116958. static get errorsCount(): number;
  116959. /**
  116960. * Callback called when a new log is added
  116961. */
  116962. static OnNewCacheEntry: (entry: string) => void;
  116963. /**
  116964. * Log a message to the console
  116965. * @param message defines the message to log
  116966. */
  116967. static Log(message: string): void;
  116968. /**
  116969. * Write a warning message to the console
  116970. * @param message defines the message to log
  116971. */
  116972. static Warn(message: string): void;
  116973. /**
  116974. * Write an error message to the console
  116975. * @param message defines the message to log
  116976. */
  116977. static Error(message: string): void;
  116978. /**
  116979. * Gets current log cache (list of logs)
  116980. */
  116981. static get LogCache(): string;
  116982. /**
  116983. * Clears the log cache
  116984. */
  116985. static ClearLogCache(): void;
  116986. /**
  116987. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  116988. */
  116989. static set LogLevels(level: number);
  116990. /**
  116991. * Checks if the window object exists
  116992. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  116993. */
  116994. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  116995. /**
  116996. * No performance log
  116997. */
  116998. static readonly PerformanceNoneLogLevel: number;
  116999. /**
  117000. * Use user marks to log performance
  117001. */
  117002. static readonly PerformanceUserMarkLogLevel: number;
  117003. /**
  117004. * Log performance to the console
  117005. */
  117006. static readonly PerformanceConsoleLogLevel: number;
  117007. private static _performance;
  117008. /**
  117009. * Sets the current performance log level
  117010. */
  117011. static set PerformanceLogLevel(level: number);
  117012. private static _StartPerformanceCounterDisabled;
  117013. private static _EndPerformanceCounterDisabled;
  117014. private static _StartUserMark;
  117015. private static _EndUserMark;
  117016. private static _StartPerformanceConsole;
  117017. private static _EndPerformanceConsole;
  117018. /**
  117019. * Starts a performance counter
  117020. */
  117021. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117022. /**
  117023. * Ends a specific performance coutner
  117024. */
  117025. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117026. /**
  117027. * Gets either window.performance.now() if supported or Date.now() else
  117028. */
  117029. static get Now(): number;
  117030. /**
  117031. * This method will return the name of the class used to create the instance of the given object.
  117032. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117033. * @param object the object to get the class name from
  117034. * @param isType defines if the object is actually a type
  117035. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117036. */
  117037. static GetClassName(object: any, isType?: boolean): string;
  117038. /**
  117039. * Gets the first element of an array satisfying a given predicate
  117040. * @param array defines the array to browse
  117041. * @param predicate defines the predicate to use
  117042. * @returns null if not found or the element
  117043. */
  117044. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117045. /**
  117046. * This method will return the name of the full name of the class, including its owning module (if any).
  117047. * 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).
  117048. * @param object the object to get the class name from
  117049. * @param isType defines if the object is actually a type
  117050. * @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.
  117051. * @ignorenaming
  117052. */
  117053. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117054. /**
  117055. * Returns a promise that resolves after the given amount of time.
  117056. * @param delay Number of milliseconds to delay
  117057. * @returns Promise that resolves after the given amount of time
  117058. */
  117059. static DelayAsync(delay: number): Promise<void>;
  117060. /**
  117061. * Utility function to detect if the current user agent is Safari
  117062. * @returns whether or not the current user agent is safari
  117063. */
  117064. static IsSafari(): boolean;
  117065. }
  117066. /**
  117067. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117068. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117069. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117070. * @param name The name of the class, case should be preserved
  117071. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117072. */
  117073. export function className(name: string, module?: string): (target: Object) => void;
  117074. /**
  117075. * An implementation of a loop for asynchronous functions.
  117076. */
  117077. export class AsyncLoop {
  117078. /**
  117079. * Defines the number of iterations for the loop
  117080. */
  117081. iterations: number;
  117082. /**
  117083. * Defines the current index of the loop.
  117084. */
  117085. index: number;
  117086. private _done;
  117087. private _fn;
  117088. private _successCallback;
  117089. /**
  117090. * Constructor.
  117091. * @param iterations the number of iterations.
  117092. * @param func the function to run each iteration
  117093. * @param successCallback the callback that will be called upon succesful execution
  117094. * @param offset starting offset.
  117095. */
  117096. constructor(
  117097. /**
  117098. * Defines the number of iterations for the loop
  117099. */
  117100. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117101. /**
  117102. * Execute the next iteration. Must be called after the last iteration was finished.
  117103. */
  117104. executeNext(): void;
  117105. /**
  117106. * Break the loop and run the success callback.
  117107. */
  117108. breakLoop(): void;
  117109. /**
  117110. * Create and run an async loop.
  117111. * @param iterations the number of iterations.
  117112. * @param fn the function to run each iteration
  117113. * @param successCallback the callback that will be called upon succesful execution
  117114. * @param offset starting offset.
  117115. * @returns the created async loop object
  117116. */
  117117. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117118. /**
  117119. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117120. * @param iterations total number of iterations
  117121. * @param syncedIterations number of synchronous iterations in each async iteration.
  117122. * @param fn the function to call each iteration.
  117123. * @param callback a success call back that will be called when iterating stops.
  117124. * @param breakFunction a break condition (optional)
  117125. * @param timeout timeout settings for the setTimeout function. default - 0.
  117126. * @returns the created async loop object
  117127. */
  117128. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117129. }
  117130. }
  117131. declare module BABYLON {
  117132. /**
  117133. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117134. * The underlying implementation relies on an associative array to ensure the best performances.
  117135. * The value can be anything including 'null' but except 'undefined'
  117136. */
  117137. export class StringDictionary<T> {
  117138. /**
  117139. * This will clear this dictionary and copy the content from the 'source' one.
  117140. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117141. * @param source the dictionary to take the content from and copy to this dictionary
  117142. */
  117143. copyFrom(source: StringDictionary<T>): void;
  117144. /**
  117145. * Get a value based from its key
  117146. * @param key the given key to get the matching value from
  117147. * @return the value if found, otherwise undefined is returned
  117148. */
  117149. get(key: string): T | undefined;
  117150. /**
  117151. * Get a value from its key or add it if it doesn't exist.
  117152. * This method will ensure you that a given key/data will be present in the dictionary.
  117153. * @param key the given key to get the matching value from
  117154. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117155. * The factory will only be invoked if there's no data for the given key.
  117156. * @return the value corresponding to the key.
  117157. */
  117158. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117159. /**
  117160. * Get a value from its key if present in the dictionary otherwise add it
  117161. * @param key the key to get the value from
  117162. * @param val if there's no such key/value pair in the dictionary add it with this value
  117163. * @return the value corresponding to the key
  117164. */
  117165. getOrAdd(key: string, val: T): T;
  117166. /**
  117167. * Check if there's a given key in the dictionary
  117168. * @param key the key to check for
  117169. * @return true if the key is present, false otherwise
  117170. */
  117171. contains(key: string): boolean;
  117172. /**
  117173. * Add a new key and its corresponding value
  117174. * @param key the key to add
  117175. * @param value the value corresponding to the key
  117176. * @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
  117177. */
  117178. add(key: string, value: T): boolean;
  117179. /**
  117180. * Update a specific value associated to a key
  117181. * @param key defines the key to use
  117182. * @param value defines the value to store
  117183. * @returns true if the value was updated (or false if the key was not found)
  117184. */
  117185. set(key: string, value: T): boolean;
  117186. /**
  117187. * Get the element of the given key and remove it from the dictionary
  117188. * @param key defines the key to search
  117189. * @returns the value associated with the key or null if not found
  117190. */
  117191. getAndRemove(key: string): Nullable<T>;
  117192. /**
  117193. * Remove a key/value from the dictionary.
  117194. * @param key the key to remove
  117195. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117196. */
  117197. remove(key: string): boolean;
  117198. /**
  117199. * Clear the whole content of the dictionary
  117200. */
  117201. clear(): void;
  117202. /**
  117203. * Gets the current count
  117204. */
  117205. get count(): number;
  117206. /**
  117207. * Execute a callback on each key/val of the dictionary.
  117208. * Note that you can remove any element in this dictionary in the callback implementation
  117209. * @param callback the callback to execute on a given key/value pair
  117210. */
  117211. forEach(callback: (key: string, val: T) => void): void;
  117212. /**
  117213. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117214. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117215. * Note that you can remove any element in this dictionary in the callback implementation
  117216. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117217. * @returns the first item
  117218. */
  117219. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117220. private _count;
  117221. private _data;
  117222. }
  117223. }
  117224. declare module BABYLON {
  117225. /** @hidden */
  117226. export interface ICollisionCoordinator {
  117227. createCollider(): Collider;
  117228. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117229. init(scene: Scene): void;
  117230. }
  117231. /** @hidden */
  117232. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117233. private _scene;
  117234. private _scaledPosition;
  117235. private _scaledVelocity;
  117236. private _finalPosition;
  117237. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117238. createCollider(): Collider;
  117239. init(scene: Scene): void;
  117240. private _collideWithWorld;
  117241. }
  117242. }
  117243. declare module BABYLON {
  117244. /**
  117245. * Class used to manage all inputs for the scene.
  117246. */
  117247. export class InputManager {
  117248. /** The distance in pixel that you have to move to prevent some events */
  117249. static DragMovementThreshold: number;
  117250. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117251. static LongPressDelay: number;
  117252. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117253. static DoubleClickDelay: number;
  117254. /** If you need to check double click without raising a single click at first click, enable this flag */
  117255. static ExclusiveDoubleClickMode: boolean;
  117256. private _wheelEventName;
  117257. private _onPointerMove;
  117258. private _onPointerDown;
  117259. private _onPointerUp;
  117260. private _initClickEvent;
  117261. private _initActionManager;
  117262. private _delayedSimpleClick;
  117263. private _delayedSimpleClickTimeout;
  117264. private _previousDelayedSimpleClickTimeout;
  117265. private _meshPickProceed;
  117266. private _previousButtonPressed;
  117267. private _currentPickResult;
  117268. private _previousPickResult;
  117269. private _totalPointersPressed;
  117270. private _doubleClickOccured;
  117271. private _pointerOverMesh;
  117272. private _pickedDownMesh;
  117273. private _pickedUpMesh;
  117274. private _pointerX;
  117275. private _pointerY;
  117276. private _unTranslatedPointerX;
  117277. private _unTranslatedPointerY;
  117278. private _startingPointerPosition;
  117279. private _previousStartingPointerPosition;
  117280. private _startingPointerTime;
  117281. private _previousStartingPointerTime;
  117282. private _pointerCaptures;
  117283. private _onKeyDown;
  117284. private _onKeyUp;
  117285. private _onCanvasFocusObserver;
  117286. private _onCanvasBlurObserver;
  117287. private _scene;
  117288. /**
  117289. * Creates a new InputManager
  117290. * @param scene defines the hosting scene
  117291. */
  117292. constructor(scene: Scene);
  117293. /**
  117294. * Gets the mesh that is currently under the pointer
  117295. */
  117296. get meshUnderPointer(): Nullable<AbstractMesh>;
  117297. /**
  117298. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117299. */
  117300. get unTranslatedPointer(): Vector2;
  117301. /**
  117302. * Gets or sets the current on-screen X position of the pointer
  117303. */
  117304. get pointerX(): number;
  117305. set pointerX(value: number);
  117306. /**
  117307. * Gets or sets the current on-screen Y position of the pointer
  117308. */
  117309. get pointerY(): number;
  117310. set pointerY(value: number);
  117311. private _updatePointerPosition;
  117312. private _processPointerMove;
  117313. private _setRayOnPointerInfo;
  117314. private _checkPrePointerObservable;
  117315. /**
  117316. * Use this method to simulate a pointer move on a mesh
  117317. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117318. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117319. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117320. */
  117321. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117322. /**
  117323. * Use this method to simulate a pointer down on a mesh
  117324. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117325. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117326. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117327. */
  117328. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117329. private _processPointerDown;
  117330. /** @hidden */
  117331. _isPointerSwiping(): boolean;
  117332. /**
  117333. * Use this method to simulate a pointer up on a mesh
  117334. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117335. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117336. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117337. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117338. */
  117339. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117340. private _processPointerUp;
  117341. /**
  117342. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117343. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117344. * @returns true if the pointer was captured
  117345. */
  117346. isPointerCaptured(pointerId?: number): boolean;
  117347. /**
  117348. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117349. * @param attachUp defines if you want to attach events to pointerup
  117350. * @param attachDown defines if you want to attach events to pointerdown
  117351. * @param attachMove defines if you want to attach events to pointermove
  117352. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117353. */
  117354. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117355. /**
  117356. * Detaches all event handlers
  117357. */
  117358. detachControl(): void;
  117359. /**
  117360. * Force the value of meshUnderPointer
  117361. * @param mesh defines the mesh to use
  117362. */
  117363. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117364. /**
  117365. * Gets the mesh under the pointer
  117366. * @returns a Mesh or null if no mesh is under the pointer
  117367. */
  117368. getPointerOverMesh(): Nullable<AbstractMesh>;
  117369. }
  117370. }
  117371. declare module BABYLON {
  117372. /**
  117373. * This class defines the direct association between an animation and a target
  117374. */
  117375. export class TargetedAnimation {
  117376. /**
  117377. * Animation to perform
  117378. */
  117379. animation: Animation;
  117380. /**
  117381. * Target to animate
  117382. */
  117383. target: any;
  117384. /**
  117385. * Returns the string "TargetedAnimation"
  117386. * @returns "TargetedAnimation"
  117387. */
  117388. getClassName(): string;
  117389. /**
  117390. * Serialize the object
  117391. * @returns the JSON object representing the current entity
  117392. */
  117393. serialize(): any;
  117394. }
  117395. /**
  117396. * Use this class to create coordinated animations on multiple targets
  117397. */
  117398. export class AnimationGroup implements IDisposable {
  117399. /** The name of the animation group */
  117400. name: string;
  117401. private _scene;
  117402. private _targetedAnimations;
  117403. private _animatables;
  117404. private _from;
  117405. private _to;
  117406. private _isStarted;
  117407. private _isPaused;
  117408. private _speedRatio;
  117409. private _loopAnimation;
  117410. private _isAdditive;
  117411. /**
  117412. * Gets or sets the unique id of the node
  117413. */
  117414. uniqueId: number;
  117415. /**
  117416. * This observable will notify when one animation have ended
  117417. */
  117418. onAnimationEndObservable: Observable<TargetedAnimation>;
  117419. /**
  117420. * Observer raised when one animation loops
  117421. */
  117422. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117423. /**
  117424. * Observer raised when all animations have looped
  117425. */
  117426. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117427. /**
  117428. * This observable will notify when all animations have ended.
  117429. */
  117430. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  117431. /**
  117432. * This observable will notify when all animations have paused.
  117433. */
  117434. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  117435. /**
  117436. * This observable will notify when all animations are playing.
  117437. */
  117438. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  117439. /**
  117440. * Gets the first frame
  117441. */
  117442. get from(): number;
  117443. /**
  117444. * Gets the last frame
  117445. */
  117446. get to(): number;
  117447. /**
  117448. * Define if the animations are started
  117449. */
  117450. get isStarted(): boolean;
  117451. /**
  117452. * Gets a value indicating that the current group is playing
  117453. */
  117454. get isPlaying(): boolean;
  117455. /**
  117456. * Gets or sets the speed ratio to use for all animations
  117457. */
  117458. get speedRatio(): number;
  117459. /**
  117460. * Gets or sets the speed ratio to use for all animations
  117461. */
  117462. set speedRatio(value: number);
  117463. /**
  117464. * Gets or sets if all animations should loop or not
  117465. */
  117466. get loopAnimation(): boolean;
  117467. set loopAnimation(value: boolean);
  117468. /**
  117469. * Gets or sets if all animations should be evaluated additively
  117470. */
  117471. get isAdditive(): boolean;
  117472. set isAdditive(value: boolean);
  117473. /**
  117474. * Gets the targeted animations for this animation group
  117475. */
  117476. get targetedAnimations(): Array<TargetedAnimation>;
  117477. /**
  117478. * returning the list of animatables controlled by this animation group.
  117479. */
  117480. get animatables(): Array<Animatable>;
  117481. /**
  117482. * Gets the list of target animations
  117483. */
  117484. get children(): TargetedAnimation[];
  117485. /**
  117486. * Instantiates a new Animation Group.
  117487. * This helps managing several animations at once.
  117488. * @see https://doc.babylonjs.com/how_to/group
  117489. * @param name Defines the name of the group
  117490. * @param scene Defines the scene the group belongs to
  117491. */
  117492. constructor(
  117493. /** The name of the animation group */
  117494. name: string, scene?: Nullable<Scene>);
  117495. /**
  117496. * Add an animation (with its target) in the group
  117497. * @param animation defines the animation we want to add
  117498. * @param target defines the target of the animation
  117499. * @returns the TargetedAnimation object
  117500. */
  117501. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  117502. /**
  117503. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  117504. * It can add constant keys at begin or end
  117505. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  117506. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  117507. * @returns the animation group
  117508. */
  117509. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  117510. private _animationLoopCount;
  117511. private _animationLoopFlags;
  117512. private _processLoop;
  117513. /**
  117514. * Start all animations on given targets
  117515. * @param loop defines if animations must loop
  117516. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  117517. * @param from defines the from key (optional)
  117518. * @param to defines the to key (optional)
  117519. * @param isAdditive defines the additive state for the resulting animatables (optional)
  117520. * @returns the current animation group
  117521. */
  117522. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  117523. /**
  117524. * Pause all animations
  117525. * @returns the animation group
  117526. */
  117527. pause(): AnimationGroup;
  117528. /**
  117529. * Play all animations to initial state
  117530. * This function will start() the animations if they were not started or will restart() them if they were paused
  117531. * @param loop defines if animations must loop
  117532. * @returns the animation group
  117533. */
  117534. play(loop?: boolean): AnimationGroup;
  117535. /**
  117536. * Reset all animations to initial state
  117537. * @returns the animation group
  117538. */
  117539. reset(): AnimationGroup;
  117540. /**
  117541. * Restart animations from key 0
  117542. * @returns the animation group
  117543. */
  117544. restart(): AnimationGroup;
  117545. /**
  117546. * Stop all animations
  117547. * @returns the animation group
  117548. */
  117549. stop(): AnimationGroup;
  117550. /**
  117551. * Set animation weight for all animatables
  117552. * @param weight defines the weight to use
  117553. * @return the animationGroup
  117554. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117555. */
  117556. setWeightForAllAnimatables(weight: number): AnimationGroup;
  117557. /**
  117558. * Synchronize and normalize all animatables with a source animatable
  117559. * @param root defines the root animatable to synchronize with
  117560. * @return the animationGroup
  117561. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117562. */
  117563. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  117564. /**
  117565. * Goes to a specific frame in this animation group
  117566. * @param frame the frame number to go to
  117567. * @return the animationGroup
  117568. */
  117569. goToFrame(frame: number): AnimationGroup;
  117570. /**
  117571. * Dispose all associated resources
  117572. */
  117573. dispose(): void;
  117574. private _checkAnimationGroupEnded;
  117575. /**
  117576. * Clone the current animation group and returns a copy
  117577. * @param newName defines the name of the new group
  117578. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  117579. * @returns the new aniamtion group
  117580. */
  117581. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  117582. /**
  117583. * Serializes the animationGroup to an object
  117584. * @returns Serialized object
  117585. */
  117586. serialize(): any;
  117587. /**
  117588. * Returns a new AnimationGroup object parsed from the source provided.
  117589. * @param parsedAnimationGroup defines the source
  117590. * @param scene defines the scene that will receive the animationGroup
  117591. * @returns a new AnimationGroup
  117592. */
  117593. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  117594. /**
  117595. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117596. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  117597. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117598. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  117599. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  117600. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  117601. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  117602. */
  117603. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  117604. /**
  117605. * Returns the string "AnimationGroup"
  117606. * @returns "AnimationGroup"
  117607. */
  117608. getClassName(): string;
  117609. /**
  117610. * Creates a detailled string about the object
  117611. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  117612. * @returns a string representing the object
  117613. */
  117614. toString(fullDetails?: boolean): string;
  117615. }
  117616. }
  117617. declare module BABYLON {
  117618. /**
  117619. * Define an interface for all classes that will hold resources
  117620. */
  117621. export interface IDisposable {
  117622. /**
  117623. * Releases all held resources
  117624. */
  117625. dispose(): void;
  117626. }
  117627. /** Interface defining initialization parameters for Scene class */
  117628. export interface SceneOptions {
  117629. /**
  117630. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  117631. * It will improve performance when the number of geometries becomes important.
  117632. */
  117633. useGeometryUniqueIdsMap?: boolean;
  117634. /**
  117635. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  117636. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  117637. */
  117638. useMaterialMeshMap?: boolean;
  117639. /**
  117640. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  117641. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  117642. */
  117643. useClonedMeshMap?: boolean;
  117644. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  117645. virtual?: boolean;
  117646. }
  117647. /**
  117648. * Represents a scene to be rendered by the engine.
  117649. * @see https://doc.babylonjs.com/features/scene
  117650. */
  117651. export class Scene extends AbstractScene implements IAnimatable {
  117652. /** The fog is deactivated */
  117653. static readonly FOGMODE_NONE: number;
  117654. /** The fog density is following an exponential function */
  117655. static readonly FOGMODE_EXP: number;
  117656. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  117657. static readonly FOGMODE_EXP2: number;
  117658. /** The fog density is following a linear function. */
  117659. static readonly FOGMODE_LINEAR: number;
  117660. /**
  117661. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  117662. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117663. */
  117664. static MinDeltaTime: number;
  117665. /**
  117666. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  117667. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117668. */
  117669. static MaxDeltaTime: number;
  117670. /**
  117671. * Factory used to create the default material.
  117672. * @param name The name of the material to create
  117673. * @param scene The scene to create the material for
  117674. * @returns The default material
  117675. */
  117676. static DefaultMaterialFactory(scene: Scene): Material;
  117677. /**
  117678. * Factory used to create the a collision coordinator.
  117679. * @returns The collision coordinator
  117680. */
  117681. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  117682. /** @hidden */
  117683. _inputManager: InputManager;
  117684. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  117685. cameraToUseForPointers: Nullable<Camera>;
  117686. /** @hidden */
  117687. readonly _isScene: boolean;
  117688. /** @hidden */
  117689. _blockEntityCollection: boolean;
  117690. /**
  117691. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  117692. */
  117693. autoClear: boolean;
  117694. /**
  117695. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  117696. */
  117697. autoClearDepthAndStencil: boolean;
  117698. /**
  117699. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  117700. */
  117701. clearColor: Color4;
  117702. /**
  117703. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  117704. */
  117705. ambientColor: Color3;
  117706. /**
  117707. * This is use to store the default BRDF lookup for PBR materials in your scene.
  117708. * It should only be one of the following (if not the default embedded one):
  117709. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117710. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  117711. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117712. * The material properties need to be setup according to the type of texture in use.
  117713. */
  117714. environmentBRDFTexture: BaseTexture;
  117715. /** @hidden */
  117716. protected _environmentTexture: Nullable<BaseTexture>;
  117717. /**
  117718. * Texture used in all pbr material as the reflection texture.
  117719. * As in the majority of the scene they are the same (exception for multi room and so on),
  117720. * this is easier to reference from here than from all the materials.
  117721. */
  117722. get environmentTexture(): Nullable<BaseTexture>;
  117723. /**
  117724. * Texture used in all pbr material as the reflection texture.
  117725. * As in the majority of the scene they are the same (exception for multi room and so on),
  117726. * this is easier to set here than in all the materials.
  117727. */
  117728. set environmentTexture(value: Nullable<BaseTexture>);
  117729. /** @hidden */
  117730. protected _environmentIntensity: number;
  117731. /**
  117732. * Intensity of the environment in all pbr material.
  117733. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  117734. * As in the majority of the scene they are the same (exception for multi room and so on),
  117735. * this is easier to reference from here than from all the materials.
  117736. */
  117737. get environmentIntensity(): number;
  117738. /**
  117739. * Intensity of the environment in all pbr material.
  117740. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  117741. * As in the majority of the scene they are the same (exception for multi room and so on),
  117742. * this is easier to set here than in all the materials.
  117743. */
  117744. set environmentIntensity(value: number);
  117745. /** @hidden */
  117746. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117747. /**
  117748. * Default image processing configuration used either in the rendering
  117749. * Forward main pass or through the imageProcessingPostProcess if present.
  117750. * As in the majority of the scene they are the same (exception for multi camera),
  117751. * this is easier to reference from here than from all the materials and post process.
  117752. *
  117753. * No setter as we it is a shared configuration, you can set the values instead.
  117754. */
  117755. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  117756. private _forceWireframe;
  117757. /**
  117758. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  117759. */
  117760. set forceWireframe(value: boolean);
  117761. get forceWireframe(): boolean;
  117762. private _skipFrustumClipping;
  117763. /**
  117764. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  117765. */
  117766. set skipFrustumClipping(value: boolean);
  117767. get skipFrustumClipping(): boolean;
  117768. private _forcePointsCloud;
  117769. /**
  117770. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  117771. */
  117772. set forcePointsCloud(value: boolean);
  117773. get forcePointsCloud(): boolean;
  117774. /**
  117775. * Gets or sets the active clipplane 1
  117776. */
  117777. clipPlane: Nullable<Plane>;
  117778. /**
  117779. * Gets or sets the active clipplane 2
  117780. */
  117781. clipPlane2: Nullable<Plane>;
  117782. /**
  117783. * Gets or sets the active clipplane 3
  117784. */
  117785. clipPlane3: Nullable<Plane>;
  117786. /**
  117787. * Gets or sets the active clipplane 4
  117788. */
  117789. clipPlane4: Nullable<Plane>;
  117790. /**
  117791. * Gets or sets the active clipplane 5
  117792. */
  117793. clipPlane5: Nullable<Plane>;
  117794. /**
  117795. * Gets or sets the active clipplane 6
  117796. */
  117797. clipPlane6: Nullable<Plane>;
  117798. /**
  117799. * Gets or sets a boolean indicating if animations are enabled
  117800. */
  117801. animationsEnabled: boolean;
  117802. private _animationPropertiesOverride;
  117803. /**
  117804. * Gets or sets the animation properties override
  117805. */
  117806. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117807. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117808. /**
  117809. * Gets or sets a boolean indicating if a constant deltatime has to be used
  117810. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  117811. */
  117812. useConstantAnimationDeltaTime: boolean;
  117813. /**
  117814. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  117815. * Please note that it requires to run a ray cast through the scene on every frame
  117816. */
  117817. constantlyUpdateMeshUnderPointer: boolean;
  117818. /**
  117819. * Defines the HTML cursor to use when hovering over interactive elements
  117820. */
  117821. hoverCursor: string;
  117822. /**
  117823. * Defines the HTML default cursor to use (empty by default)
  117824. */
  117825. defaultCursor: string;
  117826. /**
  117827. * Defines whether cursors are handled by the scene.
  117828. */
  117829. doNotHandleCursors: boolean;
  117830. /**
  117831. * This is used to call preventDefault() on pointer down
  117832. * in order to block unwanted artifacts like system double clicks
  117833. */
  117834. preventDefaultOnPointerDown: boolean;
  117835. /**
  117836. * This is used to call preventDefault() on pointer up
  117837. * in order to block unwanted artifacts like system double clicks
  117838. */
  117839. preventDefaultOnPointerUp: boolean;
  117840. /**
  117841. * Gets or sets user defined metadata
  117842. */
  117843. metadata: any;
  117844. /**
  117845. * For internal use only. Please do not use.
  117846. */
  117847. reservedDataStore: any;
  117848. /**
  117849. * Gets the name of the plugin used to load this scene (null by default)
  117850. */
  117851. loadingPluginName: string;
  117852. /**
  117853. * Use this array to add regular expressions used to disable offline support for specific urls
  117854. */
  117855. disableOfflineSupportExceptionRules: RegExp[];
  117856. /**
  117857. * An event triggered when the scene is disposed.
  117858. */
  117859. onDisposeObservable: Observable<Scene>;
  117860. private _onDisposeObserver;
  117861. /** Sets a function to be executed when this scene is disposed. */
  117862. set onDispose(callback: () => void);
  117863. /**
  117864. * An event triggered before rendering the scene (right after animations and physics)
  117865. */
  117866. onBeforeRenderObservable: Observable<Scene>;
  117867. private _onBeforeRenderObserver;
  117868. /** Sets a function to be executed before rendering this scene */
  117869. set beforeRender(callback: Nullable<() => void>);
  117870. /**
  117871. * An event triggered after rendering the scene
  117872. */
  117873. onAfterRenderObservable: Observable<Scene>;
  117874. /**
  117875. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  117876. */
  117877. onAfterRenderCameraObservable: Observable<Camera>;
  117878. private _onAfterRenderObserver;
  117879. /** Sets a function to be executed after rendering this scene */
  117880. set afterRender(callback: Nullable<() => void>);
  117881. /**
  117882. * An event triggered before animating the scene
  117883. */
  117884. onBeforeAnimationsObservable: Observable<Scene>;
  117885. /**
  117886. * An event triggered after animations processing
  117887. */
  117888. onAfterAnimationsObservable: Observable<Scene>;
  117889. /**
  117890. * An event triggered before draw calls are ready to be sent
  117891. */
  117892. onBeforeDrawPhaseObservable: Observable<Scene>;
  117893. /**
  117894. * An event triggered after draw calls have been sent
  117895. */
  117896. onAfterDrawPhaseObservable: Observable<Scene>;
  117897. /**
  117898. * An event triggered when the scene is ready
  117899. */
  117900. onReadyObservable: Observable<Scene>;
  117901. /**
  117902. * An event triggered before rendering a camera
  117903. */
  117904. onBeforeCameraRenderObservable: Observable<Camera>;
  117905. private _onBeforeCameraRenderObserver;
  117906. /** Sets a function to be executed before rendering a camera*/
  117907. set beforeCameraRender(callback: () => void);
  117908. /**
  117909. * An event triggered after rendering a camera
  117910. */
  117911. onAfterCameraRenderObservable: Observable<Camera>;
  117912. private _onAfterCameraRenderObserver;
  117913. /** Sets a function to be executed after rendering a camera*/
  117914. set afterCameraRender(callback: () => void);
  117915. /**
  117916. * An event triggered when active meshes evaluation is about to start
  117917. */
  117918. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  117919. /**
  117920. * An event triggered when active meshes evaluation is done
  117921. */
  117922. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  117923. /**
  117924. * An event triggered when particles rendering is about to start
  117925. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  117926. */
  117927. onBeforeParticlesRenderingObservable: Observable<Scene>;
  117928. /**
  117929. * An event triggered when particles rendering is done
  117930. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  117931. */
  117932. onAfterParticlesRenderingObservable: Observable<Scene>;
  117933. /**
  117934. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  117935. */
  117936. onDataLoadedObservable: Observable<Scene>;
  117937. /**
  117938. * An event triggered when a camera is created
  117939. */
  117940. onNewCameraAddedObservable: Observable<Camera>;
  117941. /**
  117942. * An event triggered when a camera is removed
  117943. */
  117944. onCameraRemovedObservable: Observable<Camera>;
  117945. /**
  117946. * An event triggered when a light is created
  117947. */
  117948. onNewLightAddedObservable: Observable<Light>;
  117949. /**
  117950. * An event triggered when a light is removed
  117951. */
  117952. onLightRemovedObservable: Observable<Light>;
  117953. /**
  117954. * An event triggered when a geometry is created
  117955. */
  117956. onNewGeometryAddedObservable: Observable<Geometry>;
  117957. /**
  117958. * An event triggered when a geometry is removed
  117959. */
  117960. onGeometryRemovedObservable: Observable<Geometry>;
  117961. /**
  117962. * An event triggered when a transform node is created
  117963. */
  117964. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  117965. /**
  117966. * An event triggered when a transform node is removed
  117967. */
  117968. onTransformNodeRemovedObservable: Observable<TransformNode>;
  117969. /**
  117970. * An event triggered when a mesh is created
  117971. */
  117972. onNewMeshAddedObservable: Observable<AbstractMesh>;
  117973. /**
  117974. * An event triggered when a mesh is removed
  117975. */
  117976. onMeshRemovedObservable: Observable<AbstractMesh>;
  117977. /**
  117978. * An event triggered when a skeleton is created
  117979. */
  117980. onNewSkeletonAddedObservable: Observable<Skeleton>;
  117981. /**
  117982. * An event triggered when a skeleton is removed
  117983. */
  117984. onSkeletonRemovedObservable: Observable<Skeleton>;
  117985. /**
  117986. * An event triggered when a material is created
  117987. */
  117988. onNewMaterialAddedObservable: Observable<Material>;
  117989. /**
  117990. * An event triggered when a material is removed
  117991. */
  117992. onMaterialRemovedObservable: Observable<Material>;
  117993. /**
  117994. * An event triggered when a texture is created
  117995. */
  117996. onNewTextureAddedObservable: Observable<BaseTexture>;
  117997. /**
  117998. * An event triggered when a texture is removed
  117999. */
  118000. onTextureRemovedObservable: Observable<BaseTexture>;
  118001. /**
  118002. * An event triggered when render targets are about to be rendered
  118003. * Can happen multiple times per frame.
  118004. */
  118005. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118006. /**
  118007. * An event triggered when render targets were rendered.
  118008. * Can happen multiple times per frame.
  118009. */
  118010. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118011. /**
  118012. * An event triggered before calculating deterministic simulation step
  118013. */
  118014. onBeforeStepObservable: Observable<Scene>;
  118015. /**
  118016. * An event triggered after calculating deterministic simulation step
  118017. */
  118018. onAfterStepObservable: Observable<Scene>;
  118019. /**
  118020. * An event triggered when the activeCamera property is updated
  118021. */
  118022. onActiveCameraChanged: Observable<Scene>;
  118023. /**
  118024. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118025. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118026. * 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)
  118027. */
  118028. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118029. /**
  118030. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118031. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118032. * 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)
  118033. */
  118034. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118035. /**
  118036. * This Observable will when a mesh has been imported into the scene.
  118037. */
  118038. onMeshImportedObservable: Observable<AbstractMesh>;
  118039. /**
  118040. * This Observable will when an animation file has been imported into the scene.
  118041. */
  118042. onAnimationFileImportedObservable: Observable<Scene>;
  118043. /**
  118044. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118045. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118046. */
  118047. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118048. /** @hidden */
  118049. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118050. /**
  118051. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118052. */
  118053. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118054. /**
  118055. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118056. */
  118057. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118058. /**
  118059. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118060. */
  118061. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118062. /** Callback called when a pointer move is detected */
  118063. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118064. /** Callback called when a pointer down is detected */
  118065. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118066. /** Callback called when a pointer up is detected */
  118067. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118068. /** Callback called when a pointer pick is detected */
  118069. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118070. /**
  118071. * 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).
  118072. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118073. */
  118074. onPrePointerObservable: Observable<PointerInfoPre>;
  118075. /**
  118076. * Observable event triggered each time an input event is received from the rendering canvas
  118077. */
  118078. onPointerObservable: Observable<PointerInfo>;
  118079. /**
  118080. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118081. */
  118082. get unTranslatedPointer(): Vector2;
  118083. /**
  118084. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118085. */
  118086. static get DragMovementThreshold(): number;
  118087. static set DragMovementThreshold(value: number);
  118088. /**
  118089. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118090. */
  118091. static get LongPressDelay(): number;
  118092. static set LongPressDelay(value: number);
  118093. /**
  118094. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118095. */
  118096. static get DoubleClickDelay(): number;
  118097. static set DoubleClickDelay(value: number);
  118098. /** If you need to check double click without raising a single click at first click, enable this flag */
  118099. static get ExclusiveDoubleClickMode(): boolean;
  118100. static set ExclusiveDoubleClickMode(value: boolean);
  118101. /** @hidden */
  118102. _mirroredCameraPosition: Nullable<Vector3>;
  118103. /**
  118104. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118105. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118106. */
  118107. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118108. /**
  118109. * Observable event triggered each time an keyboard event is received from the hosting window
  118110. */
  118111. onKeyboardObservable: Observable<KeyboardInfo>;
  118112. private _useRightHandedSystem;
  118113. /**
  118114. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118115. */
  118116. set useRightHandedSystem(value: boolean);
  118117. get useRightHandedSystem(): boolean;
  118118. private _timeAccumulator;
  118119. private _currentStepId;
  118120. private _currentInternalStep;
  118121. /**
  118122. * Sets the step Id used by deterministic lock step
  118123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118124. * @param newStepId defines the step Id
  118125. */
  118126. setStepId(newStepId: number): void;
  118127. /**
  118128. * Gets the step Id used by deterministic lock step
  118129. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118130. * @returns the step Id
  118131. */
  118132. getStepId(): number;
  118133. /**
  118134. * Gets the internal step used by deterministic lock step
  118135. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118136. * @returns the internal step
  118137. */
  118138. getInternalStep(): number;
  118139. private _fogEnabled;
  118140. /**
  118141. * Gets or sets a boolean indicating if fog is enabled on this scene
  118142. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118143. * (Default is true)
  118144. */
  118145. set fogEnabled(value: boolean);
  118146. get fogEnabled(): boolean;
  118147. private _fogMode;
  118148. /**
  118149. * Gets or sets the fog mode to use
  118150. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118151. * | mode | value |
  118152. * | --- | --- |
  118153. * | FOGMODE_NONE | 0 |
  118154. * | FOGMODE_EXP | 1 |
  118155. * | FOGMODE_EXP2 | 2 |
  118156. * | FOGMODE_LINEAR | 3 |
  118157. */
  118158. set fogMode(value: number);
  118159. get fogMode(): number;
  118160. /**
  118161. * Gets or sets the fog color to use
  118162. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118163. * (Default is Color3(0.2, 0.2, 0.3))
  118164. */
  118165. fogColor: Color3;
  118166. /**
  118167. * Gets or sets the fog density to use
  118168. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118169. * (Default is 0.1)
  118170. */
  118171. fogDensity: number;
  118172. /**
  118173. * Gets or sets the fog start distance to use
  118174. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118175. * (Default is 0)
  118176. */
  118177. fogStart: number;
  118178. /**
  118179. * Gets or sets the fog end distance to use
  118180. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118181. * (Default is 1000)
  118182. */
  118183. fogEnd: number;
  118184. /**
  118185. * Flag indicating that the frame buffer binding is handled by another component
  118186. */
  118187. prePass: boolean;
  118188. private _shadowsEnabled;
  118189. /**
  118190. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118191. */
  118192. set shadowsEnabled(value: boolean);
  118193. get shadowsEnabled(): boolean;
  118194. private _lightsEnabled;
  118195. /**
  118196. * Gets or sets a boolean indicating if lights are enabled on this scene
  118197. */
  118198. set lightsEnabled(value: boolean);
  118199. get lightsEnabled(): boolean;
  118200. /** All of the active cameras added to this scene. */
  118201. activeCameras: Camera[];
  118202. /** @hidden */
  118203. _activeCamera: Nullable<Camera>;
  118204. /** Gets or sets the current active camera */
  118205. get activeCamera(): Nullable<Camera>;
  118206. set activeCamera(value: Nullable<Camera>);
  118207. private _defaultMaterial;
  118208. /** The default material used on meshes when no material is affected */
  118209. get defaultMaterial(): Material;
  118210. /** The default material used on meshes when no material is affected */
  118211. set defaultMaterial(value: Material);
  118212. private _texturesEnabled;
  118213. /**
  118214. * Gets or sets a boolean indicating if textures are enabled on this scene
  118215. */
  118216. set texturesEnabled(value: boolean);
  118217. get texturesEnabled(): boolean;
  118218. /**
  118219. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118220. */
  118221. physicsEnabled: boolean;
  118222. /**
  118223. * Gets or sets a boolean indicating if particles are enabled on this scene
  118224. */
  118225. particlesEnabled: boolean;
  118226. /**
  118227. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118228. */
  118229. spritesEnabled: boolean;
  118230. private _skeletonsEnabled;
  118231. /**
  118232. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118233. */
  118234. set skeletonsEnabled(value: boolean);
  118235. get skeletonsEnabled(): boolean;
  118236. /**
  118237. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118238. */
  118239. lensFlaresEnabled: boolean;
  118240. /**
  118241. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118242. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118243. */
  118244. collisionsEnabled: boolean;
  118245. private _collisionCoordinator;
  118246. /** @hidden */
  118247. get collisionCoordinator(): ICollisionCoordinator;
  118248. /**
  118249. * Defines the gravity applied to this scene (used only for collisions)
  118250. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118251. */
  118252. gravity: Vector3;
  118253. /**
  118254. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118255. */
  118256. postProcessesEnabled: boolean;
  118257. /**
  118258. * The list of postprocesses added to the scene
  118259. */
  118260. postProcesses: PostProcess[];
  118261. /**
  118262. * Gets the current postprocess manager
  118263. */
  118264. postProcessManager: PostProcessManager;
  118265. /**
  118266. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118267. */
  118268. renderTargetsEnabled: boolean;
  118269. /**
  118270. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118271. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118272. */
  118273. dumpNextRenderTargets: boolean;
  118274. /**
  118275. * The list of user defined render targets added to the scene
  118276. */
  118277. customRenderTargets: RenderTargetTexture[];
  118278. /**
  118279. * Defines if texture loading must be delayed
  118280. * If true, textures will only be loaded when they need to be rendered
  118281. */
  118282. useDelayedTextureLoading: boolean;
  118283. /**
  118284. * Gets the list of meshes imported to the scene through SceneLoader
  118285. */
  118286. importedMeshesFiles: String[];
  118287. /**
  118288. * Gets or sets a boolean indicating if probes are enabled on this scene
  118289. */
  118290. probesEnabled: boolean;
  118291. /**
  118292. * Gets or sets the current offline provider to use to store scene data
  118293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118294. */
  118295. offlineProvider: IOfflineProvider;
  118296. /**
  118297. * Gets or sets the action manager associated with the scene
  118298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118299. */
  118300. actionManager: AbstractActionManager;
  118301. private _meshesForIntersections;
  118302. /**
  118303. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118304. */
  118305. proceduralTexturesEnabled: boolean;
  118306. private _engine;
  118307. private _totalVertices;
  118308. /** @hidden */
  118309. _activeIndices: PerfCounter;
  118310. /** @hidden */
  118311. _activeParticles: PerfCounter;
  118312. /** @hidden */
  118313. _activeBones: PerfCounter;
  118314. private _animationRatio;
  118315. /** @hidden */
  118316. _animationTimeLast: number;
  118317. /** @hidden */
  118318. _animationTime: number;
  118319. /**
  118320. * Gets or sets a general scale for animation speed
  118321. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118322. */
  118323. animationTimeScale: number;
  118324. /** @hidden */
  118325. _cachedMaterial: Nullable<Material>;
  118326. /** @hidden */
  118327. _cachedEffect: Nullable<Effect>;
  118328. /** @hidden */
  118329. _cachedVisibility: Nullable<number>;
  118330. private _renderId;
  118331. private _frameId;
  118332. private _executeWhenReadyTimeoutId;
  118333. private _intermediateRendering;
  118334. private _viewUpdateFlag;
  118335. private _projectionUpdateFlag;
  118336. /** @hidden */
  118337. _toBeDisposed: Nullable<IDisposable>[];
  118338. private _activeRequests;
  118339. /** @hidden */
  118340. _pendingData: any[];
  118341. private _isDisposed;
  118342. /**
  118343. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118344. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118345. */
  118346. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118347. private _activeMeshes;
  118348. private _processedMaterials;
  118349. private _renderTargets;
  118350. /** @hidden */
  118351. _activeParticleSystems: SmartArray<IParticleSystem>;
  118352. private _activeSkeletons;
  118353. private _softwareSkinnedMeshes;
  118354. private _renderingManager;
  118355. /** @hidden */
  118356. _activeAnimatables: Animatable[];
  118357. private _transformMatrix;
  118358. private _sceneUbo;
  118359. /** @hidden */
  118360. _viewMatrix: Matrix;
  118361. private _projectionMatrix;
  118362. /** @hidden */
  118363. _forcedViewPosition: Nullable<Vector3>;
  118364. /** @hidden */
  118365. _frustumPlanes: Plane[];
  118366. /**
  118367. * Gets the list of frustum planes (built from the active camera)
  118368. */
  118369. get frustumPlanes(): Plane[];
  118370. /**
  118371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118372. * This is useful if there are more lights that the maximum simulteanous authorized
  118373. */
  118374. requireLightSorting: boolean;
  118375. /** @hidden */
  118376. readonly useMaterialMeshMap: boolean;
  118377. /** @hidden */
  118378. readonly useClonedMeshMap: boolean;
  118379. private _externalData;
  118380. private _uid;
  118381. /**
  118382. * @hidden
  118383. * Backing store of defined scene components.
  118384. */
  118385. _components: ISceneComponent[];
  118386. /**
  118387. * @hidden
  118388. * Backing store of defined scene components.
  118389. */
  118390. _serializableComponents: ISceneSerializableComponent[];
  118391. /**
  118392. * List of components to register on the next registration step.
  118393. */
  118394. private _transientComponents;
  118395. /**
  118396. * Registers the transient components if needed.
  118397. */
  118398. private _registerTransientComponents;
  118399. /**
  118400. * @hidden
  118401. * Add a component to the scene.
  118402. * Note that the ccomponent could be registered on th next frame if this is called after
  118403. * the register component stage.
  118404. * @param component Defines the component to add to the scene
  118405. */
  118406. _addComponent(component: ISceneComponent): void;
  118407. /**
  118408. * @hidden
  118409. * Gets a component from the scene.
  118410. * @param name defines the name of the component to retrieve
  118411. * @returns the component or null if not present
  118412. */
  118413. _getComponent(name: string): Nullable<ISceneComponent>;
  118414. /**
  118415. * @hidden
  118416. * Defines the actions happening before camera updates.
  118417. */
  118418. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118419. /**
  118420. * @hidden
  118421. * Defines the actions happening before clear the canvas.
  118422. */
  118423. _beforeClearStage: Stage<SimpleStageAction>;
  118424. /**
  118425. * @hidden
  118426. * Defines the actions when collecting render targets for the frame.
  118427. */
  118428. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118429. /**
  118430. * @hidden
  118431. * Defines the actions happening for one camera in the frame.
  118432. */
  118433. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118434. /**
  118435. * @hidden
  118436. * Defines the actions happening during the per mesh ready checks.
  118437. */
  118438. _isReadyForMeshStage: Stage<MeshStageAction>;
  118439. /**
  118440. * @hidden
  118441. * Defines the actions happening before evaluate active mesh checks.
  118442. */
  118443. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  118444. /**
  118445. * @hidden
  118446. * Defines the actions happening during the evaluate sub mesh checks.
  118447. */
  118448. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  118449. /**
  118450. * @hidden
  118451. * Defines the actions happening during the active mesh stage.
  118452. */
  118453. _activeMeshStage: Stage<ActiveMeshStageAction>;
  118454. /**
  118455. * @hidden
  118456. * Defines the actions happening during the per camera render target step.
  118457. */
  118458. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  118459. /**
  118460. * @hidden
  118461. * Defines the actions happening just before the active camera is drawing.
  118462. */
  118463. _beforeCameraDrawStage: Stage<CameraStageAction>;
  118464. /**
  118465. * @hidden
  118466. * Defines the actions happening just before a render target is drawing.
  118467. */
  118468. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118469. /**
  118470. * @hidden
  118471. * Defines the actions happening just before a rendering group is drawing.
  118472. */
  118473. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118474. /**
  118475. * @hidden
  118476. * Defines the actions happening just before a mesh is drawing.
  118477. */
  118478. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118479. /**
  118480. * @hidden
  118481. * Defines the actions happening just after a mesh has been drawn.
  118482. */
  118483. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118484. /**
  118485. * @hidden
  118486. * Defines the actions happening just after a rendering group has been drawn.
  118487. */
  118488. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118489. /**
  118490. * @hidden
  118491. * Defines the actions happening just after the active camera has been drawn.
  118492. */
  118493. _afterCameraDrawStage: Stage<CameraStageAction>;
  118494. /**
  118495. * @hidden
  118496. * Defines the actions happening just after a render target has been drawn.
  118497. */
  118498. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118499. /**
  118500. * @hidden
  118501. * Defines the actions happening just after rendering all cameras and computing intersections.
  118502. */
  118503. _afterRenderStage: Stage<SimpleStageAction>;
  118504. /**
  118505. * @hidden
  118506. * Defines the actions happening when a pointer move event happens.
  118507. */
  118508. _pointerMoveStage: Stage<PointerMoveStageAction>;
  118509. /**
  118510. * @hidden
  118511. * Defines the actions happening when a pointer down event happens.
  118512. */
  118513. _pointerDownStage: Stage<PointerUpDownStageAction>;
  118514. /**
  118515. * @hidden
  118516. * Defines the actions happening when a pointer up event happens.
  118517. */
  118518. _pointerUpStage: Stage<PointerUpDownStageAction>;
  118519. /**
  118520. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  118521. */
  118522. private geometriesByUniqueId;
  118523. /**
  118524. * Creates a new Scene
  118525. * @param engine defines the engine to use to render this scene
  118526. * @param options defines the scene options
  118527. */
  118528. constructor(engine: Engine, options?: SceneOptions);
  118529. /**
  118530. * Gets a string idenfifying the name of the class
  118531. * @returns "Scene" string
  118532. */
  118533. getClassName(): string;
  118534. private _defaultMeshCandidates;
  118535. /**
  118536. * @hidden
  118537. */
  118538. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118539. private _defaultSubMeshCandidates;
  118540. /**
  118541. * @hidden
  118542. */
  118543. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118544. /**
  118545. * Sets the default candidate providers for the scene.
  118546. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  118547. * and getCollidingSubMeshCandidates to their default function
  118548. */
  118549. setDefaultCandidateProviders(): void;
  118550. /**
  118551. * Gets the mesh that is currently under the pointer
  118552. */
  118553. get meshUnderPointer(): Nullable<AbstractMesh>;
  118554. /**
  118555. * Gets or sets the current on-screen X position of the pointer
  118556. */
  118557. get pointerX(): number;
  118558. set pointerX(value: number);
  118559. /**
  118560. * Gets or sets the current on-screen Y position of the pointer
  118561. */
  118562. get pointerY(): number;
  118563. set pointerY(value: number);
  118564. /**
  118565. * Gets the cached material (ie. the latest rendered one)
  118566. * @returns the cached material
  118567. */
  118568. getCachedMaterial(): Nullable<Material>;
  118569. /**
  118570. * Gets the cached effect (ie. the latest rendered one)
  118571. * @returns the cached effect
  118572. */
  118573. getCachedEffect(): Nullable<Effect>;
  118574. /**
  118575. * Gets the cached visibility state (ie. the latest rendered one)
  118576. * @returns the cached visibility state
  118577. */
  118578. getCachedVisibility(): Nullable<number>;
  118579. /**
  118580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  118581. * @param material defines the current material
  118582. * @param effect defines the current effect
  118583. * @param visibility defines the current visibility state
  118584. * @returns true if one parameter is not cached
  118585. */
  118586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  118587. /**
  118588. * Gets the engine associated with the scene
  118589. * @returns an Engine
  118590. */
  118591. getEngine(): Engine;
  118592. /**
  118593. * Gets the total number of vertices rendered per frame
  118594. * @returns the total number of vertices rendered per frame
  118595. */
  118596. getTotalVertices(): number;
  118597. /**
  118598. * Gets the performance counter for total vertices
  118599. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118600. */
  118601. get totalVerticesPerfCounter(): PerfCounter;
  118602. /**
  118603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  118604. * @returns the total number of active indices rendered per frame
  118605. */
  118606. getActiveIndices(): number;
  118607. /**
  118608. * Gets the performance counter for active indices
  118609. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118610. */
  118611. get totalActiveIndicesPerfCounter(): PerfCounter;
  118612. /**
  118613. * Gets the total number of active particles rendered per frame
  118614. * @returns the total number of active particles rendered per frame
  118615. */
  118616. getActiveParticles(): number;
  118617. /**
  118618. * Gets the performance counter for active particles
  118619. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118620. */
  118621. get activeParticlesPerfCounter(): PerfCounter;
  118622. /**
  118623. * Gets the total number of active bones rendered per frame
  118624. * @returns the total number of active bones rendered per frame
  118625. */
  118626. getActiveBones(): number;
  118627. /**
  118628. * Gets the performance counter for active bones
  118629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118630. */
  118631. get activeBonesPerfCounter(): PerfCounter;
  118632. /**
  118633. * Gets the array of active meshes
  118634. * @returns an array of AbstractMesh
  118635. */
  118636. getActiveMeshes(): SmartArray<AbstractMesh>;
  118637. /**
  118638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  118639. * @returns a number
  118640. */
  118641. getAnimationRatio(): number;
  118642. /**
  118643. * Gets an unique Id for the current render phase
  118644. * @returns a number
  118645. */
  118646. getRenderId(): number;
  118647. /**
  118648. * Gets an unique Id for the current frame
  118649. * @returns a number
  118650. */
  118651. getFrameId(): number;
  118652. /** Call this function if you want to manually increment the render Id*/
  118653. incrementRenderId(): void;
  118654. private _createUbo;
  118655. /**
  118656. * Use this method to simulate a pointer move on a mesh
  118657. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118658. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118659. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118660. * @returns the current scene
  118661. */
  118662. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  118663. /**
  118664. * Use this method to simulate a pointer down on a mesh
  118665. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118666. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118667. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118668. * @returns the current scene
  118669. */
  118670. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  118671. /**
  118672. * Use this method to simulate a pointer up on a mesh
  118673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118676. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118677. * @returns the current scene
  118678. */
  118679. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  118680. /**
  118681. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118682. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118683. * @returns true if the pointer was captured
  118684. */
  118685. isPointerCaptured(pointerId?: number): boolean;
  118686. /**
  118687. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118688. * @param attachUp defines if you want to attach events to pointerup
  118689. * @param attachDown defines if you want to attach events to pointerdown
  118690. * @param attachMove defines if you want to attach events to pointermove
  118691. */
  118692. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  118693. /** Detaches all event handlers*/
  118694. detachControl(): void;
  118695. /**
  118696. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  118697. * Delay loaded resources are not taking in account
  118698. * @return true if all required resources are ready
  118699. */
  118700. isReady(): boolean;
  118701. /** Resets all cached information relative to material (including effect and visibility) */
  118702. resetCachedMaterial(): void;
  118703. /**
  118704. * Registers a function to be called before every frame render
  118705. * @param func defines the function to register
  118706. */
  118707. registerBeforeRender(func: () => void): void;
  118708. /**
  118709. * Unregisters a function called before every frame render
  118710. * @param func defines the function to unregister
  118711. */
  118712. unregisterBeforeRender(func: () => void): void;
  118713. /**
  118714. * Registers a function to be called after every frame render
  118715. * @param func defines the function to register
  118716. */
  118717. registerAfterRender(func: () => void): void;
  118718. /**
  118719. * Unregisters a function called after every frame render
  118720. * @param func defines the function to unregister
  118721. */
  118722. unregisterAfterRender(func: () => void): void;
  118723. private _executeOnceBeforeRender;
  118724. /**
  118725. * The provided function will run before render once and will be disposed afterwards.
  118726. * A timeout delay can be provided so that the function will be executed in N ms.
  118727. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  118728. * @param func The function to be executed.
  118729. * @param timeout optional delay in ms
  118730. */
  118731. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  118732. /** @hidden */
  118733. _addPendingData(data: any): void;
  118734. /** @hidden */
  118735. _removePendingData(data: any): void;
  118736. /**
  118737. * Returns the number of items waiting to be loaded
  118738. * @returns the number of items waiting to be loaded
  118739. */
  118740. getWaitingItemsCount(): number;
  118741. /**
  118742. * Returns a boolean indicating if the scene is still loading data
  118743. */
  118744. get isLoading(): boolean;
  118745. /**
  118746. * Registers a function to be executed when the scene is ready
  118747. * @param {Function} func - the function to be executed
  118748. */
  118749. executeWhenReady(func: () => void): void;
  118750. /**
  118751. * Returns a promise that resolves when the scene is ready
  118752. * @returns A promise that resolves when the scene is ready
  118753. */
  118754. whenReadyAsync(): Promise<void>;
  118755. /** @hidden */
  118756. _checkIsReady(): void;
  118757. /**
  118758. * Gets all animatable attached to the scene
  118759. */
  118760. get animatables(): Animatable[];
  118761. /**
  118762. * Resets the last animation time frame.
  118763. * Useful to override when animations start running when loading a scene for the first time.
  118764. */
  118765. resetLastAnimationTimeFrame(): void;
  118766. /**
  118767. * Gets the current view matrix
  118768. * @returns a Matrix
  118769. */
  118770. getViewMatrix(): Matrix;
  118771. /**
  118772. * Gets the current projection matrix
  118773. * @returns a Matrix
  118774. */
  118775. getProjectionMatrix(): Matrix;
  118776. /**
  118777. * Gets the current transform matrix
  118778. * @returns a Matrix made of View * Projection
  118779. */
  118780. getTransformMatrix(): Matrix;
  118781. /**
  118782. * Sets the current transform matrix
  118783. * @param viewL defines the View matrix to use
  118784. * @param projectionL defines the Projection matrix to use
  118785. * @param viewR defines the right View matrix to use (if provided)
  118786. * @param projectionR defines the right Projection matrix to use (if provided)
  118787. */
  118788. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  118789. /**
  118790. * Gets the uniform buffer used to store scene data
  118791. * @returns a UniformBuffer
  118792. */
  118793. getSceneUniformBuffer(): UniformBuffer;
  118794. /**
  118795. * Gets an unique (relatively to the current scene) Id
  118796. * @returns an unique number for the scene
  118797. */
  118798. getUniqueId(): number;
  118799. /**
  118800. * Add a mesh to the list of scene's meshes
  118801. * @param newMesh defines the mesh to add
  118802. * @param recursive if all child meshes should also be added to the scene
  118803. */
  118804. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  118805. /**
  118806. * Remove a mesh for the list of scene's meshes
  118807. * @param toRemove defines the mesh to remove
  118808. * @param recursive if all child meshes should also be removed from the scene
  118809. * @returns the index where the mesh was in the mesh list
  118810. */
  118811. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  118812. /**
  118813. * Add a transform node to the list of scene's transform nodes
  118814. * @param newTransformNode defines the transform node to add
  118815. */
  118816. addTransformNode(newTransformNode: TransformNode): void;
  118817. /**
  118818. * Remove a transform node for the list of scene's transform nodes
  118819. * @param toRemove defines the transform node to remove
  118820. * @returns the index where the transform node was in the transform node list
  118821. */
  118822. removeTransformNode(toRemove: TransformNode): number;
  118823. /**
  118824. * Remove a skeleton for the list of scene's skeletons
  118825. * @param toRemove defines the skeleton to remove
  118826. * @returns the index where the skeleton was in the skeleton list
  118827. */
  118828. removeSkeleton(toRemove: Skeleton): number;
  118829. /**
  118830. * Remove a morph target for the list of scene's morph targets
  118831. * @param toRemove defines the morph target to remove
  118832. * @returns the index where the morph target was in the morph target list
  118833. */
  118834. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  118835. /**
  118836. * Remove a light for the list of scene's lights
  118837. * @param toRemove defines the light to remove
  118838. * @returns the index where the light was in the light list
  118839. */
  118840. removeLight(toRemove: Light): number;
  118841. /**
  118842. * Remove a camera for the list of scene's cameras
  118843. * @param toRemove defines the camera to remove
  118844. * @returns the index where the camera was in the camera list
  118845. */
  118846. removeCamera(toRemove: Camera): number;
  118847. /**
  118848. * Remove a particle system for the list of scene's particle systems
  118849. * @param toRemove defines the particle system to remove
  118850. * @returns the index where the particle system was in the particle system list
  118851. */
  118852. removeParticleSystem(toRemove: IParticleSystem): number;
  118853. /**
  118854. * Remove a animation for the list of scene's animations
  118855. * @param toRemove defines the animation to remove
  118856. * @returns the index where the animation was in the animation list
  118857. */
  118858. removeAnimation(toRemove: Animation): number;
  118859. /**
  118860. * Will stop the animation of the given target
  118861. * @param target - the target
  118862. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  118863. * @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)
  118864. */
  118865. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  118866. /**
  118867. * Removes the given animation group from this scene.
  118868. * @param toRemove The animation group to remove
  118869. * @returns The index of the removed animation group
  118870. */
  118871. removeAnimationGroup(toRemove: AnimationGroup): number;
  118872. /**
  118873. * Removes the given multi-material from this scene.
  118874. * @param toRemove The multi-material to remove
  118875. * @returns The index of the removed multi-material
  118876. */
  118877. removeMultiMaterial(toRemove: MultiMaterial): number;
  118878. /**
  118879. * Removes the given material from this scene.
  118880. * @param toRemove The material to remove
  118881. * @returns The index of the removed material
  118882. */
  118883. removeMaterial(toRemove: Material): number;
  118884. /**
  118885. * Removes the given action manager from this scene.
  118886. * @param toRemove The action manager to remove
  118887. * @returns The index of the removed action manager
  118888. */
  118889. removeActionManager(toRemove: AbstractActionManager): number;
  118890. /**
  118891. * Removes the given texture from this scene.
  118892. * @param toRemove The texture to remove
  118893. * @returns The index of the removed texture
  118894. */
  118895. removeTexture(toRemove: BaseTexture): number;
  118896. /**
  118897. * Adds the given light to this scene
  118898. * @param newLight The light to add
  118899. */
  118900. addLight(newLight: Light): void;
  118901. /**
  118902. * Sorts the list list based on light priorities
  118903. */
  118904. sortLightsByPriority(): void;
  118905. /**
  118906. * Adds the given camera to this scene
  118907. * @param newCamera The camera to add
  118908. */
  118909. addCamera(newCamera: Camera): void;
  118910. /**
  118911. * Adds the given skeleton to this scene
  118912. * @param newSkeleton The skeleton to add
  118913. */
  118914. addSkeleton(newSkeleton: Skeleton): void;
  118915. /**
  118916. * Adds the given particle system to this scene
  118917. * @param newParticleSystem The particle system to add
  118918. */
  118919. addParticleSystem(newParticleSystem: IParticleSystem): void;
  118920. /**
  118921. * Adds the given animation to this scene
  118922. * @param newAnimation The animation to add
  118923. */
  118924. addAnimation(newAnimation: Animation): void;
  118925. /**
  118926. * Adds the given animation group to this scene.
  118927. * @param newAnimationGroup The animation group to add
  118928. */
  118929. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  118930. /**
  118931. * Adds the given multi-material to this scene
  118932. * @param newMultiMaterial The multi-material to add
  118933. */
  118934. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  118935. /**
  118936. * Adds the given material to this scene
  118937. * @param newMaterial The material to add
  118938. */
  118939. addMaterial(newMaterial: Material): void;
  118940. /**
  118941. * Adds the given morph target to this scene
  118942. * @param newMorphTargetManager The morph target to add
  118943. */
  118944. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  118945. /**
  118946. * Adds the given geometry to this scene
  118947. * @param newGeometry The geometry to add
  118948. */
  118949. addGeometry(newGeometry: Geometry): void;
  118950. /**
  118951. * Adds the given action manager to this scene
  118952. * @param newActionManager The action manager to add
  118953. */
  118954. addActionManager(newActionManager: AbstractActionManager): void;
  118955. /**
  118956. * Adds the given texture to this scene.
  118957. * @param newTexture The texture to add
  118958. */
  118959. addTexture(newTexture: BaseTexture): void;
  118960. /**
  118961. * Switch active camera
  118962. * @param newCamera defines the new active camera
  118963. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  118964. */
  118965. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  118966. /**
  118967. * sets the active camera of the scene using its ID
  118968. * @param id defines the camera's ID
  118969. * @return the new active camera or null if none found.
  118970. */
  118971. setActiveCameraByID(id: string): Nullable<Camera>;
  118972. /**
  118973. * sets the active camera of the scene using its name
  118974. * @param name defines the camera's name
  118975. * @returns the new active camera or null if none found.
  118976. */
  118977. setActiveCameraByName(name: string): Nullable<Camera>;
  118978. /**
  118979. * get an animation group using its name
  118980. * @param name defines the material's name
  118981. * @return the animation group or null if none found.
  118982. */
  118983. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  118984. /**
  118985. * Get a material using its unique id
  118986. * @param uniqueId defines the material's unique id
  118987. * @return the material or null if none found.
  118988. */
  118989. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  118990. /**
  118991. * get a material using its id
  118992. * @param id defines the material's ID
  118993. * @return the material or null if none found.
  118994. */
  118995. getMaterialByID(id: string): Nullable<Material>;
  118996. /**
  118997. * Gets a the last added material using a given id
  118998. * @param id defines the material's ID
  118999. * @return the last material with the given id or null if none found.
  119000. */
  119001. getLastMaterialByID(id: string): Nullable<Material>;
  119002. /**
  119003. * Gets a material using its name
  119004. * @param name defines the material's name
  119005. * @return the material or null if none found.
  119006. */
  119007. getMaterialByName(name: string): Nullable<Material>;
  119008. /**
  119009. * Get a texture using its unique id
  119010. * @param uniqueId defines the texture's unique id
  119011. * @return the texture or null if none found.
  119012. */
  119013. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119014. /**
  119015. * Gets a camera using its id
  119016. * @param id defines the id to look for
  119017. * @returns the camera or null if not found
  119018. */
  119019. getCameraByID(id: string): Nullable<Camera>;
  119020. /**
  119021. * Gets a camera using its unique id
  119022. * @param uniqueId defines the unique id to look for
  119023. * @returns the camera or null if not found
  119024. */
  119025. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119026. /**
  119027. * Gets a camera using its name
  119028. * @param name defines the camera's name
  119029. * @return the camera or null if none found.
  119030. */
  119031. getCameraByName(name: string): Nullable<Camera>;
  119032. /**
  119033. * Gets a bone using its id
  119034. * @param id defines the bone's id
  119035. * @return the bone or null if not found
  119036. */
  119037. getBoneByID(id: string): Nullable<Bone>;
  119038. /**
  119039. * Gets a bone using its id
  119040. * @param name defines the bone's name
  119041. * @return the bone or null if not found
  119042. */
  119043. getBoneByName(name: string): Nullable<Bone>;
  119044. /**
  119045. * Gets a light node using its name
  119046. * @param name defines the the light's name
  119047. * @return the light or null if none found.
  119048. */
  119049. getLightByName(name: string): Nullable<Light>;
  119050. /**
  119051. * Gets a light node using its id
  119052. * @param id defines the light's id
  119053. * @return the light or null if none found.
  119054. */
  119055. getLightByID(id: string): Nullable<Light>;
  119056. /**
  119057. * Gets a light node using its scene-generated unique ID
  119058. * @param uniqueId defines the light's unique id
  119059. * @return the light or null if none found.
  119060. */
  119061. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119062. /**
  119063. * Gets a particle system by id
  119064. * @param id defines the particle system id
  119065. * @return the corresponding system or null if none found
  119066. */
  119067. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119068. /**
  119069. * Gets a geometry using its ID
  119070. * @param id defines the geometry's id
  119071. * @return the geometry or null if none found.
  119072. */
  119073. getGeometryByID(id: string): Nullable<Geometry>;
  119074. private _getGeometryByUniqueID;
  119075. /**
  119076. * Add a new geometry to this scene
  119077. * @param geometry defines the geometry to be added to the scene.
  119078. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119079. * @return a boolean defining if the geometry was added or not
  119080. */
  119081. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119082. /**
  119083. * Removes an existing geometry
  119084. * @param geometry defines the geometry to be removed from the scene
  119085. * @return a boolean defining if the geometry was removed or not
  119086. */
  119087. removeGeometry(geometry: Geometry): boolean;
  119088. /**
  119089. * Gets the list of geometries attached to the scene
  119090. * @returns an array of Geometry
  119091. */
  119092. getGeometries(): Geometry[];
  119093. /**
  119094. * Gets the first added mesh found of a given ID
  119095. * @param id defines the id to search for
  119096. * @return the mesh found or null if not found at all
  119097. */
  119098. getMeshByID(id: string): Nullable<AbstractMesh>;
  119099. /**
  119100. * Gets a list of meshes using their id
  119101. * @param id defines the id to search for
  119102. * @returns a list of meshes
  119103. */
  119104. getMeshesByID(id: string): Array<AbstractMesh>;
  119105. /**
  119106. * Gets the first added transform node found of a given ID
  119107. * @param id defines the id to search for
  119108. * @return the found transform node or null if not found at all.
  119109. */
  119110. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119111. /**
  119112. * Gets a transform node with its auto-generated unique id
  119113. * @param uniqueId efines the unique id to search for
  119114. * @return the found transform node or null if not found at all.
  119115. */
  119116. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119117. /**
  119118. * Gets a list of transform nodes using their id
  119119. * @param id defines the id to search for
  119120. * @returns a list of transform nodes
  119121. */
  119122. getTransformNodesByID(id: string): Array<TransformNode>;
  119123. /**
  119124. * Gets a mesh with its auto-generated unique id
  119125. * @param uniqueId defines the unique id to search for
  119126. * @return the found mesh or null if not found at all.
  119127. */
  119128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119129. /**
  119130. * Gets a the last added mesh using a given id
  119131. * @param id defines the id to search for
  119132. * @return the found mesh or null if not found at all.
  119133. */
  119134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119135. /**
  119136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119137. * @param id defines the id to search for
  119138. * @return the found node or null if not found at all
  119139. */
  119140. getLastEntryByID(id: string): Nullable<Node>;
  119141. /**
  119142. * Gets a node (Mesh, Camera, Light) using a given id
  119143. * @param id defines the id to search for
  119144. * @return the found node or null if not found at all
  119145. */
  119146. getNodeByID(id: string): Nullable<Node>;
  119147. /**
  119148. * Gets a node (Mesh, Camera, Light) using a given name
  119149. * @param name defines the name to search for
  119150. * @return the found node or null if not found at all.
  119151. */
  119152. getNodeByName(name: string): Nullable<Node>;
  119153. /**
  119154. * Gets a mesh using a given name
  119155. * @param name defines the name to search for
  119156. * @return the found mesh or null if not found at all.
  119157. */
  119158. getMeshByName(name: string): Nullable<AbstractMesh>;
  119159. /**
  119160. * Gets a transform node using a given name
  119161. * @param name defines the name to search for
  119162. * @return the found transform node or null if not found at all.
  119163. */
  119164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119165. /**
  119166. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119167. * @param id defines the id to search for
  119168. * @return the found skeleton or null if not found at all.
  119169. */
  119170. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119171. /**
  119172. * Gets a skeleton using a given auto generated unique id
  119173. * @param uniqueId defines the unique id to search for
  119174. * @return the found skeleton or null if not found at all.
  119175. */
  119176. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119177. /**
  119178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119179. * @param id defines the id to search for
  119180. * @return the found skeleton or null if not found at all.
  119181. */
  119182. getSkeletonById(id: string): Nullable<Skeleton>;
  119183. /**
  119184. * Gets a skeleton using a given name
  119185. * @param name defines the name to search for
  119186. * @return the found skeleton or null if not found at all.
  119187. */
  119188. getSkeletonByName(name: string): Nullable<Skeleton>;
  119189. /**
  119190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119191. * @param id defines the id to search for
  119192. * @return the found morph target manager or null if not found at all.
  119193. */
  119194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119195. /**
  119196. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119197. * @param id defines the id to search for
  119198. * @return the found morph target or null if not found at all.
  119199. */
  119200. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119201. /**
  119202. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119203. * @param name defines the name to search for
  119204. * @return the found morph target or null if not found at all.
  119205. */
  119206. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119207. /**
  119208. * Gets a boolean indicating if the given mesh is active
  119209. * @param mesh defines the mesh to look for
  119210. * @returns true if the mesh is in the active list
  119211. */
  119212. isActiveMesh(mesh: AbstractMesh): boolean;
  119213. /**
  119214. * Return a unique id as a string which can serve as an identifier for the scene
  119215. */
  119216. get uid(): string;
  119217. /**
  119218. * Add an externaly attached data from its key.
  119219. * This method call will fail and return false, if such key already exists.
  119220. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119221. * @param key the unique key that identifies the data
  119222. * @param data the data object to associate to the key for this Engine instance
  119223. * @return true if no such key were already present and the data was added successfully, false otherwise
  119224. */
  119225. addExternalData<T>(key: string, data: T): boolean;
  119226. /**
  119227. * Get an externaly attached data from its key
  119228. * @param key the unique key that identifies the data
  119229. * @return the associated data, if present (can be null), or undefined if not present
  119230. */
  119231. getExternalData<T>(key: string): Nullable<T>;
  119232. /**
  119233. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119234. * @param key the unique key that identifies the data
  119235. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119236. * @return the associated data, can be null if the factory returned null.
  119237. */
  119238. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119239. /**
  119240. * Remove an externaly attached data from the Engine instance
  119241. * @param key the unique key that identifies the data
  119242. * @return true if the data was successfully removed, false if it doesn't exist
  119243. */
  119244. removeExternalData(key: string): boolean;
  119245. private _evaluateSubMesh;
  119246. /**
  119247. * Clear the processed materials smart array preventing retention point in material dispose.
  119248. */
  119249. freeProcessedMaterials(): void;
  119250. private _preventFreeActiveMeshesAndRenderingGroups;
  119251. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119252. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119253. * when disposing several meshes in a row or a hierarchy of meshes.
  119254. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119255. */
  119256. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119257. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119258. /**
  119259. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119260. */
  119261. freeActiveMeshes(): void;
  119262. /**
  119263. * Clear the info related to rendering groups preventing retention points during dispose.
  119264. */
  119265. freeRenderingGroups(): void;
  119266. /** @hidden */
  119267. _isInIntermediateRendering(): boolean;
  119268. /**
  119269. * Lambda returning the list of potentially active meshes.
  119270. */
  119271. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119272. /**
  119273. * Lambda returning the list of potentially active sub meshes.
  119274. */
  119275. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119276. /**
  119277. * Lambda returning the list of potentially intersecting sub meshes.
  119278. */
  119279. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119280. /**
  119281. * Lambda returning the list of potentially colliding sub meshes.
  119282. */
  119283. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119284. private _activeMeshesFrozen;
  119285. private _skipEvaluateActiveMeshesCompletely;
  119286. /**
  119287. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119288. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119289. * @returns the current scene
  119290. */
  119291. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119292. /**
  119293. * Use this function to restart evaluating active meshes on every frame
  119294. * @returns the current scene
  119295. */
  119296. unfreezeActiveMeshes(): Scene;
  119297. private _evaluateActiveMeshes;
  119298. private _activeMesh;
  119299. /**
  119300. * Update the transform matrix to update from the current active camera
  119301. * @param force defines a boolean used to force the update even if cache is up to date
  119302. */
  119303. updateTransformMatrix(force?: boolean): void;
  119304. private _bindFrameBuffer;
  119305. /** @hidden */
  119306. _allowPostProcessClearColor: boolean;
  119307. /** @hidden */
  119308. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119309. private _processSubCameras;
  119310. private _checkIntersections;
  119311. /** @hidden */
  119312. _advancePhysicsEngineStep(step: number): void;
  119313. /**
  119314. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119315. */
  119316. getDeterministicFrameTime: () => number;
  119317. /** @hidden */
  119318. _animate(): void;
  119319. /** Execute all animations (for a frame) */
  119320. animate(): void;
  119321. /**
  119322. * Render the scene
  119323. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119324. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119325. */
  119326. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119327. /**
  119328. * Freeze all materials
  119329. * A frozen material will not be updatable but should be faster to render
  119330. */
  119331. freezeMaterials(): void;
  119332. /**
  119333. * Unfreeze all materials
  119334. * A frozen material will not be updatable but should be faster to render
  119335. */
  119336. unfreezeMaterials(): void;
  119337. /**
  119338. * Releases all held ressources
  119339. */
  119340. dispose(): void;
  119341. /**
  119342. * Gets if the scene is already disposed
  119343. */
  119344. get isDisposed(): boolean;
  119345. /**
  119346. * Call this function to reduce memory footprint of the scene.
  119347. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119348. */
  119349. clearCachedVertexData(): void;
  119350. /**
  119351. * This function will remove the local cached buffer data from texture.
  119352. * It will save memory but will prevent the texture from being rebuilt
  119353. */
  119354. cleanCachedTextureBuffer(): void;
  119355. /**
  119356. * Get the world extend vectors with an optional filter
  119357. *
  119358. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119359. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119360. */
  119361. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119362. min: Vector3;
  119363. max: Vector3;
  119364. };
  119365. /**
  119366. * Creates a ray that can be used to pick in the scene
  119367. * @param x defines the x coordinate of the origin (on-screen)
  119368. * @param y defines the y coordinate of the origin (on-screen)
  119369. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119370. * @param camera defines the camera to use for the picking
  119371. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119372. * @returns a Ray
  119373. */
  119374. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119375. /**
  119376. * Creates a ray that can be used to pick in the scene
  119377. * @param x defines the x coordinate of the origin (on-screen)
  119378. * @param y defines the y coordinate of the origin (on-screen)
  119379. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119380. * @param result defines the ray where to store the picking ray
  119381. * @param camera defines the camera to use for the picking
  119382. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119383. * @returns the current scene
  119384. */
  119385. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119386. /**
  119387. * Creates a ray that can be used to pick in the scene
  119388. * @param x defines the x coordinate of the origin (on-screen)
  119389. * @param y defines the y coordinate of the origin (on-screen)
  119390. * @param camera defines the camera to use for the picking
  119391. * @returns a Ray
  119392. */
  119393. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119394. /**
  119395. * Creates a ray that can be used to pick in the scene
  119396. * @param x defines the x coordinate of the origin (on-screen)
  119397. * @param y defines the y coordinate of the origin (on-screen)
  119398. * @param result defines the ray where to store the picking ray
  119399. * @param camera defines the camera to use for the picking
  119400. * @returns the current scene
  119401. */
  119402. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119403. /** Launch a ray to try to pick a mesh in the scene
  119404. * @param x position on screen
  119405. * @param y position on screen
  119406. * @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
  119407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119408. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119409. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119410. * @returns a PickingInfo
  119411. */
  119412. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119413. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119414. * @param x position on screen
  119415. * @param y position on screen
  119416. * @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
  119417. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119418. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119419. * @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)
  119420. */
  119421. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119422. /** Use the given ray to pick a mesh in the scene
  119423. * @param ray The ray to use to pick meshes
  119424. * @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
  119425. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119427. * @returns a PickingInfo
  119428. */
  119429. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119430. /**
  119431. * Launch a ray to try to pick a mesh in the scene
  119432. * @param x X position on screen
  119433. * @param y Y position on screen
  119434. * @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
  119435. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119437. * @returns an array of PickingInfo
  119438. */
  119439. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119440. /**
  119441. * Launch a ray to try to pick a mesh in the scene
  119442. * @param ray Ray to use
  119443. * @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
  119444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119445. * @returns an array of PickingInfo
  119446. */
  119447. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119448. /**
  119449. * Force the value of meshUnderPointer
  119450. * @param mesh defines the mesh to use
  119451. */
  119452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  119453. /**
  119454. * Gets the mesh under the pointer
  119455. * @returns a Mesh or null if no mesh is under the pointer
  119456. */
  119457. getPointerOverMesh(): Nullable<AbstractMesh>;
  119458. /** @hidden */
  119459. _rebuildGeometries(): void;
  119460. /** @hidden */
  119461. _rebuildTextures(): void;
  119462. private _getByTags;
  119463. /**
  119464. * Get a list of meshes by tags
  119465. * @param tagsQuery defines the tags query to use
  119466. * @param forEach defines a predicate used to filter results
  119467. * @returns an array of Mesh
  119468. */
  119469. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  119470. /**
  119471. * Get a list of cameras by tags
  119472. * @param tagsQuery defines the tags query to use
  119473. * @param forEach defines a predicate used to filter results
  119474. * @returns an array of Camera
  119475. */
  119476. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  119477. /**
  119478. * Get a list of lights by tags
  119479. * @param tagsQuery defines the tags query to use
  119480. * @param forEach defines a predicate used to filter results
  119481. * @returns an array of Light
  119482. */
  119483. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  119484. /**
  119485. * Get a list of materials by tags
  119486. * @param tagsQuery defines the tags query to use
  119487. * @param forEach defines a predicate used to filter results
  119488. * @returns an array of Material
  119489. */
  119490. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  119491. /**
  119492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119493. * This allowed control for front to back rendering or reversly depending of the special needs.
  119494. *
  119495. * @param renderingGroupId The rendering group id corresponding to its index
  119496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119499. */
  119500. 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;
  119501. /**
  119502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119503. *
  119504. * @param renderingGroupId The rendering group id corresponding to its index
  119505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  119507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  119508. */
  119509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  119510. /**
  119511. * Gets the current auto clear configuration for one rendering group of the rendering
  119512. * manager.
  119513. * @param index the rendering group index to get the information for
  119514. * @returns The auto clear setup for the requested rendering group
  119515. */
  119516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  119517. private _blockMaterialDirtyMechanism;
  119518. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  119519. get blockMaterialDirtyMechanism(): boolean;
  119520. set blockMaterialDirtyMechanism(value: boolean);
  119521. /**
  119522. * Will flag all materials as dirty to trigger new shader compilation
  119523. * @param flag defines the flag used to specify which material part must be marked as dirty
  119524. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  119525. */
  119526. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  119527. /** @hidden */
  119528. _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;
  119529. /** @hidden */
  119530. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119531. /** @hidden */
  119532. _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;
  119533. /** @hidden */
  119534. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  119535. /** @hidden */
  119536. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119537. /** @hidden */
  119538. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119539. }
  119540. }
  119541. declare module BABYLON {
  119542. /**
  119543. * Set of assets to keep when moving a scene into an asset container.
  119544. */
  119545. export class KeepAssets extends AbstractScene {
  119546. }
  119547. /**
  119548. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  119549. */
  119550. export class InstantiatedEntries {
  119551. /**
  119552. * List of new root nodes (eg. nodes with no parent)
  119553. */
  119554. rootNodes: TransformNode[];
  119555. /**
  119556. * List of new skeletons
  119557. */
  119558. skeletons: Skeleton[];
  119559. /**
  119560. * List of new animation groups
  119561. */
  119562. animationGroups: AnimationGroup[];
  119563. }
  119564. /**
  119565. * Container with a set of assets that can be added or removed from a scene.
  119566. */
  119567. export class AssetContainer extends AbstractScene {
  119568. private _wasAddedToScene;
  119569. /**
  119570. * The scene the AssetContainer belongs to.
  119571. */
  119572. scene: Scene;
  119573. /**
  119574. * Instantiates an AssetContainer.
  119575. * @param scene The scene the AssetContainer belongs to.
  119576. */
  119577. constructor(scene: Scene);
  119578. /**
  119579. * Instantiate or clone all meshes and add the new ones to the scene.
  119580. * Skeletons and animation groups will all be cloned
  119581. * @param nameFunction defines an optional function used to get new names for clones
  119582. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  119583. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  119584. */
  119585. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  119586. /**
  119587. * Adds all the assets from the container to the scene.
  119588. */
  119589. addAllToScene(): void;
  119590. /**
  119591. * Removes all the assets in the container from the scene
  119592. */
  119593. removeAllFromScene(): void;
  119594. /**
  119595. * Disposes all the assets in the container
  119596. */
  119597. dispose(): void;
  119598. private _moveAssets;
  119599. /**
  119600. * Removes all the assets contained in the scene and adds them to the container.
  119601. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  119602. */
  119603. moveAllFromScene(keepAssets?: KeepAssets): void;
  119604. /**
  119605. * 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.
  119606. * @returns the root mesh
  119607. */
  119608. createRootMesh(): Mesh;
  119609. /**
  119610. * Merge animations (direct and animation groups) from this asset container into a scene
  119611. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119612. * @param animatables set of animatables to retarget to a node from the scene
  119613. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  119614. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  119615. */
  119616. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  119617. }
  119618. }
  119619. declare module BABYLON {
  119620. /**
  119621. * Defines how the parser contract is defined.
  119622. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  119623. */
  119624. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  119625. /**
  119626. * Defines how the individual parser contract is defined.
  119627. * These parser can parse an individual asset
  119628. */
  119629. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  119630. /**
  119631. * Base class of the scene acting as a container for the different elements composing a scene.
  119632. * This class is dynamically extended by the different components of the scene increasing
  119633. * flexibility and reducing coupling
  119634. */
  119635. export abstract class AbstractScene {
  119636. /**
  119637. * Stores the list of available parsers in the application.
  119638. */
  119639. private static _BabylonFileParsers;
  119640. /**
  119641. * Stores the list of available individual parsers in the application.
  119642. */
  119643. private static _IndividualBabylonFileParsers;
  119644. /**
  119645. * Adds a parser in the list of available ones
  119646. * @param name Defines the name of the parser
  119647. * @param parser Defines the parser to add
  119648. */
  119649. static AddParser(name: string, parser: BabylonFileParser): void;
  119650. /**
  119651. * Gets a general parser from the list of avaialble ones
  119652. * @param name Defines the name of the parser
  119653. * @returns the requested parser or null
  119654. */
  119655. static GetParser(name: string): Nullable<BabylonFileParser>;
  119656. /**
  119657. * Adds n individual parser in the list of available ones
  119658. * @param name Defines the name of the parser
  119659. * @param parser Defines the parser to add
  119660. */
  119661. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  119662. /**
  119663. * Gets an individual parser from the list of avaialble ones
  119664. * @param name Defines the name of the parser
  119665. * @returns the requested parser or null
  119666. */
  119667. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  119668. /**
  119669. * Parser json data and populate both a scene and its associated container object
  119670. * @param jsonData Defines the data to parse
  119671. * @param scene Defines the scene to parse the data for
  119672. * @param container Defines the container attached to the parsing sequence
  119673. * @param rootUrl Defines the root url of the data
  119674. */
  119675. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  119676. /**
  119677. * Gets the list of root nodes (ie. nodes with no parent)
  119678. */
  119679. rootNodes: Node[];
  119680. /** All of the cameras added to this scene
  119681. * @see https://doc.babylonjs.com/babylon101/cameras
  119682. */
  119683. cameras: Camera[];
  119684. /**
  119685. * All of the lights added to this scene
  119686. * @see https://doc.babylonjs.com/babylon101/lights
  119687. */
  119688. lights: Light[];
  119689. /**
  119690. * All of the (abstract) meshes added to this scene
  119691. */
  119692. meshes: AbstractMesh[];
  119693. /**
  119694. * The list of skeletons added to the scene
  119695. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  119696. */
  119697. skeletons: Skeleton[];
  119698. /**
  119699. * All of the particle systems added to this scene
  119700. * @see https://doc.babylonjs.com/babylon101/particles
  119701. */
  119702. particleSystems: IParticleSystem[];
  119703. /**
  119704. * Gets a list of Animations associated with the scene
  119705. */
  119706. animations: Animation[];
  119707. /**
  119708. * All of the animation groups added to this scene
  119709. * @see https://doc.babylonjs.com/how_to/group
  119710. */
  119711. animationGroups: AnimationGroup[];
  119712. /**
  119713. * All of the multi-materials added to this scene
  119714. * @see https://doc.babylonjs.com/how_to/multi_materials
  119715. */
  119716. multiMaterials: MultiMaterial[];
  119717. /**
  119718. * All of the materials added to this scene
  119719. * In the context of a Scene, it is not supposed to be modified manually.
  119720. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  119721. * Note also that the order of the Material within the array is not significant and might change.
  119722. * @see https://doc.babylonjs.com/babylon101/materials
  119723. */
  119724. materials: Material[];
  119725. /**
  119726. * The list of morph target managers added to the scene
  119727. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  119728. */
  119729. morphTargetManagers: MorphTargetManager[];
  119730. /**
  119731. * The list of geometries used in the scene.
  119732. */
  119733. geometries: Geometry[];
  119734. /**
  119735. * All of the tranform nodes added to this scene
  119736. * In the context of a Scene, it is not supposed to be modified manually.
  119737. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  119738. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  119739. * @see https://doc.babylonjs.com/how_to/transformnode
  119740. */
  119741. transformNodes: TransformNode[];
  119742. /**
  119743. * ActionManagers available on the scene.
  119744. */
  119745. actionManagers: AbstractActionManager[];
  119746. /**
  119747. * Textures to keep.
  119748. */
  119749. textures: BaseTexture[];
  119750. /**
  119751. * Environment texture for the scene
  119752. */
  119753. environmentTexture: Nullable<BaseTexture>;
  119754. /**
  119755. * @returns all meshes, lights, cameras, transformNodes and bones
  119756. */
  119757. getNodes(): Array<Node>;
  119758. }
  119759. }
  119760. declare module BABYLON {
  119761. /**
  119762. * Interface used to define options for Sound class
  119763. */
  119764. export interface ISoundOptions {
  119765. /**
  119766. * Does the sound autoplay once loaded.
  119767. */
  119768. autoplay?: boolean;
  119769. /**
  119770. * Does the sound loop after it finishes playing once.
  119771. */
  119772. loop?: boolean;
  119773. /**
  119774. * Sound's volume
  119775. */
  119776. volume?: number;
  119777. /**
  119778. * Is it a spatial sound?
  119779. */
  119780. spatialSound?: boolean;
  119781. /**
  119782. * Maximum distance to hear that sound
  119783. */
  119784. maxDistance?: number;
  119785. /**
  119786. * Uses user defined attenuation function
  119787. */
  119788. useCustomAttenuation?: boolean;
  119789. /**
  119790. * Define the roll off factor of spatial sounds.
  119791. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119792. */
  119793. rolloffFactor?: number;
  119794. /**
  119795. * Define the reference distance the sound should be heard perfectly.
  119796. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119797. */
  119798. refDistance?: number;
  119799. /**
  119800. * Define the distance attenuation model the sound will follow.
  119801. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119802. */
  119803. distanceModel?: string;
  119804. /**
  119805. * Defines the playback speed (1 by default)
  119806. */
  119807. playbackRate?: number;
  119808. /**
  119809. * Defines if the sound is from a streaming source
  119810. */
  119811. streaming?: boolean;
  119812. /**
  119813. * Defines an optional length (in seconds) inside the sound file
  119814. */
  119815. length?: number;
  119816. /**
  119817. * Defines an optional offset (in seconds) inside the sound file
  119818. */
  119819. offset?: number;
  119820. /**
  119821. * If true, URLs will not be required to state the audio file codec to use.
  119822. */
  119823. skipCodecCheck?: boolean;
  119824. }
  119825. /**
  119826. * Defines a sound that can be played in the application.
  119827. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  119828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119829. */
  119830. export class Sound {
  119831. /**
  119832. * The name of the sound in the scene.
  119833. */
  119834. name: string;
  119835. /**
  119836. * Does the sound autoplay once loaded.
  119837. */
  119838. autoplay: boolean;
  119839. /**
  119840. * Does the sound loop after it finishes playing once.
  119841. */
  119842. loop: boolean;
  119843. /**
  119844. * Does the sound use a custom attenuation curve to simulate the falloff
  119845. * happening when the source gets further away from the camera.
  119846. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  119847. */
  119848. useCustomAttenuation: boolean;
  119849. /**
  119850. * The sound track id this sound belongs to.
  119851. */
  119852. soundTrackId: number;
  119853. /**
  119854. * Is this sound currently played.
  119855. */
  119856. isPlaying: boolean;
  119857. /**
  119858. * Is this sound currently paused.
  119859. */
  119860. isPaused: boolean;
  119861. /**
  119862. * Does this sound enables spatial sound.
  119863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119864. */
  119865. spatialSound: boolean;
  119866. /**
  119867. * Define the reference distance the sound should be heard perfectly.
  119868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119869. */
  119870. refDistance: number;
  119871. /**
  119872. * Define the roll off factor of spatial sounds.
  119873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119874. */
  119875. rolloffFactor: number;
  119876. /**
  119877. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  119878. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119879. */
  119880. maxDistance: number;
  119881. /**
  119882. * Define the distance attenuation model the sound will follow.
  119883. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119884. */
  119885. distanceModel: string;
  119886. /**
  119887. * @hidden
  119888. * Back Compat
  119889. **/
  119890. onended: () => any;
  119891. /**
  119892. * Gets or sets an object used to store user defined information for the sound.
  119893. */
  119894. metadata: any;
  119895. /**
  119896. * Observable event when the current playing sound finishes.
  119897. */
  119898. onEndedObservable: Observable<Sound>;
  119899. private _panningModel;
  119900. private _playbackRate;
  119901. private _streaming;
  119902. private _startTime;
  119903. private _startOffset;
  119904. private _position;
  119905. /** @hidden */
  119906. _positionInEmitterSpace: boolean;
  119907. private _localDirection;
  119908. private _volume;
  119909. private _isReadyToPlay;
  119910. private _isDirectional;
  119911. private _readyToPlayCallback;
  119912. private _audioBuffer;
  119913. private _soundSource;
  119914. private _streamingSource;
  119915. private _soundPanner;
  119916. private _soundGain;
  119917. private _inputAudioNode;
  119918. private _outputAudioNode;
  119919. private _coneInnerAngle;
  119920. private _coneOuterAngle;
  119921. private _coneOuterGain;
  119922. private _scene;
  119923. private _connectedTransformNode;
  119924. private _customAttenuationFunction;
  119925. private _registerFunc;
  119926. private _isOutputConnected;
  119927. private _htmlAudioElement;
  119928. private _urlType;
  119929. private _length?;
  119930. private _offset?;
  119931. /** @hidden */
  119932. static _SceneComponentInitialization: (scene: Scene) => void;
  119933. /**
  119934. * Create a sound and attach it to a scene
  119935. * @param name Name of your sound
  119936. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  119937. * @param scene defines the scene the sound belongs to
  119938. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  119939. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  119940. */
  119941. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  119942. /**
  119943. * Release the sound and its associated resources
  119944. */
  119945. dispose(): void;
  119946. /**
  119947. * Gets if the sounds is ready to be played or not.
  119948. * @returns true if ready, otherwise false
  119949. */
  119950. isReady(): boolean;
  119951. private _soundLoaded;
  119952. /**
  119953. * Sets the data of the sound from an audiobuffer
  119954. * @param audioBuffer The audioBuffer containing the data
  119955. */
  119956. setAudioBuffer(audioBuffer: AudioBuffer): void;
  119957. /**
  119958. * Updates the current sounds options such as maxdistance, loop...
  119959. * @param options A JSON object containing values named as the object properties
  119960. */
  119961. updateOptions(options: ISoundOptions): void;
  119962. private _createSpatialParameters;
  119963. private _updateSpatialParameters;
  119964. /**
  119965. * Switch the panning model to HRTF:
  119966. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119968. */
  119969. switchPanningModelToHRTF(): void;
  119970. /**
  119971. * Switch the panning model to Equal Power:
  119972. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119973. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119974. */
  119975. switchPanningModelToEqualPower(): void;
  119976. private _switchPanningModel;
  119977. /**
  119978. * Connect this sound to a sound track audio node like gain...
  119979. * @param soundTrackAudioNode the sound track audio node to connect to
  119980. */
  119981. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  119982. /**
  119983. * Transform this sound into a directional source
  119984. * @param coneInnerAngle Size of the inner cone in degree
  119985. * @param coneOuterAngle Size of the outer cone in degree
  119986. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  119987. */
  119988. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  119989. /**
  119990. * Gets or sets the inner angle for the directional cone.
  119991. */
  119992. get directionalConeInnerAngle(): number;
  119993. /**
  119994. * Gets or sets the inner angle for the directional cone.
  119995. */
  119996. set directionalConeInnerAngle(value: number);
  119997. /**
  119998. * Gets or sets the outer angle for the directional cone.
  119999. */
  120000. get directionalConeOuterAngle(): number;
  120001. /**
  120002. * Gets or sets the outer angle for the directional cone.
  120003. */
  120004. set directionalConeOuterAngle(value: number);
  120005. /**
  120006. * Sets the position of the emitter if spatial sound is enabled
  120007. * @param newPosition Defines the new posisiton
  120008. */
  120009. setPosition(newPosition: Vector3): void;
  120010. /**
  120011. * Sets the local direction of the emitter if spatial sound is enabled
  120012. * @param newLocalDirection Defines the new local direction
  120013. */
  120014. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120015. private _updateDirection;
  120016. /** @hidden */
  120017. updateDistanceFromListener(): void;
  120018. /**
  120019. * Sets a new custom attenuation function for the sound.
  120020. * @param callback Defines the function used for the attenuation
  120021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120022. */
  120023. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120024. /**
  120025. * Play the sound
  120026. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120027. * @param offset (optional) Start the sound at a specific time in seconds
  120028. * @param length (optional) Sound duration (in seconds)
  120029. */
  120030. play(time?: number, offset?: number, length?: number): void;
  120031. private _onended;
  120032. /**
  120033. * Stop the sound
  120034. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120035. */
  120036. stop(time?: number): void;
  120037. /**
  120038. * Put the sound in pause
  120039. */
  120040. pause(): void;
  120041. /**
  120042. * Sets a dedicated volume for this sounds
  120043. * @param newVolume Define the new volume of the sound
  120044. * @param time Define time for gradual change to new volume
  120045. */
  120046. setVolume(newVolume: number, time?: number): void;
  120047. /**
  120048. * Set the sound play back rate
  120049. * @param newPlaybackRate Define the playback rate the sound should be played at
  120050. */
  120051. setPlaybackRate(newPlaybackRate: number): void;
  120052. /**
  120053. * Gets the volume of the sound.
  120054. * @returns the volume of the sound
  120055. */
  120056. getVolume(): number;
  120057. /**
  120058. * Attach the sound to a dedicated mesh
  120059. * @param transformNode The transform node to connect the sound with
  120060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120061. */
  120062. attachToMesh(transformNode: TransformNode): void;
  120063. /**
  120064. * Detach the sound from the previously attached mesh
  120065. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120066. */
  120067. detachFromMesh(): void;
  120068. private _onRegisterAfterWorldMatrixUpdate;
  120069. /**
  120070. * Clone the current sound in the scene.
  120071. * @returns the new sound clone
  120072. */
  120073. clone(): Nullable<Sound>;
  120074. /**
  120075. * Gets the current underlying audio buffer containing the data
  120076. * @returns the audio buffer
  120077. */
  120078. getAudioBuffer(): Nullable<AudioBuffer>;
  120079. /**
  120080. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120081. * @returns the source node
  120082. */
  120083. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120084. /**
  120085. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120086. * @returns the gain node
  120087. */
  120088. getSoundGain(): Nullable<GainNode>;
  120089. /**
  120090. * Serializes the Sound in a JSON representation
  120091. * @returns the JSON representation of the sound
  120092. */
  120093. serialize(): any;
  120094. /**
  120095. * Parse a JSON representation of a sound to innstantiate in a given scene
  120096. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120097. * @param scene Define the scene the new parsed sound should be created in
  120098. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120099. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120100. * @returns the newly parsed sound
  120101. */
  120102. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120103. }
  120104. }
  120105. declare module BABYLON {
  120106. /**
  120107. * This defines an action helpful to play a defined sound on a triggered action.
  120108. */
  120109. export class PlaySoundAction extends Action {
  120110. private _sound;
  120111. /**
  120112. * Instantiate the action
  120113. * @param triggerOptions defines the trigger options
  120114. * @param sound defines the sound to play
  120115. * @param condition defines the trigger related conditions
  120116. */
  120117. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120118. /** @hidden */
  120119. _prepare(): void;
  120120. /**
  120121. * Execute the action and play the sound.
  120122. */
  120123. execute(): void;
  120124. /**
  120125. * Serializes the actions and its related information.
  120126. * @param parent defines the object to serialize in
  120127. * @returns the serialized object
  120128. */
  120129. serialize(parent: any): any;
  120130. }
  120131. /**
  120132. * This defines an action helpful to stop a defined sound on a triggered action.
  120133. */
  120134. export class StopSoundAction extends Action {
  120135. private _sound;
  120136. /**
  120137. * Instantiate the action
  120138. * @param triggerOptions defines the trigger options
  120139. * @param sound defines the sound to stop
  120140. * @param condition defines the trigger related conditions
  120141. */
  120142. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120143. /** @hidden */
  120144. _prepare(): void;
  120145. /**
  120146. * Execute the action and stop the sound.
  120147. */
  120148. execute(): void;
  120149. /**
  120150. * Serializes the actions and its related information.
  120151. * @param parent defines the object to serialize in
  120152. * @returns the serialized object
  120153. */
  120154. serialize(parent: any): any;
  120155. }
  120156. }
  120157. declare module BABYLON {
  120158. /**
  120159. * This defines an action responsible to change the value of a property
  120160. * by interpolating between its current value and the newly set one once triggered.
  120161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120162. */
  120163. export class InterpolateValueAction extends Action {
  120164. /**
  120165. * Defines the path of the property where the value should be interpolated
  120166. */
  120167. propertyPath: string;
  120168. /**
  120169. * Defines the target value at the end of the interpolation.
  120170. */
  120171. value: any;
  120172. /**
  120173. * Defines the time it will take for the property to interpolate to the value.
  120174. */
  120175. duration: number;
  120176. /**
  120177. * Defines if the other scene animations should be stopped when the action has been triggered
  120178. */
  120179. stopOtherAnimations?: boolean;
  120180. /**
  120181. * Defines a callback raised once the interpolation animation has been done.
  120182. */
  120183. onInterpolationDone?: () => void;
  120184. /**
  120185. * Observable triggered once the interpolation animation has been done.
  120186. */
  120187. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120188. private _target;
  120189. private _effectiveTarget;
  120190. private _property;
  120191. /**
  120192. * Instantiate the action
  120193. * @param triggerOptions defines the trigger options
  120194. * @param target defines the object containing the value to interpolate
  120195. * @param propertyPath defines the path to the property in the target object
  120196. * @param value defines the target value at the end of the interpolation
  120197. * @param duration deines the time it will take for the property to interpolate to the value.
  120198. * @param condition defines the trigger related conditions
  120199. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120200. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120201. */
  120202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120203. /** @hidden */
  120204. _prepare(): void;
  120205. /**
  120206. * Execute the action starts the value interpolation.
  120207. */
  120208. execute(): void;
  120209. /**
  120210. * Serializes the actions and its related information.
  120211. * @param parent defines the object to serialize in
  120212. * @returns the serialized object
  120213. */
  120214. serialize(parent: any): any;
  120215. }
  120216. }
  120217. declare module BABYLON {
  120218. /**
  120219. * Options allowed during the creation of a sound track.
  120220. */
  120221. export interface ISoundTrackOptions {
  120222. /**
  120223. * The volume the sound track should take during creation
  120224. */
  120225. volume?: number;
  120226. /**
  120227. * Define if the sound track is the main sound track of the scene
  120228. */
  120229. mainTrack?: boolean;
  120230. }
  120231. /**
  120232. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120233. * It will be also used in a future release to apply effects on a specific track.
  120234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120235. */
  120236. export class SoundTrack {
  120237. /**
  120238. * The unique identifier of the sound track in the scene.
  120239. */
  120240. id: number;
  120241. /**
  120242. * The list of sounds included in the sound track.
  120243. */
  120244. soundCollection: Array<Sound>;
  120245. private _outputAudioNode;
  120246. private _scene;
  120247. private _connectedAnalyser;
  120248. private _options;
  120249. private _isInitialized;
  120250. /**
  120251. * Creates a new sound track.
  120252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120253. * @param scene Define the scene the sound track belongs to
  120254. * @param options
  120255. */
  120256. constructor(scene: Scene, options?: ISoundTrackOptions);
  120257. private _initializeSoundTrackAudioGraph;
  120258. /**
  120259. * Release the sound track and its associated resources
  120260. */
  120261. dispose(): void;
  120262. /**
  120263. * Adds a sound to this sound track
  120264. * @param sound define the cound to add
  120265. * @ignoreNaming
  120266. */
  120267. AddSound(sound: Sound): void;
  120268. /**
  120269. * Removes a sound to this sound track
  120270. * @param sound define the cound to remove
  120271. * @ignoreNaming
  120272. */
  120273. RemoveSound(sound: Sound): void;
  120274. /**
  120275. * Set a global volume for the full sound track.
  120276. * @param newVolume Define the new volume of the sound track
  120277. */
  120278. setVolume(newVolume: number): void;
  120279. /**
  120280. * Switch the panning model to HRTF:
  120281. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120283. */
  120284. switchPanningModelToHRTF(): void;
  120285. /**
  120286. * Switch the panning model to Equal Power:
  120287. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120289. */
  120290. switchPanningModelToEqualPower(): void;
  120291. /**
  120292. * Connect the sound track to an audio analyser allowing some amazing
  120293. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120294. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120295. * @param analyser The analyser to connect to the engine
  120296. */
  120297. connectToAnalyser(analyser: Analyser): void;
  120298. }
  120299. }
  120300. declare module BABYLON {
  120301. interface AbstractScene {
  120302. /**
  120303. * The list of sounds used in the scene.
  120304. */
  120305. sounds: Nullable<Array<Sound>>;
  120306. }
  120307. interface Scene {
  120308. /**
  120309. * @hidden
  120310. * Backing field
  120311. */
  120312. _mainSoundTrack: SoundTrack;
  120313. /**
  120314. * The main sound track played by the scene.
  120315. * It cotains your primary collection of sounds.
  120316. */
  120317. mainSoundTrack: SoundTrack;
  120318. /**
  120319. * The list of sound tracks added to the scene
  120320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120321. */
  120322. soundTracks: Nullable<Array<SoundTrack>>;
  120323. /**
  120324. * Gets a sound using a given name
  120325. * @param name defines the name to search for
  120326. * @return the found sound or null if not found at all.
  120327. */
  120328. getSoundByName(name: string): Nullable<Sound>;
  120329. /**
  120330. * Gets or sets if audio support is enabled
  120331. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120332. */
  120333. audioEnabled: boolean;
  120334. /**
  120335. * Gets or sets if audio will be output to headphones
  120336. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120337. */
  120338. headphone: boolean;
  120339. /**
  120340. * Gets or sets custom audio listener position provider
  120341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120342. */
  120343. audioListenerPositionProvider: Nullable<() => Vector3>;
  120344. /**
  120345. * Gets or sets a refresh rate when using 3D audio positioning
  120346. */
  120347. audioPositioningRefreshRate: number;
  120348. }
  120349. /**
  120350. * Defines the sound scene component responsible to manage any sounds
  120351. * in a given scene.
  120352. */
  120353. export class AudioSceneComponent implements ISceneSerializableComponent {
  120354. /**
  120355. * The component name helpfull to identify the component in the list of scene components.
  120356. */
  120357. readonly name: string;
  120358. /**
  120359. * The scene the component belongs to.
  120360. */
  120361. scene: Scene;
  120362. private _audioEnabled;
  120363. /**
  120364. * Gets whether audio is enabled or not.
  120365. * Please use related enable/disable method to switch state.
  120366. */
  120367. get audioEnabled(): boolean;
  120368. private _headphone;
  120369. /**
  120370. * Gets whether audio is outputing to headphone or not.
  120371. * Please use the according Switch methods to change output.
  120372. */
  120373. get headphone(): boolean;
  120374. /**
  120375. * Gets or sets a refresh rate when using 3D audio positioning
  120376. */
  120377. audioPositioningRefreshRate: number;
  120378. private _audioListenerPositionProvider;
  120379. /**
  120380. * Gets the current audio listener position provider
  120381. */
  120382. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120383. /**
  120384. * Sets a custom listener position for all sounds in the scene
  120385. * By default, this is the position of the first active camera
  120386. */
  120387. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120388. /**
  120389. * Creates a new instance of the component for the given scene
  120390. * @param scene Defines the scene to register the component in
  120391. */
  120392. constructor(scene: Scene);
  120393. /**
  120394. * Registers the component in a given scene
  120395. */
  120396. register(): void;
  120397. /**
  120398. * Rebuilds the elements related to this component in case of
  120399. * context lost for instance.
  120400. */
  120401. rebuild(): void;
  120402. /**
  120403. * Serializes the component data to the specified json object
  120404. * @param serializationObject The object to serialize to
  120405. */
  120406. serialize(serializationObject: any): void;
  120407. /**
  120408. * Adds all the elements from the container to the scene
  120409. * @param container the container holding the elements
  120410. */
  120411. addFromContainer(container: AbstractScene): void;
  120412. /**
  120413. * Removes all the elements in the container from the scene
  120414. * @param container contains the elements to remove
  120415. * @param dispose if the removed element should be disposed (default: false)
  120416. */
  120417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120418. /**
  120419. * Disposes the component and the associated ressources.
  120420. */
  120421. dispose(): void;
  120422. /**
  120423. * Disables audio in the associated scene.
  120424. */
  120425. disableAudio(): void;
  120426. /**
  120427. * Enables audio in the associated scene.
  120428. */
  120429. enableAudio(): void;
  120430. /**
  120431. * Switch audio to headphone output.
  120432. */
  120433. switchAudioModeForHeadphones(): void;
  120434. /**
  120435. * Switch audio to normal speakers.
  120436. */
  120437. switchAudioModeForNormalSpeakers(): void;
  120438. private _cachedCameraDirection;
  120439. private _cachedCameraPosition;
  120440. private _lastCheck;
  120441. private _afterRender;
  120442. }
  120443. }
  120444. declare module BABYLON {
  120445. /**
  120446. * Wraps one or more Sound objects and selects one with random weight for playback.
  120447. */
  120448. export class WeightedSound {
  120449. /** When true a Sound will be selected and played when the current playing Sound completes. */
  120450. loop: boolean;
  120451. private _coneInnerAngle;
  120452. private _coneOuterAngle;
  120453. private _volume;
  120454. /** A Sound is currently playing. */
  120455. isPlaying: boolean;
  120456. /** A Sound is currently paused. */
  120457. isPaused: boolean;
  120458. private _sounds;
  120459. private _weights;
  120460. private _currentIndex?;
  120461. /**
  120462. * Creates a new WeightedSound from the list of sounds given.
  120463. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  120464. * @param sounds Array of Sounds that will be selected from.
  120465. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  120466. */
  120467. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  120468. /**
  120469. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  120470. */
  120471. get directionalConeInnerAngle(): number;
  120472. /**
  120473. * The size of cone in degress for a directional sound in which there will be no attenuation.
  120474. */
  120475. set directionalConeInnerAngle(value: number);
  120476. /**
  120477. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120478. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120479. */
  120480. get directionalConeOuterAngle(): number;
  120481. /**
  120482. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120483. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120484. */
  120485. set directionalConeOuterAngle(value: number);
  120486. /**
  120487. * Playback volume.
  120488. */
  120489. get volume(): number;
  120490. /**
  120491. * Playback volume.
  120492. */
  120493. set volume(value: number);
  120494. private _onended;
  120495. /**
  120496. * Suspend playback
  120497. */
  120498. pause(): void;
  120499. /**
  120500. * Stop playback
  120501. */
  120502. stop(): void;
  120503. /**
  120504. * Start playback.
  120505. * @param startOffset Position the clip head at a specific time in seconds.
  120506. */
  120507. play(startOffset?: number): void;
  120508. }
  120509. }
  120510. declare module BABYLON {
  120511. /**
  120512. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  120513. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120514. */
  120515. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  120516. /**
  120517. * Gets the name of the behavior.
  120518. */
  120519. get name(): string;
  120520. /**
  120521. * The easing function used by animations
  120522. */
  120523. static EasingFunction: BackEase;
  120524. /**
  120525. * The easing mode used by animations
  120526. */
  120527. static EasingMode: number;
  120528. /**
  120529. * The duration of the animation, in milliseconds
  120530. */
  120531. transitionDuration: number;
  120532. /**
  120533. * Length of the distance animated by the transition when lower radius is reached
  120534. */
  120535. lowerRadiusTransitionRange: number;
  120536. /**
  120537. * Length of the distance animated by the transition when upper radius is reached
  120538. */
  120539. upperRadiusTransitionRange: number;
  120540. private _autoTransitionRange;
  120541. /**
  120542. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120543. */
  120544. get autoTransitionRange(): boolean;
  120545. /**
  120546. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120547. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  120548. */
  120549. set autoTransitionRange(value: boolean);
  120550. private _attachedCamera;
  120551. private _onAfterCheckInputsObserver;
  120552. private _onMeshTargetChangedObserver;
  120553. /**
  120554. * Initializes the behavior.
  120555. */
  120556. init(): void;
  120557. /**
  120558. * Attaches the behavior to its arc rotate camera.
  120559. * @param camera Defines the camera to attach the behavior to
  120560. */
  120561. attach(camera: ArcRotateCamera): void;
  120562. /**
  120563. * Detaches the behavior from its current arc rotate camera.
  120564. */
  120565. detach(): void;
  120566. private _radiusIsAnimating;
  120567. private _radiusBounceTransition;
  120568. private _animatables;
  120569. private _cachedWheelPrecision;
  120570. /**
  120571. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  120572. * @param radiusLimit The limit to check against.
  120573. * @return Bool to indicate if at limit.
  120574. */
  120575. private _isRadiusAtLimit;
  120576. /**
  120577. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  120578. * @param radiusDelta The delta by which to animate to. Can be negative.
  120579. */
  120580. private _applyBoundRadiusAnimation;
  120581. /**
  120582. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  120583. */
  120584. protected _clearAnimationLocks(): void;
  120585. /**
  120586. * Stops and removes all animations that have been applied to the camera
  120587. */
  120588. stopAllAnimations(): void;
  120589. }
  120590. }
  120591. declare module BABYLON {
  120592. /**
  120593. * 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.
  120594. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120595. */
  120596. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  120597. /**
  120598. * Gets the name of the behavior.
  120599. */
  120600. get name(): string;
  120601. private _mode;
  120602. private _radiusScale;
  120603. private _positionScale;
  120604. private _defaultElevation;
  120605. private _elevationReturnTime;
  120606. private _elevationReturnWaitTime;
  120607. private _zoomStopsAnimation;
  120608. private _framingTime;
  120609. /**
  120610. * The easing function used by animations
  120611. */
  120612. static EasingFunction: ExponentialEase;
  120613. /**
  120614. * The easing mode used by animations
  120615. */
  120616. static EasingMode: number;
  120617. /**
  120618. * Sets the current mode used by the behavior
  120619. */
  120620. set mode(mode: number);
  120621. /**
  120622. * Gets current mode used by the behavior.
  120623. */
  120624. get mode(): number;
  120625. /**
  120626. * Sets the scale applied to the radius (1 by default)
  120627. */
  120628. set radiusScale(radius: number);
  120629. /**
  120630. * Gets the scale applied to the radius
  120631. */
  120632. get radiusScale(): number;
  120633. /**
  120634. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  120635. */
  120636. set positionScale(scale: number);
  120637. /**
  120638. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  120639. */
  120640. get positionScale(): number;
  120641. /**
  120642. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  120643. * behaviour is triggered, in radians.
  120644. */
  120645. set defaultElevation(elevation: number);
  120646. /**
  120647. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  120648. * behaviour is triggered, in radians.
  120649. */
  120650. get defaultElevation(): number;
  120651. /**
  120652. * Sets the time (in milliseconds) taken to return to the default beta position.
  120653. * Negative value indicates camera should not return to default.
  120654. */
  120655. set elevationReturnTime(speed: number);
  120656. /**
  120657. * Gets the time (in milliseconds) taken to return to the default beta position.
  120658. * Negative value indicates camera should not return to default.
  120659. */
  120660. get elevationReturnTime(): number;
  120661. /**
  120662. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  120663. */
  120664. set elevationReturnWaitTime(time: number);
  120665. /**
  120666. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  120667. */
  120668. get elevationReturnWaitTime(): number;
  120669. /**
  120670. * Sets the flag that indicates if user zooming should stop animation.
  120671. */
  120672. set zoomStopsAnimation(flag: boolean);
  120673. /**
  120674. * Gets the flag that indicates if user zooming should stop animation.
  120675. */
  120676. get zoomStopsAnimation(): boolean;
  120677. /**
  120678. * Sets the transition time when framing the mesh, in milliseconds
  120679. */
  120680. set framingTime(time: number);
  120681. /**
  120682. * Gets the transition time when framing the mesh, in milliseconds
  120683. */
  120684. get framingTime(): number;
  120685. /**
  120686. * Define if the behavior should automatically change the configured
  120687. * camera limits and sensibilities.
  120688. */
  120689. autoCorrectCameraLimitsAndSensibility: boolean;
  120690. private _onPrePointerObservableObserver;
  120691. private _onAfterCheckInputsObserver;
  120692. private _onMeshTargetChangedObserver;
  120693. private _attachedCamera;
  120694. private _isPointerDown;
  120695. private _lastInteractionTime;
  120696. /**
  120697. * Initializes the behavior.
  120698. */
  120699. init(): void;
  120700. /**
  120701. * Attaches the behavior to its arc rotate camera.
  120702. * @param camera Defines the camera to attach the behavior to
  120703. */
  120704. attach(camera: ArcRotateCamera): void;
  120705. /**
  120706. * Detaches the behavior from its current arc rotate camera.
  120707. */
  120708. detach(): void;
  120709. private _animatables;
  120710. private _betaIsAnimating;
  120711. private _betaTransition;
  120712. private _radiusTransition;
  120713. private _vectorTransition;
  120714. /**
  120715. * Targets the given mesh and updates zoom level accordingly.
  120716. * @param mesh The mesh to target.
  120717. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120718. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120719. */
  120720. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120721. /**
  120722. * Targets the given mesh with its children and updates zoom level accordingly.
  120723. * @param mesh The mesh to target.
  120724. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120725. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120726. */
  120727. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120728. /**
  120729. * Targets the given meshes with their children and updates zoom level accordingly.
  120730. * @param meshes The mesh to target.
  120731. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120732. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120733. */
  120734. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120735. /**
  120736. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  120737. * @param minimumWorld Determines the smaller position of the bounding box extend
  120738. * @param maximumWorld Determines the bigger position of the bounding box extend
  120739. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120740. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120741. */
  120742. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120743. /**
  120744. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  120745. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  120746. * frustum width.
  120747. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  120748. * to fully enclose the mesh in the viewing frustum.
  120749. */
  120750. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  120751. /**
  120752. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  120753. * is automatically returned to its default position (expected to be above ground plane).
  120754. */
  120755. private _maintainCameraAboveGround;
  120756. /**
  120757. * Returns the frustum slope based on the canvas ratio and camera FOV
  120758. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  120759. */
  120760. private _getFrustumSlope;
  120761. /**
  120762. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  120763. */
  120764. private _clearAnimationLocks;
  120765. /**
  120766. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120767. */
  120768. private _applyUserInteraction;
  120769. /**
  120770. * Stops and removes all animations that have been applied to the camera
  120771. */
  120772. stopAllAnimations(): void;
  120773. /**
  120774. * Gets a value indicating if the user is moving the camera
  120775. */
  120776. get isUserIsMoving(): boolean;
  120777. /**
  120778. * The camera can move all the way towards the mesh.
  120779. */
  120780. static IgnoreBoundsSizeMode: number;
  120781. /**
  120782. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  120783. */
  120784. static FitFrustumSidesMode: number;
  120785. }
  120786. }
  120787. declare module BABYLON {
  120788. /**
  120789. * Base class for Camera Pointer Inputs.
  120790. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  120791. * for example usage.
  120792. */
  120793. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  120794. /**
  120795. * Defines the camera the input is attached to.
  120796. */
  120797. abstract camera: Camera;
  120798. /**
  120799. * Whether keyboard modifier keys are pressed at time of last mouse event.
  120800. */
  120801. protected _altKey: boolean;
  120802. protected _ctrlKey: boolean;
  120803. protected _metaKey: boolean;
  120804. protected _shiftKey: boolean;
  120805. /**
  120806. * Which mouse buttons were pressed at time of last mouse event.
  120807. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  120808. */
  120809. protected _buttonsPressed: number;
  120810. /**
  120811. * Defines the buttons associated with the input to handle camera move.
  120812. */
  120813. buttons: number[];
  120814. /**
  120815. * Attach the input controls to a specific dom element to get the input from.
  120816. * @param element Defines the element the controls should be listened from
  120817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120818. */
  120819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120820. /**
  120821. * Detach the current controls from the specified dom element.
  120822. * @param element Defines the element to stop listening the inputs from
  120823. */
  120824. detachControl(element: Nullable<HTMLElement>): void;
  120825. /**
  120826. * Gets the class name of the current input.
  120827. * @returns the class name
  120828. */
  120829. getClassName(): string;
  120830. /**
  120831. * Get the friendly name associated with the input class.
  120832. * @returns the input friendly name
  120833. */
  120834. getSimpleName(): string;
  120835. /**
  120836. * Called on pointer POINTERDOUBLETAP event.
  120837. * Override this method to provide functionality on POINTERDOUBLETAP event.
  120838. */
  120839. protected onDoubleTap(type: string): void;
  120840. /**
  120841. * Called on pointer POINTERMOVE event if only a single touch is active.
  120842. * Override this method to provide functionality.
  120843. */
  120844. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120845. /**
  120846. * Called on pointer POINTERMOVE event if multiple touches are active.
  120847. * Override this method to provide functionality.
  120848. */
  120849. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120850. /**
  120851. * Called on JS contextmenu event.
  120852. * Override this method to provide functionality.
  120853. */
  120854. protected onContextMenu(evt: PointerEvent): void;
  120855. /**
  120856. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  120857. * press.
  120858. * Override this method to provide functionality.
  120859. */
  120860. protected onButtonDown(evt: PointerEvent): void;
  120861. /**
  120862. * Called each time a new POINTERUP event occurs. Ie, for each button
  120863. * release.
  120864. * Override this method to provide functionality.
  120865. */
  120866. protected onButtonUp(evt: PointerEvent): void;
  120867. /**
  120868. * Called when window becomes inactive.
  120869. * Override this method to provide functionality.
  120870. */
  120871. protected onLostFocus(): void;
  120872. private _pointerInput;
  120873. private _observer;
  120874. private _onLostFocus;
  120875. private pointA;
  120876. private pointB;
  120877. }
  120878. }
  120879. declare module BABYLON {
  120880. /**
  120881. * Manage the pointers inputs to control an arc rotate camera.
  120882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120883. */
  120884. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  120885. /**
  120886. * Defines the camera the input is attached to.
  120887. */
  120888. camera: ArcRotateCamera;
  120889. /**
  120890. * Gets the class name of the current input.
  120891. * @returns the class name
  120892. */
  120893. getClassName(): string;
  120894. /**
  120895. * Defines the buttons associated with the input to handle camera move.
  120896. */
  120897. buttons: number[];
  120898. /**
  120899. * Defines the pointer angular sensibility along the X axis or how fast is
  120900. * the camera rotating.
  120901. */
  120902. angularSensibilityX: number;
  120903. /**
  120904. * Defines the pointer angular sensibility along the Y axis or how fast is
  120905. * the camera rotating.
  120906. */
  120907. angularSensibilityY: number;
  120908. /**
  120909. * Defines the pointer pinch precision or how fast is the camera zooming.
  120910. */
  120911. pinchPrecision: number;
  120912. /**
  120913. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120914. * from 0.
  120915. * It defines the percentage of current camera.radius to use as delta when
  120916. * pinch zoom is used.
  120917. */
  120918. pinchDeltaPercentage: number;
  120919. /**
  120920. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120921. * that any object in the plane at the camera's target point will scale
  120922. * perfectly with finger motion.
  120923. * Overrides pinchDeltaPercentage and pinchPrecision.
  120924. */
  120925. useNaturalPinchZoom: boolean;
  120926. /**
  120927. * Defines the pointer panning sensibility or how fast is the camera moving.
  120928. */
  120929. panningSensibility: number;
  120930. /**
  120931. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  120932. */
  120933. multiTouchPanning: boolean;
  120934. /**
  120935. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  120936. * zoom (pinch) through multitouch.
  120937. */
  120938. multiTouchPanAndZoom: boolean;
  120939. /**
  120940. * Revers pinch action direction.
  120941. */
  120942. pinchInwards: boolean;
  120943. private _isPanClick;
  120944. private _twoFingerActivityCount;
  120945. private _isPinching;
  120946. /**
  120947. * Called on pointer POINTERMOVE event if only a single touch is active.
  120948. */
  120949. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120950. /**
  120951. * Called on pointer POINTERDOUBLETAP event.
  120952. */
  120953. protected onDoubleTap(type: string): void;
  120954. /**
  120955. * Called on pointer POINTERMOVE event if multiple touches are active.
  120956. */
  120957. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120958. /**
  120959. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  120960. * press.
  120961. */
  120962. protected onButtonDown(evt: PointerEvent): void;
  120963. /**
  120964. * Called each time a new POINTERUP event occurs. Ie, for each button
  120965. * release.
  120966. */
  120967. protected onButtonUp(evt: PointerEvent): void;
  120968. /**
  120969. * Called when window becomes inactive.
  120970. */
  120971. protected onLostFocus(): void;
  120972. }
  120973. }
  120974. declare module BABYLON {
  120975. /**
  120976. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  120977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120978. */
  120979. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  120980. /**
  120981. * Defines the camera the input is attached to.
  120982. */
  120983. camera: ArcRotateCamera;
  120984. /**
  120985. * Defines the list of key codes associated with the up action (increase alpha)
  120986. */
  120987. keysUp: number[];
  120988. /**
  120989. * Defines the list of key codes associated with the down action (decrease alpha)
  120990. */
  120991. keysDown: number[];
  120992. /**
  120993. * Defines the list of key codes associated with the left action (increase beta)
  120994. */
  120995. keysLeft: number[];
  120996. /**
  120997. * Defines the list of key codes associated with the right action (decrease beta)
  120998. */
  120999. keysRight: number[];
  121000. /**
  121001. * Defines the list of key codes associated with the reset action.
  121002. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121003. */
  121004. keysReset: number[];
  121005. /**
  121006. * Defines the panning sensibility of the inputs.
  121007. * (How fast is the camera panning)
  121008. */
  121009. panningSensibility: number;
  121010. /**
  121011. * Defines the zooming sensibility of the inputs.
  121012. * (How fast is the camera zooming)
  121013. */
  121014. zoomingSensibility: number;
  121015. /**
  121016. * Defines whether maintaining the alt key down switch the movement mode from
  121017. * orientation to zoom.
  121018. */
  121019. useAltToZoom: boolean;
  121020. /**
  121021. * Rotation speed of the camera
  121022. */
  121023. angularSpeed: number;
  121024. private _keys;
  121025. private _ctrlPressed;
  121026. private _altPressed;
  121027. private _onCanvasBlurObserver;
  121028. private _onKeyboardObserver;
  121029. private _engine;
  121030. private _scene;
  121031. /**
  121032. * Attach the input controls to a specific dom element to get the input from.
  121033. * @param element Defines the element the controls should be listened from
  121034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121035. */
  121036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121037. /**
  121038. * Detach the current controls from the specified dom element.
  121039. * @param element Defines the element to stop listening the inputs from
  121040. */
  121041. detachControl(element: Nullable<HTMLElement>): void;
  121042. /**
  121043. * Update the current camera state depending on the inputs that have been used this frame.
  121044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121045. */
  121046. checkInputs(): void;
  121047. /**
  121048. * Gets the class name of the current intput.
  121049. * @returns the class name
  121050. */
  121051. getClassName(): string;
  121052. /**
  121053. * Get the friendly name associated with the input class.
  121054. * @returns the input friendly name
  121055. */
  121056. getSimpleName(): string;
  121057. }
  121058. }
  121059. declare module BABYLON {
  121060. /**
  121061. * Manage the mouse wheel inputs to control an arc rotate camera.
  121062. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121063. */
  121064. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121065. /**
  121066. * Defines the camera the input is attached to.
  121067. */
  121068. camera: ArcRotateCamera;
  121069. /**
  121070. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121071. */
  121072. wheelPrecision: number;
  121073. /**
  121074. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121075. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121076. */
  121077. wheelDeltaPercentage: number;
  121078. private _wheel;
  121079. private _observer;
  121080. private computeDeltaFromMouseWheelLegacyEvent;
  121081. /**
  121082. * Attach the input controls to a specific dom element to get the input from.
  121083. * @param element Defines the element the controls should be listened from
  121084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121085. */
  121086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121087. /**
  121088. * Detach the current controls from the specified dom element.
  121089. * @param element Defines the element to stop listening the inputs from
  121090. */
  121091. detachControl(element: Nullable<HTMLElement>): void;
  121092. /**
  121093. * Gets the class name of the current intput.
  121094. * @returns the class name
  121095. */
  121096. getClassName(): string;
  121097. /**
  121098. * Get the friendly name associated with the input class.
  121099. * @returns the input friendly name
  121100. */
  121101. getSimpleName(): string;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Default Inputs manager for the ArcRotateCamera.
  121107. * It groups all the default supported inputs for ease of use.
  121108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121109. */
  121110. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121111. /**
  121112. * Instantiates a new ArcRotateCameraInputsManager.
  121113. * @param camera Defines the camera the inputs belong to
  121114. */
  121115. constructor(camera: ArcRotateCamera);
  121116. /**
  121117. * Add mouse wheel input support to the input manager.
  121118. * @returns the current input manager
  121119. */
  121120. addMouseWheel(): ArcRotateCameraInputsManager;
  121121. /**
  121122. * Add pointers input support to the input manager.
  121123. * @returns the current input manager
  121124. */
  121125. addPointers(): ArcRotateCameraInputsManager;
  121126. /**
  121127. * Add keyboard input support to the input manager.
  121128. * @returns the current input manager
  121129. */
  121130. addKeyboard(): ArcRotateCameraInputsManager;
  121131. }
  121132. }
  121133. declare module BABYLON {
  121134. /**
  121135. * This represents an orbital type of camera.
  121136. *
  121137. * 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.
  121138. * 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.
  121139. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121140. */
  121141. export class ArcRotateCamera extends TargetCamera {
  121142. /**
  121143. * Defines the rotation angle of the camera along the longitudinal axis.
  121144. */
  121145. alpha: number;
  121146. /**
  121147. * Defines the rotation angle of the camera along the latitudinal axis.
  121148. */
  121149. beta: number;
  121150. /**
  121151. * Defines the radius of the camera from it s target point.
  121152. */
  121153. radius: number;
  121154. protected _target: Vector3;
  121155. protected _targetHost: Nullable<AbstractMesh>;
  121156. /**
  121157. * Defines the target point of the camera.
  121158. * The camera looks towards it form the radius distance.
  121159. */
  121160. get target(): Vector3;
  121161. set target(value: Vector3);
  121162. /**
  121163. * Define the current local position of the camera in the scene
  121164. */
  121165. get position(): Vector3;
  121166. set position(newPosition: Vector3);
  121167. protected _upVector: Vector3;
  121168. protected _upToYMatrix: Matrix;
  121169. protected _YToUpMatrix: Matrix;
  121170. /**
  121171. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121172. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121173. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121174. */
  121175. set upVector(vec: Vector3);
  121176. get upVector(): Vector3;
  121177. /**
  121178. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121179. */
  121180. setMatUp(): void;
  121181. /**
  121182. * Current inertia value on the longitudinal axis.
  121183. * The bigger this number the longer it will take for the camera to stop.
  121184. */
  121185. inertialAlphaOffset: number;
  121186. /**
  121187. * Current inertia value on the latitudinal axis.
  121188. * The bigger this number the longer it will take for the camera to stop.
  121189. */
  121190. inertialBetaOffset: number;
  121191. /**
  121192. * Current inertia value on the radius axis.
  121193. * The bigger this number the longer it will take for the camera to stop.
  121194. */
  121195. inertialRadiusOffset: number;
  121196. /**
  121197. * Minimum allowed angle on the longitudinal axis.
  121198. * This can help limiting how the Camera is able to move in the scene.
  121199. */
  121200. lowerAlphaLimit: Nullable<number>;
  121201. /**
  121202. * Maximum allowed angle on the longitudinal axis.
  121203. * This can help limiting how the Camera is able to move in the scene.
  121204. */
  121205. upperAlphaLimit: Nullable<number>;
  121206. /**
  121207. * Minimum allowed angle on the latitudinal axis.
  121208. * This can help limiting how the Camera is able to move in the scene.
  121209. */
  121210. lowerBetaLimit: number;
  121211. /**
  121212. * Maximum allowed angle on the latitudinal axis.
  121213. * This can help limiting how the Camera is able to move in the scene.
  121214. */
  121215. upperBetaLimit: number;
  121216. /**
  121217. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121218. * This can help limiting how the Camera is able to move in the scene.
  121219. */
  121220. lowerRadiusLimit: Nullable<number>;
  121221. /**
  121222. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121223. * This can help limiting how the Camera is able to move in the scene.
  121224. */
  121225. upperRadiusLimit: Nullable<number>;
  121226. /**
  121227. * Defines the current inertia value used during panning of the camera along the X axis.
  121228. */
  121229. inertialPanningX: number;
  121230. /**
  121231. * Defines the current inertia value used during panning of the camera along the Y axis.
  121232. */
  121233. inertialPanningY: number;
  121234. /**
  121235. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121236. * Basically if your fingers moves away from more than this distance you will be considered
  121237. * in pinch mode.
  121238. */
  121239. pinchToPanMaxDistance: number;
  121240. /**
  121241. * Defines the maximum distance the camera can pan.
  121242. * This could help keeping the cammera always in your scene.
  121243. */
  121244. panningDistanceLimit: Nullable<number>;
  121245. /**
  121246. * Defines the target of the camera before paning.
  121247. */
  121248. panningOriginTarget: Vector3;
  121249. /**
  121250. * Defines the value of the inertia used during panning.
  121251. * 0 would mean stop inertia and one would mean no decelleration at all.
  121252. */
  121253. panningInertia: number;
  121254. /**
  121255. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121256. */
  121257. get angularSensibilityX(): number;
  121258. set angularSensibilityX(value: number);
  121259. /**
  121260. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121261. */
  121262. get angularSensibilityY(): number;
  121263. set angularSensibilityY(value: number);
  121264. /**
  121265. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121266. */
  121267. get pinchPrecision(): number;
  121268. set pinchPrecision(value: number);
  121269. /**
  121270. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121271. * It will be used instead of pinchDeltaPrecision if different from 0.
  121272. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121273. */
  121274. get pinchDeltaPercentage(): number;
  121275. set pinchDeltaPercentage(value: number);
  121276. /**
  121277. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121278. * and pinch delta percentage.
  121279. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121280. * that any object in the plane at the camera's target point will scale
  121281. * perfectly with finger motion.
  121282. */
  121283. get useNaturalPinchZoom(): boolean;
  121284. set useNaturalPinchZoom(value: boolean);
  121285. /**
  121286. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121287. */
  121288. get panningSensibility(): number;
  121289. set panningSensibility(value: number);
  121290. /**
  121291. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121292. */
  121293. get keysUp(): number[];
  121294. set keysUp(value: number[]);
  121295. /**
  121296. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121297. */
  121298. get keysDown(): number[];
  121299. set keysDown(value: number[]);
  121300. /**
  121301. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121302. */
  121303. get keysLeft(): number[];
  121304. set keysLeft(value: number[]);
  121305. /**
  121306. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121307. */
  121308. get keysRight(): number[];
  121309. set keysRight(value: number[]);
  121310. /**
  121311. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121312. */
  121313. get wheelPrecision(): number;
  121314. set wheelPrecision(value: number);
  121315. /**
  121316. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121317. * It will be used instead of pinchDeltaPrecision if different from 0.
  121318. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121319. */
  121320. get wheelDeltaPercentage(): number;
  121321. set wheelDeltaPercentage(value: number);
  121322. /**
  121323. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121324. */
  121325. zoomOnFactor: number;
  121326. /**
  121327. * Defines a screen offset for the camera position.
  121328. */
  121329. targetScreenOffset: Vector2;
  121330. /**
  121331. * Allows the camera to be completely reversed.
  121332. * If false the camera can not arrive upside down.
  121333. */
  121334. allowUpsideDown: boolean;
  121335. /**
  121336. * Define if double tap/click is used to restore the previously saved state of the camera.
  121337. */
  121338. useInputToRestoreState: boolean;
  121339. /** @hidden */
  121340. _viewMatrix: Matrix;
  121341. /** @hidden */
  121342. _useCtrlForPanning: boolean;
  121343. /** @hidden */
  121344. _panningMouseButton: number;
  121345. /**
  121346. * Defines the input associated to the camera.
  121347. */
  121348. inputs: ArcRotateCameraInputsManager;
  121349. /** @hidden */
  121350. _reset: () => void;
  121351. /**
  121352. * Defines the allowed panning axis.
  121353. */
  121354. panningAxis: Vector3;
  121355. protected _localDirection: Vector3;
  121356. protected _transformedDirection: Vector3;
  121357. private _bouncingBehavior;
  121358. /**
  121359. * Gets the bouncing behavior of the camera if it has been enabled.
  121360. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121361. */
  121362. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121363. /**
  121364. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121365. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121366. */
  121367. get useBouncingBehavior(): boolean;
  121368. set useBouncingBehavior(value: boolean);
  121369. private _framingBehavior;
  121370. /**
  121371. * Gets the framing behavior of the camera if it has been enabled.
  121372. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121373. */
  121374. get framingBehavior(): Nullable<FramingBehavior>;
  121375. /**
  121376. * Defines if the framing behavior of the camera is enabled on the camera.
  121377. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121378. */
  121379. get useFramingBehavior(): boolean;
  121380. set useFramingBehavior(value: boolean);
  121381. private _autoRotationBehavior;
  121382. /**
  121383. * Gets the auto rotation behavior of the camera if it has been enabled.
  121384. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121385. */
  121386. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121387. /**
  121388. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121389. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121390. */
  121391. get useAutoRotationBehavior(): boolean;
  121392. set useAutoRotationBehavior(value: boolean);
  121393. /**
  121394. * Observable triggered when the mesh target has been changed on the camera.
  121395. */
  121396. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121397. /**
  121398. * Event raised when the camera is colliding with a mesh.
  121399. */
  121400. onCollide: (collidedMesh: AbstractMesh) => void;
  121401. /**
  121402. * Defines whether the camera should check collision with the objects oh the scene.
  121403. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121404. */
  121405. checkCollisions: boolean;
  121406. /**
  121407. * Defines the collision radius of the camera.
  121408. * This simulates a sphere around the camera.
  121409. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121410. */
  121411. collisionRadius: Vector3;
  121412. protected _collider: Collider;
  121413. protected _previousPosition: Vector3;
  121414. protected _collisionVelocity: Vector3;
  121415. protected _newPosition: Vector3;
  121416. protected _previousAlpha: number;
  121417. protected _previousBeta: number;
  121418. protected _previousRadius: number;
  121419. protected _collisionTriggered: boolean;
  121420. protected _targetBoundingCenter: Nullable<Vector3>;
  121421. private _computationVector;
  121422. /**
  121423. * Instantiates a new ArcRotateCamera in a given scene
  121424. * @param name Defines the name of the camera
  121425. * @param alpha Defines the camera rotation along the logitudinal axis
  121426. * @param beta Defines the camera rotation along the latitudinal axis
  121427. * @param radius Defines the camera distance from its target
  121428. * @param target Defines the camera target
  121429. * @param scene Defines the scene the camera belongs to
  121430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  121431. */
  121432. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121433. /** @hidden */
  121434. _initCache(): void;
  121435. /** @hidden */
  121436. _updateCache(ignoreParentClass?: boolean): void;
  121437. protected _getTargetPosition(): Vector3;
  121438. private _storedAlpha;
  121439. private _storedBeta;
  121440. private _storedRadius;
  121441. private _storedTarget;
  121442. private _storedTargetScreenOffset;
  121443. /**
  121444. * Stores the current state of the camera (alpha, beta, radius and target)
  121445. * @returns the camera itself
  121446. */
  121447. storeState(): Camera;
  121448. /**
  121449. * @hidden
  121450. * Restored camera state. You must call storeState() first
  121451. */
  121452. _restoreStateValues(): boolean;
  121453. /** @hidden */
  121454. _isSynchronizedViewMatrix(): boolean;
  121455. /**
  121456. * Attached controls to the current camera.
  121457. * @param element Defines the element the controls should be listened from
  121458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121459. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  121460. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  121461. */
  121462. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  121463. /**
  121464. * Detach the current controls from the camera.
  121465. * The camera will stop reacting to inputs.
  121466. * @param element Defines the element to stop listening the inputs from
  121467. */
  121468. detachControl(element: HTMLElement): void;
  121469. /** @hidden */
  121470. _checkInputs(): void;
  121471. protected _checkLimits(): void;
  121472. /**
  121473. * Rebuilds angles (alpha, beta) and radius from the give position and target
  121474. */
  121475. rebuildAnglesAndRadius(): void;
  121476. /**
  121477. * Use a position to define the current camera related information like alpha, beta and radius
  121478. * @param position Defines the position to set the camera at
  121479. */
  121480. setPosition(position: Vector3): void;
  121481. /**
  121482. * Defines the target the camera should look at.
  121483. * This will automatically adapt alpha beta and radius to fit within the new target.
  121484. * @param target Defines the new target as a Vector or a mesh
  121485. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  121486. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  121487. */
  121488. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  121489. /** @hidden */
  121490. _getViewMatrix(): Matrix;
  121491. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  121492. /**
  121493. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  121494. * @param meshes Defines the mesh to zoom on
  121495. * @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)
  121496. */
  121497. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  121498. /**
  121499. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  121500. * The target will be changed but the radius
  121501. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  121502. * @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)
  121503. */
  121504. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  121505. min: Vector3;
  121506. max: Vector3;
  121507. distance: number;
  121508. }, doNotUpdateMaxZ?: boolean): void;
  121509. /**
  121510. * @override
  121511. * Override Camera.createRigCamera
  121512. */
  121513. createRigCamera(name: string, cameraIndex: number): Camera;
  121514. /**
  121515. * @hidden
  121516. * @override
  121517. * Override Camera._updateRigCameras
  121518. */
  121519. _updateRigCameras(): void;
  121520. /**
  121521. * Destroy the camera and release the current resources hold by it.
  121522. */
  121523. dispose(): void;
  121524. /**
  121525. * Gets the current object class name.
  121526. * @return the class name
  121527. */
  121528. getClassName(): string;
  121529. }
  121530. }
  121531. declare module BABYLON {
  121532. /**
  121533. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  121534. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121535. */
  121536. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  121537. /**
  121538. * Gets the name of the behavior.
  121539. */
  121540. get name(): string;
  121541. private _zoomStopsAnimation;
  121542. private _idleRotationSpeed;
  121543. private _idleRotationWaitTime;
  121544. private _idleRotationSpinupTime;
  121545. /**
  121546. * Sets the flag that indicates if user zooming should stop animation.
  121547. */
  121548. set zoomStopsAnimation(flag: boolean);
  121549. /**
  121550. * Gets the flag that indicates if user zooming should stop animation.
  121551. */
  121552. get zoomStopsAnimation(): boolean;
  121553. /**
  121554. * Sets the default speed at which the camera rotates around the model.
  121555. */
  121556. set idleRotationSpeed(speed: number);
  121557. /**
  121558. * Gets the default speed at which the camera rotates around the model.
  121559. */
  121560. get idleRotationSpeed(): number;
  121561. /**
  121562. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  121563. */
  121564. set idleRotationWaitTime(time: number);
  121565. /**
  121566. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  121567. */
  121568. get idleRotationWaitTime(): number;
  121569. /**
  121570. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121571. */
  121572. set idleRotationSpinupTime(time: number);
  121573. /**
  121574. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121575. */
  121576. get idleRotationSpinupTime(): number;
  121577. /**
  121578. * Gets a value indicating if the camera is currently rotating because of this behavior
  121579. */
  121580. get rotationInProgress(): boolean;
  121581. private _onPrePointerObservableObserver;
  121582. private _onAfterCheckInputsObserver;
  121583. private _attachedCamera;
  121584. private _isPointerDown;
  121585. private _lastFrameTime;
  121586. private _lastInteractionTime;
  121587. private _cameraRotationSpeed;
  121588. /**
  121589. * Initializes the behavior.
  121590. */
  121591. init(): void;
  121592. /**
  121593. * Attaches the behavior to its arc rotate camera.
  121594. * @param camera Defines the camera to attach the behavior to
  121595. */
  121596. attach(camera: ArcRotateCamera): void;
  121597. /**
  121598. * Detaches the behavior from its current arc rotate camera.
  121599. */
  121600. detach(): void;
  121601. /**
  121602. * Returns true if user is scrolling.
  121603. * @return true if user is scrolling.
  121604. */
  121605. private _userIsZooming;
  121606. private _lastFrameRadius;
  121607. private _shouldAnimationStopForInteraction;
  121608. /**
  121609. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121610. */
  121611. private _applyUserInteraction;
  121612. private _userIsMoving;
  121613. }
  121614. }
  121615. declare module BABYLON {
  121616. /**
  121617. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  121618. */
  121619. export class AttachToBoxBehavior implements Behavior<Mesh> {
  121620. private ui;
  121621. /**
  121622. * The name of the behavior
  121623. */
  121624. name: string;
  121625. /**
  121626. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  121627. */
  121628. distanceAwayFromFace: number;
  121629. /**
  121630. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  121631. */
  121632. distanceAwayFromBottomOfFace: number;
  121633. private _faceVectors;
  121634. private _target;
  121635. private _scene;
  121636. private _onRenderObserver;
  121637. private _tmpMatrix;
  121638. private _tmpVector;
  121639. /**
  121640. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  121641. * @param ui The transform node that should be attched to the mesh
  121642. */
  121643. constructor(ui: TransformNode);
  121644. /**
  121645. * Initializes the behavior
  121646. */
  121647. init(): void;
  121648. private _closestFace;
  121649. private _zeroVector;
  121650. private _lookAtTmpMatrix;
  121651. private _lookAtToRef;
  121652. /**
  121653. * Attaches the AttachToBoxBehavior to the passed in mesh
  121654. * @param target The mesh that the specified node will be attached to
  121655. */
  121656. attach(target: Mesh): void;
  121657. /**
  121658. * Detaches the behavior from the mesh
  121659. */
  121660. detach(): void;
  121661. }
  121662. }
  121663. declare module BABYLON {
  121664. /**
  121665. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  121666. */
  121667. export class FadeInOutBehavior implements Behavior<Mesh> {
  121668. /**
  121669. * Time in milliseconds to delay before fading in (Default: 0)
  121670. */
  121671. delay: number;
  121672. /**
  121673. * Time in milliseconds for the mesh to fade in (Default: 300)
  121674. */
  121675. fadeInTime: number;
  121676. private _millisecondsPerFrame;
  121677. private _hovered;
  121678. private _hoverValue;
  121679. private _ownerNode;
  121680. /**
  121681. * Instatiates the FadeInOutBehavior
  121682. */
  121683. constructor();
  121684. /**
  121685. * The name of the behavior
  121686. */
  121687. get name(): string;
  121688. /**
  121689. * Initializes the behavior
  121690. */
  121691. init(): void;
  121692. /**
  121693. * Attaches the fade behavior on the passed in mesh
  121694. * @param ownerNode The mesh that will be faded in/out once attached
  121695. */
  121696. attach(ownerNode: Mesh): void;
  121697. /**
  121698. * Detaches the behavior from the mesh
  121699. */
  121700. detach(): void;
  121701. /**
  121702. * Triggers the mesh to begin fading in or out
  121703. * @param value if the object should fade in or out (true to fade in)
  121704. */
  121705. fadeIn(value: boolean): void;
  121706. private _update;
  121707. private _setAllVisibility;
  121708. }
  121709. }
  121710. declare module BABYLON {
  121711. /**
  121712. * Class containing a set of static utilities functions for managing Pivots
  121713. * @hidden
  121714. */
  121715. export class PivotTools {
  121716. private static _PivotCached;
  121717. private static _OldPivotPoint;
  121718. private static _PivotTranslation;
  121719. private static _PivotTmpVector;
  121720. /** @hidden */
  121721. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  121722. /** @hidden */
  121723. static _RestorePivotPoint(mesh: AbstractMesh): void;
  121724. }
  121725. }
  121726. declare module BABYLON {
  121727. /**
  121728. * Class containing static functions to help procedurally build meshes
  121729. */
  121730. export class PlaneBuilder {
  121731. /**
  121732. * Creates a plane mesh
  121733. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121734. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121735. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121739. * @param name defines the name of the mesh
  121740. * @param options defines the options used to create the mesh
  121741. * @param scene defines the hosting scene
  121742. * @returns the plane mesh
  121743. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121744. */
  121745. static CreatePlane(name: string, options: {
  121746. size?: number;
  121747. width?: number;
  121748. height?: number;
  121749. sideOrientation?: number;
  121750. frontUVs?: Vector4;
  121751. backUVs?: Vector4;
  121752. updatable?: boolean;
  121753. sourcePlane?: Plane;
  121754. }, scene?: Nullable<Scene>): Mesh;
  121755. }
  121756. }
  121757. declare module BABYLON {
  121758. /**
  121759. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  121760. */
  121761. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  121762. private static _AnyMouseID;
  121763. /**
  121764. * Abstract mesh the behavior is set on
  121765. */
  121766. attachedNode: AbstractMesh;
  121767. private _dragPlane;
  121768. private _scene;
  121769. private _pointerObserver;
  121770. private _beforeRenderObserver;
  121771. private static _planeScene;
  121772. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  121773. /**
  121774. * 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)
  121775. */
  121776. maxDragAngle: number;
  121777. /**
  121778. * @hidden
  121779. */
  121780. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  121781. /**
  121782. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  121783. */
  121784. currentDraggingPointerID: number;
  121785. /**
  121786. * The last position where the pointer hit the drag plane in world space
  121787. */
  121788. lastDragPosition: Vector3;
  121789. /**
  121790. * If the behavior is currently in a dragging state
  121791. */
  121792. dragging: boolean;
  121793. /**
  121794. * 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)
  121795. */
  121796. dragDeltaRatio: number;
  121797. /**
  121798. * If the drag plane orientation should be updated during the dragging (Default: true)
  121799. */
  121800. updateDragPlane: boolean;
  121801. private _debugMode;
  121802. private _moving;
  121803. /**
  121804. * Fires each time the attached mesh is dragged with the pointer
  121805. * * delta between last drag position and current drag position in world space
  121806. * * dragDistance along the drag axis
  121807. * * dragPlaneNormal normal of the current drag plane used during the drag
  121808. * * dragPlanePoint in world space where the drag intersects the drag plane
  121809. */
  121810. onDragObservable: Observable<{
  121811. delta: Vector3;
  121812. dragPlanePoint: Vector3;
  121813. dragPlaneNormal: Vector3;
  121814. dragDistance: number;
  121815. pointerId: number;
  121816. }>;
  121817. /**
  121818. * Fires each time a drag begins (eg. mouse down on mesh)
  121819. */
  121820. onDragStartObservable: Observable<{
  121821. dragPlanePoint: Vector3;
  121822. pointerId: number;
  121823. }>;
  121824. /**
  121825. * Fires each time a drag ends (eg. mouse release after drag)
  121826. */
  121827. onDragEndObservable: Observable<{
  121828. dragPlanePoint: Vector3;
  121829. pointerId: number;
  121830. }>;
  121831. /**
  121832. * If the attached mesh should be moved when dragged
  121833. */
  121834. moveAttached: boolean;
  121835. /**
  121836. * If the drag behavior will react to drag events (Default: true)
  121837. */
  121838. enabled: boolean;
  121839. /**
  121840. * If pointer events should start and release the drag (Default: true)
  121841. */
  121842. startAndReleaseDragOnPointerEvents: boolean;
  121843. /**
  121844. * If camera controls should be detached during the drag
  121845. */
  121846. detachCameraControls: boolean;
  121847. /**
  121848. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  121849. */
  121850. useObjectOrientationForDragging: boolean;
  121851. private _options;
  121852. /**
  121853. * Gets the options used by the behavior
  121854. */
  121855. get options(): {
  121856. dragAxis?: Vector3;
  121857. dragPlaneNormal?: Vector3;
  121858. };
  121859. /**
  121860. * Sets the options used by the behavior
  121861. */
  121862. set options(options: {
  121863. dragAxis?: Vector3;
  121864. dragPlaneNormal?: Vector3;
  121865. });
  121866. /**
  121867. * Creates a pointer drag behavior that can be attached to a mesh
  121868. * @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)
  121869. */
  121870. constructor(options?: {
  121871. dragAxis?: Vector3;
  121872. dragPlaneNormal?: Vector3;
  121873. });
  121874. /**
  121875. * Predicate to determine if it is valid to move the object to a new position when it is moved
  121876. */
  121877. validateDrag: (targetPosition: Vector3) => boolean;
  121878. /**
  121879. * The name of the behavior
  121880. */
  121881. get name(): string;
  121882. /**
  121883. * Initializes the behavior
  121884. */
  121885. init(): void;
  121886. private _tmpVector;
  121887. private _alternatePickedPoint;
  121888. private _worldDragAxis;
  121889. private _targetPosition;
  121890. private _attachedElement;
  121891. /**
  121892. * Attaches the drag behavior the passed in mesh
  121893. * @param ownerNode The mesh that will be dragged around once attached
  121894. * @param predicate Predicate to use for pick filtering
  121895. */
  121896. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  121897. /**
  121898. * Force relase the drag action by code.
  121899. */
  121900. releaseDrag(): void;
  121901. private _startDragRay;
  121902. private _lastPointerRay;
  121903. /**
  121904. * Simulates the start of a pointer drag event on the behavior
  121905. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  121906. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  121907. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  121908. */
  121909. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  121910. private _startDrag;
  121911. private _dragDelta;
  121912. private _moveDrag;
  121913. private _pickWithRayOnDragPlane;
  121914. private _pointA;
  121915. private _pointC;
  121916. private _localAxis;
  121917. private _lookAt;
  121918. private _updateDragPlanePosition;
  121919. /**
  121920. * Detaches the behavior from the mesh
  121921. */
  121922. detach(): void;
  121923. }
  121924. }
  121925. declare module BABYLON {
  121926. /**
  121927. * A behavior that when attached to a mesh will allow the mesh to be scaled
  121928. */
  121929. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  121930. private _dragBehaviorA;
  121931. private _dragBehaviorB;
  121932. private _startDistance;
  121933. private _initialScale;
  121934. private _targetScale;
  121935. private _ownerNode;
  121936. private _sceneRenderObserver;
  121937. /**
  121938. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  121939. */
  121940. constructor();
  121941. /**
  121942. * The name of the behavior
  121943. */
  121944. get name(): string;
  121945. /**
  121946. * Initializes the behavior
  121947. */
  121948. init(): void;
  121949. private _getCurrentDistance;
  121950. /**
  121951. * Attaches the scale behavior the passed in mesh
  121952. * @param ownerNode The mesh that will be scaled around once attached
  121953. */
  121954. attach(ownerNode: Mesh): void;
  121955. /**
  121956. * Detaches the behavior from the mesh
  121957. */
  121958. detach(): void;
  121959. }
  121960. }
  121961. declare module BABYLON {
  121962. /**
  121963. * 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
  121964. */
  121965. export class SixDofDragBehavior implements Behavior<Mesh> {
  121966. private static _virtualScene;
  121967. private _ownerNode;
  121968. private _sceneRenderObserver;
  121969. private _scene;
  121970. private _targetPosition;
  121971. private _virtualOriginMesh;
  121972. private _virtualDragMesh;
  121973. private _pointerObserver;
  121974. private _moving;
  121975. private _startingOrientation;
  121976. private _attachedElement;
  121977. /**
  121978. * 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)
  121979. */
  121980. private zDragFactor;
  121981. /**
  121982. * If the object should rotate to face the drag origin
  121983. */
  121984. rotateDraggedObject: boolean;
  121985. /**
  121986. * If the behavior is currently in a dragging state
  121987. */
  121988. dragging: boolean;
  121989. /**
  121990. * 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)
  121991. */
  121992. dragDeltaRatio: number;
  121993. /**
  121994. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  121995. */
  121996. currentDraggingPointerID: number;
  121997. /**
  121998. * If camera controls should be detached during the drag
  121999. */
  122000. detachCameraControls: boolean;
  122001. /**
  122002. * Fires each time a drag starts
  122003. */
  122004. onDragStartObservable: Observable<{}>;
  122005. /**
  122006. * Fires each time a drag ends (eg. mouse release after drag)
  122007. */
  122008. onDragEndObservable: Observable<{}>;
  122009. /**
  122010. * 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
  122011. */
  122012. constructor();
  122013. /**
  122014. * The name of the behavior
  122015. */
  122016. get name(): string;
  122017. /**
  122018. * Initializes the behavior
  122019. */
  122020. init(): void;
  122021. /**
  122022. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122023. */
  122024. private get _pointerCamera();
  122025. /**
  122026. * Attaches the scale behavior the passed in mesh
  122027. * @param ownerNode The mesh that will be scaled around once attached
  122028. */
  122029. attach(ownerNode: Mesh): void;
  122030. /**
  122031. * Detaches the behavior from the mesh
  122032. */
  122033. detach(): void;
  122034. }
  122035. }
  122036. declare module BABYLON {
  122037. /**
  122038. * Class used to apply inverse kinematics to bones
  122039. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122040. */
  122041. export class BoneIKController {
  122042. private static _tmpVecs;
  122043. private static _tmpQuat;
  122044. private static _tmpMats;
  122045. /**
  122046. * Gets or sets the target mesh
  122047. */
  122048. targetMesh: AbstractMesh;
  122049. /** Gets or sets the mesh used as pole */
  122050. poleTargetMesh: AbstractMesh;
  122051. /**
  122052. * Gets or sets the bone used as pole
  122053. */
  122054. poleTargetBone: Nullable<Bone>;
  122055. /**
  122056. * Gets or sets the target position
  122057. */
  122058. targetPosition: Vector3;
  122059. /**
  122060. * Gets or sets the pole target position
  122061. */
  122062. poleTargetPosition: Vector3;
  122063. /**
  122064. * Gets or sets the pole target local offset
  122065. */
  122066. poleTargetLocalOffset: Vector3;
  122067. /**
  122068. * Gets or sets the pole angle
  122069. */
  122070. poleAngle: number;
  122071. /**
  122072. * Gets or sets the mesh associated with the controller
  122073. */
  122074. mesh: AbstractMesh;
  122075. /**
  122076. * 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)
  122077. */
  122078. slerpAmount: number;
  122079. private _bone1Quat;
  122080. private _bone1Mat;
  122081. private _bone2Ang;
  122082. private _bone1;
  122083. private _bone2;
  122084. private _bone1Length;
  122085. private _bone2Length;
  122086. private _maxAngle;
  122087. private _maxReach;
  122088. private _rightHandedSystem;
  122089. private _bendAxis;
  122090. private _slerping;
  122091. private _adjustRoll;
  122092. /**
  122093. * Gets or sets maximum allowed angle
  122094. */
  122095. get maxAngle(): number;
  122096. set maxAngle(value: number);
  122097. /**
  122098. * Creates a new BoneIKController
  122099. * @param mesh defines the mesh to control
  122100. * @param bone defines the bone to control
  122101. * @param options defines options to set up the controller
  122102. */
  122103. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122104. targetMesh?: AbstractMesh;
  122105. poleTargetMesh?: AbstractMesh;
  122106. poleTargetBone?: Bone;
  122107. poleTargetLocalOffset?: Vector3;
  122108. poleAngle?: number;
  122109. bendAxis?: Vector3;
  122110. maxAngle?: number;
  122111. slerpAmount?: number;
  122112. });
  122113. private _setMaxAngle;
  122114. /**
  122115. * Force the controller to update the bones
  122116. */
  122117. update(): void;
  122118. }
  122119. }
  122120. declare module BABYLON {
  122121. /**
  122122. * Class used to make a bone look toward a point in space
  122123. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122124. */
  122125. export class BoneLookController {
  122126. private static _tmpVecs;
  122127. private static _tmpQuat;
  122128. private static _tmpMats;
  122129. /**
  122130. * The target Vector3 that the bone will look at
  122131. */
  122132. target: Vector3;
  122133. /**
  122134. * The mesh that the bone is attached to
  122135. */
  122136. mesh: AbstractMesh;
  122137. /**
  122138. * The bone that will be looking to the target
  122139. */
  122140. bone: Bone;
  122141. /**
  122142. * The up axis of the coordinate system that is used when the bone is rotated
  122143. */
  122144. upAxis: Vector3;
  122145. /**
  122146. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122147. */
  122148. upAxisSpace: Space;
  122149. /**
  122150. * Used to make an adjustment to the yaw of the bone
  122151. */
  122152. adjustYaw: number;
  122153. /**
  122154. * Used to make an adjustment to the pitch of the bone
  122155. */
  122156. adjustPitch: number;
  122157. /**
  122158. * Used to make an adjustment to the roll of the bone
  122159. */
  122160. adjustRoll: number;
  122161. /**
  122162. * 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)
  122163. */
  122164. slerpAmount: number;
  122165. private _minYaw;
  122166. private _maxYaw;
  122167. private _minPitch;
  122168. private _maxPitch;
  122169. private _minYawSin;
  122170. private _minYawCos;
  122171. private _maxYawSin;
  122172. private _maxYawCos;
  122173. private _midYawConstraint;
  122174. private _minPitchTan;
  122175. private _maxPitchTan;
  122176. private _boneQuat;
  122177. private _slerping;
  122178. private _transformYawPitch;
  122179. private _transformYawPitchInv;
  122180. private _firstFrameSkipped;
  122181. private _yawRange;
  122182. private _fowardAxis;
  122183. /**
  122184. * Gets or sets the minimum yaw angle that the bone can look to
  122185. */
  122186. get minYaw(): number;
  122187. set minYaw(value: number);
  122188. /**
  122189. * Gets or sets the maximum yaw angle that the bone can look to
  122190. */
  122191. get maxYaw(): number;
  122192. set maxYaw(value: number);
  122193. /**
  122194. * Gets or sets the minimum pitch angle that the bone can look to
  122195. */
  122196. get minPitch(): number;
  122197. set minPitch(value: number);
  122198. /**
  122199. * Gets or sets the maximum pitch angle that the bone can look to
  122200. */
  122201. get maxPitch(): number;
  122202. set maxPitch(value: number);
  122203. /**
  122204. * Create a BoneLookController
  122205. * @param mesh the mesh that the bone belongs to
  122206. * @param bone the bone that will be looking to the target
  122207. * @param target the target Vector3 to look at
  122208. * @param options optional settings:
  122209. * * maxYaw: the maximum angle the bone will yaw to
  122210. * * minYaw: the minimum angle the bone will yaw to
  122211. * * maxPitch: the maximum angle the bone will pitch to
  122212. * * minPitch: the minimum angle the bone will yaw to
  122213. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122214. * * upAxis: the up axis of the coordinate system
  122215. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122216. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122217. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122218. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122219. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122220. * * adjustRoll: used to make an adjustment to the roll of the bone
  122221. **/
  122222. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122223. maxYaw?: number;
  122224. minYaw?: number;
  122225. maxPitch?: number;
  122226. minPitch?: number;
  122227. slerpAmount?: number;
  122228. upAxis?: Vector3;
  122229. upAxisSpace?: Space;
  122230. yawAxis?: Vector3;
  122231. pitchAxis?: Vector3;
  122232. adjustYaw?: number;
  122233. adjustPitch?: number;
  122234. adjustRoll?: number;
  122235. });
  122236. /**
  122237. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122238. */
  122239. update(): void;
  122240. private _getAngleDiff;
  122241. private _getAngleBetween;
  122242. private _isAngleBetween;
  122243. }
  122244. }
  122245. declare module BABYLON {
  122246. /**
  122247. * Manage the gamepad inputs to control an arc rotate camera.
  122248. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122249. */
  122250. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122251. /**
  122252. * Defines the camera the input is attached to.
  122253. */
  122254. camera: ArcRotateCamera;
  122255. /**
  122256. * Defines the gamepad the input is gathering event from.
  122257. */
  122258. gamepad: Nullable<Gamepad>;
  122259. /**
  122260. * Defines the gamepad rotation sensiblity.
  122261. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122262. */
  122263. gamepadRotationSensibility: number;
  122264. /**
  122265. * Defines the gamepad move sensiblity.
  122266. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122267. */
  122268. gamepadMoveSensibility: number;
  122269. private _yAxisScale;
  122270. /**
  122271. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122272. */
  122273. get invertYAxis(): boolean;
  122274. set invertYAxis(value: boolean);
  122275. private _onGamepadConnectedObserver;
  122276. private _onGamepadDisconnectedObserver;
  122277. /**
  122278. * Attach the input controls to a specific dom element to get the input from.
  122279. * @param element Defines the element the controls should be listened from
  122280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122281. */
  122282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122283. /**
  122284. * Detach the current controls from the specified dom element.
  122285. * @param element Defines the element to stop listening the inputs from
  122286. */
  122287. detachControl(element: Nullable<HTMLElement>): void;
  122288. /**
  122289. * Update the current camera state depending on the inputs that have been used this frame.
  122290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122291. */
  122292. checkInputs(): void;
  122293. /**
  122294. * Gets the class name of the current intput.
  122295. * @returns the class name
  122296. */
  122297. getClassName(): string;
  122298. /**
  122299. * Get the friendly name associated with the input class.
  122300. * @returns the input friendly name
  122301. */
  122302. getSimpleName(): string;
  122303. }
  122304. }
  122305. declare module BABYLON {
  122306. interface ArcRotateCameraInputsManager {
  122307. /**
  122308. * Add orientation input support to the input manager.
  122309. * @returns the current input manager
  122310. */
  122311. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122312. }
  122313. /**
  122314. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122315. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122316. */
  122317. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122318. /**
  122319. * Defines the camera the input is attached to.
  122320. */
  122321. camera: ArcRotateCamera;
  122322. /**
  122323. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122324. */
  122325. alphaCorrection: number;
  122326. /**
  122327. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122328. */
  122329. gammaCorrection: number;
  122330. private _alpha;
  122331. private _gamma;
  122332. private _dirty;
  122333. private _deviceOrientationHandler;
  122334. /**
  122335. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122336. */
  122337. constructor();
  122338. /**
  122339. * Attach the input controls to a specific dom element to get the input from.
  122340. * @param element Defines the element the controls should be listened from
  122341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122342. */
  122343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122344. /** @hidden */
  122345. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122346. /**
  122347. * Update the current camera state depending on the inputs that have been used this frame.
  122348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122349. */
  122350. checkInputs(): void;
  122351. /**
  122352. * Detach the current controls from the specified dom element.
  122353. * @param element Defines the element to stop listening the inputs from
  122354. */
  122355. detachControl(element: Nullable<HTMLElement>): void;
  122356. /**
  122357. * Gets the class name of the current intput.
  122358. * @returns the class name
  122359. */
  122360. getClassName(): string;
  122361. /**
  122362. * Get the friendly name associated with the input class.
  122363. * @returns the input friendly name
  122364. */
  122365. getSimpleName(): string;
  122366. }
  122367. }
  122368. declare module BABYLON {
  122369. /**
  122370. * Listen to mouse events to control the camera.
  122371. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122372. */
  122373. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122374. /**
  122375. * Defines the camera the input is attached to.
  122376. */
  122377. camera: FlyCamera;
  122378. /**
  122379. * Defines if touch is enabled. (Default is true.)
  122380. */
  122381. touchEnabled: boolean;
  122382. /**
  122383. * Defines the buttons associated with the input to handle camera rotation.
  122384. */
  122385. buttons: number[];
  122386. /**
  122387. * Assign buttons for Yaw control.
  122388. */
  122389. buttonsYaw: number[];
  122390. /**
  122391. * Assign buttons for Pitch control.
  122392. */
  122393. buttonsPitch: number[];
  122394. /**
  122395. * Assign buttons for Roll control.
  122396. */
  122397. buttonsRoll: number[];
  122398. /**
  122399. * Detect if any button is being pressed while mouse is moved.
  122400. * -1 = Mouse locked.
  122401. * 0 = Left button.
  122402. * 1 = Middle Button.
  122403. * 2 = Right Button.
  122404. */
  122405. activeButton: number;
  122406. /**
  122407. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122408. * Higher values reduce its sensitivity.
  122409. */
  122410. angularSensibility: number;
  122411. private _mousemoveCallback;
  122412. private _observer;
  122413. private _rollObserver;
  122414. private previousPosition;
  122415. private noPreventDefault;
  122416. private element;
  122417. /**
  122418. * Listen to mouse events to control the camera.
  122419. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122420. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122421. */
  122422. constructor(touchEnabled?: boolean);
  122423. /**
  122424. * Attach the mouse control to the HTML DOM element.
  122425. * @param element Defines the element that listens to the input events.
  122426. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  122427. */
  122428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122429. /**
  122430. * Detach the current controls from the specified dom element.
  122431. * @param element Defines the element to stop listening the inputs from
  122432. */
  122433. detachControl(element: Nullable<HTMLElement>): void;
  122434. /**
  122435. * Gets the class name of the current input.
  122436. * @returns the class name.
  122437. */
  122438. getClassName(): string;
  122439. /**
  122440. * Get the friendly name associated with the input class.
  122441. * @returns the input's friendly name.
  122442. */
  122443. getSimpleName(): string;
  122444. private _pointerInput;
  122445. private _onMouseMove;
  122446. /**
  122447. * Rotate camera by mouse offset.
  122448. */
  122449. private rotateCamera;
  122450. }
  122451. }
  122452. declare module BABYLON {
  122453. /**
  122454. * Default Inputs manager for the FlyCamera.
  122455. * It groups all the default supported inputs for ease of use.
  122456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122457. */
  122458. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  122459. /**
  122460. * Instantiates a new FlyCameraInputsManager.
  122461. * @param camera Defines the camera the inputs belong to.
  122462. */
  122463. constructor(camera: FlyCamera);
  122464. /**
  122465. * Add keyboard input support to the input manager.
  122466. * @returns the new FlyCameraKeyboardMoveInput().
  122467. */
  122468. addKeyboard(): FlyCameraInputsManager;
  122469. /**
  122470. * Add mouse input support to the input manager.
  122471. * @param touchEnabled Enable touch screen support.
  122472. * @returns the new FlyCameraMouseInput().
  122473. */
  122474. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  122475. }
  122476. }
  122477. declare module BABYLON {
  122478. /**
  122479. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122480. * such as in a 3D Space Shooter or a Flight Simulator.
  122481. */
  122482. export class FlyCamera extends TargetCamera {
  122483. /**
  122484. * Define the collision ellipsoid of the camera.
  122485. * This is helpful for simulating a camera body, like a player's body.
  122486. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122487. */
  122488. ellipsoid: Vector3;
  122489. /**
  122490. * Define an offset for the position of the ellipsoid around the camera.
  122491. * This can be helpful if the camera is attached away from the player's body center,
  122492. * such as at its head.
  122493. */
  122494. ellipsoidOffset: Vector3;
  122495. /**
  122496. * Enable or disable collisions of the camera with the rest of the scene objects.
  122497. */
  122498. checkCollisions: boolean;
  122499. /**
  122500. * Enable or disable gravity on the camera.
  122501. */
  122502. applyGravity: boolean;
  122503. /**
  122504. * Define the current direction the camera is moving to.
  122505. */
  122506. cameraDirection: Vector3;
  122507. /**
  122508. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  122509. * This overrides and empties cameraRotation.
  122510. */
  122511. rotationQuaternion: Quaternion;
  122512. /**
  122513. * Track Roll to maintain the wanted Rolling when looking around.
  122514. */
  122515. _trackRoll: number;
  122516. /**
  122517. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  122518. */
  122519. rollCorrect: number;
  122520. /**
  122521. * Mimic a banked turn, Rolling the camera when Yawing.
  122522. * It's recommended to use rollCorrect = 10 for faster banking correction.
  122523. */
  122524. bankedTurn: boolean;
  122525. /**
  122526. * Limit in radians for how much Roll banking will add. (Default: 90°)
  122527. */
  122528. bankedTurnLimit: number;
  122529. /**
  122530. * Value of 0 disables the banked Roll.
  122531. * Value of 1 is equal to the Yaw angle in radians.
  122532. */
  122533. bankedTurnMultiplier: number;
  122534. /**
  122535. * The inputs manager loads all the input sources, such as keyboard and mouse.
  122536. */
  122537. inputs: FlyCameraInputsManager;
  122538. /**
  122539. * Gets the input sensibility for mouse input.
  122540. * Higher values reduce sensitivity.
  122541. */
  122542. get angularSensibility(): number;
  122543. /**
  122544. * Sets the input sensibility for a mouse input.
  122545. * Higher values reduce sensitivity.
  122546. */
  122547. set angularSensibility(value: number);
  122548. /**
  122549. * Get the keys for camera movement forward.
  122550. */
  122551. get keysForward(): number[];
  122552. /**
  122553. * Set the keys for camera movement forward.
  122554. */
  122555. set keysForward(value: number[]);
  122556. /**
  122557. * Get the keys for camera movement backward.
  122558. */
  122559. get keysBackward(): number[];
  122560. set keysBackward(value: number[]);
  122561. /**
  122562. * Get the keys for camera movement up.
  122563. */
  122564. get keysUp(): number[];
  122565. /**
  122566. * Set the keys for camera movement up.
  122567. */
  122568. set keysUp(value: number[]);
  122569. /**
  122570. * Get the keys for camera movement down.
  122571. */
  122572. get keysDown(): number[];
  122573. /**
  122574. * Set the keys for camera movement down.
  122575. */
  122576. set keysDown(value: number[]);
  122577. /**
  122578. * Get the keys for camera movement left.
  122579. */
  122580. get keysLeft(): number[];
  122581. /**
  122582. * Set the keys for camera movement left.
  122583. */
  122584. set keysLeft(value: number[]);
  122585. /**
  122586. * Set the keys for camera movement right.
  122587. */
  122588. get keysRight(): number[];
  122589. /**
  122590. * Set the keys for camera movement right.
  122591. */
  122592. set keysRight(value: number[]);
  122593. /**
  122594. * Event raised when the camera collides with a mesh in the scene.
  122595. */
  122596. onCollide: (collidedMesh: AbstractMesh) => void;
  122597. private _collider;
  122598. private _needMoveForGravity;
  122599. private _oldPosition;
  122600. private _diffPosition;
  122601. private _newPosition;
  122602. /** @hidden */
  122603. _localDirection: Vector3;
  122604. /** @hidden */
  122605. _transformedDirection: Vector3;
  122606. /**
  122607. * Instantiates a FlyCamera.
  122608. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122609. * such as in a 3D Space Shooter or a Flight Simulator.
  122610. * @param name Define the name of the camera in the scene.
  122611. * @param position Define the starting position of the camera in the scene.
  122612. * @param scene Define the scene the camera belongs to.
  122613. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  122614. */
  122615. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122616. /**
  122617. * Attach a control to the HTML DOM element.
  122618. * @param element Defines the element that listens to the input events.
  122619. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  122620. */
  122621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122622. /**
  122623. * Detach a control from the HTML DOM element.
  122624. * The camera will stop reacting to that input.
  122625. * @param element Defines the element that listens to the input events.
  122626. */
  122627. detachControl(element: HTMLElement): void;
  122628. private _collisionMask;
  122629. /**
  122630. * Get the mask that the camera ignores in collision events.
  122631. */
  122632. get collisionMask(): number;
  122633. /**
  122634. * Set the mask that the camera ignores in collision events.
  122635. */
  122636. set collisionMask(mask: number);
  122637. /** @hidden */
  122638. _collideWithWorld(displacement: Vector3): void;
  122639. /** @hidden */
  122640. private _onCollisionPositionChange;
  122641. /** @hidden */
  122642. _checkInputs(): void;
  122643. /** @hidden */
  122644. _decideIfNeedsToMove(): boolean;
  122645. /** @hidden */
  122646. _updatePosition(): void;
  122647. /**
  122648. * Restore the Roll to its target value at the rate specified.
  122649. * @param rate - Higher means slower restoring.
  122650. * @hidden
  122651. */
  122652. restoreRoll(rate: number): void;
  122653. /**
  122654. * Destroy the camera and release the current resources held by it.
  122655. */
  122656. dispose(): void;
  122657. /**
  122658. * Get the current object class name.
  122659. * @returns the class name.
  122660. */
  122661. getClassName(): string;
  122662. }
  122663. }
  122664. declare module BABYLON {
  122665. /**
  122666. * Listen to keyboard events to control the camera.
  122667. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122668. */
  122669. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  122670. /**
  122671. * Defines the camera the input is attached to.
  122672. */
  122673. camera: FlyCamera;
  122674. /**
  122675. * The list of keyboard keys used to control the forward move of the camera.
  122676. */
  122677. keysForward: number[];
  122678. /**
  122679. * The list of keyboard keys used to control the backward move of the camera.
  122680. */
  122681. keysBackward: number[];
  122682. /**
  122683. * The list of keyboard keys used to control the forward move of the camera.
  122684. */
  122685. keysUp: number[];
  122686. /**
  122687. * The list of keyboard keys used to control the backward move of the camera.
  122688. */
  122689. keysDown: number[];
  122690. /**
  122691. * The list of keyboard keys used to control the right strafe move of the camera.
  122692. */
  122693. keysRight: number[];
  122694. /**
  122695. * The list of keyboard keys used to control the left strafe move of the camera.
  122696. */
  122697. keysLeft: number[];
  122698. private _keys;
  122699. private _onCanvasBlurObserver;
  122700. private _onKeyboardObserver;
  122701. private _engine;
  122702. private _scene;
  122703. /**
  122704. * Attach the input controls to a specific dom element to get the input from.
  122705. * @param element Defines the element the controls should be listened from
  122706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122707. */
  122708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122709. /**
  122710. * Detach the current controls from the specified dom element.
  122711. * @param element Defines the element to stop listening the inputs from
  122712. */
  122713. detachControl(element: Nullable<HTMLElement>): void;
  122714. /**
  122715. * Gets the class name of the current intput.
  122716. * @returns the class name
  122717. */
  122718. getClassName(): string;
  122719. /** @hidden */
  122720. _onLostFocus(e: FocusEvent): void;
  122721. /**
  122722. * Get the friendly name associated with the input class.
  122723. * @returns the input friendly name
  122724. */
  122725. getSimpleName(): string;
  122726. /**
  122727. * Update the current camera state depending on the inputs that have been used this frame.
  122728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122729. */
  122730. checkInputs(): void;
  122731. }
  122732. }
  122733. declare module BABYLON {
  122734. /**
  122735. * Manage the mouse wheel inputs to control a follow camera.
  122736. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122737. */
  122738. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  122739. /**
  122740. * Defines the camera the input is attached to.
  122741. */
  122742. camera: FollowCamera;
  122743. /**
  122744. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  122745. */
  122746. axisControlRadius: boolean;
  122747. /**
  122748. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  122749. */
  122750. axisControlHeight: boolean;
  122751. /**
  122752. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  122753. */
  122754. axisControlRotation: boolean;
  122755. /**
  122756. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  122757. * relation to mouseWheel events.
  122758. */
  122759. wheelPrecision: number;
  122760. /**
  122761. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122762. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122763. */
  122764. wheelDeltaPercentage: number;
  122765. private _wheel;
  122766. private _observer;
  122767. /**
  122768. * Attach the input controls to a specific dom element to get the input from.
  122769. * @param element Defines the element the controls should be listened from
  122770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122771. */
  122772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122773. /**
  122774. * Detach the current controls from the specified dom element.
  122775. * @param element Defines the element to stop listening the inputs from
  122776. */
  122777. detachControl(element: Nullable<HTMLElement>): void;
  122778. /**
  122779. * Gets the class name of the current intput.
  122780. * @returns the class name
  122781. */
  122782. getClassName(): string;
  122783. /**
  122784. * Get the friendly name associated with the input class.
  122785. * @returns the input friendly name
  122786. */
  122787. getSimpleName(): string;
  122788. }
  122789. }
  122790. declare module BABYLON {
  122791. /**
  122792. * Manage the pointers inputs to control an follow camera.
  122793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122794. */
  122795. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  122796. /**
  122797. * Defines the camera the input is attached to.
  122798. */
  122799. camera: FollowCamera;
  122800. /**
  122801. * Gets the class name of the current input.
  122802. * @returns the class name
  122803. */
  122804. getClassName(): string;
  122805. /**
  122806. * Defines the pointer angular sensibility along the X axis or how fast is
  122807. * the camera rotating.
  122808. * A negative number will reverse the axis direction.
  122809. */
  122810. angularSensibilityX: number;
  122811. /**
  122812. * Defines the pointer angular sensibility along the Y axis or how fast is
  122813. * the camera rotating.
  122814. * A negative number will reverse the axis direction.
  122815. */
  122816. angularSensibilityY: number;
  122817. /**
  122818. * Defines the pointer pinch precision or how fast is the camera zooming.
  122819. * A negative number will reverse the axis direction.
  122820. */
  122821. pinchPrecision: number;
  122822. /**
  122823. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122824. * from 0.
  122825. * It defines the percentage of current camera.radius to use as delta when
  122826. * pinch zoom is used.
  122827. */
  122828. pinchDeltaPercentage: number;
  122829. /**
  122830. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  122831. */
  122832. axisXControlRadius: boolean;
  122833. /**
  122834. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  122835. */
  122836. axisXControlHeight: boolean;
  122837. /**
  122838. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  122839. */
  122840. axisXControlRotation: boolean;
  122841. /**
  122842. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  122843. */
  122844. axisYControlRadius: boolean;
  122845. /**
  122846. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  122847. */
  122848. axisYControlHeight: boolean;
  122849. /**
  122850. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  122851. */
  122852. axisYControlRotation: boolean;
  122853. /**
  122854. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  122855. */
  122856. axisPinchControlRadius: boolean;
  122857. /**
  122858. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  122859. */
  122860. axisPinchControlHeight: boolean;
  122861. /**
  122862. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  122863. */
  122864. axisPinchControlRotation: boolean;
  122865. /**
  122866. * Log error messages if basic misconfiguration has occurred.
  122867. */
  122868. warningEnable: boolean;
  122869. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122870. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122871. private _warningCounter;
  122872. private _warning;
  122873. }
  122874. }
  122875. declare module BABYLON {
  122876. /**
  122877. * Default Inputs manager for the FollowCamera.
  122878. * It groups all the default supported inputs for ease of use.
  122879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122880. */
  122881. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  122882. /**
  122883. * Instantiates a new FollowCameraInputsManager.
  122884. * @param camera Defines the camera the inputs belong to
  122885. */
  122886. constructor(camera: FollowCamera);
  122887. /**
  122888. * Add keyboard input support to the input manager.
  122889. * @returns the current input manager
  122890. */
  122891. addKeyboard(): FollowCameraInputsManager;
  122892. /**
  122893. * Add mouse wheel input support to the input manager.
  122894. * @returns the current input manager
  122895. */
  122896. addMouseWheel(): FollowCameraInputsManager;
  122897. /**
  122898. * Add pointers input support to the input manager.
  122899. * @returns the current input manager
  122900. */
  122901. addPointers(): FollowCameraInputsManager;
  122902. /**
  122903. * Add orientation input support to the input manager.
  122904. * @returns the current input manager
  122905. */
  122906. addVRDeviceOrientation(): FollowCameraInputsManager;
  122907. }
  122908. }
  122909. declare module BABYLON {
  122910. /**
  122911. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  122912. * an arc rotate version arcFollowCamera are available.
  122913. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122914. */
  122915. export class FollowCamera extends TargetCamera {
  122916. /**
  122917. * Distance the follow camera should follow an object at
  122918. */
  122919. radius: number;
  122920. /**
  122921. * Minimum allowed distance of the camera to the axis of rotation
  122922. * (The camera can not get closer).
  122923. * This can help limiting how the Camera is able to move in the scene.
  122924. */
  122925. lowerRadiusLimit: Nullable<number>;
  122926. /**
  122927. * Maximum allowed distance of the camera to the axis of rotation
  122928. * (The camera can not get further).
  122929. * This can help limiting how the Camera is able to move in the scene.
  122930. */
  122931. upperRadiusLimit: Nullable<number>;
  122932. /**
  122933. * Define a rotation offset between the camera and the object it follows
  122934. */
  122935. rotationOffset: number;
  122936. /**
  122937. * Minimum allowed angle to camera position relative to target object.
  122938. * This can help limiting how the Camera is able to move in the scene.
  122939. */
  122940. lowerRotationOffsetLimit: Nullable<number>;
  122941. /**
  122942. * Maximum allowed angle to camera position relative to target object.
  122943. * This can help limiting how the Camera is able to move in the scene.
  122944. */
  122945. upperRotationOffsetLimit: Nullable<number>;
  122946. /**
  122947. * Define a height offset between the camera and the object it follows.
  122948. * It can help following an object from the top (like a car chaing a plane)
  122949. */
  122950. heightOffset: number;
  122951. /**
  122952. * Minimum allowed height of camera position relative to target object.
  122953. * This can help limiting how the Camera is able to move in the scene.
  122954. */
  122955. lowerHeightOffsetLimit: Nullable<number>;
  122956. /**
  122957. * Maximum allowed height of camera position relative to target object.
  122958. * This can help limiting how the Camera is able to move in the scene.
  122959. */
  122960. upperHeightOffsetLimit: Nullable<number>;
  122961. /**
  122962. * Define how fast the camera can accelerate to follow it s target.
  122963. */
  122964. cameraAcceleration: number;
  122965. /**
  122966. * Define the speed limit of the camera following an object.
  122967. */
  122968. maxCameraSpeed: number;
  122969. /**
  122970. * Define the target of the camera.
  122971. */
  122972. lockedTarget: Nullable<AbstractMesh>;
  122973. /**
  122974. * Defines the input associated with the camera.
  122975. */
  122976. inputs: FollowCameraInputsManager;
  122977. /**
  122978. * Instantiates the follow camera.
  122979. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122980. * @param name Define the name of the camera in the scene
  122981. * @param position Define the position of the camera
  122982. * @param scene Define the scene the camera belong to
  122983. * @param lockedTarget Define the target of the camera
  122984. */
  122985. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  122986. private _follow;
  122987. /**
  122988. * Attached controls to the current camera.
  122989. * @param element Defines the element the controls should be listened from
  122990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122991. */
  122992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122993. /**
  122994. * Detach the current controls from the camera.
  122995. * The camera will stop reacting to inputs.
  122996. * @param element Defines the element to stop listening the inputs from
  122997. */
  122998. detachControl(element: HTMLElement): void;
  122999. /** @hidden */
  123000. _checkInputs(): void;
  123001. private _checkLimits;
  123002. /**
  123003. * Gets the camera class name.
  123004. * @returns the class name
  123005. */
  123006. getClassName(): string;
  123007. }
  123008. /**
  123009. * Arc Rotate version of the follow camera.
  123010. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123011. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123012. */
  123013. export class ArcFollowCamera extends TargetCamera {
  123014. /** The longitudinal angle of the camera */
  123015. alpha: number;
  123016. /** The latitudinal angle of the camera */
  123017. beta: number;
  123018. /** The radius of the camera from its target */
  123019. radius: number;
  123020. /** Define the camera target (the mesh it should follow) */
  123021. target: Nullable<AbstractMesh>;
  123022. private _cartesianCoordinates;
  123023. /**
  123024. * Instantiates a new ArcFollowCamera
  123025. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123026. * @param name Define the name of the camera
  123027. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123028. * @param beta Define the rotation angle of the camera around the elevation axis
  123029. * @param radius Define the radius of the camera from its target point
  123030. * @param target Define the target of the camera
  123031. * @param scene Define the scene the camera belongs to
  123032. */
  123033. constructor(name: string,
  123034. /** The longitudinal angle of the camera */
  123035. alpha: number,
  123036. /** The latitudinal angle of the camera */
  123037. beta: number,
  123038. /** The radius of the camera from its target */
  123039. radius: number,
  123040. /** Define the camera target (the mesh it should follow) */
  123041. target: Nullable<AbstractMesh>, scene: Scene);
  123042. private _follow;
  123043. /** @hidden */
  123044. _checkInputs(): void;
  123045. /**
  123046. * Returns the class name of the object.
  123047. * It is mostly used internally for serialization purposes.
  123048. */
  123049. getClassName(): string;
  123050. }
  123051. }
  123052. declare module BABYLON {
  123053. /**
  123054. * Manage the keyboard inputs to control the movement of a follow camera.
  123055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123056. */
  123057. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123058. /**
  123059. * Defines the camera the input is attached to.
  123060. */
  123061. camera: FollowCamera;
  123062. /**
  123063. * Defines the list of key codes associated with the up action (increase heightOffset)
  123064. */
  123065. keysHeightOffsetIncr: number[];
  123066. /**
  123067. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123068. */
  123069. keysHeightOffsetDecr: number[];
  123070. /**
  123071. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123072. */
  123073. keysHeightOffsetModifierAlt: boolean;
  123074. /**
  123075. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123076. */
  123077. keysHeightOffsetModifierCtrl: boolean;
  123078. /**
  123079. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123080. */
  123081. keysHeightOffsetModifierShift: boolean;
  123082. /**
  123083. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123084. */
  123085. keysRotationOffsetIncr: number[];
  123086. /**
  123087. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123088. */
  123089. keysRotationOffsetDecr: number[];
  123090. /**
  123091. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123092. */
  123093. keysRotationOffsetModifierAlt: boolean;
  123094. /**
  123095. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123096. */
  123097. keysRotationOffsetModifierCtrl: boolean;
  123098. /**
  123099. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123100. */
  123101. keysRotationOffsetModifierShift: boolean;
  123102. /**
  123103. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123104. */
  123105. keysRadiusIncr: number[];
  123106. /**
  123107. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123108. */
  123109. keysRadiusDecr: number[];
  123110. /**
  123111. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123112. */
  123113. keysRadiusModifierAlt: boolean;
  123114. /**
  123115. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123116. */
  123117. keysRadiusModifierCtrl: boolean;
  123118. /**
  123119. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123120. */
  123121. keysRadiusModifierShift: boolean;
  123122. /**
  123123. * Defines the rate of change of heightOffset.
  123124. */
  123125. heightSensibility: number;
  123126. /**
  123127. * Defines the rate of change of rotationOffset.
  123128. */
  123129. rotationSensibility: number;
  123130. /**
  123131. * Defines the rate of change of radius.
  123132. */
  123133. radiusSensibility: number;
  123134. private _keys;
  123135. private _ctrlPressed;
  123136. private _altPressed;
  123137. private _shiftPressed;
  123138. private _onCanvasBlurObserver;
  123139. private _onKeyboardObserver;
  123140. private _engine;
  123141. private _scene;
  123142. /**
  123143. * Attach the input controls to a specific dom element to get the input from.
  123144. * @param element Defines the element the controls should be listened from
  123145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123146. */
  123147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123148. /**
  123149. * Detach the current controls from the specified dom element.
  123150. * @param element Defines the element to stop listening the inputs from
  123151. */
  123152. detachControl(element: Nullable<HTMLElement>): void;
  123153. /**
  123154. * Update the current camera state depending on the inputs that have been used this frame.
  123155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123156. */
  123157. checkInputs(): void;
  123158. /**
  123159. * Gets the class name of the current input.
  123160. * @returns the class name
  123161. */
  123162. getClassName(): string;
  123163. /**
  123164. * Get the friendly name associated with the input class.
  123165. * @returns the input friendly name
  123166. */
  123167. getSimpleName(): string;
  123168. /**
  123169. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123170. * allow modification of the heightOffset value.
  123171. */
  123172. private _modifierHeightOffset;
  123173. /**
  123174. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123175. * allow modification of the rotationOffset value.
  123176. */
  123177. private _modifierRotationOffset;
  123178. /**
  123179. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123180. * allow modification of the radius value.
  123181. */
  123182. private _modifierRadius;
  123183. }
  123184. }
  123185. declare module BABYLON {
  123186. interface FreeCameraInputsManager {
  123187. /**
  123188. * @hidden
  123189. */
  123190. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123191. /**
  123192. * Add orientation input support to the input manager.
  123193. * @returns the current input manager
  123194. */
  123195. addDeviceOrientation(): FreeCameraInputsManager;
  123196. }
  123197. /**
  123198. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123199. * Screen rotation is taken into account.
  123200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123201. */
  123202. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123203. private _camera;
  123204. private _screenOrientationAngle;
  123205. private _constantTranform;
  123206. private _screenQuaternion;
  123207. private _alpha;
  123208. private _beta;
  123209. private _gamma;
  123210. /**
  123211. * Can be used to detect if a device orientation sensor is available on a device
  123212. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123213. * @returns a promise that will resolve on orientation change
  123214. */
  123215. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123216. /**
  123217. * @hidden
  123218. */
  123219. _onDeviceOrientationChangedObservable: Observable<void>;
  123220. /**
  123221. * Instantiates a new input
  123222. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123223. */
  123224. constructor();
  123225. /**
  123226. * Define the camera controlled by the input.
  123227. */
  123228. get camera(): FreeCamera;
  123229. set camera(camera: FreeCamera);
  123230. /**
  123231. * Attach the input controls to a specific dom element to get the input from.
  123232. * @param element Defines the element the controls should be listened from
  123233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123234. */
  123235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123236. private _orientationChanged;
  123237. private _deviceOrientation;
  123238. /**
  123239. * Detach the current controls from the specified dom element.
  123240. * @param element Defines the element to stop listening the inputs from
  123241. */
  123242. detachControl(element: Nullable<HTMLElement>): void;
  123243. /**
  123244. * Update the current camera state depending on the inputs that have been used this frame.
  123245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123246. */
  123247. checkInputs(): void;
  123248. /**
  123249. * Gets the class name of the current intput.
  123250. * @returns the class name
  123251. */
  123252. getClassName(): string;
  123253. /**
  123254. * Get the friendly name associated with the input class.
  123255. * @returns the input friendly name
  123256. */
  123257. getSimpleName(): string;
  123258. }
  123259. }
  123260. declare module BABYLON {
  123261. /**
  123262. * Manage the gamepad inputs to control a free camera.
  123263. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123264. */
  123265. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123266. /**
  123267. * Define the camera the input is attached to.
  123268. */
  123269. camera: FreeCamera;
  123270. /**
  123271. * Define the Gamepad controlling the input
  123272. */
  123273. gamepad: Nullable<Gamepad>;
  123274. /**
  123275. * Defines the gamepad rotation sensiblity.
  123276. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123277. */
  123278. gamepadAngularSensibility: number;
  123279. /**
  123280. * Defines the gamepad move sensiblity.
  123281. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123282. */
  123283. gamepadMoveSensibility: number;
  123284. private _yAxisScale;
  123285. /**
  123286. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123287. */
  123288. get invertYAxis(): boolean;
  123289. set invertYAxis(value: boolean);
  123290. private _onGamepadConnectedObserver;
  123291. private _onGamepadDisconnectedObserver;
  123292. private _cameraTransform;
  123293. private _deltaTransform;
  123294. private _vector3;
  123295. private _vector2;
  123296. /**
  123297. * Attach the input controls to a specific dom element to get the input from.
  123298. * @param element Defines the element the controls should be listened from
  123299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123300. */
  123301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123302. /**
  123303. * Detach the current controls from the specified dom element.
  123304. * @param element Defines the element to stop listening the inputs from
  123305. */
  123306. detachControl(element: Nullable<HTMLElement>): void;
  123307. /**
  123308. * Update the current camera state depending on the inputs that have been used this frame.
  123309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123310. */
  123311. checkInputs(): void;
  123312. /**
  123313. * Gets the class name of the current intput.
  123314. * @returns the class name
  123315. */
  123316. getClassName(): string;
  123317. /**
  123318. * Get the friendly name associated with the input class.
  123319. * @returns the input friendly name
  123320. */
  123321. getSimpleName(): string;
  123322. }
  123323. }
  123324. declare module BABYLON {
  123325. /**
  123326. * Defines the potential axis of a Joystick
  123327. */
  123328. export enum JoystickAxis {
  123329. /** X axis */
  123330. X = 0,
  123331. /** Y axis */
  123332. Y = 1,
  123333. /** Z axis */
  123334. Z = 2
  123335. }
  123336. /**
  123337. * Represents the different customization options available
  123338. * for VirtualJoystick
  123339. */
  123340. interface VirtualJoystickCustomizations {
  123341. /**
  123342. * Size of the joystick's puck
  123343. */
  123344. puckSize: number;
  123345. /**
  123346. * Size of the joystick's container
  123347. */
  123348. containerSize: number;
  123349. /**
  123350. * Color of the joystick && puck
  123351. */
  123352. color: string;
  123353. /**
  123354. * Image URL for the joystick's puck
  123355. */
  123356. puckImage?: string;
  123357. /**
  123358. * Image URL for the joystick's container
  123359. */
  123360. containerImage?: string;
  123361. /**
  123362. * Defines the unmoving position of the joystick container
  123363. */
  123364. position?: {
  123365. x: number;
  123366. y: number;
  123367. };
  123368. /**
  123369. * Defines whether or not the joystick container is always visible
  123370. */
  123371. alwaysVisible: boolean;
  123372. /**
  123373. * Defines whether or not to limit the movement of the puck to the joystick's container
  123374. */
  123375. limitToContainer: boolean;
  123376. }
  123377. /**
  123378. * Class used to define virtual joystick (used in touch mode)
  123379. */
  123380. export class VirtualJoystick {
  123381. /**
  123382. * Gets or sets a boolean indicating that left and right values must be inverted
  123383. */
  123384. reverseLeftRight: boolean;
  123385. /**
  123386. * Gets or sets a boolean indicating that up and down values must be inverted
  123387. */
  123388. reverseUpDown: boolean;
  123389. /**
  123390. * Gets the offset value for the position (ie. the change of the position value)
  123391. */
  123392. deltaPosition: Vector3;
  123393. /**
  123394. * Gets a boolean indicating if the virtual joystick was pressed
  123395. */
  123396. pressed: boolean;
  123397. /**
  123398. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123399. */
  123400. static Canvas: Nullable<HTMLCanvasElement>;
  123401. /**
  123402. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123403. */
  123404. limitToContainer: boolean;
  123405. private static _globalJoystickIndex;
  123406. private static _alwaysVisibleSticks;
  123407. private static vjCanvasContext;
  123408. private static vjCanvasWidth;
  123409. private static vjCanvasHeight;
  123410. private static halfWidth;
  123411. private static _GetDefaultOptions;
  123412. private _action;
  123413. private _axisTargetedByLeftAndRight;
  123414. private _axisTargetedByUpAndDown;
  123415. private _joystickSensibility;
  123416. private _inversedSensibility;
  123417. private _joystickPointerID;
  123418. private _joystickColor;
  123419. private _joystickPointerPos;
  123420. private _joystickPreviousPointerPos;
  123421. private _joystickPointerStartPos;
  123422. private _deltaJoystickVector;
  123423. private _leftJoystick;
  123424. private _touches;
  123425. private _joystickPosition;
  123426. private _alwaysVisible;
  123427. private _puckImage;
  123428. private _containerImage;
  123429. private _joystickPuckSize;
  123430. private _joystickContainerSize;
  123431. private _clearPuckSize;
  123432. private _clearContainerSize;
  123433. private _clearPuckSizeOffset;
  123434. private _clearContainerSizeOffset;
  123435. private _onPointerDownHandlerRef;
  123436. private _onPointerMoveHandlerRef;
  123437. private _onPointerUpHandlerRef;
  123438. private _onResize;
  123439. /**
  123440. * Creates a new virtual joystick
  123441. * @param leftJoystick defines that the joystick is for left hand (false by default)
  123442. * @param customizations Defines the options we want to customize the VirtualJoystick
  123443. */
  123444. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  123445. /**
  123446. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  123447. * @param newJoystickSensibility defines the new sensibility
  123448. */
  123449. setJoystickSensibility(newJoystickSensibility: number): void;
  123450. private _onPointerDown;
  123451. private _onPointerMove;
  123452. private _onPointerUp;
  123453. /**
  123454. * Change the color of the virtual joystick
  123455. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  123456. */
  123457. setJoystickColor(newColor: string): void;
  123458. /**
  123459. * Size of the joystick's container
  123460. */
  123461. set containerSize(newSize: number);
  123462. get containerSize(): number;
  123463. /**
  123464. * Size of the joystick's puck
  123465. */
  123466. set puckSize(newSize: number);
  123467. get puckSize(): number;
  123468. /**
  123469. * Clears the set position of the joystick
  123470. */
  123471. clearPosition(): void;
  123472. /**
  123473. * Defines whether or not the joystick container is always visible
  123474. */
  123475. set alwaysVisible(value: boolean);
  123476. get alwaysVisible(): boolean;
  123477. /**
  123478. * Sets the constant position of the Joystick container
  123479. * @param x X axis coordinate
  123480. * @param y Y axis coordinate
  123481. */
  123482. setPosition(x: number, y: number): void;
  123483. /**
  123484. * Defines a callback to call when the joystick is touched
  123485. * @param action defines the callback
  123486. */
  123487. setActionOnTouch(action: () => any): void;
  123488. /**
  123489. * Defines which axis you'd like to control for left & right
  123490. * @param axis defines the axis to use
  123491. */
  123492. setAxisForLeftRight(axis: JoystickAxis): void;
  123493. /**
  123494. * Defines which axis you'd like to control for up & down
  123495. * @param axis defines the axis to use
  123496. */
  123497. setAxisForUpDown(axis: JoystickAxis): void;
  123498. /**
  123499. * Clears the canvas from the previous puck / container draw
  123500. */
  123501. private _clearPreviousDraw;
  123502. /**
  123503. * Loads `urlPath` to be used for the container's image
  123504. * @param urlPath defines the urlPath of an image to use
  123505. */
  123506. setContainerImage(urlPath: string): void;
  123507. /**
  123508. * Loads `urlPath` to be used for the puck's image
  123509. * @param urlPath defines the urlPath of an image to use
  123510. */
  123511. setPuckImage(urlPath: string): void;
  123512. /**
  123513. * Draws the Virtual Joystick's container
  123514. */
  123515. private _drawContainer;
  123516. /**
  123517. * Draws the Virtual Joystick's puck
  123518. */
  123519. private _drawPuck;
  123520. private _drawVirtualJoystick;
  123521. /**
  123522. * Release internal HTML canvas
  123523. */
  123524. releaseCanvas(): void;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. interface FreeCameraInputsManager {
  123529. /**
  123530. * Add virtual joystick input support to the input manager.
  123531. * @returns the current input manager
  123532. */
  123533. addVirtualJoystick(): FreeCameraInputsManager;
  123534. }
  123535. /**
  123536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  123537. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123538. */
  123539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  123540. /**
  123541. * Defines the camera the input is attached to.
  123542. */
  123543. camera: FreeCamera;
  123544. private _leftjoystick;
  123545. private _rightjoystick;
  123546. /**
  123547. * Gets the left stick of the virtual joystick.
  123548. * @returns The virtual Joystick
  123549. */
  123550. getLeftJoystick(): VirtualJoystick;
  123551. /**
  123552. * Gets the right stick of the virtual joystick.
  123553. * @returns The virtual Joystick
  123554. */
  123555. getRightJoystick(): VirtualJoystick;
  123556. /**
  123557. * Update the current camera state depending on the inputs that have been used this frame.
  123558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123559. */
  123560. checkInputs(): void;
  123561. /**
  123562. * Attach the input controls to a specific dom element to get the input from.
  123563. * @param element Defines the element the controls should be listened from
  123564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123565. */
  123566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123567. /**
  123568. * Detach the current controls from the specified dom element.
  123569. * @param element Defines the element to stop listening the inputs from
  123570. */
  123571. detachControl(element: Nullable<HTMLElement>): void;
  123572. /**
  123573. * Gets the class name of the current intput.
  123574. * @returns the class name
  123575. */
  123576. getClassName(): string;
  123577. /**
  123578. * Get the friendly name associated with the input class.
  123579. * @returns the input friendly name
  123580. */
  123581. getSimpleName(): string;
  123582. }
  123583. }
  123584. declare module BABYLON {
  123585. /**
  123586. * This represents a FPS type of camera controlled by touch.
  123587. * This is like a universal camera minus the Gamepad controls.
  123588. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123589. */
  123590. export class TouchCamera extends FreeCamera {
  123591. /**
  123592. * Defines the touch sensibility for rotation.
  123593. * The higher the faster.
  123594. */
  123595. get touchAngularSensibility(): number;
  123596. set touchAngularSensibility(value: number);
  123597. /**
  123598. * Defines the touch sensibility for move.
  123599. * The higher the faster.
  123600. */
  123601. get touchMoveSensibility(): number;
  123602. set touchMoveSensibility(value: number);
  123603. /**
  123604. * Instantiates a new touch camera.
  123605. * This represents a FPS type of camera controlled by touch.
  123606. * This is like a universal camera minus the Gamepad controls.
  123607. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123608. * @param name Define the name of the camera in the scene
  123609. * @param position Define the start position of the camera in the scene
  123610. * @param scene Define the scene the camera belongs to
  123611. */
  123612. constructor(name: string, position: Vector3, scene: Scene);
  123613. /**
  123614. * Gets the current object class name.
  123615. * @return the class name
  123616. */
  123617. getClassName(): string;
  123618. /** @hidden */
  123619. _setupInputs(): void;
  123620. }
  123621. }
  123622. declare module BABYLON {
  123623. /**
  123624. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  123625. * being tilted forward or back and left or right.
  123626. */
  123627. export class DeviceOrientationCamera extends FreeCamera {
  123628. private _initialQuaternion;
  123629. private _quaternionCache;
  123630. private _tmpDragQuaternion;
  123631. private _disablePointerInputWhenUsingDeviceOrientation;
  123632. /**
  123633. * Creates a new device orientation camera
  123634. * @param name The name of the camera
  123635. * @param position The start position camera
  123636. * @param scene The scene the camera belongs to
  123637. */
  123638. constructor(name: string, position: Vector3, scene: Scene);
  123639. /**
  123640. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  123641. */
  123642. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  123643. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  123644. private _dragFactor;
  123645. /**
  123646. * Enabled turning on the y axis when the orientation sensor is active
  123647. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  123648. */
  123649. enableHorizontalDragging(dragFactor?: number): void;
  123650. /**
  123651. * Gets the current instance class name ("DeviceOrientationCamera").
  123652. * This helps avoiding instanceof at run time.
  123653. * @returns the class name
  123654. */
  123655. getClassName(): string;
  123656. /**
  123657. * @hidden
  123658. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  123659. */
  123660. _checkInputs(): void;
  123661. /**
  123662. * Reset the camera to its default orientation on the specified axis only.
  123663. * @param axis The axis to reset
  123664. */
  123665. resetToCurrentRotation(axis?: Axis): void;
  123666. }
  123667. }
  123668. declare module BABYLON {
  123669. /**
  123670. * Defines supported buttons for XBox360 compatible gamepads
  123671. */
  123672. export enum Xbox360Button {
  123673. /** A */
  123674. A = 0,
  123675. /** B */
  123676. B = 1,
  123677. /** X */
  123678. X = 2,
  123679. /** Y */
  123680. Y = 3,
  123681. /** Left button */
  123682. LB = 4,
  123683. /** Right button */
  123684. RB = 5,
  123685. /** Back */
  123686. Back = 8,
  123687. /** Start */
  123688. Start = 9,
  123689. /** Left stick */
  123690. LeftStick = 10,
  123691. /** Right stick */
  123692. RightStick = 11
  123693. }
  123694. /** Defines values for XBox360 DPad */
  123695. export enum Xbox360Dpad {
  123696. /** Up */
  123697. Up = 12,
  123698. /** Down */
  123699. Down = 13,
  123700. /** Left */
  123701. Left = 14,
  123702. /** Right */
  123703. Right = 15
  123704. }
  123705. /**
  123706. * Defines a XBox360 gamepad
  123707. */
  123708. export class Xbox360Pad extends Gamepad {
  123709. private _leftTrigger;
  123710. private _rightTrigger;
  123711. private _onlefttriggerchanged;
  123712. private _onrighttriggerchanged;
  123713. private _onbuttondown;
  123714. private _onbuttonup;
  123715. private _ondpaddown;
  123716. private _ondpadup;
  123717. /** Observable raised when a button is pressed */
  123718. onButtonDownObservable: Observable<Xbox360Button>;
  123719. /** Observable raised when a button is released */
  123720. onButtonUpObservable: Observable<Xbox360Button>;
  123721. /** Observable raised when a pad is pressed */
  123722. onPadDownObservable: Observable<Xbox360Dpad>;
  123723. /** Observable raised when a pad is released */
  123724. onPadUpObservable: Observable<Xbox360Dpad>;
  123725. private _buttonA;
  123726. private _buttonB;
  123727. private _buttonX;
  123728. private _buttonY;
  123729. private _buttonBack;
  123730. private _buttonStart;
  123731. private _buttonLB;
  123732. private _buttonRB;
  123733. private _buttonLeftStick;
  123734. private _buttonRightStick;
  123735. private _dPadUp;
  123736. private _dPadDown;
  123737. private _dPadLeft;
  123738. private _dPadRight;
  123739. private _isXboxOnePad;
  123740. /**
  123741. * Creates a new XBox360 gamepad object
  123742. * @param id defines the id of this gamepad
  123743. * @param index defines its index
  123744. * @param gamepad defines the internal HTML gamepad object
  123745. * @param xboxOne defines if it is a XBox One gamepad
  123746. */
  123747. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  123748. /**
  123749. * Defines the callback to call when left trigger is pressed
  123750. * @param callback defines the callback to use
  123751. */
  123752. onlefttriggerchanged(callback: (value: number) => void): void;
  123753. /**
  123754. * Defines the callback to call when right trigger is pressed
  123755. * @param callback defines the callback to use
  123756. */
  123757. onrighttriggerchanged(callback: (value: number) => void): void;
  123758. /**
  123759. * Gets the left trigger value
  123760. */
  123761. get leftTrigger(): number;
  123762. /**
  123763. * Sets the left trigger value
  123764. */
  123765. set leftTrigger(newValue: number);
  123766. /**
  123767. * Gets the right trigger value
  123768. */
  123769. get rightTrigger(): number;
  123770. /**
  123771. * Sets the right trigger value
  123772. */
  123773. set rightTrigger(newValue: number);
  123774. /**
  123775. * Defines the callback to call when a button is pressed
  123776. * @param callback defines the callback to use
  123777. */
  123778. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  123779. /**
  123780. * Defines the callback to call when a button is released
  123781. * @param callback defines the callback to use
  123782. */
  123783. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  123784. /**
  123785. * Defines the callback to call when a pad is pressed
  123786. * @param callback defines the callback to use
  123787. */
  123788. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  123789. /**
  123790. * Defines the callback to call when a pad is released
  123791. * @param callback defines the callback to use
  123792. */
  123793. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  123794. private _setButtonValue;
  123795. private _setDPadValue;
  123796. /**
  123797. * Gets the value of the `A` button
  123798. */
  123799. get buttonA(): number;
  123800. /**
  123801. * Sets the value of the `A` button
  123802. */
  123803. set buttonA(value: number);
  123804. /**
  123805. * Gets the value of the `B` button
  123806. */
  123807. get buttonB(): number;
  123808. /**
  123809. * Sets the value of the `B` button
  123810. */
  123811. set buttonB(value: number);
  123812. /**
  123813. * Gets the value of the `X` button
  123814. */
  123815. get buttonX(): number;
  123816. /**
  123817. * Sets the value of the `X` button
  123818. */
  123819. set buttonX(value: number);
  123820. /**
  123821. * Gets the value of the `Y` button
  123822. */
  123823. get buttonY(): number;
  123824. /**
  123825. * Sets the value of the `Y` button
  123826. */
  123827. set buttonY(value: number);
  123828. /**
  123829. * Gets the value of the `Start` button
  123830. */
  123831. get buttonStart(): number;
  123832. /**
  123833. * Sets the value of the `Start` button
  123834. */
  123835. set buttonStart(value: number);
  123836. /**
  123837. * Gets the value of the `Back` button
  123838. */
  123839. get buttonBack(): number;
  123840. /**
  123841. * Sets the value of the `Back` button
  123842. */
  123843. set buttonBack(value: number);
  123844. /**
  123845. * Gets the value of the `Left` button
  123846. */
  123847. get buttonLB(): number;
  123848. /**
  123849. * Sets the value of the `Left` button
  123850. */
  123851. set buttonLB(value: number);
  123852. /**
  123853. * Gets the value of the `Right` button
  123854. */
  123855. get buttonRB(): number;
  123856. /**
  123857. * Sets the value of the `Right` button
  123858. */
  123859. set buttonRB(value: number);
  123860. /**
  123861. * Gets the value of the Left joystick
  123862. */
  123863. get buttonLeftStick(): number;
  123864. /**
  123865. * Sets the value of the Left joystick
  123866. */
  123867. set buttonLeftStick(value: number);
  123868. /**
  123869. * Gets the value of the Right joystick
  123870. */
  123871. get buttonRightStick(): number;
  123872. /**
  123873. * Sets the value of the Right joystick
  123874. */
  123875. set buttonRightStick(value: number);
  123876. /**
  123877. * Gets the value of D-pad up
  123878. */
  123879. get dPadUp(): number;
  123880. /**
  123881. * Sets the value of D-pad up
  123882. */
  123883. set dPadUp(value: number);
  123884. /**
  123885. * Gets the value of D-pad down
  123886. */
  123887. get dPadDown(): number;
  123888. /**
  123889. * Sets the value of D-pad down
  123890. */
  123891. set dPadDown(value: number);
  123892. /**
  123893. * Gets the value of D-pad left
  123894. */
  123895. get dPadLeft(): number;
  123896. /**
  123897. * Sets the value of D-pad left
  123898. */
  123899. set dPadLeft(value: number);
  123900. /**
  123901. * Gets the value of D-pad right
  123902. */
  123903. get dPadRight(): number;
  123904. /**
  123905. * Sets the value of D-pad right
  123906. */
  123907. set dPadRight(value: number);
  123908. /**
  123909. * Force the gamepad to synchronize with device values
  123910. */
  123911. update(): void;
  123912. /**
  123913. * Disposes the gamepad
  123914. */
  123915. dispose(): void;
  123916. }
  123917. }
  123918. declare module BABYLON {
  123919. /**
  123920. * Defines supported buttons for DualShock compatible gamepads
  123921. */
  123922. export enum DualShockButton {
  123923. /** Cross */
  123924. Cross = 0,
  123925. /** Circle */
  123926. Circle = 1,
  123927. /** Square */
  123928. Square = 2,
  123929. /** Triangle */
  123930. Triangle = 3,
  123931. /** L1 */
  123932. L1 = 4,
  123933. /** R1 */
  123934. R1 = 5,
  123935. /** Share */
  123936. Share = 8,
  123937. /** Options */
  123938. Options = 9,
  123939. /** Left stick */
  123940. LeftStick = 10,
  123941. /** Right stick */
  123942. RightStick = 11
  123943. }
  123944. /** Defines values for DualShock DPad */
  123945. export enum DualShockDpad {
  123946. /** Up */
  123947. Up = 12,
  123948. /** Down */
  123949. Down = 13,
  123950. /** Left */
  123951. Left = 14,
  123952. /** Right */
  123953. Right = 15
  123954. }
  123955. /**
  123956. * Defines a DualShock gamepad
  123957. */
  123958. export class DualShockPad extends Gamepad {
  123959. private _leftTrigger;
  123960. private _rightTrigger;
  123961. private _onlefttriggerchanged;
  123962. private _onrighttriggerchanged;
  123963. private _onbuttondown;
  123964. private _onbuttonup;
  123965. private _ondpaddown;
  123966. private _ondpadup;
  123967. /** Observable raised when a button is pressed */
  123968. onButtonDownObservable: Observable<DualShockButton>;
  123969. /** Observable raised when a button is released */
  123970. onButtonUpObservable: Observable<DualShockButton>;
  123971. /** Observable raised when a pad is pressed */
  123972. onPadDownObservable: Observable<DualShockDpad>;
  123973. /** Observable raised when a pad is released */
  123974. onPadUpObservable: Observable<DualShockDpad>;
  123975. private _buttonCross;
  123976. private _buttonCircle;
  123977. private _buttonSquare;
  123978. private _buttonTriangle;
  123979. private _buttonShare;
  123980. private _buttonOptions;
  123981. private _buttonL1;
  123982. private _buttonR1;
  123983. private _buttonLeftStick;
  123984. private _buttonRightStick;
  123985. private _dPadUp;
  123986. private _dPadDown;
  123987. private _dPadLeft;
  123988. private _dPadRight;
  123989. /**
  123990. * Creates a new DualShock gamepad object
  123991. * @param id defines the id of this gamepad
  123992. * @param index defines its index
  123993. * @param gamepad defines the internal HTML gamepad object
  123994. */
  123995. constructor(id: string, index: number, gamepad: any);
  123996. /**
  123997. * Defines the callback to call when left trigger is pressed
  123998. * @param callback defines the callback to use
  123999. */
  124000. onlefttriggerchanged(callback: (value: number) => void): void;
  124001. /**
  124002. * Defines the callback to call when right trigger is pressed
  124003. * @param callback defines the callback to use
  124004. */
  124005. onrighttriggerchanged(callback: (value: number) => void): void;
  124006. /**
  124007. * Gets the left trigger value
  124008. */
  124009. get leftTrigger(): number;
  124010. /**
  124011. * Sets the left trigger value
  124012. */
  124013. set leftTrigger(newValue: number);
  124014. /**
  124015. * Gets the right trigger value
  124016. */
  124017. get rightTrigger(): number;
  124018. /**
  124019. * Sets the right trigger value
  124020. */
  124021. set rightTrigger(newValue: number);
  124022. /**
  124023. * Defines the callback to call when a button is pressed
  124024. * @param callback defines the callback to use
  124025. */
  124026. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124027. /**
  124028. * Defines the callback to call when a button is released
  124029. * @param callback defines the callback to use
  124030. */
  124031. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124032. /**
  124033. * Defines the callback to call when a pad is pressed
  124034. * @param callback defines the callback to use
  124035. */
  124036. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124037. /**
  124038. * Defines the callback to call when a pad is released
  124039. * @param callback defines the callback to use
  124040. */
  124041. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124042. private _setButtonValue;
  124043. private _setDPadValue;
  124044. /**
  124045. * Gets the value of the `Cross` button
  124046. */
  124047. get buttonCross(): number;
  124048. /**
  124049. * Sets the value of the `Cross` button
  124050. */
  124051. set buttonCross(value: number);
  124052. /**
  124053. * Gets the value of the `Circle` button
  124054. */
  124055. get buttonCircle(): number;
  124056. /**
  124057. * Sets the value of the `Circle` button
  124058. */
  124059. set buttonCircle(value: number);
  124060. /**
  124061. * Gets the value of the `Square` button
  124062. */
  124063. get buttonSquare(): number;
  124064. /**
  124065. * Sets the value of the `Square` button
  124066. */
  124067. set buttonSquare(value: number);
  124068. /**
  124069. * Gets the value of the `Triangle` button
  124070. */
  124071. get buttonTriangle(): number;
  124072. /**
  124073. * Sets the value of the `Triangle` button
  124074. */
  124075. set buttonTriangle(value: number);
  124076. /**
  124077. * Gets the value of the `Options` button
  124078. */
  124079. get buttonOptions(): number;
  124080. /**
  124081. * Sets the value of the `Options` button
  124082. */
  124083. set buttonOptions(value: number);
  124084. /**
  124085. * Gets the value of the `Share` button
  124086. */
  124087. get buttonShare(): number;
  124088. /**
  124089. * Sets the value of the `Share` button
  124090. */
  124091. set buttonShare(value: number);
  124092. /**
  124093. * Gets the value of the `L1` button
  124094. */
  124095. get buttonL1(): number;
  124096. /**
  124097. * Sets the value of the `L1` button
  124098. */
  124099. set buttonL1(value: number);
  124100. /**
  124101. * Gets the value of the `R1` button
  124102. */
  124103. get buttonR1(): number;
  124104. /**
  124105. * Sets the value of the `R1` button
  124106. */
  124107. set buttonR1(value: number);
  124108. /**
  124109. * Gets the value of the Left joystick
  124110. */
  124111. get buttonLeftStick(): number;
  124112. /**
  124113. * Sets the value of the Left joystick
  124114. */
  124115. set buttonLeftStick(value: number);
  124116. /**
  124117. * Gets the value of the Right joystick
  124118. */
  124119. get buttonRightStick(): number;
  124120. /**
  124121. * Sets the value of the Right joystick
  124122. */
  124123. set buttonRightStick(value: number);
  124124. /**
  124125. * Gets the value of D-pad up
  124126. */
  124127. get dPadUp(): number;
  124128. /**
  124129. * Sets the value of D-pad up
  124130. */
  124131. set dPadUp(value: number);
  124132. /**
  124133. * Gets the value of D-pad down
  124134. */
  124135. get dPadDown(): number;
  124136. /**
  124137. * Sets the value of D-pad down
  124138. */
  124139. set dPadDown(value: number);
  124140. /**
  124141. * Gets the value of D-pad left
  124142. */
  124143. get dPadLeft(): number;
  124144. /**
  124145. * Sets the value of D-pad left
  124146. */
  124147. set dPadLeft(value: number);
  124148. /**
  124149. * Gets the value of D-pad right
  124150. */
  124151. get dPadRight(): number;
  124152. /**
  124153. * Sets the value of D-pad right
  124154. */
  124155. set dPadRight(value: number);
  124156. /**
  124157. * Force the gamepad to synchronize with device values
  124158. */
  124159. update(): void;
  124160. /**
  124161. * Disposes the gamepad
  124162. */
  124163. dispose(): void;
  124164. }
  124165. }
  124166. declare module BABYLON {
  124167. /**
  124168. * Manager for handling gamepads
  124169. */
  124170. export class GamepadManager {
  124171. private _scene?;
  124172. private _babylonGamepads;
  124173. private _oneGamepadConnected;
  124174. /** @hidden */
  124175. _isMonitoring: boolean;
  124176. private _gamepadEventSupported;
  124177. private _gamepadSupport?;
  124178. /**
  124179. * observable to be triggered when the gamepad controller has been connected
  124180. */
  124181. onGamepadConnectedObservable: Observable<Gamepad>;
  124182. /**
  124183. * observable to be triggered when the gamepad controller has been disconnected
  124184. */
  124185. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124186. private _onGamepadConnectedEvent;
  124187. private _onGamepadDisconnectedEvent;
  124188. /**
  124189. * Initializes the gamepad manager
  124190. * @param _scene BabylonJS scene
  124191. */
  124192. constructor(_scene?: Scene | undefined);
  124193. /**
  124194. * The gamepads in the game pad manager
  124195. */
  124196. get gamepads(): Gamepad[];
  124197. /**
  124198. * Get the gamepad controllers based on type
  124199. * @param type The type of gamepad controller
  124200. * @returns Nullable gamepad
  124201. */
  124202. getGamepadByType(type?: number): Nullable<Gamepad>;
  124203. /**
  124204. * Disposes the gamepad manager
  124205. */
  124206. dispose(): void;
  124207. private _addNewGamepad;
  124208. private _startMonitoringGamepads;
  124209. private _stopMonitoringGamepads;
  124210. /** @hidden */
  124211. _checkGamepadsStatus(): void;
  124212. private _updateGamepadObjects;
  124213. }
  124214. }
  124215. declare module BABYLON {
  124216. interface Scene {
  124217. /** @hidden */
  124218. _gamepadManager: Nullable<GamepadManager>;
  124219. /**
  124220. * Gets the gamepad manager associated with the scene
  124221. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124222. */
  124223. gamepadManager: GamepadManager;
  124224. }
  124225. /**
  124226. * Interface representing a free camera inputs manager
  124227. */
  124228. interface FreeCameraInputsManager {
  124229. /**
  124230. * Adds gamepad input support to the FreeCameraInputsManager.
  124231. * @returns the FreeCameraInputsManager
  124232. */
  124233. addGamepad(): FreeCameraInputsManager;
  124234. }
  124235. /**
  124236. * Interface representing an arc rotate camera inputs manager
  124237. */
  124238. interface ArcRotateCameraInputsManager {
  124239. /**
  124240. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124241. * @returns the camera inputs manager
  124242. */
  124243. addGamepad(): ArcRotateCameraInputsManager;
  124244. }
  124245. /**
  124246. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124247. */
  124248. export class GamepadSystemSceneComponent implements ISceneComponent {
  124249. /**
  124250. * The component name helpfull to identify the component in the list of scene components.
  124251. */
  124252. readonly name: string;
  124253. /**
  124254. * The scene the component belongs to.
  124255. */
  124256. scene: Scene;
  124257. /**
  124258. * Creates a new instance of the component for the given scene
  124259. * @param scene Defines the scene to register the component in
  124260. */
  124261. constructor(scene: Scene);
  124262. /**
  124263. * Registers the component in a given scene
  124264. */
  124265. register(): void;
  124266. /**
  124267. * Rebuilds the elements related to this component in case of
  124268. * context lost for instance.
  124269. */
  124270. rebuild(): void;
  124271. /**
  124272. * Disposes the component and the associated ressources
  124273. */
  124274. dispose(): void;
  124275. private _beforeCameraUpdate;
  124276. }
  124277. }
  124278. declare module BABYLON {
  124279. /**
  124280. * 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,
  124281. * which still works and will still be found in many Playgrounds.
  124282. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124283. */
  124284. export class UniversalCamera extends TouchCamera {
  124285. /**
  124286. * Defines the gamepad rotation sensiblity.
  124287. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124288. */
  124289. get gamepadAngularSensibility(): number;
  124290. set gamepadAngularSensibility(value: number);
  124291. /**
  124292. * Defines the gamepad move sensiblity.
  124293. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124294. */
  124295. get gamepadMoveSensibility(): number;
  124296. set gamepadMoveSensibility(value: number);
  124297. /**
  124298. * 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,
  124299. * which still works and will still be found in many Playgrounds.
  124300. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124301. * @param name Define the name of the camera in the scene
  124302. * @param position Define the start position of the camera in the scene
  124303. * @param scene Define the scene the camera belongs to
  124304. */
  124305. constructor(name: string, position: Vector3, scene: Scene);
  124306. /**
  124307. * Gets the current object class name.
  124308. * @return the class name
  124309. */
  124310. getClassName(): string;
  124311. }
  124312. }
  124313. declare module BABYLON {
  124314. /**
  124315. * This represents a FPS type of camera. This is only here for back compat purpose.
  124316. * Please use the UniversalCamera instead as both are identical.
  124317. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124318. */
  124319. export class GamepadCamera extends UniversalCamera {
  124320. /**
  124321. * Instantiates a new Gamepad Camera
  124322. * This represents a FPS type of camera. This is only here for back compat purpose.
  124323. * Please use the UniversalCamera instead as both are identical.
  124324. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124325. * @param name Define the name of the camera in the scene
  124326. * @param position Define the start position of the camera in the scene
  124327. * @param scene Define the scene the camera belongs to
  124328. */
  124329. constructor(name: string, position: Vector3, scene: Scene);
  124330. /**
  124331. * Gets the current object class name.
  124332. * @return the class name
  124333. */
  124334. getClassName(): string;
  124335. }
  124336. }
  124337. declare module BABYLON {
  124338. /** @hidden */
  124339. export var passPixelShader: {
  124340. name: string;
  124341. shader: string;
  124342. };
  124343. }
  124344. declare module BABYLON {
  124345. /** @hidden */
  124346. export var passCubePixelShader: {
  124347. name: string;
  124348. shader: string;
  124349. };
  124350. }
  124351. declare module BABYLON {
  124352. /**
  124353. * PassPostProcess which produces an output the same as it's input
  124354. */
  124355. export class PassPostProcess extends PostProcess {
  124356. /**
  124357. * Creates the PassPostProcess
  124358. * @param name The name of the effect.
  124359. * @param options The required width/height ratio to downsize to before computing the render pass.
  124360. * @param camera The camera to apply the render pass to.
  124361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124362. * @param engine The engine which the post process will be applied. (default: current engine)
  124363. * @param reusable If the post process can be reused on the same frame. (default: false)
  124364. * @param textureType The type of texture to be used when performing the post processing.
  124365. * @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)
  124366. */
  124367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124368. }
  124369. /**
  124370. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124371. */
  124372. export class PassCubePostProcess extends PostProcess {
  124373. private _face;
  124374. /**
  124375. * Gets or sets the cube face to display.
  124376. * * 0 is +X
  124377. * * 1 is -X
  124378. * * 2 is +Y
  124379. * * 3 is -Y
  124380. * * 4 is +Z
  124381. * * 5 is -Z
  124382. */
  124383. get face(): number;
  124384. set face(value: number);
  124385. /**
  124386. * Creates the PassCubePostProcess
  124387. * @param name The name of the effect.
  124388. * @param options The required width/height ratio to downsize to before computing the render pass.
  124389. * @param camera The camera to apply the render pass to.
  124390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124391. * @param engine The engine which the post process will be applied. (default: current engine)
  124392. * @param reusable If the post process can be reused on the same frame. (default: false)
  124393. * @param textureType The type of texture to be used when performing the post processing.
  124394. * @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)
  124395. */
  124396. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124397. }
  124398. }
  124399. declare module BABYLON {
  124400. /** @hidden */
  124401. export var anaglyphPixelShader: {
  124402. name: string;
  124403. shader: string;
  124404. };
  124405. }
  124406. declare module BABYLON {
  124407. /**
  124408. * Postprocess used to generate anaglyphic rendering
  124409. */
  124410. export class AnaglyphPostProcess extends PostProcess {
  124411. private _passedProcess;
  124412. /**
  124413. * Creates a new AnaglyphPostProcess
  124414. * @param name defines postprocess name
  124415. * @param options defines creation options or target ratio scale
  124416. * @param rigCameras defines cameras using this postprocess
  124417. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124418. * @param engine defines hosting engine
  124419. * @param reusable defines if the postprocess will be reused multiple times per frame
  124420. */
  124421. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124422. }
  124423. }
  124424. declare module BABYLON {
  124425. /**
  124426. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  124427. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124428. */
  124429. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  124430. /**
  124431. * Creates a new AnaglyphArcRotateCamera
  124432. * @param name defines camera name
  124433. * @param alpha defines alpha angle (in radians)
  124434. * @param beta defines beta angle (in radians)
  124435. * @param radius defines radius
  124436. * @param target defines camera target
  124437. * @param interaxialDistance defines distance between each color axis
  124438. * @param scene defines the hosting scene
  124439. */
  124440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  124441. /**
  124442. * Gets camera class name
  124443. * @returns AnaglyphArcRotateCamera
  124444. */
  124445. getClassName(): string;
  124446. }
  124447. }
  124448. declare module BABYLON {
  124449. /**
  124450. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  124451. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124452. */
  124453. export class AnaglyphFreeCamera extends FreeCamera {
  124454. /**
  124455. * Creates a new AnaglyphFreeCamera
  124456. * @param name defines camera name
  124457. * @param position defines initial position
  124458. * @param interaxialDistance defines distance between each color axis
  124459. * @param scene defines the hosting scene
  124460. */
  124461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124462. /**
  124463. * Gets camera class name
  124464. * @returns AnaglyphFreeCamera
  124465. */
  124466. getClassName(): string;
  124467. }
  124468. }
  124469. declare module BABYLON {
  124470. /**
  124471. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  124472. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124473. */
  124474. export class AnaglyphGamepadCamera extends GamepadCamera {
  124475. /**
  124476. * Creates a new AnaglyphGamepadCamera
  124477. * @param name defines camera name
  124478. * @param position defines initial position
  124479. * @param interaxialDistance defines distance between each color axis
  124480. * @param scene defines the hosting scene
  124481. */
  124482. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124483. /**
  124484. * Gets camera class name
  124485. * @returns AnaglyphGamepadCamera
  124486. */
  124487. getClassName(): string;
  124488. }
  124489. }
  124490. declare module BABYLON {
  124491. /**
  124492. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  124493. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124494. */
  124495. export class AnaglyphUniversalCamera extends UniversalCamera {
  124496. /**
  124497. * Creates a new AnaglyphUniversalCamera
  124498. * @param name defines camera name
  124499. * @param position defines initial position
  124500. * @param interaxialDistance defines distance between each color axis
  124501. * @param scene defines the hosting scene
  124502. */
  124503. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124504. /**
  124505. * Gets camera class name
  124506. * @returns AnaglyphUniversalCamera
  124507. */
  124508. getClassName(): string;
  124509. }
  124510. }
  124511. declare module BABYLON {
  124512. /**
  124513. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  124514. * @see https://doc.babylonjs.com/features/cameras
  124515. */
  124516. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  124517. /**
  124518. * Creates a new StereoscopicArcRotateCamera
  124519. * @param name defines camera name
  124520. * @param alpha defines alpha angle (in radians)
  124521. * @param beta defines beta angle (in radians)
  124522. * @param radius defines radius
  124523. * @param target defines camera target
  124524. * @param interaxialDistance defines distance between each color axis
  124525. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124526. * @param scene defines the hosting scene
  124527. */
  124528. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124529. /**
  124530. * Gets camera class name
  124531. * @returns StereoscopicArcRotateCamera
  124532. */
  124533. getClassName(): string;
  124534. }
  124535. }
  124536. declare module BABYLON {
  124537. /**
  124538. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  124539. * @see https://doc.babylonjs.com/features/cameras
  124540. */
  124541. export class StereoscopicFreeCamera extends FreeCamera {
  124542. /**
  124543. * Creates a new StereoscopicFreeCamera
  124544. * @param name defines camera name
  124545. * @param position defines initial position
  124546. * @param interaxialDistance defines distance between each color axis
  124547. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124548. * @param scene defines the hosting scene
  124549. */
  124550. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124551. /**
  124552. * Gets camera class name
  124553. * @returns StereoscopicFreeCamera
  124554. */
  124555. getClassName(): string;
  124556. }
  124557. }
  124558. declare module BABYLON {
  124559. /**
  124560. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  124561. * @see https://doc.babylonjs.com/features/cameras
  124562. */
  124563. export class StereoscopicGamepadCamera extends GamepadCamera {
  124564. /**
  124565. * Creates a new StereoscopicGamepadCamera
  124566. * @param name defines camera name
  124567. * @param position defines initial position
  124568. * @param interaxialDistance defines distance between each color axis
  124569. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124570. * @param scene defines the hosting scene
  124571. */
  124572. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124573. /**
  124574. * Gets camera class name
  124575. * @returns StereoscopicGamepadCamera
  124576. */
  124577. getClassName(): string;
  124578. }
  124579. }
  124580. declare module BABYLON {
  124581. /**
  124582. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  124583. * @see https://doc.babylonjs.com/features/cameras
  124584. */
  124585. export class StereoscopicUniversalCamera extends UniversalCamera {
  124586. /**
  124587. * Creates a new StereoscopicUniversalCamera
  124588. * @param name defines camera name
  124589. * @param position defines initial position
  124590. * @param interaxialDistance defines distance between each color axis
  124591. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124592. * @param scene defines the hosting scene
  124593. */
  124594. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124595. /**
  124596. * Gets camera class name
  124597. * @returns StereoscopicUniversalCamera
  124598. */
  124599. getClassName(): string;
  124600. }
  124601. }
  124602. declare module BABYLON {
  124603. /**
  124604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  124605. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124606. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124607. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124608. */
  124609. export class VirtualJoysticksCamera extends FreeCamera {
  124610. /**
  124611. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  124612. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124613. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124614. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124615. * @param name Define the name of the camera in the scene
  124616. * @param position Define the start position of the camera in the scene
  124617. * @param scene Define the scene the camera belongs to
  124618. */
  124619. constructor(name: string, position: Vector3, scene: Scene);
  124620. /**
  124621. * Gets the current object class name.
  124622. * @return the class name
  124623. */
  124624. getClassName(): string;
  124625. }
  124626. }
  124627. declare module BABYLON {
  124628. /**
  124629. * This represents all the required metrics to create a VR camera.
  124630. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  124631. */
  124632. export class VRCameraMetrics {
  124633. /**
  124634. * Define the horizontal resolution off the screen.
  124635. */
  124636. hResolution: number;
  124637. /**
  124638. * Define the vertical resolution off the screen.
  124639. */
  124640. vResolution: number;
  124641. /**
  124642. * Define the horizontal screen size.
  124643. */
  124644. hScreenSize: number;
  124645. /**
  124646. * Define the vertical screen size.
  124647. */
  124648. vScreenSize: number;
  124649. /**
  124650. * Define the vertical screen center position.
  124651. */
  124652. vScreenCenter: number;
  124653. /**
  124654. * Define the distance of the eyes to the screen.
  124655. */
  124656. eyeToScreenDistance: number;
  124657. /**
  124658. * Define the distance between both lenses
  124659. */
  124660. lensSeparationDistance: number;
  124661. /**
  124662. * Define the distance between both viewer's eyes.
  124663. */
  124664. interpupillaryDistance: number;
  124665. /**
  124666. * Define the distortion factor of the VR postprocess.
  124667. * Please, touch with care.
  124668. */
  124669. distortionK: number[];
  124670. /**
  124671. * Define the chromatic aberration correction factors for the VR post process.
  124672. */
  124673. chromaAbCorrection: number[];
  124674. /**
  124675. * Define the scale factor of the post process.
  124676. * The smaller the better but the slower.
  124677. */
  124678. postProcessScaleFactor: number;
  124679. /**
  124680. * Define an offset for the lens center.
  124681. */
  124682. lensCenterOffset: number;
  124683. /**
  124684. * Define if the current vr camera should compensate the distortion of the lense or not.
  124685. */
  124686. compensateDistortion: boolean;
  124687. /**
  124688. * Defines if multiview should be enabled when rendering (Default: false)
  124689. */
  124690. multiviewEnabled: boolean;
  124691. /**
  124692. * Gets the rendering aspect ratio based on the provided resolutions.
  124693. */
  124694. get aspectRatio(): number;
  124695. /**
  124696. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  124697. */
  124698. get aspectRatioFov(): number;
  124699. /**
  124700. * @hidden
  124701. */
  124702. get leftHMatrix(): Matrix;
  124703. /**
  124704. * @hidden
  124705. */
  124706. get rightHMatrix(): Matrix;
  124707. /**
  124708. * @hidden
  124709. */
  124710. get leftPreViewMatrix(): Matrix;
  124711. /**
  124712. * @hidden
  124713. */
  124714. get rightPreViewMatrix(): Matrix;
  124715. /**
  124716. * Get the default VRMetrics based on the most generic setup.
  124717. * @returns the default vr metrics
  124718. */
  124719. static GetDefault(): VRCameraMetrics;
  124720. }
  124721. }
  124722. declare module BABYLON {
  124723. /** @hidden */
  124724. export var vrDistortionCorrectionPixelShader: {
  124725. name: string;
  124726. shader: string;
  124727. };
  124728. }
  124729. declare module BABYLON {
  124730. /**
  124731. * VRDistortionCorrectionPostProcess used for mobile VR
  124732. */
  124733. export class VRDistortionCorrectionPostProcess extends PostProcess {
  124734. private _isRightEye;
  124735. private _distortionFactors;
  124736. private _postProcessScaleFactor;
  124737. private _lensCenterOffset;
  124738. private _scaleIn;
  124739. private _scaleFactor;
  124740. private _lensCenter;
  124741. /**
  124742. * Initializes the VRDistortionCorrectionPostProcess
  124743. * @param name The name of the effect.
  124744. * @param camera The camera to apply the render pass to.
  124745. * @param isRightEye If this is for the right eye distortion
  124746. * @param vrMetrics All the required metrics for the VR camera
  124747. */
  124748. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  124749. }
  124750. }
  124751. declare module BABYLON {
  124752. /**
  124753. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  124754. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124755. */
  124756. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  124757. /**
  124758. * Creates a new VRDeviceOrientationArcRotateCamera
  124759. * @param name defines camera name
  124760. * @param alpha defines the camera rotation along the logitudinal axis
  124761. * @param beta defines the camera rotation along the latitudinal axis
  124762. * @param radius defines the camera distance from its target
  124763. * @param target defines the camera target
  124764. * @param scene defines the scene the camera belongs to
  124765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124767. */
  124768. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124769. /**
  124770. * Gets camera class name
  124771. * @returns VRDeviceOrientationArcRotateCamera
  124772. */
  124773. getClassName(): string;
  124774. }
  124775. }
  124776. declare module BABYLON {
  124777. /**
  124778. * Camera used to simulate VR rendering (based on FreeCamera)
  124779. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124780. */
  124781. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  124782. /**
  124783. * Creates a new VRDeviceOrientationFreeCamera
  124784. * @param name defines camera name
  124785. * @param position defines the start position of the camera
  124786. * @param scene defines the scene the camera belongs to
  124787. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124788. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124789. */
  124790. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124791. /**
  124792. * Gets camera class name
  124793. * @returns VRDeviceOrientationFreeCamera
  124794. */
  124795. getClassName(): string;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /**
  124800. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  124801. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124802. */
  124803. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  124804. /**
  124805. * Creates a new VRDeviceOrientationGamepadCamera
  124806. * @param name defines camera name
  124807. * @param position defines the start position of the camera
  124808. * @param scene defines the scene the camera belongs to
  124809. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124810. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124811. */
  124812. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124813. /**
  124814. * Gets camera class name
  124815. * @returns VRDeviceOrientationGamepadCamera
  124816. */
  124817. getClassName(): string;
  124818. }
  124819. }
  124820. declare module BABYLON {
  124821. /**
  124822. * A class extending Texture allowing drawing on a texture
  124823. * @see https://doc.babylonjs.com/how_to/dynamictexture
  124824. */
  124825. export class DynamicTexture extends Texture {
  124826. private _generateMipMaps;
  124827. private _canvas;
  124828. private _context;
  124829. /**
  124830. * Creates a DynamicTexture
  124831. * @param name defines the name of the texture
  124832. * @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
  124833. * @param scene defines the scene where you want the texture
  124834. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  124835. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124836. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  124837. */
  124838. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  124839. /**
  124840. * Get the current class name of the texture useful for serialization or dynamic coding.
  124841. * @returns "DynamicTexture"
  124842. */
  124843. getClassName(): string;
  124844. /**
  124845. * Gets the current state of canRescale
  124846. */
  124847. get canRescale(): boolean;
  124848. private _recreate;
  124849. /**
  124850. * Scales the texture
  124851. * @param ratio the scale factor to apply to both width and height
  124852. */
  124853. scale(ratio: number): void;
  124854. /**
  124855. * Resizes the texture
  124856. * @param width the new width
  124857. * @param height the new height
  124858. */
  124859. scaleTo(width: number, height: number): void;
  124860. /**
  124861. * Gets the context of the canvas used by the texture
  124862. * @returns the canvas context of the dynamic texture
  124863. */
  124864. getContext(): CanvasRenderingContext2D;
  124865. /**
  124866. * Clears the texture
  124867. */
  124868. clear(): void;
  124869. /**
  124870. * Updates the texture
  124871. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  124872. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  124873. */
  124874. update(invertY?: boolean, premulAlpha?: boolean): void;
  124875. /**
  124876. * Draws text onto the texture
  124877. * @param text defines the text to be drawn
  124878. * @param x defines the placement of the text from the left
  124879. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  124880. * @param font defines the font to be used with font-style, font-size, font-name
  124881. * @param color defines the color used for the text
  124882. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  124883. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  124884. * @param update defines whether texture is immediately update (default is true)
  124885. */
  124886. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  124887. /**
  124888. * Clones the texture
  124889. * @returns the clone of the texture.
  124890. */
  124891. clone(): DynamicTexture;
  124892. /**
  124893. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  124894. * @returns a serialized dynamic texture object
  124895. */
  124896. serialize(): any;
  124897. private _IsCanvasElement;
  124898. /** @hidden */
  124899. _rebuild(): void;
  124900. }
  124901. }
  124902. declare module BABYLON {
  124903. /**
  124904. * Class containing static functions to help procedurally build meshes
  124905. */
  124906. export class GroundBuilder {
  124907. /**
  124908. * Creates a ground mesh
  124909. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124910. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124912. * @param name defines the name of the mesh
  124913. * @param options defines the options used to create the mesh
  124914. * @param scene defines the hosting scene
  124915. * @returns the ground mesh
  124916. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124917. */
  124918. static CreateGround(name: string, options: {
  124919. width?: number;
  124920. height?: number;
  124921. subdivisions?: number;
  124922. subdivisionsX?: number;
  124923. subdivisionsY?: number;
  124924. updatable?: boolean;
  124925. }, scene: any): Mesh;
  124926. /**
  124927. * Creates a tiled ground mesh
  124928. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124929. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124930. * * 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
  124931. * * 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
  124932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124933. * @param name defines the name of the mesh
  124934. * @param options defines the options used to create the mesh
  124935. * @param scene defines the hosting scene
  124936. * @returns the tiled ground mesh
  124937. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124938. */
  124939. static CreateTiledGround(name: string, options: {
  124940. xmin: number;
  124941. zmin: number;
  124942. xmax: number;
  124943. zmax: number;
  124944. subdivisions?: {
  124945. w: number;
  124946. h: number;
  124947. };
  124948. precision?: {
  124949. w: number;
  124950. h: number;
  124951. };
  124952. updatable?: boolean;
  124953. }, scene?: Nullable<Scene>): Mesh;
  124954. /**
  124955. * Creates a ground mesh from a height map
  124956. * * The parameter `url` sets the URL of the height map image resource.
  124957. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124958. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124959. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124960. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124961. * * 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.
  124962. * * 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).
  124963. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124965. * @param name defines the name of the mesh
  124966. * @param url defines the url to the height map
  124967. * @param options defines the options used to create the mesh
  124968. * @param scene defines the hosting scene
  124969. * @returns the ground mesh
  124970. * @see https://doc.babylonjs.com/babylon101/height_map
  124971. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124972. */
  124973. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124974. width?: number;
  124975. height?: number;
  124976. subdivisions?: number;
  124977. minHeight?: number;
  124978. maxHeight?: number;
  124979. colorFilter?: Color3;
  124980. alphaFilter?: number;
  124981. updatable?: boolean;
  124982. onReady?: (mesh: GroundMesh) => void;
  124983. }, scene?: Nullable<Scene>): GroundMesh;
  124984. }
  124985. }
  124986. declare module BABYLON {
  124987. /**
  124988. * Class containing static functions to help procedurally build meshes
  124989. */
  124990. export class TorusBuilder {
  124991. /**
  124992. * Creates a torus mesh
  124993. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124994. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124995. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124999. * @param name defines the name of the mesh
  125000. * @param options defines the options used to create the mesh
  125001. * @param scene defines the hosting scene
  125002. * @returns the torus mesh
  125003. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125004. */
  125005. static CreateTorus(name: string, options: {
  125006. diameter?: number;
  125007. thickness?: number;
  125008. tessellation?: number;
  125009. updatable?: boolean;
  125010. sideOrientation?: number;
  125011. frontUVs?: Vector4;
  125012. backUVs?: Vector4;
  125013. }, scene: any): Mesh;
  125014. }
  125015. }
  125016. declare module BABYLON {
  125017. /**
  125018. * Class containing static functions to help procedurally build meshes
  125019. */
  125020. export class CylinderBuilder {
  125021. /**
  125022. * Creates a cylinder or a cone mesh
  125023. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125024. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125025. * * 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.
  125026. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125027. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125028. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125029. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125030. * * 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).
  125031. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125032. * * 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).
  125033. * * 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
  125034. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125035. * * 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
  125036. * * 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.
  125037. * * If `enclose` is false, a ring surface is one element.
  125038. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125039. * * 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
  125040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125043. * @param name defines the name of the mesh
  125044. * @param options defines the options used to create the mesh
  125045. * @param scene defines the hosting scene
  125046. * @returns the cylinder mesh
  125047. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125048. */
  125049. static CreateCylinder(name: string, options: {
  125050. height?: number;
  125051. diameterTop?: number;
  125052. diameterBottom?: number;
  125053. diameter?: number;
  125054. tessellation?: number;
  125055. subdivisions?: number;
  125056. arc?: number;
  125057. faceColors?: Color4[];
  125058. faceUV?: Vector4[];
  125059. updatable?: boolean;
  125060. hasRings?: boolean;
  125061. enclose?: boolean;
  125062. cap?: number;
  125063. sideOrientation?: number;
  125064. frontUVs?: Vector4;
  125065. backUVs?: Vector4;
  125066. }, scene: any): Mesh;
  125067. }
  125068. }
  125069. declare module BABYLON {
  125070. /**
  125071. * States of the webXR experience
  125072. */
  125073. export enum WebXRState {
  125074. /**
  125075. * Transitioning to being in XR mode
  125076. */
  125077. ENTERING_XR = 0,
  125078. /**
  125079. * Transitioning to non XR mode
  125080. */
  125081. EXITING_XR = 1,
  125082. /**
  125083. * In XR mode and presenting
  125084. */
  125085. IN_XR = 2,
  125086. /**
  125087. * Not entered XR mode
  125088. */
  125089. NOT_IN_XR = 3
  125090. }
  125091. /**
  125092. * Abstraction of the XR render target
  125093. */
  125094. export interface WebXRRenderTarget extends IDisposable {
  125095. /**
  125096. * xrpresent context of the canvas which can be used to display/mirror xr content
  125097. */
  125098. canvasContext: WebGLRenderingContext;
  125099. /**
  125100. * xr layer for the canvas
  125101. */
  125102. xrLayer: Nullable<XRWebGLLayer>;
  125103. /**
  125104. * Initializes the xr layer for the session
  125105. * @param xrSession xr session
  125106. * @returns a promise that will resolve once the XR Layer has been created
  125107. */
  125108. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125109. }
  125110. }
  125111. declare module BABYLON {
  125112. /**
  125113. * COnfiguration object for WebXR output canvas
  125114. */
  125115. export class WebXRManagedOutputCanvasOptions {
  125116. /**
  125117. * An optional canvas in case you wish to create it yourself and provide it here.
  125118. * If not provided, a new canvas will be created
  125119. */
  125120. canvasElement?: HTMLCanvasElement;
  125121. /**
  125122. * Options for this XR Layer output
  125123. */
  125124. canvasOptions?: XRWebGLLayerOptions;
  125125. /**
  125126. * CSS styling for a newly created canvas (if not provided)
  125127. */
  125128. newCanvasCssStyle?: string;
  125129. /**
  125130. * Get the default values of the configuration object
  125131. * @returns default values of this configuration object
  125132. */
  125133. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125134. }
  125135. /**
  125136. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125137. */
  125138. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125139. private _options;
  125140. private _canvas;
  125141. private _engine;
  125142. private _originalCanvasSize;
  125143. /**
  125144. * Rendering context of the canvas which can be used to display/mirror xr content
  125145. */
  125146. canvasContext: WebGLRenderingContext;
  125147. /**
  125148. * xr layer for the canvas
  125149. */
  125150. xrLayer: Nullable<XRWebGLLayer>;
  125151. /**
  125152. * Obseervers registered here will be triggered when the xr layer was initialized
  125153. */
  125154. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125155. /**
  125156. * Initializes the canvas to be added/removed upon entering/exiting xr
  125157. * @param _xrSessionManager The XR Session manager
  125158. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125159. */
  125160. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125161. /**
  125162. * Disposes of the object
  125163. */
  125164. dispose(): void;
  125165. /**
  125166. * Initializes the xr layer for the session
  125167. * @param xrSession xr session
  125168. * @returns a promise that will resolve once the XR Layer has been created
  125169. */
  125170. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125171. private _addCanvas;
  125172. private _removeCanvas;
  125173. private _setCanvasSize;
  125174. private _setManagedOutputCanvas;
  125175. }
  125176. }
  125177. declare module BABYLON {
  125178. /**
  125179. * Manages an XRSession to work with Babylon's engine
  125180. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125181. */
  125182. export class WebXRSessionManager implements IDisposable {
  125183. /** The scene which the session should be created for */
  125184. scene: Scene;
  125185. private _referenceSpace;
  125186. private _rttProvider;
  125187. private _sessionEnded;
  125188. private _xrNavigator;
  125189. private baseLayer;
  125190. /**
  125191. * The base reference space from which the session started. good if you want to reset your
  125192. * reference space
  125193. */
  125194. baseReferenceSpace: XRReferenceSpace;
  125195. /**
  125196. * Current XR frame
  125197. */
  125198. currentFrame: Nullable<XRFrame>;
  125199. /** WebXR timestamp updated every frame */
  125200. currentTimestamp: number;
  125201. /**
  125202. * Used just in case of a failure to initialize an immersive session.
  125203. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125204. */
  125205. defaultHeightCompensation: number;
  125206. /**
  125207. * Fires every time a new xrFrame arrives which can be used to update the camera
  125208. */
  125209. onXRFrameObservable: Observable<XRFrame>;
  125210. /**
  125211. * Fires when the reference space changed
  125212. */
  125213. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125214. /**
  125215. * Fires when the xr session is ended either by the device or manually done
  125216. */
  125217. onXRSessionEnded: Observable<any>;
  125218. /**
  125219. * Fires when the xr session is ended either by the device or manually done
  125220. */
  125221. onXRSessionInit: Observable<XRSession>;
  125222. /**
  125223. * Underlying xr session
  125224. */
  125225. session: XRSession;
  125226. /**
  125227. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125228. * or get the offset the player is currently at.
  125229. */
  125230. viewerReferenceSpace: XRReferenceSpace;
  125231. /**
  125232. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125233. * @param scene The scene which the session should be created for
  125234. */
  125235. constructor(
  125236. /** The scene which the session should be created for */
  125237. scene: Scene);
  125238. /**
  125239. * The current reference space used in this session. This reference space can constantly change!
  125240. * It is mainly used to offset the camera's position.
  125241. */
  125242. get referenceSpace(): XRReferenceSpace;
  125243. /**
  125244. * Set a new reference space and triggers the observable
  125245. */
  125246. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125247. /**
  125248. * Disposes of the session manager
  125249. */
  125250. dispose(): void;
  125251. /**
  125252. * Stops the xrSession and restores the render loop
  125253. * @returns Promise which resolves after it exits XR
  125254. */
  125255. exitXRAsync(): Promise<void>;
  125256. /**
  125257. * Gets the correct render target texture to be rendered this frame for this eye
  125258. * @param eye the eye for which to get the render target
  125259. * @returns the render target for the specified eye
  125260. */
  125261. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125262. /**
  125263. * Creates a WebXRRenderTarget object for the XR session
  125264. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125265. * @param options optional options to provide when creating a new render target
  125266. * @returns a WebXR render target to which the session can render
  125267. */
  125268. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125269. /**
  125270. * Initializes the manager
  125271. * After initialization enterXR can be called to start an XR session
  125272. * @returns Promise which resolves after it is initialized
  125273. */
  125274. initializeAsync(): Promise<void>;
  125275. /**
  125276. * Initializes an xr session
  125277. * @param xrSessionMode mode to initialize
  125278. * @param xrSessionInit defines optional and required values to pass to the session builder
  125279. * @returns a promise which will resolve once the session has been initialized
  125280. */
  125281. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125282. /**
  125283. * Checks if a session would be supported for the creation options specified
  125284. * @param sessionMode session mode to check if supported eg. immersive-vr
  125285. * @returns A Promise that resolves to true if supported and false if not
  125286. */
  125287. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125288. /**
  125289. * Resets the reference space to the one started the session
  125290. */
  125291. resetReferenceSpace(): void;
  125292. /**
  125293. * Starts rendering to the xr layer
  125294. */
  125295. runXRRenderLoop(): void;
  125296. /**
  125297. * Sets the reference space on the xr session
  125298. * @param referenceSpaceType space to set
  125299. * @returns a promise that will resolve once the reference space has been set
  125300. */
  125301. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125302. /**
  125303. * Updates the render state of the session
  125304. * @param state state to set
  125305. * @returns a promise that resolves once the render state has been updated
  125306. */
  125307. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125308. /**
  125309. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125310. * @param sessionMode defines the session to test
  125311. * @returns a promise with boolean as final value
  125312. */
  125313. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125314. private _createRenderTargetTexture;
  125315. }
  125316. }
  125317. declare module BABYLON {
  125318. /**
  125319. * WebXR Camera which holds the views for the xrSession
  125320. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125321. */
  125322. export class WebXRCamera extends FreeCamera {
  125323. private _xrSessionManager;
  125324. private _firstFrame;
  125325. private _referenceQuaternion;
  125326. private _referencedPosition;
  125327. private _xrInvPositionCache;
  125328. private _xrInvQuaternionCache;
  125329. /**
  125330. * Should position compensation execute on first frame.
  125331. * This is used when copying the position from a native (non XR) camera
  125332. */
  125333. compensateOnFirstFrame: boolean;
  125334. /**
  125335. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125336. * @param name the name of the camera
  125337. * @param scene the scene to add the camera to
  125338. * @param _xrSessionManager a constructed xr session manager
  125339. */
  125340. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125341. /**
  125342. * Return the user's height, unrelated to the current ground.
  125343. * This will be the y position of this camera, when ground level is 0.
  125344. */
  125345. get realWorldHeight(): number;
  125346. /** @hidden */
  125347. _updateForDualEyeDebugging(): void;
  125348. /**
  125349. * Sets this camera's transformation based on a non-vr camera
  125350. * @param otherCamera the non-vr camera to copy the transformation from
  125351. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125352. */
  125353. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125354. /**
  125355. * Gets the current instance class name ("WebXRCamera").
  125356. * @returns the class name
  125357. */
  125358. getClassName(): string;
  125359. private _rotate180;
  125360. private _updateFromXRSession;
  125361. private _updateNumberOfRigCameras;
  125362. private _updateReferenceSpace;
  125363. private _updateReferenceSpaceOffset;
  125364. }
  125365. }
  125366. declare module BABYLON {
  125367. /**
  125368. * Defining the interface required for a (webxr) feature
  125369. */
  125370. export interface IWebXRFeature extends IDisposable {
  125371. /**
  125372. * Is this feature attached
  125373. */
  125374. attached: boolean;
  125375. /**
  125376. * Should auto-attach be disabled?
  125377. */
  125378. disableAutoAttach: boolean;
  125379. /**
  125380. * Attach the feature to the session
  125381. * Will usually be called by the features manager
  125382. *
  125383. * @param force should attachment be forced (even when already attached)
  125384. * @returns true if successful.
  125385. */
  125386. attach(force?: boolean): boolean;
  125387. /**
  125388. * Detach the feature from the session
  125389. * Will usually be called by the features manager
  125390. *
  125391. * @returns true if successful.
  125392. */
  125393. detach(): boolean;
  125394. /**
  125395. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125396. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125397. *
  125398. * @returns whether or not the feature is compatible in this environment
  125399. */
  125400. isCompatible(): boolean;
  125401. /**
  125402. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125403. */
  125404. xrNativeFeatureName?: string;
  125405. }
  125406. /**
  125407. * A list of the currently available features without referencing them
  125408. */
  125409. export class WebXRFeatureName {
  125410. /**
  125411. * The name of the anchor system feature
  125412. */
  125413. static ANCHOR_SYSTEM: string;
  125414. /**
  125415. * The name of the background remover feature
  125416. */
  125417. static BACKGROUND_REMOVER: string;
  125418. /**
  125419. * The name of the hit test feature
  125420. */
  125421. static HIT_TEST: string;
  125422. /**
  125423. * physics impostors for xr controllers feature
  125424. */
  125425. static PHYSICS_CONTROLLERS: string;
  125426. /**
  125427. * The name of the plane detection feature
  125428. */
  125429. static PLANE_DETECTION: string;
  125430. /**
  125431. * The name of the pointer selection feature
  125432. */
  125433. static POINTER_SELECTION: string;
  125434. /**
  125435. * The name of the teleportation feature
  125436. */
  125437. static TELEPORTATION: string;
  125438. }
  125439. /**
  125440. * Defining the constructor of a feature. Used to register the modules.
  125441. */
  125442. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  125443. /**
  125444. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  125445. * It is mainly used in AR sessions.
  125446. *
  125447. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  125448. */
  125449. export class WebXRFeaturesManager implements IDisposable {
  125450. private _xrSessionManager;
  125451. private static readonly _AvailableFeatures;
  125452. private _features;
  125453. /**
  125454. * constructs a new features manages.
  125455. *
  125456. * @param _xrSessionManager an instance of WebXRSessionManager
  125457. */
  125458. constructor(_xrSessionManager: WebXRSessionManager);
  125459. /**
  125460. * Used to register a module. After calling this function a developer can use this feature in the scene.
  125461. * Mainly used internally.
  125462. *
  125463. * @param featureName the name of the feature to register
  125464. * @param constructorFunction the function used to construct the module
  125465. * @param version the (babylon) version of the module
  125466. * @param stable is that a stable version of this module
  125467. */
  125468. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  125469. /**
  125470. * Returns a constructor of a specific feature.
  125471. *
  125472. * @param featureName the name of the feature to construct
  125473. * @param version the version of the feature to load
  125474. * @param xrSessionManager the xrSessionManager. Used to construct the module
  125475. * @param options optional options provided to the module.
  125476. * @returns a function that, when called, will return a new instance of this feature
  125477. */
  125478. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  125479. /**
  125480. * Can be used to return the list of features currently registered
  125481. *
  125482. * @returns an Array of available features
  125483. */
  125484. static GetAvailableFeatures(): string[];
  125485. /**
  125486. * Gets the versions available for a specific feature
  125487. * @param featureName the name of the feature
  125488. * @returns an array with the available versions
  125489. */
  125490. static GetAvailableVersions(featureName: string): string[];
  125491. /**
  125492. * Return the latest unstable version of this feature
  125493. * @param featureName the name of the feature to search
  125494. * @returns the version number. if not found will return -1
  125495. */
  125496. static GetLatestVersionOfFeature(featureName: string): number;
  125497. /**
  125498. * Return the latest stable version of this feature
  125499. * @param featureName the name of the feature to search
  125500. * @returns the version number. if not found will return -1
  125501. */
  125502. static GetStableVersionOfFeature(featureName: string): number;
  125503. /**
  125504. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  125505. * Can be used during a session to start a feature
  125506. * @param featureName the name of feature to attach
  125507. */
  125508. attachFeature(featureName: string): void;
  125509. /**
  125510. * Can be used inside a session or when the session ends to detach a specific feature
  125511. * @param featureName the name of the feature to detach
  125512. */
  125513. detachFeature(featureName: string): void;
  125514. /**
  125515. * Used to disable an already-enabled feature
  125516. * The feature will be disposed and will be recreated once enabled.
  125517. * @param featureName the feature to disable
  125518. * @returns true if disable was successful
  125519. */
  125520. disableFeature(featureName: string | {
  125521. Name: string;
  125522. }): boolean;
  125523. /**
  125524. * dispose this features manager
  125525. */
  125526. dispose(): void;
  125527. /**
  125528. * 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.
  125529. * 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.
  125530. *
  125531. * @param featureName the name of the feature to load or the class of the feature
  125532. * @param version optional version to load. if not provided the latest version will be enabled
  125533. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  125534. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  125535. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  125536. * @returns a new constructed feature or throws an error if feature not found.
  125537. */
  125538. enableFeature(featureName: string | {
  125539. Name: string;
  125540. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  125541. /**
  125542. * get the implementation of an enabled feature.
  125543. * @param featureName the name of the feature to load
  125544. * @returns the feature class, if found
  125545. */
  125546. getEnabledFeature(featureName: string): IWebXRFeature;
  125547. /**
  125548. * Get the list of enabled features
  125549. * @returns an array of enabled features
  125550. */
  125551. getEnabledFeatures(): string[];
  125552. /**
  125553. * This function will exten the session creation configuration object with enabled features.
  125554. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  125555. * according to the defined "required" variable, provided during enableFeature call
  125556. * @param xrSessionInit the xr Session init object to extend
  125557. *
  125558. * @returns an extended XRSessionInit object
  125559. */
  125560. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  125561. }
  125562. }
  125563. declare module BABYLON {
  125564. /**
  125565. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  125566. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  125567. */
  125568. export class WebXRExperienceHelper implements IDisposable {
  125569. private scene;
  125570. private _nonVRCamera;
  125571. private _originalSceneAutoClear;
  125572. private _supported;
  125573. /**
  125574. * Camera used to render xr content
  125575. */
  125576. camera: WebXRCamera;
  125577. /** A features manager for this xr session */
  125578. featuresManager: WebXRFeaturesManager;
  125579. /**
  125580. * Observers registered here will be triggered after the camera's initial transformation is set
  125581. * This can be used to set a different ground level or an extra rotation.
  125582. *
  125583. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  125584. * to the position set after this observable is done executing.
  125585. */
  125586. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  125587. /**
  125588. * Fires when the state of the experience helper has changed
  125589. */
  125590. onStateChangedObservable: Observable<WebXRState>;
  125591. /** Session manager used to keep track of xr session */
  125592. sessionManager: WebXRSessionManager;
  125593. /**
  125594. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  125595. */
  125596. state: WebXRState;
  125597. /**
  125598. * Creates a WebXRExperienceHelper
  125599. * @param scene The scene the helper should be created in
  125600. */
  125601. private constructor();
  125602. /**
  125603. * Creates the experience helper
  125604. * @param scene the scene to attach the experience helper to
  125605. * @returns a promise for the experience helper
  125606. */
  125607. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  125608. /**
  125609. * Disposes of the experience helper
  125610. */
  125611. dispose(): void;
  125612. /**
  125613. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  125614. * @param sessionMode options for the XR session
  125615. * @param referenceSpaceType frame of reference of the XR session
  125616. * @param renderTarget the output canvas that will be used to enter XR mode
  125617. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  125618. * @returns promise that resolves after xr mode has entered
  125619. */
  125620. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  125621. /**
  125622. * Exits XR mode and returns the scene to its original state
  125623. * @returns promise that resolves after xr mode has exited
  125624. */
  125625. exitXRAsync(): Promise<void>;
  125626. private _nonXRToXRCamera;
  125627. private _setState;
  125628. }
  125629. }
  125630. declare module BABYLON {
  125631. /**
  125632. * X-Y values for axes in WebXR
  125633. */
  125634. export interface IWebXRMotionControllerAxesValue {
  125635. /**
  125636. * The value of the x axis
  125637. */
  125638. x: number;
  125639. /**
  125640. * The value of the y-axis
  125641. */
  125642. y: number;
  125643. }
  125644. /**
  125645. * changed / previous values for the values of this component
  125646. */
  125647. export interface IWebXRMotionControllerComponentChangesValues<T> {
  125648. /**
  125649. * current (this frame) value
  125650. */
  125651. current: T;
  125652. /**
  125653. * previous (last change) value
  125654. */
  125655. previous: T;
  125656. }
  125657. /**
  125658. * Represents changes in the component between current frame and last values recorded
  125659. */
  125660. export interface IWebXRMotionControllerComponentChanges {
  125661. /**
  125662. * will be populated with previous and current values if axes changed
  125663. */
  125664. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  125665. /**
  125666. * will be populated with previous and current values if pressed changed
  125667. */
  125668. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  125669. /**
  125670. * will be populated with previous and current values if touched changed
  125671. */
  125672. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  125673. /**
  125674. * will be populated with previous and current values if value changed
  125675. */
  125676. value?: IWebXRMotionControllerComponentChangesValues<number>;
  125677. }
  125678. /**
  125679. * This class represents a single component (for example button or thumbstick) of a motion controller
  125680. */
  125681. export class WebXRControllerComponent implements IDisposable {
  125682. /**
  125683. * the id of this component
  125684. */
  125685. id: string;
  125686. /**
  125687. * the type of the component
  125688. */
  125689. type: MotionControllerComponentType;
  125690. private _buttonIndex;
  125691. private _axesIndices;
  125692. private _axes;
  125693. private _changes;
  125694. private _currentValue;
  125695. private _hasChanges;
  125696. private _pressed;
  125697. private _touched;
  125698. /**
  125699. * button component type
  125700. */
  125701. static BUTTON_TYPE: MotionControllerComponentType;
  125702. /**
  125703. * squeeze component type
  125704. */
  125705. static SQUEEZE_TYPE: MotionControllerComponentType;
  125706. /**
  125707. * Thumbstick component type
  125708. */
  125709. static THUMBSTICK_TYPE: MotionControllerComponentType;
  125710. /**
  125711. * Touchpad component type
  125712. */
  125713. static TOUCHPAD_TYPE: MotionControllerComponentType;
  125714. /**
  125715. * trigger component type
  125716. */
  125717. static TRIGGER_TYPE: MotionControllerComponentType;
  125718. /**
  125719. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  125720. * the axes data changes
  125721. */
  125722. onAxisValueChangedObservable: Observable<{
  125723. x: number;
  125724. y: number;
  125725. }>;
  125726. /**
  125727. * Observers registered here will be triggered when the state of a button changes
  125728. * State change is either pressed / touched / value
  125729. */
  125730. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  125731. /**
  125732. * Creates a new component for a motion controller.
  125733. * It is created by the motion controller itself
  125734. *
  125735. * @param id the id of this component
  125736. * @param type the type of the component
  125737. * @param _buttonIndex index in the buttons array of the gamepad
  125738. * @param _axesIndices indices of the values in the axes array of the gamepad
  125739. */
  125740. constructor(
  125741. /**
  125742. * the id of this component
  125743. */
  125744. id: string,
  125745. /**
  125746. * the type of the component
  125747. */
  125748. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  125749. /**
  125750. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  125751. */
  125752. get axes(): IWebXRMotionControllerAxesValue;
  125753. /**
  125754. * Get the changes. Elements will be populated only if they changed with their previous and current value
  125755. */
  125756. get changes(): IWebXRMotionControllerComponentChanges;
  125757. /**
  125758. * Return whether or not the component changed the last frame
  125759. */
  125760. get hasChanges(): boolean;
  125761. /**
  125762. * is the button currently pressed
  125763. */
  125764. get pressed(): boolean;
  125765. /**
  125766. * is the button currently touched
  125767. */
  125768. get touched(): boolean;
  125769. /**
  125770. * Get the current value of this component
  125771. */
  125772. get value(): number;
  125773. /**
  125774. * Dispose this component
  125775. */
  125776. dispose(): void;
  125777. /**
  125778. * Are there axes correlating to this component
  125779. * @return true is axes data is available
  125780. */
  125781. isAxes(): boolean;
  125782. /**
  125783. * Is this component a button (hence - pressable)
  125784. * @returns true if can be pressed
  125785. */
  125786. isButton(): boolean;
  125787. /**
  125788. * update this component using the gamepad object it is in. Called on every frame
  125789. * @param nativeController the native gamepad controller object
  125790. */
  125791. update(nativeController: IMinimalMotionControllerObject): void;
  125792. }
  125793. }
  125794. declare module BABYLON {
  125795. /**
  125796. * Interface used to represent data loading progression
  125797. */
  125798. export interface ISceneLoaderProgressEvent {
  125799. /**
  125800. * Defines if data length to load can be evaluated
  125801. */
  125802. readonly lengthComputable: boolean;
  125803. /**
  125804. * Defines the loaded data length
  125805. */
  125806. readonly loaded: number;
  125807. /**
  125808. * Defines the data length to load
  125809. */
  125810. readonly total: number;
  125811. }
  125812. /**
  125813. * Interface used by SceneLoader plugins to define supported file extensions
  125814. */
  125815. export interface ISceneLoaderPluginExtensions {
  125816. /**
  125817. * Defines the list of supported extensions
  125818. */
  125819. [extension: string]: {
  125820. isBinary: boolean;
  125821. };
  125822. }
  125823. /**
  125824. * Interface used by SceneLoader plugin factory
  125825. */
  125826. export interface ISceneLoaderPluginFactory {
  125827. /**
  125828. * Defines the name of the factory
  125829. */
  125830. name: string;
  125831. /**
  125832. * Function called to create a new plugin
  125833. * @return the new plugin
  125834. */
  125835. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  125836. /**
  125837. * The callback that returns true if the data can be directly loaded.
  125838. * @param data string containing the file data
  125839. * @returns if the data can be loaded directly
  125840. */
  125841. canDirectLoad?(data: string): boolean;
  125842. }
  125843. /**
  125844. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  125845. */
  125846. export interface ISceneLoaderPluginBase {
  125847. /**
  125848. * The friendly name of this plugin.
  125849. */
  125850. name: string;
  125851. /**
  125852. * The file extensions supported by this plugin.
  125853. */
  125854. extensions: string | ISceneLoaderPluginExtensions;
  125855. /**
  125856. * The callback called when loading from a url.
  125857. * @param scene scene loading this url
  125858. * @param url url to load
  125859. * @param onSuccess callback called when the file successfully loads
  125860. * @param onProgress callback called while file is loading (if the server supports this mode)
  125861. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  125862. * @param onError callback called when the file fails to load
  125863. * @returns a file request object
  125864. */
  125865. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125866. /**
  125867. * The callback called when loading from a file object.
  125868. * @param scene scene loading this file
  125869. * @param file defines the file to load
  125870. * @param onSuccess defines the callback to call when data is loaded
  125871. * @param onProgress defines the callback to call during loading process
  125872. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  125873. * @param onError defines the callback to call when an error occurs
  125874. * @returns a file request object
  125875. */
  125876. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125877. /**
  125878. * The callback that returns true if the data can be directly loaded.
  125879. * @param data string containing the file data
  125880. * @returns if the data can be loaded directly
  125881. */
  125882. canDirectLoad?(data: string): boolean;
  125883. /**
  125884. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125885. * @param scene scene loading this data
  125886. * @param data string containing the data
  125887. * @returns data to pass to the plugin
  125888. */
  125889. directLoad?(scene: Scene, data: string): any;
  125890. /**
  125891. * The callback that allows custom handling of the root url based on the response url.
  125892. * @param rootUrl the original root url
  125893. * @param responseURL the response url if available
  125894. * @returns the new root url
  125895. */
  125896. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125897. }
  125898. /**
  125899. * Interface used to define a SceneLoader plugin
  125900. */
  125901. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125902. /**
  125903. * Import meshes into a scene.
  125904. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125905. * @param scene The scene to import into
  125906. * @param data The data to import
  125907. * @param rootUrl The root url for scene and resources
  125908. * @param meshes The meshes array to import into
  125909. * @param particleSystems The particle systems array to import into
  125910. * @param skeletons The skeletons array to import into
  125911. * @param onError The callback when import fails
  125912. * @returns True if successful or false otherwise
  125913. */
  125914. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125915. /**
  125916. * Load into a scene.
  125917. * @param scene The scene to load into
  125918. * @param data The data to import
  125919. * @param rootUrl The root url for scene and resources
  125920. * @param onError The callback when import fails
  125921. * @returns True if successful or false otherwise
  125922. */
  125923. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125924. /**
  125925. * Load into an asset container.
  125926. * @param scene The scene to load into
  125927. * @param data The data to import
  125928. * @param rootUrl The root url for scene and resources
  125929. * @param onError The callback when import fails
  125930. * @returns The loaded asset container
  125931. */
  125932. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125933. }
  125934. /**
  125935. * Interface used to define an async SceneLoader plugin
  125936. */
  125937. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125938. /**
  125939. * Import meshes into a scene.
  125940. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125941. * @param scene The scene to import into
  125942. * @param data The data to import
  125943. * @param rootUrl The root url for scene and resources
  125944. * @param onProgress The callback when the load progresses
  125945. * @param fileName Defines the name of the file to load
  125946. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125947. */
  125948. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125949. meshes: AbstractMesh[];
  125950. particleSystems: IParticleSystem[];
  125951. skeletons: Skeleton[];
  125952. animationGroups: AnimationGroup[];
  125953. }>;
  125954. /**
  125955. * Load into a scene.
  125956. * @param scene The scene to load into
  125957. * @param data The data to import
  125958. * @param rootUrl The root url for scene and resources
  125959. * @param onProgress The callback when the load progresses
  125960. * @param fileName Defines the name of the file to load
  125961. * @returns Nothing
  125962. */
  125963. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125964. /**
  125965. * Load into an asset container.
  125966. * @param scene The scene to load into
  125967. * @param data The data to import
  125968. * @param rootUrl The root url for scene and resources
  125969. * @param onProgress The callback when the load progresses
  125970. * @param fileName Defines the name of the file to load
  125971. * @returns The loaded asset container
  125972. */
  125973. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125974. }
  125975. /**
  125976. * Mode that determines how to handle old animation groups before loading new ones.
  125977. */
  125978. export enum SceneLoaderAnimationGroupLoadingMode {
  125979. /**
  125980. * Reset all old animations to initial state then dispose them.
  125981. */
  125982. Clean = 0,
  125983. /**
  125984. * Stop all old animations.
  125985. */
  125986. Stop = 1,
  125987. /**
  125988. * Restart old animations from first frame.
  125989. */
  125990. Sync = 2,
  125991. /**
  125992. * Old animations remains untouched.
  125993. */
  125994. NoSync = 3
  125995. }
  125996. /**
  125997. * Class used to load scene from various file formats using registered plugins
  125998. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125999. */
  126000. export class SceneLoader {
  126001. /**
  126002. * No logging while loading
  126003. */
  126004. static readonly NO_LOGGING: number;
  126005. /**
  126006. * Minimal logging while loading
  126007. */
  126008. static readonly MINIMAL_LOGGING: number;
  126009. /**
  126010. * Summary logging while loading
  126011. */
  126012. static readonly SUMMARY_LOGGING: number;
  126013. /**
  126014. * Detailled logging while loading
  126015. */
  126016. static readonly DETAILED_LOGGING: number;
  126017. /**
  126018. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126019. */
  126020. static get ForceFullSceneLoadingForIncremental(): boolean;
  126021. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126022. /**
  126023. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126024. */
  126025. static get ShowLoadingScreen(): boolean;
  126026. static set ShowLoadingScreen(value: boolean);
  126027. /**
  126028. * Defines the current logging level (while loading the scene)
  126029. * @ignorenaming
  126030. */
  126031. static get loggingLevel(): number;
  126032. static set loggingLevel(value: number);
  126033. /**
  126034. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126035. */
  126036. static get CleanBoneMatrixWeights(): boolean;
  126037. static set CleanBoneMatrixWeights(value: boolean);
  126038. /**
  126039. * Event raised when a plugin is used to load a scene
  126040. */
  126041. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126042. private static _registeredPlugins;
  126043. private static _showingLoadingScreen;
  126044. private static _getDefaultPlugin;
  126045. private static _getPluginForExtension;
  126046. private static _getPluginForDirectLoad;
  126047. private static _getPluginForFilename;
  126048. private static _getDirectLoad;
  126049. private static _loadData;
  126050. private static _getFileInfo;
  126051. /**
  126052. * Gets a plugin that can load the given extension
  126053. * @param extension defines the extension to load
  126054. * @returns a plugin or null if none works
  126055. */
  126056. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126057. /**
  126058. * Gets a boolean indicating that the given extension can be loaded
  126059. * @param extension defines the extension to load
  126060. * @returns true if the extension is supported
  126061. */
  126062. static IsPluginForExtensionAvailable(extension: string): boolean;
  126063. /**
  126064. * Adds a new plugin to the list of registered plugins
  126065. * @param plugin defines the plugin to add
  126066. */
  126067. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126068. /**
  126069. * Import meshes into a scene
  126070. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126071. * @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)
  126072. * @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)
  126073. * @param scene the instance of BABYLON.Scene to append to
  126074. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126075. * @param onProgress a callback with a progress event for each file being loaded
  126076. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126077. * @param pluginExtension the extension used to determine the plugin
  126078. * @returns The loaded plugin
  126079. */
  126080. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126081. /**
  126082. * Import meshes into a scene
  126083. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126084. * @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)
  126085. * @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)
  126086. * @param scene the instance of BABYLON.Scene to append to
  126087. * @param onProgress a callback with a progress event for each file being loaded
  126088. * @param pluginExtension the extension used to determine the plugin
  126089. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126090. */
  126091. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126092. meshes: AbstractMesh[];
  126093. particleSystems: IParticleSystem[];
  126094. skeletons: Skeleton[];
  126095. animationGroups: AnimationGroup[];
  126096. }>;
  126097. /**
  126098. * Load a scene
  126099. * @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)
  126100. * @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)
  126101. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126102. * @param onSuccess a callback with the scene when import succeeds
  126103. * @param onProgress a callback with a progress event for each file being loaded
  126104. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126105. * @param pluginExtension the extension used to determine the plugin
  126106. * @returns The loaded plugin
  126107. */
  126108. 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>;
  126109. /**
  126110. * Load a scene
  126111. * @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)
  126112. * @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)
  126113. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126114. * @param onProgress a callback with a progress event for each file being loaded
  126115. * @param pluginExtension the extension used to determine the plugin
  126116. * @returns The loaded scene
  126117. */
  126118. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126119. /**
  126120. * Append a scene
  126121. * @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)
  126122. * @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)
  126123. * @param scene is the instance of BABYLON.Scene to append to
  126124. * @param onSuccess a callback with the scene when import succeeds
  126125. * @param onProgress a callback with a progress event for each file being loaded
  126126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126127. * @param pluginExtension the extension used to determine the plugin
  126128. * @returns The loaded plugin
  126129. */
  126130. 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>;
  126131. /**
  126132. * Append a scene
  126133. * @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)
  126134. * @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)
  126135. * @param scene is the instance of BABYLON.Scene to append to
  126136. * @param onProgress a callback with a progress event for each file being loaded
  126137. * @param pluginExtension the extension used to determine the plugin
  126138. * @returns The given scene
  126139. */
  126140. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126141. /**
  126142. * Load a scene into an asset container
  126143. * @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)
  126144. * @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)
  126145. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126146. * @param onSuccess a callback with the scene when import succeeds
  126147. * @param onProgress a callback with a progress event for each file being loaded
  126148. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126149. * @param pluginExtension the extension used to determine the plugin
  126150. * @returns The loaded plugin
  126151. */
  126152. 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>;
  126153. /**
  126154. * Load a scene into an asset container
  126155. * @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)
  126156. * @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)
  126157. * @param scene is the instance of Scene to append to
  126158. * @param onProgress a callback with a progress event for each file being loaded
  126159. * @param pluginExtension the extension used to determine the plugin
  126160. * @returns The loaded asset container
  126161. */
  126162. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126163. /**
  126164. * Import animations from a file into a scene
  126165. * @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)
  126166. * @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)
  126167. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126168. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126169. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126170. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126171. * @param onSuccess a callback with the scene when import succeeds
  126172. * @param onProgress a callback with a progress event for each file being loaded
  126173. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126174. * @param pluginExtension the extension used to determine the plugin
  126175. */
  126176. 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;
  126177. /**
  126178. * Import animations from a file into a scene
  126179. * @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)
  126180. * @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)
  126181. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126182. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126183. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126184. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126185. * @param onSuccess a callback with the scene when import succeeds
  126186. * @param onProgress a callback with a progress event for each file being loaded
  126187. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126188. * @param pluginExtension the extension used to determine the plugin
  126189. * @returns the updated scene with imported animations
  126190. */
  126191. 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>;
  126192. }
  126193. }
  126194. declare module BABYLON {
  126195. /**
  126196. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126197. */
  126198. export type MotionControllerHandedness = "none" | "left" | "right";
  126199. /**
  126200. * The type of components available in motion controllers.
  126201. * This is not the name of the component.
  126202. */
  126203. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126204. /**
  126205. * The state of a controller component
  126206. */
  126207. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126208. /**
  126209. * The schema of motion controller layout.
  126210. * No object will be initialized using this interface
  126211. * This is used just to define the profile.
  126212. */
  126213. export interface IMotionControllerLayout {
  126214. /**
  126215. * Path to load the assets. Usually relative to the base path
  126216. */
  126217. assetPath: string;
  126218. /**
  126219. * Available components (unsorted)
  126220. */
  126221. components: {
  126222. /**
  126223. * A map of component Ids
  126224. */
  126225. [componentId: string]: {
  126226. /**
  126227. * The type of input the component outputs
  126228. */
  126229. type: MotionControllerComponentType;
  126230. /**
  126231. * The indices of this component in the gamepad object
  126232. */
  126233. gamepadIndices: {
  126234. /**
  126235. * Index of button
  126236. */
  126237. button?: number;
  126238. /**
  126239. * If available, index of x-axis
  126240. */
  126241. xAxis?: number;
  126242. /**
  126243. * If available, index of y-axis
  126244. */
  126245. yAxis?: number;
  126246. };
  126247. /**
  126248. * The mesh's root node name
  126249. */
  126250. rootNodeName: string;
  126251. /**
  126252. * Animation definitions for this model
  126253. */
  126254. visualResponses: {
  126255. [stateKey: string]: {
  126256. /**
  126257. * What property will be animated
  126258. */
  126259. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126260. /**
  126261. * What states influence this visual response
  126262. */
  126263. states: MotionControllerComponentStateType[];
  126264. /**
  126265. * Type of animation - movement or visibility
  126266. */
  126267. valueNodeProperty: "transform" | "visibility";
  126268. /**
  126269. * Base node name to move. Its position will be calculated according to the min and max nodes
  126270. */
  126271. valueNodeName?: string;
  126272. /**
  126273. * Minimum movement node
  126274. */
  126275. minNodeName?: string;
  126276. /**
  126277. * Max movement node
  126278. */
  126279. maxNodeName?: string;
  126280. };
  126281. };
  126282. /**
  126283. * If touch enabled, what is the name of node to display user feedback
  126284. */
  126285. touchPointNodeName?: string;
  126286. };
  126287. };
  126288. /**
  126289. * Is it xr standard mapping or not
  126290. */
  126291. gamepadMapping: "" | "xr-standard";
  126292. /**
  126293. * Base root node of this entire model
  126294. */
  126295. rootNodeName: string;
  126296. /**
  126297. * Defines the main button component id
  126298. */
  126299. selectComponentId: string;
  126300. }
  126301. /**
  126302. * A definition for the layout map in the input profile
  126303. */
  126304. export interface IMotionControllerLayoutMap {
  126305. /**
  126306. * Layouts with handedness type as a key
  126307. */
  126308. [handedness: string]: IMotionControllerLayout;
  126309. }
  126310. /**
  126311. * The XR Input profile schema
  126312. * Profiles can be found here:
  126313. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126314. */
  126315. export interface IMotionControllerProfile {
  126316. /**
  126317. * fallback profiles for this profileId
  126318. */
  126319. fallbackProfileIds: string[];
  126320. /**
  126321. * The layout map, with handedness as key
  126322. */
  126323. layouts: IMotionControllerLayoutMap;
  126324. /**
  126325. * The id of this profile
  126326. * correlates to the profile(s) in the xrInput.profiles array
  126327. */
  126328. profileId: string;
  126329. }
  126330. /**
  126331. * A helper-interface for the 3 meshes needed for controller button animation
  126332. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126333. */
  126334. export interface IMotionControllerButtonMeshMap {
  126335. /**
  126336. * the mesh that defines the pressed value mesh position.
  126337. * This is used to find the max-position of this button
  126338. */
  126339. pressedMesh: AbstractMesh;
  126340. /**
  126341. * the mesh that defines the unpressed value mesh position.
  126342. * This is used to find the min (or initial) position of this button
  126343. */
  126344. unpressedMesh: AbstractMesh;
  126345. /**
  126346. * The mesh that will be changed when value changes
  126347. */
  126348. valueMesh: AbstractMesh;
  126349. }
  126350. /**
  126351. * A helper-interface for the 3 meshes needed for controller axis animation.
  126352. * This will be expanded when touchpad animations are fully supported
  126353. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126354. */
  126355. export interface IMotionControllerMeshMap {
  126356. /**
  126357. * the mesh that defines the maximum value mesh position.
  126358. */
  126359. maxMesh?: AbstractMesh;
  126360. /**
  126361. * the mesh that defines the minimum value mesh position.
  126362. */
  126363. minMesh?: AbstractMesh;
  126364. /**
  126365. * The mesh that will be changed when axis value changes
  126366. */
  126367. valueMesh: AbstractMesh;
  126368. }
  126369. /**
  126370. * The elements needed for change-detection of the gamepad objects in motion controllers
  126371. */
  126372. export interface IMinimalMotionControllerObject {
  126373. /**
  126374. * Available axes of this controller
  126375. */
  126376. axes: number[];
  126377. /**
  126378. * An array of available buttons
  126379. */
  126380. buttons: Array<{
  126381. /**
  126382. * Value of the button/trigger
  126383. */
  126384. value: number;
  126385. /**
  126386. * If the button/trigger is currently touched
  126387. */
  126388. touched: boolean;
  126389. /**
  126390. * If the button/trigger is currently pressed
  126391. */
  126392. pressed: boolean;
  126393. }>;
  126394. /**
  126395. * EXPERIMENTAL haptic support.
  126396. */
  126397. hapticActuators?: Array<{
  126398. pulse: (value: number, duration: number) => Promise<boolean>;
  126399. }>;
  126400. }
  126401. /**
  126402. * An Abstract Motion controller
  126403. * This class receives an xrInput and a profile layout and uses those to initialize the components
  126404. * Each component has an observable to check for changes in value and state
  126405. */
  126406. export abstract class WebXRAbstractMotionController implements IDisposable {
  126407. protected scene: Scene;
  126408. protected layout: IMotionControllerLayout;
  126409. /**
  126410. * The gamepad object correlating to this controller
  126411. */
  126412. gamepadObject: IMinimalMotionControllerObject;
  126413. /**
  126414. * handedness (left/right/none) of this controller
  126415. */
  126416. handedness: MotionControllerHandedness;
  126417. private _initComponent;
  126418. private _modelReady;
  126419. /**
  126420. * A map of components (WebXRControllerComponent) in this motion controller
  126421. * Components have a ComponentType and can also have both button and axis definitions
  126422. */
  126423. readonly components: {
  126424. [id: string]: WebXRControllerComponent;
  126425. };
  126426. /**
  126427. * Disable the model's animation. Can be set at any time.
  126428. */
  126429. disableAnimation: boolean;
  126430. /**
  126431. * Observers registered here will be triggered when the model of this controller is done loading
  126432. */
  126433. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  126434. /**
  126435. * The profile id of this motion controller
  126436. */
  126437. abstract profileId: string;
  126438. /**
  126439. * The root mesh of the model. It is null if the model was not yet initialized
  126440. */
  126441. rootMesh: Nullable<AbstractMesh>;
  126442. /**
  126443. * constructs a new abstract motion controller
  126444. * @param scene the scene to which the model of the controller will be added
  126445. * @param layout The profile layout to load
  126446. * @param gamepadObject The gamepad object correlating to this controller
  126447. * @param handedness handedness (left/right/none) of this controller
  126448. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  126449. */
  126450. constructor(scene: Scene, layout: IMotionControllerLayout,
  126451. /**
  126452. * The gamepad object correlating to this controller
  126453. */
  126454. gamepadObject: IMinimalMotionControllerObject,
  126455. /**
  126456. * handedness (left/right/none) of this controller
  126457. */
  126458. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  126459. /**
  126460. * Dispose this controller, the model mesh and all its components
  126461. */
  126462. dispose(): void;
  126463. /**
  126464. * Returns all components of specific type
  126465. * @param type the type to search for
  126466. * @return an array of components with this type
  126467. */
  126468. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  126469. /**
  126470. * get a component based an its component id as defined in layout.components
  126471. * @param id the id of the component
  126472. * @returns the component correlates to the id or undefined if not found
  126473. */
  126474. getComponent(id: string): WebXRControllerComponent;
  126475. /**
  126476. * Get the list of components available in this motion controller
  126477. * @returns an array of strings correlating to available components
  126478. */
  126479. getComponentIds(): string[];
  126480. /**
  126481. * Get the first component of specific type
  126482. * @param type type of component to find
  126483. * @return a controller component or null if not found
  126484. */
  126485. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  126486. /**
  126487. * Get the main (Select) component of this controller as defined in the layout
  126488. * @returns the main component of this controller
  126489. */
  126490. getMainComponent(): WebXRControllerComponent;
  126491. /**
  126492. * Loads the model correlating to this controller
  126493. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  126494. * @returns A promise fulfilled with the result of the model loading
  126495. */
  126496. loadModel(): Promise<boolean>;
  126497. /**
  126498. * Update this model using the current XRFrame
  126499. * @param xrFrame the current xr frame to use and update the model
  126500. */
  126501. updateFromXRFrame(xrFrame: XRFrame): void;
  126502. /**
  126503. * Backwards compatibility due to a deeply-integrated typo
  126504. */
  126505. get handness(): XREye;
  126506. /**
  126507. * Pulse (vibrate) this controller
  126508. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  126509. * Consecutive calls to this function will cancel the last pulse call
  126510. *
  126511. * @param value the strength of the pulse in 0.0...1.0 range
  126512. * @param duration Duration of the pulse in milliseconds
  126513. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  126514. * @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
  126515. */
  126516. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  126517. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126518. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126519. /**
  126520. * Moves the axis on the controller mesh based on its current state
  126521. * @param axis the index of the axis
  126522. * @param axisValue the value of the axis which determines the meshes new position
  126523. * @hidden
  126524. */
  126525. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  126526. /**
  126527. * Update the model itself with the current frame data
  126528. * @param xrFrame the frame to use for updating the model mesh
  126529. */
  126530. protected updateModel(xrFrame: XRFrame): void;
  126531. /**
  126532. * Get the filename and path for this controller's model
  126533. * @returns a map of filename and path
  126534. */
  126535. protected abstract _getFilenameAndPath(): {
  126536. filename: string;
  126537. path: string;
  126538. };
  126539. /**
  126540. * This function is called before the mesh is loaded. It checks for loading constraints.
  126541. * For example, this function can check if the GLB loader is available
  126542. * If this function returns false, the generic controller will be loaded instead
  126543. * @returns Is the client ready to load the mesh
  126544. */
  126545. protected abstract _getModelLoadingConstraints(): boolean;
  126546. /**
  126547. * This function will be called after the model was successfully loaded and can be used
  126548. * for mesh transformations before it is available for the user
  126549. * @param meshes the loaded meshes
  126550. */
  126551. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  126552. /**
  126553. * Set the root mesh for this controller. Important for the WebXR controller class
  126554. * @param meshes the loaded meshes
  126555. */
  126556. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  126557. /**
  126558. * A function executed each frame that updates the mesh (if needed)
  126559. * @param xrFrame the current xrFrame
  126560. */
  126561. protected abstract _updateModel(xrFrame: XRFrame): void;
  126562. private _getGenericFilenameAndPath;
  126563. private _getGenericParentMesh;
  126564. }
  126565. }
  126566. declare module BABYLON {
  126567. /**
  126568. * A generic trigger-only motion controller for WebXR
  126569. */
  126570. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  126571. /**
  126572. * Static version of the profile id of this controller
  126573. */
  126574. static ProfileId: string;
  126575. profileId: string;
  126576. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  126577. protected _getFilenameAndPath(): {
  126578. filename: string;
  126579. path: string;
  126580. };
  126581. protected _getModelLoadingConstraints(): boolean;
  126582. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  126583. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126584. protected _updateModel(): void;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * Class containing static functions to help procedurally build meshes
  126590. */
  126591. export class SphereBuilder {
  126592. /**
  126593. * Creates a sphere mesh
  126594. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126595. * * 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`)
  126596. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126597. * * 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
  126598. * * 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)
  126599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126602. * @param name defines the name of the mesh
  126603. * @param options defines the options used to create the mesh
  126604. * @param scene defines the hosting scene
  126605. * @returns the sphere mesh
  126606. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126607. */
  126608. static CreateSphere(name: string, options: {
  126609. segments?: number;
  126610. diameter?: number;
  126611. diameterX?: number;
  126612. diameterY?: number;
  126613. diameterZ?: number;
  126614. arc?: number;
  126615. slice?: number;
  126616. sideOrientation?: number;
  126617. frontUVs?: Vector4;
  126618. backUVs?: Vector4;
  126619. updatable?: boolean;
  126620. }, scene?: Nullable<Scene>): Mesh;
  126621. }
  126622. }
  126623. declare module BABYLON {
  126624. /**
  126625. * A profiled motion controller has its profile loaded from an online repository.
  126626. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  126627. */
  126628. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  126629. private _repositoryUrl;
  126630. private _buttonMeshMapping;
  126631. private _touchDots;
  126632. /**
  126633. * The profile ID of this controller. Will be populated when the controller initializes.
  126634. */
  126635. profileId: string;
  126636. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  126637. dispose(): void;
  126638. protected _getFilenameAndPath(): {
  126639. filename: string;
  126640. path: string;
  126641. };
  126642. protected _getModelLoadingConstraints(): boolean;
  126643. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  126644. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126645. protected _updateModel(_xrFrame: XRFrame): void;
  126646. }
  126647. }
  126648. declare module BABYLON {
  126649. /**
  126650. * A construction function type to create a new controller based on an xrInput object
  126651. */
  126652. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  126653. /**
  126654. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  126655. *
  126656. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  126657. * it should be replaced with auto-loaded controllers.
  126658. *
  126659. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  126660. */
  126661. export class WebXRMotionControllerManager {
  126662. private static _AvailableControllers;
  126663. private static _Fallbacks;
  126664. private static _ProfileLoadingPromises;
  126665. private static _ProfilesList;
  126666. /**
  126667. * The base URL of the online controller repository. Can be changed at any time.
  126668. */
  126669. static BaseRepositoryUrl: string;
  126670. /**
  126671. * Which repository gets priority - local or online
  126672. */
  126673. static PrioritizeOnlineRepository: boolean;
  126674. /**
  126675. * Use the online repository, or use only locally-defined controllers
  126676. */
  126677. static UseOnlineRepository: boolean;
  126678. /**
  126679. * Clear the cache used for profile loading and reload when requested again
  126680. */
  126681. static ClearProfilesCache(): void;
  126682. /**
  126683. * Register the default fallbacks.
  126684. * This function is called automatically when this file is imported.
  126685. */
  126686. static DefaultFallbacks(): void;
  126687. /**
  126688. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  126689. * @param profileId the profile to which a fallback needs to be found
  126690. * @return an array with corresponding fallback profiles
  126691. */
  126692. static FindFallbackWithProfileId(profileId: string): string[];
  126693. /**
  126694. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  126695. * The order of search:
  126696. *
  126697. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  126698. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  126699. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  126700. * 4) return the generic trigger controller if none were found
  126701. *
  126702. * @param xrInput the xrInput to which a new controller is initialized
  126703. * @param scene the scene to which the model will be added
  126704. * @param forceProfile force a certain profile for this controller
  126705. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  126706. */
  126707. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  126708. /**
  126709. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  126710. *
  126711. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  126712. *
  126713. * @param type the profile type to register
  126714. * @param constructFunction the function to be called when loading this profile
  126715. */
  126716. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  126717. /**
  126718. * Register a fallback to a specific profile.
  126719. * @param profileId the profileId that will receive the fallbacks
  126720. * @param fallbacks A list of fallback profiles
  126721. */
  126722. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  126723. /**
  126724. * Will update the list of profiles available in the repository
  126725. * @return a promise that resolves to a map of profiles available online
  126726. */
  126727. static UpdateProfilesList(): Promise<{
  126728. [profile: string]: string;
  126729. }>;
  126730. private static _LoadProfileFromRepository;
  126731. private static _LoadProfilesFromAvailableControllers;
  126732. }
  126733. }
  126734. declare module BABYLON {
  126735. /**
  126736. * Configuration options for the WebXR controller creation
  126737. */
  126738. export interface IWebXRControllerOptions {
  126739. /**
  126740. * Should the controller mesh be animated when a user interacts with it
  126741. * The pressed buttons / thumbstick and touchpad animations will be disabled
  126742. */
  126743. disableMotionControllerAnimation?: boolean;
  126744. /**
  126745. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  126746. */
  126747. doNotLoadControllerMesh?: boolean;
  126748. /**
  126749. * Force a specific controller type for this controller.
  126750. * This can be used when creating your own profile or when testing different controllers
  126751. */
  126752. forceControllerProfile?: string;
  126753. /**
  126754. * Defines a rendering group ID for meshes that will be loaded.
  126755. * This is for the default controllers only.
  126756. */
  126757. renderingGroupId?: number;
  126758. }
  126759. /**
  126760. * Represents an XR controller
  126761. */
  126762. export class WebXRInputSource {
  126763. private _scene;
  126764. /** The underlying input source for the controller */
  126765. inputSource: XRInputSource;
  126766. private _options;
  126767. private _tmpVector;
  126768. private _uniqueId;
  126769. /**
  126770. * 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
  126771. */
  126772. grip?: AbstractMesh;
  126773. /**
  126774. * If available, this is the gamepad object related to this controller.
  126775. * Using this object it is possible to get click events and trackpad changes of the
  126776. * webxr controller that is currently being used.
  126777. */
  126778. motionController?: WebXRAbstractMotionController;
  126779. /**
  126780. * Event that fires when the controller is removed/disposed.
  126781. * The object provided as event data is this controller, after associated assets were disposed.
  126782. * uniqueId is still available.
  126783. */
  126784. onDisposeObservable: Observable<WebXRInputSource>;
  126785. /**
  126786. * Will be triggered when the mesh associated with the motion controller is done loading.
  126787. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  126788. * A shortened version of controller -> motion controller -> on mesh loaded.
  126789. */
  126790. onMeshLoadedObservable: Observable<AbstractMesh>;
  126791. /**
  126792. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  126793. */
  126794. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  126795. /**
  126796. * Pointer which can be used to select objects or attach a visible laser to
  126797. */
  126798. pointer: AbstractMesh;
  126799. /**
  126800. * Creates the input source object
  126801. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  126802. * @param _scene the scene which the controller should be associated to
  126803. * @param inputSource the underlying input source for the controller
  126804. * @param _options options for this controller creation
  126805. */
  126806. constructor(_scene: Scene,
  126807. /** The underlying input source for the controller */
  126808. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  126809. /**
  126810. * Get this controllers unique id
  126811. */
  126812. get uniqueId(): string;
  126813. /**
  126814. * Disposes of the object
  126815. */
  126816. dispose(): void;
  126817. /**
  126818. * Gets a world space ray coming from the pointer or grip
  126819. * @param result the resulting ray
  126820. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  126821. */
  126822. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  126823. /**
  126824. * Updates the controller pose based on the given XRFrame
  126825. * @param xrFrame xr frame to update the pose with
  126826. * @param referenceSpace reference space to use
  126827. */
  126828. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  126829. }
  126830. }
  126831. declare module BABYLON {
  126832. /**
  126833. * The schema for initialization options of the XR Input class
  126834. */
  126835. export interface IWebXRInputOptions {
  126836. /**
  126837. * If set to true no model will be automatically loaded
  126838. */
  126839. doNotLoadControllerMeshes?: boolean;
  126840. /**
  126841. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  126842. * If not found, the xr input profile data will be used.
  126843. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  126844. */
  126845. forceInputProfile?: string;
  126846. /**
  126847. * Do not send a request to the controller repository to load the profile.
  126848. *
  126849. * Instead, use the controllers available in babylon itself.
  126850. */
  126851. disableOnlineControllerRepository?: boolean;
  126852. /**
  126853. * A custom URL for the controllers repository
  126854. */
  126855. customControllersRepositoryURL?: string;
  126856. /**
  126857. * Should the controller model's components not move according to the user input
  126858. */
  126859. disableControllerAnimation?: boolean;
  126860. /**
  126861. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  126862. */
  126863. controllerOptions?: IWebXRControllerOptions;
  126864. }
  126865. /**
  126866. * XR input used to track XR inputs such as controllers/rays
  126867. */
  126868. export class WebXRInput implements IDisposable {
  126869. /**
  126870. * the xr session manager for this session
  126871. */
  126872. xrSessionManager: WebXRSessionManager;
  126873. /**
  126874. * the WebXR camera for this session. Mainly used for teleportation
  126875. */
  126876. xrCamera: WebXRCamera;
  126877. private readonly options;
  126878. /**
  126879. * XR controllers being tracked
  126880. */
  126881. controllers: Array<WebXRInputSource>;
  126882. private _frameObserver;
  126883. private _sessionEndedObserver;
  126884. private _sessionInitObserver;
  126885. /**
  126886. * Event when a controller has been connected/added
  126887. */
  126888. onControllerAddedObservable: Observable<WebXRInputSource>;
  126889. /**
  126890. * Event when a controller has been removed/disconnected
  126891. */
  126892. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126893. /**
  126894. * Initializes the WebXRInput
  126895. * @param xrSessionManager the xr session manager for this session
  126896. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126897. * @param options = initialization options for this xr input
  126898. */
  126899. constructor(
  126900. /**
  126901. * the xr session manager for this session
  126902. */
  126903. xrSessionManager: WebXRSessionManager,
  126904. /**
  126905. * the WebXR camera for this session. Mainly used for teleportation
  126906. */
  126907. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126908. private _onInputSourcesChange;
  126909. private _addAndRemoveControllers;
  126910. /**
  126911. * Disposes of the object
  126912. */
  126913. dispose(): void;
  126914. }
  126915. }
  126916. declare module BABYLON {
  126917. /**
  126918. * This is the base class for all WebXR features.
  126919. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126920. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126921. */
  126922. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126923. protected _xrSessionManager: WebXRSessionManager;
  126924. private _attached;
  126925. private _removeOnDetach;
  126926. /**
  126927. * Should auto-attach be disabled?
  126928. */
  126929. disableAutoAttach: boolean;
  126930. /**
  126931. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  126932. */
  126933. xrNativeFeatureName: string;
  126934. /**
  126935. * Construct a new (abstract) WebXR feature
  126936. * @param _xrSessionManager the xr session manager for this feature
  126937. */
  126938. constructor(_xrSessionManager: WebXRSessionManager);
  126939. /**
  126940. * Is this feature attached
  126941. */
  126942. get attached(): boolean;
  126943. /**
  126944. * attach this feature
  126945. *
  126946. * @param force should attachment be forced (even when already attached)
  126947. * @returns true if successful, false is failed or already attached
  126948. */
  126949. attach(force?: boolean): boolean;
  126950. /**
  126951. * detach this feature.
  126952. *
  126953. * @returns true if successful, false if failed or already detached
  126954. */
  126955. detach(): boolean;
  126956. /**
  126957. * Dispose this feature and all of the resources attached
  126958. */
  126959. dispose(): void;
  126960. /**
  126961. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126962. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126963. *
  126964. * @returns whether or not the feature is compatible in this environment
  126965. */
  126966. isCompatible(): boolean;
  126967. /**
  126968. * This is used to register callbacks that will automatically be removed when detach is called.
  126969. * @param observable the observable to which the observer will be attached
  126970. * @param callback the callback to register
  126971. */
  126972. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126973. /**
  126974. * Code in this function will be executed on each xrFrame received from the browser.
  126975. * This function will not execute after the feature is detached.
  126976. * @param _xrFrame the current frame
  126977. */
  126978. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126979. }
  126980. }
  126981. declare module BABYLON {
  126982. /**
  126983. * Renders a layer on top of an existing scene
  126984. */
  126985. export class UtilityLayerRenderer implements IDisposable {
  126986. /** the original scene that will be rendered on top of */
  126987. originalScene: Scene;
  126988. private _pointerCaptures;
  126989. private _lastPointerEvents;
  126990. private static _DefaultUtilityLayer;
  126991. private static _DefaultKeepDepthUtilityLayer;
  126992. private _sharedGizmoLight;
  126993. private _renderCamera;
  126994. /**
  126995. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126996. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126997. * @returns the camera that is used when rendering the utility layer
  126998. */
  126999. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127000. /**
  127001. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127002. * @param cam the camera that should be used when rendering the utility layer
  127003. */
  127004. setRenderCamera(cam: Nullable<Camera>): void;
  127005. /**
  127006. * @hidden
  127007. * Light which used by gizmos to get light shading
  127008. */
  127009. _getSharedGizmoLight(): HemisphericLight;
  127010. /**
  127011. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127012. */
  127013. pickUtilitySceneFirst: boolean;
  127014. /**
  127015. * 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)
  127016. */
  127017. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127018. /**
  127019. * 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)
  127020. */
  127021. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127022. /**
  127023. * The scene that is rendered on top of the original scene
  127024. */
  127025. utilityLayerScene: Scene;
  127026. /**
  127027. * If the utility layer should automatically be rendered on top of existing scene
  127028. */
  127029. shouldRender: boolean;
  127030. /**
  127031. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127032. */
  127033. onlyCheckPointerDownEvents: boolean;
  127034. /**
  127035. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127036. */
  127037. processAllEvents: boolean;
  127038. /**
  127039. * Observable raised when the pointer move from the utility layer scene to the main scene
  127040. */
  127041. onPointerOutObservable: Observable<number>;
  127042. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127043. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127044. private _afterRenderObserver;
  127045. private _sceneDisposeObserver;
  127046. private _originalPointerObserver;
  127047. /**
  127048. * Instantiates a UtilityLayerRenderer
  127049. * @param originalScene the original scene that will be rendered on top of
  127050. * @param handleEvents boolean indicating if the utility layer should handle events
  127051. */
  127052. constructor(
  127053. /** the original scene that will be rendered on top of */
  127054. originalScene: Scene, handleEvents?: boolean);
  127055. private _notifyObservers;
  127056. /**
  127057. * Renders the utility layers scene on top of the original scene
  127058. */
  127059. render(): void;
  127060. /**
  127061. * Disposes of the renderer
  127062. */
  127063. dispose(): void;
  127064. private _updateCamera;
  127065. }
  127066. }
  127067. declare module BABYLON {
  127068. /**
  127069. * Options interface for the pointer selection module
  127070. */
  127071. export interface IWebXRControllerPointerSelectionOptions {
  127072. /**
  127073. * if provided, this scene will be used to render meshes.
  127074. */
  127075. customUtilityLayerScene?: Scene;
  127076. /**
  127077. * 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)
  127078. * If not disabled, the last picked point will be used to execute a pointer up event
  127079. * If disabled, pointer up event will be triggered right after the pointer down event.
  127080. * Used in screen and gaze target ray mode only
  127081. */
  127082. disablePointerUpOnTouchOut: boolean;
  127083. /**
  127084. * For gaze mode (time to select instead of press)
  127085. */
  127086. forceGazeMode: boolean;
  127087. /**
  127088. * 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
  127089. * to start a new countdown to the pointer down event.
  127090. * Defaults to 1.
  127091. */
  127092. gazeModePointerMovedFactor?: number;
  127093. /**
  127094. * Different button type to use instead of the main component
  127095. */
  127096. overrideButtonId?: string;
  127097. /**
  127098. * use this rendering group id for the meshes (optional)
  127099. */
  127100. renderingGroupId?: number;
  127101. /**
  127102. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127103. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127104. * 3000 means 3 seconds between pointing at something and selecting it
  127105. */
  127106. timeToSelect?: number;
  127107. /**
  127108. * Should meshes created here be added to a utility layer or the main scene
  127109. */
  127110. useUtilityLayer?: boolean;
  127111. /**
  127112. * the xr input to use with this pointer selection
  127113. */
  127114. xrInput: WebXRInput;
  127115. }
  127116. /**
  127117. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127118. */
  127119. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127120. private readonly _options;
  127121. private static _idCounter;
  127122. private _attachController;
  127123. private _controllers;
  127124. private _scene;
  127125. private _tmpVectorForPickCompare;
  127126. /**
  127127. * The module's name
  127128. */
  127129. static readonly Name: string;
  127130. /**
  127131. * The (Babylon) version of this module.
  127132. * This is an integer representing the implementation version.
  127133. * This number does not correspond to the WebXR specs version
  127134. */
  127135. static readonly Version: number;
  127136. /**
  127137. * Disable lighting on the laser pointer (so it will always be visible)
  127138. */
  127139. disablePointerLighting: boolean;
  127140. /**
  127141. * Disable lighting on the selection mesh (so it will always be visible)
  127142. */
  127143. disableSelectionMeshLighting: boolean;
  127144. /**
  127145. * Should the laser pointer be displayed
  127146. */
  127147. displayLaserPointer: boolean;
  127148. /**
  127149. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127150. */
  127151. displaySelectionMesh: boolean;
  127152. /**
  127153. * This color will be set to the laser pointer when selection is triggered
  127154. */
  127155. laserPointerPickedColor: Color3;
  127156. /**
  127157. * Default color of the laser pointer
  127158. */
  127159. laserPointerDefaultColor: Color3;
  127160. /**
  127161. * default color of the selection ring
  127162. */
  127163. selectionMeshDefaultColor: Color3;
  127164. /**
  127165. * This color will be applied to the selection ring when selection is triggered
  127166. */
  127167. selectionMeshPickedColor: Color3;
  127168. /**
  127169. * Optional filter to be used for ray selection. This predicate shares behavior with
  127170. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127171. */
  127172. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127173. /**
  127174. * constructs a new background remover module
  127175. * @param _xrSessionManager the session manager for this module
  127176. * @param _options read-only options to be used in this module
  127177. */
  127178. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127179. /**
  127180. * attach this feature
  127181. * Will usually be called by the features manager
  127182. *
  127183. * @returns true if successful.
  127184. */
  127185. attach(): boolean;
  127186. /**
  127187. * detach this feature.
  127188. * Will usually be called by the features manager
  127189. *
  127190. * @returns true if successful.
  127191. */
  127192. detach(): boolean;
  127193. /**
  127194. * Will get the mesh under a specific pointer.
  127195. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127196. * @param controllerId the controllerId to check
  127197. * @returns The mesh under pointer or null if no mesh is under the pointer
  127198. */
  127199. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127200. /**
  127201. * Get the xr controller that correlates to the pointer id in the pointer event
  127202. *
  127203. * @param id the pointer id to search for
  127204. * @returns the controller that correlates to this id or null if not found
  127205. */
  127206. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127207. protected _onXRFrame(_xrFrame: XRFrame): void;
  127208. private _attachGazeMode;
  127209. private _attachScreenRayMode;
  127210. private _attachTrackedPointerRayMode;
  127211. private _convertNormalToDirectionOfRay;
  127212. private _detachController;
  127213. private _generateNewMeshPair;
  127214. private _pickingMoved;
  127215. private _updatePointerDistance;
  127216. /** @hidden */
  127217. get lasterPointerDefaultColor(): Color3;
  127218. }
  127219. }
  127220. declare module BABYLON {
  127221. /**
  127222. * Button which can be used to enter a different mode of XR
  127223. */
  127224. export class WebXREnterExitUIButton {
  127225. /** button element */
  127226. element: HTMLElement;
  127227. /** XR initialization options for the button */
  127228. sessionMode: XRSessionMode;
  127229. /** Reference space type */
  127230. referenceSpaceType: XRReferenceSpaceType;
  127231. /**
  127232. * Creates a WebXREnterExitUIButton
  127233. * @param element button element
  127234. * @param sessionMode XR initialization session mode
  127235. * @param referenceSpaceType the type of reference space to be used
  127236. */
  127237. constructor(
  127238. /** button element */
  127239. element: HTMLElement,
  127240. /** XR initialization options for the button */
  127241. sessionMode: XRSessionMode,
  127242. /** Reference space type */
  127243. referenceSpaceType: XRReferenceSpaceType);
  127244. /**
  127245. * Extendable function which can be used to update the button's visuals when the state changes
  127246. * @param activeButton the current active button in the UI
  127247. */
  127248. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127249. }
  127250. /**
  127251. * Options to create the webXR UI
  127252. */
  127253. export class WebXREnterExitUIOptions {
  127254. /**
  127255. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127256. */
  127257. customButtons?: Array<WebXREnterExitUIButton>;
  127258. /**
  127259. * A reference space type to use when creating the default button.
  127260. * Default is local-floor
  127261. */
  127262. referenceSpaceType?: XRReferenceSpaceType;
  127263. /**
  127264. * Context to enter xr with
  127265. */
  127266. renderTarget?: Nullable<WebXRRenderTarget>;
  127267. /**
  127268. * A session mode to use when creating the default button.
  127269. * Default is immersive-vr
  127270. */
  127271. sessionMode?: XRSessionMode;
  127272. /**
  127273. * A list of optional features to init the session with
  127274. */
  127275. optionalFeatures?: string[];
  127276. /**
  127277. * A list of optional features to init the session with
  127278. */
  127279. requiredFeatures?: string[];
  127280. }
  127281. /**
  127282. * UI to allow the user to enter/exit XR mode
  127283. */
  127284. export class WebXREnterExitUI implements IDisposable {
  127285. private scene;
  127286. /** version of the options passed to this UI */
  127287. options: WebXREnterExitUIOptions;
  127288. private _activeButton;
  127289. private _buttons;
  127290. private _overlay;
  127291. /**
  127292. * Fired every time the active button is changed.
  127293. *
  127294. * When xr is entered via a button that launches xr that button will be the callback parameter
  127295. *
  127296. * When exiting xr the callback parameter will be null)
  127297. */
  127298. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127299. /**
  127300. *
  127301. * @param scene babylon scene object to use
  127302. * @param options (read-only) version of the options passed to this UI
  127303. */
  127304. private constructor();
  127305. /**
  127306. * Creates UI to allow the user to enter/exit XR mode
  127307. * @param scene the scene to add the ui to
  127308. * @param helper the xr experience helper to enter/exit xr with
  127309. * @param options options to configure the UI
  127310. * @returns the created ui
  127311. */
  127312. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127313. /**
  127314. * Disposes of the XR UI component
  127315. */
  127316. dispose(): void;
  127317. private _updateButtons;
  127318. }
  127319. }
  127320. declare module BABYLON {
  127321. /**
  127322. * Class containing static functions to help procedurally build meshes
  127323. */
  127324. export class LinesBuilder {
  127325. /**
  127326. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127327. * * 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
  127328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127329. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127330. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127331. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127332. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127333. * * 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
  127334. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127337. * @param name defines the name of the new line system
  127338. * @param options defines the options used to create the line system
  127339. * @param scene defines the hosting scene
  127340. * @returns a new line system mesh
  127341. */
  127342. static CreateLineSystem(name: string, options: {
  127343. lines: Vector3[][];
  127344. updatable?: boolean;
  127345. instance?: Nullable<LinesMesh>;
  127346. colors?: Nullable<Color4[][]>;
  127347. useVertexAlpha?: boolean;
  127348. }, scene: Nullable<Scene>): LinesMesh;
  127349. /**
  127350. * Creates a line mesh
  127351. * 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
  127352. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127353. * * The parameter `points` is an array successive Vector3
  127354. * * 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
  127355. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127356. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127357. * * When updating an instance, remember that only point positions can change, not the number of points
  127358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127360. * @param name defines the name of the new line system
  127361. * @param options defines the options used to create the line system
  127362. * @param scene defines the hosting scene
  127363. * @returns a new line mesh
  127364. */
  127365. static CreateLines(name: string, options: {
  127366. points: Vector3[];
  127367. updatable?: boolean;
  127368. instance?: Nullable<LinesMesh>;
  127369. colors?: Color4[];
  127370. useVertexAlpha?: boolean;
  127371. }, scene?: Nullable<Scene>): LinesMesh;
  127372. /**
  127373. * Creates a dashed line mesh
  127374. * * 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
  127375. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127376. * * The parameter `points` is an array successive Vector3
  127377. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127378. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127379. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127380. * * 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
  127381. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127382. * * When updating an instance, remember that only point positions can change, not the number of points
  127383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127384. * @param name defines the name of the mesh
  127385. * @param options defines the options used to create the mesh
  127386. * @param scene defines the hosting scene
  127387. * @returns the dashed line mesh
  127388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127389. */
  127390. static CreateDashedLines(name: string, options: {
  127391. points: Vector3[];
  127392. dashSize?: number;
  127393. gapSize?: number;
  127394. dashNb?: number;
  127395. updatable?: boolean;
  127396. instance?: LinesMesh;
  127397. useVertexAlpha?: boolean;
  127398. }, scene?: Nullable<Scene>): LinesMesh;
  127399. }
  127400. }
  127401. declare module BABYLON {
  127402. /**
  127403. * Construction options for a timer
  127404. */
  127405. export interface ITimerOptions<T> {
  127406. /**
  127407. * Time-to-end
  127408. */
  127409. timeout: number;
  127410. /**
  127411. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  127412. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  127413. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  127414. */
  127415. contextObservable: Observable<T>;
  127416. /**
  127417. * Optional parameters when adding an observer to the observable
  127418. */
  127419. observableParameters?: {
  127420. mask?: number;
  127421. insertFirst?: boolean;
  127422. scope?: any;
  127423. };
  127424. /**
  127425. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  127426. */
  127427. breakCondition?: (data?: ITimerData<T>) => boolean;
  127428. /**
  127429. * Will be triggered when the time condition has met
  127430. */
  127431. onEnded?: (data: ITimerData<any>) => void;
  127432. /**
  127433. * Will be triggered when the break condition has met (prematurely ended)
  127434. */
  127435. onAborted?: (data: ITimerData<any>) => void;
  127436. /**
  127437. * Optional function to execute on each tick (or count)
  127438. */
  127439. onTick?: (data: ITimerData<any>) => void;
  127440. }
  127441. /**
  127442. * An interface defining the data sent by the timer
  127443. */
  127444. export interface ITimerData<T> {
  127445. /**
  127446. * When did it start
  127447. */
  127448. startTime: number;
  127449. /**
  127450. * Time now
  127451. */
  127452. currentTime: number;
  127453. /**
  127454. * Time passed since started
  127455. */
  127456. deltaTime: number;
  127457. /**
  127458. * How much is completed, in [0.0...1.0].
  127459. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  127460. */
  127461. completeRate: number;
  127462. /**
  127463. * What the registered observable sent in the last count
  127464. */
  127465. payload: T;
  127466. }
  127467. /**
  127468. * The current state of the timer
  127469. */
  127470. export enum TimerState {
  127471. /**
  127472. * Timer initialized, not yet started
  127473. */
  127474. INIT = 0,
  127475. /**
  127476. * Timer started and counting
  127477. */
  127478. STARTED = 1,
  127479. /**
  127480. * Timer ended (whether aborted or time reached)
  127481. */
  127482. ENDED = 2
  127483. }
  127484. /**
  127485. * A simple version of the timer. Will take options and start the timer immediately after calling it
  127486. *
  127487. * @param options options with which to initialize this timer
  127488. */
  127489. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  127490. /**
  127491. * An advanced implementation of a timer class
  127492. */
  127493. export class AdvancedTimer<T = any> implements IDisposable {
  127494. /**
  127495. * Will notify each time the timer calculates the remaining time
  127496. */
  127497. onEachCountObservable: Observable<ITimerData<T>>;
  127498. /**
  127499. * Will trigger when the timer was aborted due to the break condition
  127500. */
  127501. onTimerAbortedObservable: Observable<ITimerData<T>>;
  127502. /**
  127503. * Will trigger when the timer ended successfully
  127504. */
  127505. onTimerEndedObservable: Observable<ITimerData<T>>;
  127506. /**
  127507. * Will trigger when the timer state has changed
  127508. */
  127509. onStateChangedObservable: Observable<TimerState>;
  127510. private _observer;
  127511. private _contextObservable;
  127512. private _observableParameters;
  127513. private _startTime;
  127514. private _timer;
  127515. private _state;
  127516. private _breakCondition;
  127517. private _timeToEnd;
  127518. private _breakOnNextTick;
  127519. /**
  127520. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  127521. * @param options construction options for this advanced timer
  127522. */
  127523. constructor(options: ITimerOptions<T>);
  127524. /**
  127525. * set a breaking condition for this timer. Default is to never break during count
  127526. * @param predicate the new break condition. Returns true to break, false otherwise
  127527. */
  127528. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  127529. /**
  127530. * Reset ALL associated observables in this advanced timer
  127531. */
  127532. clearObservables(): void;
  127533. /**
  127534. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  127535. *
  127536. * @param timeToEnd how much time to measure until timer ended
  127537. */
  127538. start(timeToEnd?: number): void;
  127539. /**
  127540. * Will force a stop on the next tick.
  127541. */
  127542. stop(): void;
  127543. /**
  127544. * Dispose this timer, clearing all resources
  127545. */
  127546. dispose(): void;
  127547. private _setState;
  127548. private _tick;
  127549. private _stop;
  127550. }
  127551. }
  127552. declare module BABYLON {
  127553. /**
  127554. * The options container for the teleportation module
  127555. */
  127556. export interface IWebXRTeleportationOptions {
  127557. /**
  127558. * if provided, this scene will be used to render meshes.
  127559. */
  127560. customUtilityLayerScene?: Scene;
  127561. /**
  127562. * Values to configure the default target mesh
  127563. */
  127564. defaultTargetMeshOptions?: {
  127565. /**
  127566. * Fill color of the teleportation area
  127567. */
  127568. teleportationFillColor?: string;
  127569. /**
  127570. * Border color for the teleportation area
  127571. */
  127572. teleportationBorderColor?: string;
  127573. /**
  127574. * Disable the mesh's animation sequence
  127575. */
  127576. disableAnimation?: boolean;
  127577. /**
  127578. * Disable lighting on the material or the ring and arrow
  127579. */
  127580. disableLighting?: boolean;
  127581. /**
  127582. * Override the default material of the torus and arrow
  127583. */
  127584. torusArrowMaterial?: Material;
  127585. };
  127586. /**
  127587. * A list of meshes to use as floor meshes.
  127588. * Meshes can be added and removed after initializing the feature using the
  127589. * addFloorMesh and removeFloorMesh functions
  127590. * If empty, rotation will still work
  127591. */
  127592. floorMeshes?: AbstractMesh[];
  127593. /**
  127594. * use this rendering group id for the meshes (optional)
  127595. */
  127596. renderingGroupId?: number;
  127597. /**
  127598. * Should teleportation move only to snap points
  127599. */
  127600. snapPointsOnly?: boolean;
  127601. /**
  127602. * An array of points to which the teleportation will snap to.
  127603. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  127604. */
  127605. snapPositions?: Vector3[];
  127606. /**
  127607. * How close should the teleportation ray be in order to snap to position.
  127608. * Default to 0.8 units (meters)
  127609. */
  127610. snapToPositionRadius?: number;
  127611. /**
  127612. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  127613. * If you want to support rotation, make sure your mesh has a direction indicator.
  127614. *
  127615. * When left untouched, the default mesh will be initialized.
  127616. */
  127617. teleportationTargetMesh?: AbstractMesh;
  127618. /**
  127619. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  127620. */
  127621. timeToTeleport?: number;
  127622. /**
  127623. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  127624. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  127625. */
  127626. useMainComponentOnly?: boolean;
  127627. /**
  127628. * Should meshes created here be added to a utility layer or the main scene
  127629. */
  127630. useUtilityLayer?: boolean;
  127631. /**
  127632. * Babylon XR Input class for controller
  127633. */
  127634. xrInput: WebXRInput;
  127635. }
  127636. /**
  127637. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  127638. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  127639. * the input of the attached controllers.
  127640. */
  127641. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  127642. private _options;
  127643. private _controllers;
  127644. private _currentTeleportationControllerId;
  127645. private _floorMeshes;
  127646. private _quadraticBezierCurve;
  127647. private _selectionFeature;
  127648. private _snapToPositions;
  127649. private _snappedToPoint;
  127650. private _teleportationRingMaterial?;
  127651. private _tmpRay;
  127652. private _tmpVector;
  127653. /**
  127654. * The module's name
  127655. */
  127656. static readonly Name: string;
  127657. /**
  127658. * The (Babylon) version of this module.
  127659. * This is an integer representing the implementation version.
  127660. * This number does not correspond to the webxr specs version
  127661. */
  127662. static readonly Version: number;
  127663. /**
  127664. * Is movement backwards enabled
  127665. */
  127666. backwardsMovementEnabled: boolean;
  127667. /**
  127668. * Distance to travel when moving backwards
  127669. */
  127670. backwardsTeleportationDistance: number;
  127671. /**
  127672. * The distance from the user to the inspection point in the direction of the controller
  127673. * A higher number will allow the user to move further
  127674. * defaults to 5 (meters, in xr units)
  127675. */
  127676. parabolicCheckRadius: number;
  127677. /**
  127678. * Should the module support parabolic ray on top of direct ray
  127679. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  127680. * Very helpful when moving between floors / different heights
  127681. */
  127682. parabolicRayEnabled: boolean;
  127683. /**
  127684. * How much rotation should be applied when rotating right and left
  127685. */
  127686. rotationAngle: number;
  127687. /**
  127688. * Is rotation enabled when moving forward?
  127689. * Disabling this feature will prevent the user from deciding the direction when teleporting
  127690. */
  127691. rotationEnabled: boolean;
  127692. /**
  127693. * constructs a new anchor system
  127694. * @param _xrSessionManager an instance of WebXRSessionManager
  127695. * @param _options configuration object for this feature
  127696. */
  127697. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  127698. /**
  127699. * Get the snapPointsOnly flag
  127700. */
  127701. get snapPointsOnly(): boolean;
  127702. /**
  127703. * Sets the snapPointsOnly flag
  127704. * @param snapToPoints should teleportation be exclusively to snap points
  127705. */
  127706. set snapPointsOnly(snapToPoints: boolean);
  127707. /**
  127708. * Add a new mesh to the floor meshes array
  127709. * @param mesh the mesh to use as floor mesh
  127710. */
  127711. addFloorMesh(mesh: AbstractMesh): void;
  127712. /**
  127713. * Add a new snap-to point to fix teleportation to this position
  127714. * @param newSnapPoint The new Snap-To point
  127715. */
  127716. addSnapPoint(newSnapPoint: Vector3): void;
  127717. attach(): boolean;
  127718. detach(): boolean;
  127719. dispose(): void;
  127720. /**
  127721. * Remove a mesh from the floor meshes array
  127722. * @param mesh the mesh to remove
  127723. */
  127724. removeFloorMesh(mesh: AbstractMesh): void;
  127725. /**
  127726. * Remove a mesh from the floor meshes array using its name
  127727. * @param name the mesh name to remove
  127728. */
  127729. removeFloorMeshByName(name: string): void;
  127730. /**
  127731. * 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
  127732. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  127733. * @returns was the point found and removed or not
  127734. */
  127735. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  127736. /**
  127737. * This function sets a selection feature that will be disabled when
  127738. * the forward ray is shown and will be reattached when hidden.
  127739. * This is used to remove the selection rays when moving.
  127740. * @param selectionFeature the feature to disable when forward movement is enabled
  127741. */
  127742. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  127743. protected _onXRFrame(_xrFrame: XRFrame): void;
  127744. private _attachController;
  127745. private _createDefaultTargetMesh;
  127746. private _detachController;
  127747. private _findClosestSnapPointWithRadius;
  127748. private _setTargetMeshPosition;
  127749. private _setTargetMeshVisibility;
  127750. private _showParabolicPath;
  127751. private _teleportForward;
  127752. }
  127753. }
  127754. declare module BABYLON {
  127755. /**
  127756. * Options for the default xr helper
  127757. */
  127758. export class WebXRDefaultExperienceOptions {
  127759. /**
  127760. * Enable or disable default UI to enter XR
  127761. */
  127762. disableDefaultUI?: boolean;
  127763. /**
  127764. * Should teleportation not initialize. defaults to false.
  127765. */
  127766. disableTeleportation?: boolean;
  127767. /**
  127768. * Floor meshes that will be used for teleport
  127769. */
  127770. floorMeshes?: Array<AbstractMesh>;
  127771. /**
  127772. * If set to true, the first frame will not be used to reset position
  127773. * The first frame is mainly used when copying transformation from the old camera
  127774. * Mainly used in AR
  127775. */
  127776. ignoreNativeCameraTransformation?: boolean;
  127777. /**
  127778. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  127779. */
  127780. inputOptions?: IWebXRInputOptions;
  127781. /**
  127782. * optional configuration for the output canvas
  127783. */
  127784. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  127785. /**
  127786. * optional UI options. This can be used among other to change session mode and reference space type
  127787. */
  127788. uiOptions?: WebXREnterExitUIOptions;
  127789. /**
  127790. * When loading teleportation and pointer select, use stable versions instead of latest.
  127791. */
  127792. useStablePlugins?: boolean;
  127793. /**
  127794. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  127795. */
  127796. renderingGroupId?: number;
  127797. /**
  127798. * A list of optional features to init the session with
  127799. * If set to true, all features we support will be added
  127800. */
  127801. optionalFeatures?: boolean | string[];
  127802. }
  127803. /**
  127804. * Default experience which provides a similar setup to the previous webVRExperience
  127805. */
  127806. export class WebXRDefaultExperience {
  127807. /**
  127808. * Base experience
  127809. */
  127810. baseExperience: WebXRExperienceHelper;
  127811. /**
  127812. * Enables ui for entering/exiting xr
  127813. */
  127814. enterExitUI: WebXREnterExitUI;
  127815. /**
  127816. * Input experience extension
  127817. */
  127818. input: WebXRInput;
  127819. /**
  127820. * Enables laser pointer and selection
  127821. */
  127822. pointerSelection: WebXRControllerPointerSelection;
  127823. /**
  127824. * Default target xr should render to
  127825. */
  127826. renderTarget: WebXRRenderTarget;
  127827. /**
  127828. * Enables teleportation
  127829. */
  127830. teleportation: WebXRMotionControllerTeleportation;
  127831. private constructor();
  127832. /**
  127833. * Creates the default xr experience
  127834. * @param scene scene
  127835. * @param options options for basic configuration
  127836. * @returns resulting WebXRDefaultExperience
  127837. */
  127838. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127839. /**
  127840. * DIsposes of the experience helper
  127841. */
  127842. dispose(): void;
  127843. }
  127844. }
  127845. declare module BABYLON {
  127846. /**
  127847. * Options to modify the vr teleportation behavior.
  127848. */
  127849. export interface VRTeleportationOptions {
  127850. /**
  127851. * The name of the mesh which should be used as the teleportation floor. (default: null)
  127852. */
  127853. floorMeshName?: string;
  127854. /**
  127855. * A list of meshes to be used as the teleportation floor. (default: empty)
  127856. */
  127857. floorMeshes?: Mesh[];
  127858. /**
  127859. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  127860. */
  127861. teleportationMode?: number;
  127862. /**
  127863. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  127864. */
  127865. teleportationTime?: number;
  127866. /**
  127867. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  127868. */
  127869. teleportationSpeed?: number;
  127870. /**
  127871. * The easing function used in the animation or null for Linear. (default CircleEase)
  127872. */
  127873. easingFunction?: EasingFunction;
  127874. }
  127875. /**
  127876. * Options to modify the vr experience helper's behavior.
  127877. */
  127878. export interface VRExperienceHelperOptions extends WebVROptions {
  127879. /**
  127880. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  127881. */
  127882. createDeviceOrientationCamera?: boolean;
  127883. /**
  127884. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  127885. */
  127886. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  127887. /**
  127888. * Uses the main button on the controller to toggle the laser casted. (default: true)
  127889. */
  127890. laserToggle?: boolean;
  127891. /**
  127892. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  127893. */
  127894. floorMeshes?: Mesh[];
  127895. /**
  127896. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  127897. */
  127898. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127899. /**
  127900. * Defines if WebXR should be used instead of WebVR (if available)
  127901. */
  127902. useXR?: boolean;
  127903. }
  127904. /**
  127905. * Event containing information after VR has been entered
  127906. */
  127907. export class OnAfterEnteringVRObservableEvent {
  127908. /**
  127909. * If entering vr was successful
  127910. */
  127911. success: boolean;
  127912. }
  127913. /**
  127914. * Helps to quickly add VR support to an existing scene.
  127915. * See https://doc.babylonjs.com/how_to/webvr_helper
  127916. */
  127917. export class VRExperienceHelper {
  127918. /** Options to modify the vr experience helper's behavior. */
  127919. webVROptions: VRExperienceHelperOptions;
  127920. private _scene;
  127921. private _position;
  127922. private _btnVR;
  127923. private _btnVRDisplayed;
  127924. private _webVRsupported;
  127925. private _webVRready;
  127926. private _webVRrequesting;
  127927. private _webVRpresenting;
  127928. private _hasEnteredVR;
  127929. private _fullscreenVRpresenting;
  127930. private _inputElement;
  127931. private _webVRCamera;
  127932. private _vrDeviceOrientationCamera;
  127933. private _deviceOrientationCamera;
  127934. private _existingCamera;
  127935. private _onKeyDown;
  127936. private _onVrDisplayPresentChange;
  127937. private _onVRDisplayChanged;
  127938. private _onVRRequestPresentStart;
  127939. private _onVRRequestPresentComplete;
  127940. /**
  127941. * 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)
  127942. */
  127943. enableGazeEvenWhenNoPointerLock: boolean;
  127944. /**
  127945. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127946. */
  127947. exitVROnDoubleTap: boolean;
  127948. /**
  127949. * Observable raised right before entering VR.
  127950. */
  127951. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127952. /**
  127953. * Observable raised when entering VR has completed.
  127954. */
  127955. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127956. /**
  127957. * Observable raised when exiting VR.
  127958. */
  127959. onExitingVRObservable: Observable<VRExperienceHelper>;
  127960. /**
  127961. * Observable raised when controller mesh is loaded.
  127962. */
  127963. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127964. /** Return this.onEnteringVRObservable
  127965. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127966. */
  127967. get onEnteringVR(): Observable<VRExperienceHelper>;
  127968. /** Return this.onExitingVRObservable
  127969. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127970. */
  127971. get onExitingVR(): Observable<VRExperienceHelper>;
  127972. /** Return this.onControllerMeshLoadedObservable
  127973. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127974. */
  127975. get onControllerMeshLoaded(): Observable<WebVRController>;
  127976. private _rayLength;
  127977. private _useCustomVRButton;
  127978. private _teleportationRequested;
  127979. private _teleportActive;
  127980. private _floorMeshName;
  127981. private _floorMeshesCollection;
  127982. private _teleportationMode;
  127983. private _teleportationTime;
  127984. private _teleportationSpeed;
  127985. private _teleportationEasing;
  127986. private _rotationAllowed;
  127987. private _teleportBackwardsVector;
  127988. private _teleportationTarget;
  127989. private _isDefaultTeleportationTarget;
  127990. private _postProcessMove;
  127991. private _teleportationFillColor;
  127992. private _teleportationBorderColor;
  127993. private _rotationAngle;
  127994. private _haloCenter;
  127995. private _cameraGazer;
  127996. private _padSensibilityUp;
  127997. private _padSensibilityDown;
  127998. private _leftController;
  127999. private _rightController;
  128000. private _gazeColor;
  128001. private _laserColor;
  128002. private _pickedLaserColor;
  128003. private _pickedGazeColor;
  128004. /**
  128005. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128006. */
  128007. onNewMeshSelected: Observable<AbstractMesh>;
  128008. /**
  128009. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128010. * This observable will provide the mesh and the controller used to select the mesh
  128011. */
  128012. onMeshSelectedWithController: Observable<{
  128013. mesh: AbstractMesh;
  128014. controller: WebVRController;
  128015. }>;
  128016. /**
  128017. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128018. */
  128019. onNewMeshPicked: Observable<PickingInfo>;
  128020. private _circleEase;
  128021. /**
  128022. * Observable raised before camera teleportation
  128023. */
  128024. onBeforeCameraTeleport: Observable<Vector3>;
  128025. /**
  128026. * Observable raised after camera teleportation
  128027. */
  128028. onAfterCameraTeleport: Observable<Vector3>;
  128029. /**
  128030. * Observable raised when current selected mesh gets unselected
  128031. */
  128032. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128033. private _raySelectionPredicate;
  128034. /**
  128035. * To be optionaly changed by user to define custom ray selection
  128036. */
  128037. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128038. /**
  128039. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128040. */
  128041. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128042. /**
  128043. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128044. */
  128045. teleportationEnabled: boolean;
  128046. private _defaultHeight;
  128047. private _teleportationInitialized;
  128048. private _interactionsEnabled;
  128049. private _interactionsRequested;
  128050. private _displayGaze;
  128051. private _displayLaserPointer;
  128052. /**
  128053. * The mesh used to display where the user is going to teleport.
  128054. */
  128055. get teleportationTarget(): Mesh;
  128056. /**
  128057. * Sets the mesh to be used to display where the user is going to teleport.
  128058. */
  128059. set teleportationTarget(value: Mesh);
  128060. /**
  128061. * 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
  128062. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128063. * See https://doc.babylonjs.com/resources/baking_transformations
  128064. */
  128065. get gazeTrackerMesh(): Mesh;
  128066. set gazeTrackerMesh(value: Mesh);
  128067. /**
  128068. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128069. */
  128070. updateGazeTrackerScale: boolean;
  128071. /**
  128072. * If the gaze trackers color should be updated when selecting meshes
  128073. */
  128074. updateGazeTrackerColor: boolean;
  128075. /**
  128076. * If the controller laser color should be updated when selecting meshes
  128077. */
  128078. updateControllerLaserColor: boolean;
  128079. /**
  128080. * The gaze tracking mesh corresponding to the left controller
  128081. */
  128082. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128083. /**
  128084. * The gaze tracking mesh corresponding to the right controller
  128085. */
  128086. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128087. /**
  128088. * If the ray of the gaze should be displayed.
  128089. */
  128090. get displayGaze(): boolean;
  128091. /**
  128092. * Sets if the ray of the gaze should be displayed.
  128093. */
  128094. set displayGaze(value: boolean);
  128095. /**
  128096. * If the ray of the LaserPointer should be displayed.
  128097. */
  128098. get displayLaserPointer(): boolean;
  128099. /**
  128100. * Sets if the ray of the LaserPointer should be displayed.
  128101. */
  128102. set displayLaserPointer(value: boolean);
  128103. /**
  128104. * The deviceOrientationCamera used as the camera when not in VR.
  128105. */
  128106. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128107. /**
  128108. * Based on the current WebVR support, returns the current VR camera used.
  128109. */
  128110. get currentVRCamera(): Nullable<Camera>;
  128111. /**
  128112. * The webVRCamera which is used when in VR.
  128113. */
  128114. get webVRCamera(): WebVRFreeCamera;
  128115. /**
  128116. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128117. */
  128118. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128119. /**
  128120. * The html button that is used to trigger entering into VR.
  128121. */
  128122. get vrButton(): Nullable<HTMLButtonElement>;
  128123. private get _teleportationRequestInitiated();
  128124. /**
  128125. * Defines whether or not Pointer lock should be requested when switching to
  128126. * full screen.
  128127. */
  128128. requestPointerLockOnFullScreen: boolean;
  128129. /**
  128130. * If asking to force XR, this will be populated with the default xr experience
  128131. */
  128132. xr: WebXRDefaultExperience;
  128133. /**
  128134. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128135. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128136. */
  128137. xrTestDone: boolean;
  128138. /**
  128139. * Instantiates a VRExperienceHelper.
  128140. * Helps to quickly add VR support to an existing scene.
  128141. * @param scene The scene the VRExperienceHelper belongs to.
  128142. * @param webVROptions Options to modify the vr experience helper's behavior.
  128143. */
  128144. constructor(scene: Scene,
  128145. /** Options to modify the vr experience helper's behavior. */
  128146. webVROptions?: VRExperienceHelperOptions);
  128147. private completeVRInit;
  128148. private _onDefaultMeshLoaded;
  128149. private _onResize;
  128150. private _onFullscreenChange;
  128151. /**
  128152. * Gets a value indicating if we are currently in VR mode.
  128153. */
  128154. get isInVRMode(): boolean;
  128155. private onVrDisplayPresentChange;
  128156. private onVRDisplayChanged;
  128157. private moveButtonToBottomRight;
  128158. private displayVRButton;
  128159. private updateButtonVisibility;
  128160. private _cachedAngularSensibility;
  128161. /**
  128162. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128163. * Otherwise, will use the fullscreen API.
  128164. */
  128165. enterVR(): void;
  128166. /**
  128167. * Attempt to exit VR, or fullscreen.
  128168. */
  128169. exitVR(): void;
  128170. /**
  128171. * The position of the vr experience helper.
  128172. */
  128173. get position(): Vector3;
  128174. /**
  128175. * Sets the position of the vr experience helper.
  128176. */
  128177. set position(value: Vector3);
  128178. /**
  128179. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128180. */
  128181. enableInteractions(): void;
  128182. private get _noControllerIsActive();
  128183. private beforeRender;
  128184. private _isTeleportationFloor;
  128185. /**
  128186. * Adds a floor mesh to be used for teleportation.
  128187. * @param floorMesh the mesh to be used for teleportation.
  128188. */
  128189. addFloorMesh(floorMesh: Mesh): void;
  128190. /**
  128191. * Removes a floor mesh from being used for teleportation.
  128192. * @param floorMesh the mesh to be removed.
  128193. */
  128194. removeFloorMesh(floorMesh: Mesh): void;
  128195. /**
  128196. * Enables interactions and teleportation using the VR controllers and gaze.
  128197. * @param vrTeleportationOptions options to modify teleportation behavior.
  128198. */
  128199. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128200. private _onNewGamepadConnected;
  128201. private _tryEnableInteractionOnController;
  128202. private _onNewGamepadDisconnected;
  128203. private _enableInteractionOnController;
  128204. private _checkTeleportWithRay;
  128205. private _checkRotate;
  128206. private _checkTeleportBackwards;
  128207. private _enableTeleportationOnController;
  128208. private _createTeleportationCircles;
  128209. private _displayTeleportationTarget;
  128210. private _hideTeleportationTarget;
  128211. private _rotateCamera;
  128212. private _moveTeleportationSelectorTo;
  128213. private _workingVector;
  128214. private _workingQuaternion;
  128215. private _workingMatrix;
  128216. /**
  128217. * Time Constant Teleportation Mode
  128218. */
  128219. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128220. /**
  128221. * Speed Constant Teleportation Mode
  128222. */
  128223. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128224. /**
  128225. * Teleports the users feet to the desired location
  128226. * @param location The location where the user's feet should be placed
  128227. */
  128228. teleportCamera(location: Vector3): void;
  128229. private _convertNormalToDirectionOfRay;
  128230. private _castRayAndSelectObject;
  128231. private _notifySelectedMeshUnselected;
  128232. /**
  128233. * Permanently set new colors for the laser pointer
  128234. * @param color the new laser color
  128235. * @param pickedColor the new laser color when picked mesh detected
  128236. */
  128237. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128238. /**
  128239. * Set lighting enabled / disabled on the laser pointer of both controllers
  128240. * @param enabled should the lighting be enabled on the laser pointer
  128241. */
  128242. setLaserLightingState(enabled?: boolean): void;
  128243. /**
  128244. * Permanently set new colors for the gaze pointer
  128245. * @param color the new gaze color
  128246. * @param pickedColor the new gaze color when picked mesh detected
  128247. */
  128248. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128249. /**
  128250. * Sets the color of the laser ray from the vr controllers.
  128251. * @param color new color for the ray.
  128252. */
  128253. changeLaserColor(color: Color3): void;
  128254. /**
  128255. * Sets the color of the ray from the vr headsets gaze.
  128256. * @param color new color for the ray.
  128257. */
  128258. changeGazeColor(color: Color3): void;
  128259. /**
  128260. * Exits VR and disposes of the vr experience helper
  128261. */
  128262. dispose(): void;
  128263. /**
  128264. * Gets the name of the VRExperienceHelper class
  128265. * @returns "VRExperienceHelper"
  128266. */
  128267. getClassName(): string;
  128268. }
  128269. }
  128270. declare module BABYLON {
  128271. /**
  128272. * Contains an array of blocks representing the octree
  128273. */
  128274. export interface IOctreeContainer<T> {
  128275. /**
  128276. * Blocks within the octree
  128277. */
  128278. blocks: Array<OctreeBlock<T>>;
  128279. }
  128280. /**
  128281. * Class used to store a cell in an octree
  128282. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128283. */
  128284. export class OctreeBlock<T> {
  128285. /**
  128286. * Gets the content of the current block
  128287. */
  128288. entries: T[];
  128289. /**
  128290. * Gets the list of block children
  128291. */
  128292. blocks: Array<OctreeBlock<T>>;
  128293. private _depth;
  128294. private _maxDepth;
  128295. private _capacity;
  128296. private _minPoint;
  128297. private _maxPoint;
  128298. private _boundingVectors;
  128299. private _creationFunc;
  128300. /**
  128301. * Creates a new block
  128302. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128303. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128304. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128305. * @param depth defines the current depth of this block in the octree
  128306. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128307. * @param creationFunc defines a callback to call when an element is added to the block
  128308. */
  128309. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128310. /**
  128311. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128312. */
  128313. get capacity(): number;
  128314. /**
  128315. * Gets the minimum vector (in world space) of the block's bounding box
  128316. */
  128317. get minPoint(): Vector3;
  128318. /**
  128319. * Gets the maximum vector (in world space) of the block's bounding box
  128320. */
  128321. get maxPoint(): Vector3;
  128322. /**
  128323. * Add a new element to this block
  128324. * @param entry defines the element to add
  128325. */
  128326. addEntry(entry: T): void;
  128327. /**
  128328. * Remove an element from this block
  128329. * @param entry defines the element to remove
  128330. */
  128331. removeEntry(entry: T): void;
  128332. /**
  128333. * Add an array of elements to this block
  128334. * @param entries defines the array of elements to add
  128335. */
  128336. addEntries(entries: T[]): void;
  128337. /**
  128338. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128339. * @param frustumPlanes defines the frustum planes to test
  128340. * @param selection defines the array to store current content if selection is positive
  128341. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128342. */
  128343. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128344. /**
  128345. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128346. * @param sphereCenter defines the bounding sphere center
  128347. * @param sphereRadius defines the bounding sphere radius
  128348. * @param selection defines the array to store current content if selection is positive
  128349. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128350. */
  128351. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128352. /**
  128353. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128354. * @param ray defines the ray to test with
  128355. * @param selection defines the array to store current content if selection is positive
  128356. */
  128357. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128358. /**
  128359. * Subdivide the content into child blocks (this block will then be empty)
  128360. */
  128361. createInnerBlocks(): void;
  128362. /**
  128363. * @hidden
  128364. */
  128365. 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;
  128366. }
  128367. }
  128368. declare module BABYLON {
  128369. /**
  128370. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128371. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128372. */
  128373. export class Octree<T> {
  128374. /** 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.) */
  128375. maxDepth: number;
  128376. /**
  128377. * Blocks within the octree containing objects
  128378. */
  128379. blocks: Array<OctreeBlock<T>>;
  128380. /**
  128381. * Content stored in the octree
  128382. */
  128383. dynamicContent: T[];
  128384. private _maxBlockCapacity;
  128385. private _selectionContent;
  128386. private _creationFunc;
  128387. /**
  128388. * Creates a octree
  128389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128390. * @param creationFunc function to be used to instatiate the octree
  128391. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128392. * @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.)
  128393. */
  128394. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128395. /** 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.) */
  128396. maxDepth?: number);
  128397. /**
  128398. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  128399. * @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);
  128400. * @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);
  128401. * @param entries meshes to be added to the octree blocks
  128402. */
  128403. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  128404. /**
  128405. * Adds a mesh to the octree
  128406. * @param entry Mesh to add to the octree
  128407. */
  128408. addMesh(entry: T): void;
  128409. /**
  128410. * Remove an element from the octree
  128411. * @param entry defines the element to remove
  128412. */
  128413. removeMesh(entry: T): void;
  128414. /**
  128415. * Selects an array of meshes within the frustum
  128416. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  128417. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  128418. * @returns array of meshes within the frustum
  128419. */
  128420. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  128421. /**
  128422. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  128423. * @param sphereCenter defines the bounding sphere center
  128424. * @param sphereRadius defines the bounding sphere radius
  128425. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128426. * @returns an array of objects that intersect the sphere
  128427. */
  128428. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  128429. /**
  128430. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  128431. * @param ray defines the ray to test with
  128432. * @returns array of intersected objects
  128433. */
  128434. intersectsRay(ray: Ray): SmartArray<T>;
  128435. /**
  128436. * Adds a mesh into the octree block if it intersects the block
  128437. */
  128438. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  128439. /**
  128440. * Adds a submesh into the octree block if it intersects the block
  128441. */
  128442. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  128443. }
  128444. }
  128445. declare module BABYLON {
  128446. interface Scene {
  128447. /**
  128448. * @hidden
  128449. * Backing Filed
  128450. */
  128451. _selectionOctree: Octree<AbstractMesh>;
  128452. /**
  128453. * Gets the octree used to boost mesh selection (picking)
  128454. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128455. */
  128456. selectionOctree: Octree<AbstractMesh>;
  128457. /**
  128458. * Creates or updates the octree used to boost selection (picking)
  128459. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128460. * @param maxCapacity defines the maximum capacity per leaf
  128461. * @param maxDepth defines the maximum depth of the octree
  128462. * @returns an octree of AbstractMesh
  128463. */
  128464. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  128465. }
  128466. interface AbstractMesh {
  128467. /**
  128468. * @hidden
  128469. * Backing Field
  128470. */
  128471. _submeshesOctree: Octree<SubMesh>;
  128472. /**
  128473. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  128474. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  128475. * @param maxCapacity defines the maximum size of each block (64 by default)
  128476. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  128477. * @returns the new octree
  128478. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  128479. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128480. */
  128481. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  128482. }
  128483. /**
  128484. * Defines the octree scene component responsible to manage any octrees
  128485. * in a given scene.
  128486. */
  128487. export class OctreeSceneComponent {
  128488. /**
  128489. * The component name help to identify the component in the list of scene components.
  128490. */
  128491. readonly name: string;
  128492. /**
  128493. * The scene the component belongs to.
  128494. */
  128495. scene: Scene;
  128496. /**
  128497. * Indicates if the meshes have been checked to make sure they are isEnabled()
  128498. */
  128499. readonly checksIsEnabled: boolean;
  128500. /**
  128501. * Creates a new instance of the component for the given scene
  128502. * @param scene Defines the scene to register the component in
  128503. */
  128504. constructor(scene: Scene);
  128505. /**
  128506. * Registers the component in a given scene
  128507. */
  128508. register(): void;
  128509. /**
  128510. * Return the list of active meshes
  128511. * @returns the list of active meshes
  128512. */
  128513. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  128514. /**
  128515. * Return the list of active sub meshes
  128516. * @param mesh The mesh to get the candidates sub meshes from
  128517. * @returns the list of active sub meshes
  128518. */
  128519. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  128520. private _tempRay;
  128521. /**
  128522. * Return the list of sub meshes intersecting with a given local ray
  128523. * @param mesh defines the mesh to find the submesh for
  128524. * @param localRay defines the ray in local space
  128525. * @returns the list of intersecting sub meshes
  128526. */
  128527. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  128528. /**
  128529. * Return the list of sub meshes colliding with a collider
  128530. * @param mesh defines the mesh to find the submesh for
  128531. * @param collider defines the collider to evaluate the collision against
  128532. * @returns the list of colliding sub meshes
  128533. */
  128534. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  128535. /**
  128536. * Rebuilds the elements related to this component in case of
  128537. * context lost for instance.
  128538. */
  128539. rebuild(): void;
  128540. /**
  128541. * Disposes the component and the associated ressources.
  128542. */
  128543. dispose(): void;
  128544. }
  128545. }
  128546. declare module BABYLON {
  128547. /**
  128548. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  128549. */
  128550. export class Gizmo implements IDisposable {
  128551. /** The utility layer the gizmo will be added to */
  128552. gizmoLayer: UtilityLayerRenderer;
  128553. /**
  128554. * The root mesh of the gizmo
  128555. */
  128556. _rootMesh: Mesh;
  128557. private _attachedMesh;
  128558. private _attachedNode;
  128559. /**
  128560. * Ratio for the scale of the gizmo (Default: 1)
  128561. */
  128562. scaleRatio: number;
  128563. /**
  128564. * If a custom mesh has been set (Default: false)
  128565. */
  128566. protected _customMeshSet: boolean;
  128567. /**
  128568. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  128569. * * When set, interactions will be enabled
  128570. */
  128571. get attachedMesh(): Nullable<AbstractMesh>;
  128572. set attachedMesh(value: Nullable<AbstractMesh>);
  128573. /**
  128574. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  128575. * * When set, interactions will be enabled
  128576. */
  128577. get attachedNode(): Nullable<Node>;
  128578. set attachedNode(value: Nullable<Node>);
  128579. /**
  128580. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128581. * @param mesh The mesh to replace the default mesh of the gizmo
  128582. */
  128583. setCustomMesh(mesh: Mesh): void;
  128584. /**
  128585. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  128586. */
  128587. updateGizmoRotationToMatchAttachedMesh: boolean;
  128588. /**
  128589. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  128590. */
  128591. updateGizmoPositionToMatchAttachedMesh: boolean;
  128592. /**
  128593. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  128594. */
  128595. updateScale: boolean;
  128596. protected _interactionsEnabled: boolean;
  128597. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128598. private _beforeRenderObserver;
  128599. private _tempVector;
  128600. /**
  128601. * Creates a gizmo
  128602. * @param gizmoLayer The utility layer the gizmo will be added to
  128603. */
  128604. constructor(
  128605. /** The utility layer the gizmo will be added to */
  128606. gizmoLayer?: UtilityLayerRenderer);
  128607. /**
  128608. * Updates the gizmo to match the attached mesh's position/rotation
  128609. */
  128610. protected _update(): void;
  128611. /**
  128612. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  128613. * @param value Node, TransformNode or mesh
  128614. */
  128615. protected _matrixChanged(): void;
  128616. /**
  128617. * Disposes of the gizmo
  128618. */
  128619. dispose(): void;
  128620. }
  128621. }
  128622. declare module BABYLON {
  128623. /**
  128624. * Single plane drag gizmo
  128625. */
  128626. export class PlaneDragGizmo extends Gizmo {
  128627. /**
  128628. * Drag behavior responsible for the gizmos dragging interactions
  128629. */
  128630. dragBehavior: PointerDragBehavior;
  128631. private _pointerObserver;
  128632. /**
  128633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128634. */
  128635. snapDistance: number;
  128636. /**
  128637. * Event that fires each time the gizmo snaps to a new location.
  128638. * * snapDistance is the the change in distance
  128639. */
  128640. onSnapObservable: Observable<{
  128641. snapDistance: number;
  128642. }>;
  128643. private _plane;
  128644. private _coloredMaterial;
  128645. private _hoverMaterial;
  128646. private _isEnabled;
  128647. private _parent;
  128648. /** @hidden */
  128649. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  128650. /** @hidden */
  128651. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128652. /**
  128653. * Creates a PlaneDragGizmo
  128654. * @param gizmoLayer The utility layer the gizmo will be added to
  128655. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  128656. * @param color The color of the gizmo
  128657. */
  128658. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  128659. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128660. /**
  128661. * If the gizmo is enabled
  128662. */
  128663. set isEnabled(value: boolean);
  128664. get isEnabled(): boolean;
  128665. /**
  128666. * Disposes of the gizmo
  128667. */
  128668. dispose(): void;
  128669. }
  128670. }
  128671. declare module BABYLON {
  128672. /**
  128673. * Gizmo that enables dragging a mesh along 3 axis
  128674. */
  128675. export class PositionGizmo extends Gizmo {
  128676. /**
  128677. * Internal gizmo used for interactions on the x axis
  128678. */
  128679. xGizmo: AxisDragGizmo;
  128680. /**
  128681. * Internal gizmo used for interactions on the y axis
  128682. */
  128683. yGizmo: AxisDragGizmo;
  128684. /**
  128685. * Internal gizmo used for interactions on the z axis
  128686. */
  128687. zGizmo: AxisDragGizmo;
  128688. /**
  128689. * Internal gizmo used for interactions on the yz plane
  128690. */
  128691. xPlaneGizmo: PlaneDragGizmo;
  128692. /**
  128693. * Internal gizmo used for interactions on the xz plane
  128694. */
  128695. yPlaneGizmo: PlaneDragGizmo;
  128696. /**
  128697. * Internal gizmo used for interactions on the xy plane
  128698. */
  128699. zPlaneGizmo: PlaneDragGizmo;
  128700. /**
  128701. * private variables
  128702. */
  128703. private _meshAttached;
  128704. private _nodeAttached;
  128705. private _updateGizmoRotationToMatchAttachedMesh;
  128706. private _snapDistance;
  128707. private _scaleRatio;
  128708. /** Fires an event when any of it's sub gizmos are dragged */
  128709. onDragStartObservable: Observable<unknown>;
  128710. /** Fires an event when any of it's sub gizmos are released from dragging */
  128711. onDragEndObservable: Observable<unknown>;
  128712. /**
  128713. * If set to true, planar drag is enabled
  128714. */
  128715. private _planarGizmoEnabled;
  128716. get attachedMesh(): Nullable<AbstractMesh>;
  128717. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128718. get attachedNode(): Nullable<Node>;
  128719. set attachedNode(node: Nullable<Node>);
  128720. /**
  128721. * Creates a PositionGizmo
  128722. * @param gizmoLayer The utility layer the gizmo will be added to
  128723. @param thickness display gizmo axis thickness
  128724. */
  128725. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  128726. /**
  128727. * If the planar drag gizmo is enabled
  128728. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  128729. */
  128730. set planarGizmoEnabled(value: boolean);
  128731. get planarGizmoEnabled(): boolean;
  128732. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128733. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128734. /**
  128735. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128736. */
  128737. set snapDistance(value: number);
  128738. get snapDistance(): number;
  128739. /**
  128740. * Ratio for the scale of the gizmo (Default: 1)
  128741. */
  128742. set scaleRatio(value: number);
  128743. get scaleRatio(): number;
  128744. /**
  128745. * Disposes of the gizmo
  128746. */
  128747. dispose(): void;
  128748. /**
  128749. * CustomMeshes are not supported by this gizmo
  128750. * @param mesh The mesh to replace the default mesh of the gizmo
  128751. */
  128752. setCustomMesh(mesh: Mesh): void;
  128753. }
  128754. }
  128755. declare module BABYLON {
  128756. /**
  128757. * Single axis drag gizmo
  128758. */
  128759. export class AxisDragGizmo extends Gizmo {
  128760. /**
  128761. * Drag behavior responsible for the gizmos dragging interactions
  128762. */
  128763. dragBehavior: PointerDragBehavior;
  128764. private _pointerObserver;
  128765. /**
  128766. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128767. */
  128768. snapDistance: number;
  128769. /**
  128770. * Event that fires each time the gizmo snaps to a new location.
  128771. * * snapDistance is the the change in distance
  128772. */
  128773. onSnapObservable: Observable<{
  128774. snapDistance: number;
  128775. }>;
  128776. private _isEnabled;
  128777. private _parent;
  128778. private _arrow;
  128779. private _coloredMaterial;
  128780. private _hoverMaterial;
  128781. /** @hidden */
  128782. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  128783. /** @hidden */
  128784. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128785. /**
  128786. * Creates an AxisDragGizmo
  128787. * @param gizmoLayer The utility layer the gizmo will be added to
  128788. * @param dragAxis The axis which the gizmo will be able to drag on
  128789. * @param color The color of the gizmo
  128790. * @param thickness display gizmo axis thickness
  128791. */
  128792. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  128793. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128794. /**
  128795. * If the gizmo is enabled
  128796. */
  128797. set isEnabled(value: boolean);
  128798. get isEnabled(): boolean;
  128799. /**
  128800. * Disposes of the gizmo
  128801. */
  128802. dispose(): void;
  128803. }
  128804. }
  128805. declare module BABYLON.Debug {
  128806. /**
  128807. * The Axes viewer will show 3 axes in a specific point in space
  128808. */
  128809. export class AxesViewer {
  128810. private _xAxis;
  128811. private _yAxis;
  128812. private _zAxis;
  128813. private _scaleLinesFactor;
  128814. private _instanced;
  128815. /**
  128816. * Gets the hosting scene
  128817. */
  128818. scene: Scene;
  128819. /**
  128820. * Gets or sets a number used to scale line length
  128821. */
  128822. scaleLines: number;
  128823. /** Gets the node hierarchy used to render x-axis */
  128824. get xAxis(): TransformNode;
  128825. /** Gets the node hierarchy used to render y-axis */
  128826. get yAxis(): TransformNode;
  128827. /** Gets the node hierarchy used to render z-axis */
  128828. get zAxis(): TransformNode;
  128829. /**
  128830. * Creates a new AxesViewer
  128831. * @param scene defines the hosting scene
  128832. * @param scaleLines defines a number used to scale line length (1 by default)
  128833. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  128834. * @param xAxis defines the node hierarchy used to render the x-axis
  128835. * @param yAxis defines the node hierarchy used to render the y-axis
  128836. * @param zAxis defines the node hierarchy used to render the z-axis
  128837. */
  128838. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  128839. /**
  128840. * Force the viewer to update
  128841. * @param position defines the position of the viewer
  128842. * @param xaxis defines the x axis of the viewer
  128843. * @param yaxis defines the y axis of the viewer
  128844. * @param zaxis defines the z axis of the viewer
  128845. */
  128846. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  128847. /**
  128848. * Creates an instance of this axes viewer.
  128849. * @returns a new axes viewer with instanced meshes
  128850. */
  128851. createInstance(): AxesViewer;
  128852. /** Releases resources */
  128853. dispose(): void;
  128854. private static _SetRenderingGroupId;
  128855. }
  128856. }
  128857. declare module BABYLON.Debug {
  128858. /**
  128859. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  128860. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  128861. */
  128862. export class BoneAxesViewer extends AxesViewer {
  128863. /**
  128864. * Gets or sets the target mesh where to display the axes viewer
  128865. */
  128866. mesh: Nullable<Mesh>;
  128867. /**
  128868. * Gets or sets the target bone where to display the axes viewer
  128869. */
  128870. bone: Nullable<Bone>;
  128871. /** Gets current position */
  128872. pos: Vector3;
  128873. /** Gets direction of X axis */
  128874. xaxis: Vector3;
  128875. /** Gets direction of Y axis */
  128876. yaxis: Vector3;
  128877. /** Gets direction of Z axis */
  128878. zaxis: Vector3;
  128879. /**
  128880. * Creates a new BoneAxesViewer
  128881. * @param scene defines the hosting scene
  128882. * @param bone defines the target bone
  128883. * @param mesh defines the target mesh
  128884. * @param scaleLines defines a scaling factor for line length (1 by default)
  128885. */
  128886. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  128887. /**
  128888. * Force the viewer to update
  128889. */
  128890. update(): void;
  128891. /** Releases resources */
  128892. dispose(): void;
  128893. }
  128894. }
  128895. declare module BABYLON {
  128896. /**
  128897. * Interface used to define scene explorer extensibility option
  128898. */
  128899. export interface IExplorerExtensibilityOption {
  128900. /**
  128901. * Define the option label
  128902. */
  128903. label: string;
  128904. /**
  128905. * Defines the action to execute on click
  128906. */
  128907. action: (entity: any) => void;
  128908. }
  128909. /**
  128910. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  128911. */
  128912. export interface IExplorerExtensibilityGroup {
  128913. /**
  128914. * Defines a predicate to test if a given type mut be extended
  128915. */
  128916. predicate: (entity: any) => boolean;
  128917. /**
  128918. * Gets the list of options added to a type
  128919. */
  128920. entries: IExplorerExtensibilityOption[];
  128921. }
  128922. /**
  128923. * Interface used to define the options to use to create the Inspector
  128924. */
  128925. export interface IInspectorOptions {
  128926. /**
  128927. * Display in overlay mode (default: false)
  128928. */
  128929. overlay?: boolean;
  128930. /**
  128931. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128932. */
  128933. globalRoot?: HTMLElement;
  128934. /**
  128935. * Display the Scene explorer
  128936. */
  128937. showExplorer?: boolean;
  128938. /**
  128939. * Display the property inspector
  128940. */
  128941. showInspector?: boolean;
  128942. /**
  128943. * Display in embed mode (both panes on the right)
  128944. */
  128945. embedMode?: boolean;
  128946. /**
  128947. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128948. */
  128949. handleResize?: boolean;
  128950. /**
  128951. * Allow the panes to popup (default: true)
  128952. */
  128953. enablePopup?: boolean;
  128954. /**
  128955. * Allow the panes to be closed by users (default: true)
  128956. */
  128957. enableClose?: boolean;
  128958. /**
  128959. * Optional list of extensibility entries
  128960. */
  128961. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128962. /**
  128963. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128964. */
  128965. inspectorURL?: string;
  128966. /**
  128967. * Optional initial tab (default to DebugLayerTab.Properties)
  128968. */
  128969. initialTab?: DebugLayerTab;
  128970. }
  128971. interface Scene {
  128972. /**
  128973. * @hidden
  128974. * Backing field
  128975. */
  128976. _debugLayer: DebugLayer;
  128977. /**
  128978. * Gets the debug layer (aka Inspector) associated with the scene
  128979. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128980. */
  128981. debugLayer: DebugLayer;
  128982. }
  128983. /**
  128984. * Enum of inspector action tab
  128985. */
  128986. export enum DebugLayerTab {
  128987. /**
  128988. * Properties tag (default)
  128989. */
  128990. Properties = 0,
  128991. /**
  128992. * Debug tab
  128993. */
  128994. Debug = 1,
  128995. /**
  128996. * Statistics tab
  128997. */
  128998. Statistics = 2,
  128999. /**
  129000. * Tools tab
  129001. */
  129002. Tools = 3,
  129003. /**
  129004. * Settings tab
  129005. */
  129006. Settings = 4
  129007. }
  129008. /**
  129009. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129010. * what is happening in your scene
  129011. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129012. */
  129013. export class DebugLayer {
  129014. /**
  129015. * Define the url to get the inspector script from.
  129016. * By default it uses the babylonjs CDN.
  129017. * @ignoreNaming
  129018. */
  129019. static InspectorURL: string;
  129020. private _scene;
  129021. private BJSINSPECTOR;
  129022. private _onPropertyChangedObservable?;
  129023. /**
  129024. * Observable triggered when a property is changed through the inspector.
  129025. */
  129026. get onPropertyChangedObservable(): any;
  129027. /**
  129028. * Instantiates a new debug layer.
  129029. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129030. * what is happening in your scene
  129031. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129032. * @param scene Defines the scene to inspect
  129033. */
  129034. constructor(scene: Scene);
  129035. /** Creates the inspector window. */
  129036. private _createInspector;
  129037. /**
  129038. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129039. * @param entity defines the entity to select
  129040. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129041. */
  129042. select(entity: any, lineContainerTitles?: string | string[]): void;
  129043. /** Get the inspector from bundle or global */
  129044. private _getGlobalInspector;
  129045. /**
  129046. * Get if the inspector is visible or not.
  129047. * @returns true if visible otherwise, false
  129048. */
  129049. isVisible(): boolean;
  129050. /**
  129051. * Hide the inspector and close its window.
  129052. */
  129053. hide(): void;
  129054. /**
  129055. * Update the scene in the inspector
  129056. */
  129057. setAsActiveScene(): void;
  129058. /**
  129059. * Launch the debugLayer.
  129060. * @param config Define the configuration of the inspector
  129061. * @return a promise fulfilled when the debug layer is visible
  129062. */
  129063. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129064. }
  129065. }
  129066. declare module BABYLON {
  129067. /**
  129068. * Class containing static functions to help procedurally build meshes
  129069. */
  129070. export class BoxBuilder {
  129071. /**
  129072. * Creates a box mesh
  129073. * * The parameter `size` sets the size (float) of each box side (default 1)
  129074. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129075. * * 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)
  129076. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129080. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129081. * @param name defines the name of the mesh
  129082. * @param options defines the options used to create the mesh
  129083. * @param scene defines the hosting scene
  129084. * @returns the box mesh
  129085. */
  129086. static CreateBox(name: string, options: {
  129087. size?: number;
  129088. width?: number;
  129089. height?: number;
  129090. depth?: number;
  129091. faceUV?: Vector4[];
  129092. faceColors?: Color4[];
  129093. sideOrientation?: number;
  129094. frontUVs?: Vector4;
  129095. backUVs?: Vector4;
  129096. wrap?: boolean;
  129097. topBaseAt?: number;
  129098. bottomBaseAt?: number;
  129099. updatable?: boolean;
  129100. }, scene?: Nullable<Scene>): Mesh;
  129101. }
  129102. }
  129103. declare module BABYLON.Debug {
  129104. /**
  129105. * Used to show the physics impostor around the specific mesh
  129106. */
  129107. export class PhysicsViewer {
  129108. /** @hidden */
  129109. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129110. /** @hidden */
  129111. protected _meshes: Array<Nullable<AbstractMesh>>;
  129112. /** @hidden */
  129113. protected _scene: Nullable<Scene>;
  129114. /** @hidden */
  129115. protected _numMeshes: number;
  129116. /** @hidden */
  129117. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129118. private _renderFunction;
  129119. private _utilityLayer;
  129120. private _debugBoxMesh;
  129121. private _debugSphereMesh;
  129122. private _debugCylinderMesh;
  129123. private _debugMaterial;
  129124. private _debugMeshMeshes;
  129125. /**
  129126. * Creates a new PhysicsViewer
  129127. * @param scene defines the hosting scene
  129128. */
  129129. constructor(scene: Scene);
  129130. /** @hidden */
  129131. protected _updateDebugMeshes(): void;
  129132. /**
  129133. * Renders a specified physic impostor
  129134. * @param impostor defines the impostor to render
  129135. * @param targetMesh defines the mesh represented by the impostor
  129136. * @returns the new debug mesh used to render the impostor
  129137. */
  129138. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129139. /**
  129140. * Hides a specified physic impostor
  129141. * @param impostor defines the impostor to hide
  129142. */
  129143. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129144. private _getDebugMaterial;
  129145. private _getDebugBoxMesh;
  129146. private _getDebugSphereMesh;
  129147. private _getDebugCylinderMesh;
  129148. private _getDebugMeshMesh;
  129149. private _getDebugMesh;
  129150. /** Releases all resources */
  129151. dispose(): void;
  129152. }
  129153. }
  129154. declare module BABYLON {
  129155. /**
  129156. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129157. * in order to better appreciate the issue one might have.
  129158. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129159. */
  129160. export class RayHelper {
  129161. /**
  129162. * Defines the ray we are currently tryin to visualize.
  129163. */
  129164. ray: Nullable<Ray>;
  129165. private _renderPoints;
  129166. private _renderLine;
  129167. private _renderFunction;
  129168. private _scene;
  129169. private _updateToMeshFunction;
  129170. private _attachedToMesh;
  129171. private _meshSpaceDirection;
  129172. private _meshSpaceOrigin;
  129173. /**
  129174. * Helper function to create a colored helper in a scene in one line.
  129175. * @param ray Defines the ray we are currently tryin to visualize
  129176. * @param scene Defines the scene the ray is used in
  129177. * @param color Defines the color we want to see the ray in
  129178. * @returns The newly created ray helper.
  129179. */
  129180. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129181. /**
  129182. * Instantiate a new ray helper.
  129183. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129184. * in order to better appreciate the issue one might have.
  129185. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129186. * @param ray Defines the ray we are currently tryin to visualize
  129187. */
  129188. constructor(ray: Ray);
  129189. /**
  129190. * Shows the ray we are willing to debug.
  129191. * @param scene Defines the scene the ray needs to be rendered in
  129192. * @param color Defines the color the ray needs to be rendered in
  129193. */
  129194. show(scene: Scene, color?: Color3): void;
  129195. /**
  129196. * Hides the ray we are debugging.
  129197. */
  129198. hide(): void;
  129199. private _render;
  129200. /**
  129201. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129202. * @param mesh Defines the mesh we want the helper attached to
  129203. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129204. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129205. * @param length Defines the length of the ray
  129206. */
  129207. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129208. /**
  129209. * Detach the ray helper from the mesh it has previously been attached to.
  129210. */
  129211. detachFromMesh(): void;
  129212. private _updateToMesh;
  129213. /**
  129214. * Dispose the helper and release its associated resources.
  129215. */
  129216. dispose(): void;
  129217. }
  129218. }
  129219. declare module BABYLON.Debug {
  129220. /**
  129221. * Class used to render a debug view of a given skeleton
  129222. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129223. */
  129224. export class SkeletonViewer {
  129225. /** defines the skeleton to render */
  129226. skeleton: Skeleton;
  129227. /** defines the mesh attached to the skeleton */
  129228. mesh: AbstractMesh;
  129229. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129230. autoUpdateBonesMatrices: boolean;
  129231. /** defines the rendering group id to use with the viewer */
  129232. renderingGroupId: number;
  129233. /** Gets or sets the color used to render the skeleton */
  129234. color: Color3;
  129235. private _scene;
  129236. private _debugLines;
  129237. private _debugMesh;
  129238. private _isEnabled;
  129239. private _renderFunction;
  129240. private _utilityLayer;
  129241. /**
  129242. * Returns the mesh used to render the bones
  129243. */
  129244. get debugMesh(): Nullable<LinesMesh>;
  129245. /**
  129246. * Creates a new SkeletonViewer
  129247. * @param skeleton defines the skeleton to render
  129248. * @param mesh defines the mesh attached to the skeleton
  129249. * @param scene defines the hosting scene
  129250. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  129251. * @param renderingGroupId defines the rendering group id to use with the viewer
  129252. */
  129253. constructor(
  129254. /** defines the skeleton to render */
  129255. skeleton: Skeleton,
  129256. /** defines the mesh attached to the skeleton */
  129257. mesh: AbstractMesh, scene: Scene,
  129258. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129259. autoUpdateBonesMatrices?: boolean,
  129260. /** defines the rendering group id to use with the viewer */
  129261. renderingGroupId?: number);
  129262. /** Gets or sets a boolean indicating if the viewer is enabled */
  129263. set isEnabled(value: boolean);
  129264. get isEnabled(): boolean;
  129265. private _getBonePosition;
  129266. private _getLinesForBonesWithLength;
  129267. private _getLinesForBonesNoLength;
  129268. /** Update the viewer to sync with current skeleton state */
  129269. update(): void;
  129270. /** Release associated resources */
  129271. dispose(): void;
  129272. }
  129273. }
  129274. declare module BABYLON {
  129275. /**
  129276. * Enum for Device Types
  129277. */
  129278. export enum DeviceType {
  129279. /** Generic */
  129280. Generic = 0,
  129281. /** Keyboard */
  129282. Keyboard = 1,
  129283. /** Mouse */
  129284. Mouse = 2,
  129285. /** Touch Pointers */
  129286. Touch = 3,
  129287. /** PS4 Dual Shock */
  129288. DualShock = 4,
  129289. /** Xbox */
  129290. Xbox = 5,
  129291. /** Switch Controller */
  129292. Switch = 6
  129293. }
  129294. /**
  129295. * Enum for All Pointers (Touch/Mouse)
  129296. */
  129297. export enum PointerInput {
  129298. /** Horizontal Axis */
  129299. Horizontal = 0,
  129300. /** Vertical Axis */
  129301. Vertical = 1,
  129302. /** Left Click or Touch */
  129303. LeftClick = 2,
  129304. /** Middle Click */
  129305. MiddleClick = 3,
  129306. /** Right Click */
  129307. RightClick = 4,
  129308. /** Browser Back */
  129309. BrowserBack = 5,
  129310. /** Browser Forward */
  129311. BrowserForward = 6
  129312. }
  129313. /**
  129314. * Enum for Dual Shock Gamepad
  129315. */
  129316. export enum DualShockInput {
  129317. /** Cross */
  129318. Cross = 0,
  129319. /** Circle */
  129320. Circle = 1,
  129321. /** Square */
  129322. Square = 2,
  129323. /** Triangle */
  129324. Triangle = 3,
  129325. /** L1 */
  129326. L1 = 4,
  129327. /** R1 */
  129328. R1 = 5,
  129329. /** L2 */
  129330. L2 = 6,
  129331. /** R2 */
  129332. R2 = 7,
  129333. /** Share */
  129334. Share = 8,
  129335. /** Options */
  129336. Options = 9,
  129337. /** L3 */
  129338. L3 = 10,
  129339. /** R3 */
  129340. R3 = 11,
  129341. /** DPadUp */
  129342. DPadUp = 12,
  129343. /** DPadDown */
  129344. DPadDown = 13,
  129345. /** DPadLeft */
  129346. DPadLeft = 14,
  129347. /** DRight */
  129348. DPadRight = 15,
  129349. /** Home */
  129350. Home = 16,
  129351. /** TouchPad */
  129352. TouchPad = 17,
  129353. /** LStickXAxis */
  129354. LStickXAxis = 18,
  129355. /** LStickYAxis */
  129356. LStickYAxis = 19,
  129357. /** RStickXAxis */
  129358. RStickXAxis = 20,
  129359. /** RStickYAxis */
  129360. RStickYAxis = 21
  129361. }
  129362. /**
  129363. * Enum for Xbox Gamepad
  129364. */
  129365. export enum XboxInput {
  129366. /** A */
  129367. A = 0,
  129368. /** B */
  129369. B = 1,
  129370. /** X */
  129371. X = 2,
  129372. /** Y */
  129373. Y = 3,
  129374. /** LB */
  129375. LB = 4,
  129376. /** RB */
  129377. RB = 5,
  129378. /** LT */
  129379. LT = 6,
  129380. /** RT */
  129381. RT = 7,
  129382. /** Back */
  129383. Back = 8,
  129384. /** Start */
  129385. Start = 9,
  129386. /** LS */
  129387. LS = 10,
  129388. /** RS */
  129389. RS = 11,
  129390. /** DPadUp */
  129391. DPadUp = 12,
  129392. /** DPadDown */
  129393. DPadDown = 13,
  129394. /** DPadLeft */
  129395. DPadLeft = 14,
  129396. /** DRight */
  129397. DPadRight = 15,
  129398. /** Home */
  129399. Home = 16,
  129400. /** LStickXAxis */
  129401. LStickXAxis = 17,
  129402. /** LStickYAxis */
  129403. LStickYAxis = 18,
  129404. /** RStickXAxis */
  129405. RStickXAxis = 19,
  129406. /** RStickYAxis */
  129407. RStickYAxis = 20
  129408. }
  129409. /**
  129410. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  129411. */
  129412. export enum SwitchInput {
  129413. /** B */
  129414. B = 0,
  129415. /** A */
  129416. A = 1,
  129417. /** Y */
  129418. Y = 2,
  129419. /** X */
  129420. X = 3,
  129421. /** L */
  129422. L = 4,
  129423. /** R */
  129424. R = 5,
  129425. /** ZL */
  129426. ZL = 6,
  129427. /** ZR */
  129428. ZR = 7,
  129429. /** Minus */
  129430. Minus = 8,
  129431. /** Plus */
  129432. Plus = 9,
  129433. /** LS */
  129434. LS = 10,
  129435. /** RS */
  129436. RS = 11,
  129437. /** DPadUp */
  129438. DPadUp = 12,
  129439. /** DPadDown */
  129440. DPadDown = 13,
  129441. /** DPadLeft */
  129442. DPadLeft = 14,
  129443. /** DRight */
  129444. DPadRight = 15,
  129445. /** Home */
  129446. Home = 16,
  129447. /** Capture */
  129448. Capture = 17,
  129449. /** LStickXAxis */
  129450. LStickXAxis = 18,
  129451. /** LStickYAxis */
  129452. LStickYAxis = 19,
  129453. /** RStickXAxis */
  129454. RStickXAxis = 20,
  129455. /** RStickYAxis */
  129456. RStickYAxis = 21
  129457. }
  129458. }
  129459. declare module BABYLON {
  129460. /**
  129461. * This class will take all inputs from Keyboard, Pointer, and
  129462. * any Gamepads and provide a polling system that all devices
  129463. * will use. This class assumes that there will only be one
  129464. * pointer device and one keyboard.
  129465. */
  129466. export class DeviceInputSystem implements IDisposable {
  129467. /**
  129468. * Callback to be triggered when a device is connected
  129469. */
  129470. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  129471. /**
  129472. * Callback to be triggered when a device is disconnected
  129473. */
  129474. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  129475. /**
  129476. * Callback to be triggered when event driven input is updated
  129477. */
  129478. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  129479. private _inputs;
  129480. private _gamepads;
  129481. private _keyboardActive;
  129482. private _pointerActive;
  129483. private _elementToAttachTo;
  129484. private _keyboardDownEvent;
  129485. private _keyboardUpEvent;
  129486. private _pointerMoveEvent;
  129487. private _pointerDownEvent;
  129488. private _pointerUpEvent;
  129489. private _gamepadConnectedEvent;
  129490. private _gamepadDisconnectedEvent;
  129491. private static _MAX_KEYCODES;
  129492. private static _MAX_POINTER_INPUTS;
  129493. private constructor();
  129494. /**
  129495. * Creates a new DeviceInputSystem instance
  129496. * @param engine Engine to pull input element from
  129497. * @returns The new instance
  129498. */
  129499. static Create(engine: Engine): DeviceInputSystem;
  129500. /**
  129501. * Checks for current device input value, given an id and input index
  129502. * @param deviceName Id of connected device
  129503. * @param inputIndex Index of device input
  129504. * @returns Current value of input
  129505. */
  129506. /**
  129507. * Checks for current device input value, given an id and input index
  129508. * @param deviceType Enum specifiying device type
  129509. * @param deviceSlot "Slot" or index that device is referenced in
  129510. * @param inputIndex Id of input to be checked
  129511. * @returns Current value of input
  129512. */
  129513. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  129514. /**
  129515. * Dispose of all the eventlisteners
  129516. */
  129517. dispose(): void;
  129518. /**
  129519. * Add device and inputs to device array
  129520. * @param deviceType Enum specifiying device type
  129521. * @param deviceSlot "Slot" or index that device is referenced in
  129522. * @param numberOfInputs Number of input entries to create for given device
  129523. */
  129524. private _registerDevice;
  129525. /**
  129526. * Given a specific device name, remove that device from the device map
  129527. * @param deviceType Enum specifiying device type
  129528. * @param deviceSlot "Slot" or index that device is referenced in
  129529. */
  129530. private _unregisterDevice;
  129531. /**
  129532. * Handle all actions that come from keyboard interaction
  129533. */
  129534. private _handleKeyActions;
  129535. /**
  129536. * Handle all actions that come from pointer interaction
  129537. */
  129538. private _handlePointerActions;
  129539. /**
  129540. * Handle all actions that come from gamepad interaction
  129541. */
  129542. private _handleGamepadActions;
  129543. /**
  129544. * Update all non-event based devices with each frame
  129545. * @param deviceType Enum specifiying device type
  129546. * @param deviceSlot "Slot" or index that device is referenced in
  129547. * @param inputIndex Id of input to be checked
  129548. */
  129549. private _updateDevice;
  129550. /**
  129551. * Gets DeviceType from the device name
  129552. * @param deviceName Name of Device from DeviceInputSystem
  129553. * @returns DeviceType enum value
  129554. */
  129555. private _getGamepadDeviceType;
  129556. }
  129557. }
  129558. declare module BABYLON {
  129559. /**
  129560. * Type to handle enforcement of inputs
  129561. */
  129562. 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;
  129563. }
  129564. declare module BABYLON {
  129565. /**
  129566. * Class that handles all input for a specific device
  129567. */
  129568. export class DeviceSource<T extends DeviceType> {
  129569. /** Type of device */
  129570. readonly deviceType: DeviceType;
  129571. /** "Slot" or index that device is referenced in */
  129572. readonly deviceSlot: number;
  129573. /**
  129574. * Observable to handle device input changes per device
  129575. */
  129576. readonly onInputChangedObservable: Observable<{
  129577. inputIndex: DeviceInput<T>;
  129578. previousState: Nullable<number>;
  129579. currentState: Nullable<number>;
  129580. }>;
  129581. private readonly _deviceInputSystem;
  129582. /**
  129583. * Default Constructor
  129584. * @param deviceInputSystem Reference to DeviceInputSystem
  129585. * @param deviceType Type of device
  129586. * @param deviceSlot "Slot" or index that device is referenced in
  129587. */
  129588. constructor(deviceInputSystem: DeviceInputSystem,
  129589. /** Type of device */
  129590. deviceType: DeviceType,
  129591. /** "Slot" or index that device is referenced in */
  129592. deviceSlot?: number);
  129593. /**
  129594. * Get input for specific input
  129595. * @param inputIndex index of specific input on device
  129596. * @returns Input value from DeviceInputSystem
  129597. */
  129598. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  129599. }
  129600. /**
  129601. * Class to keep track of devices
  129602. */
  129603. export class DeviceSourceManager implements IDisposable {
  129604. /**
  129605. * Observable to be triggered when before a device is connected
  129606. */
  129607. readonly onBeforeDeviceConnectedObservable: Observable<{
  129608. deviceType: DeviceType;
  129609. deviceSlot: number;
  129610. }>;
  129611. /**
  129612. * Observable to be triggered when before a device is disconnected
  129613. */
  129614. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  129615. deviceType: DeviceType;
  129616. deviceSlot: number;
  129617. }>;
  129618. /**
  129619. * Observable to be triggered when after a device is connected
  129620. */
  129621. readonly onAfterDeviceConnectedObservable: Observable<{
  129622. deviceType: DeviceType;
  129623. deviceSlot: number;
  129624. }>;
  129625. /**
  129626. * Observable to be triggered when after a device is disconnected
  129627. */
  129628. readonly onAfterDeviceDisconnectedObservable: Observable<{
  129629. deviceType: DeviceType;
  129630. deviceSlot: number;
  129631. }>;
  129632. private readonly _devices;
  129633. private readonly _firstDevice;
  129634. private readonly _deviceInputSystem;
  129635. /**
  129636. * Default Constructor
  129637. * @param engine engine to pull input element from
  129638. */
  129639. constructor(engine: Engine);
  129640. /**
  129641. * Gets a DeviceSource, given a type and slot
  129642. * @param deviceType Enum specifying device type
  129643. * @param deviceSlot "Slot" or index that device is referenced in
  129644. * @returns DeviceSource object
  129645. */
  129646. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  129647. /**
  129648. * Gets an array of DeviceSource objects for a given device type
  129649. * @param deviceType Enum specifying device type
  129650. * @returns Array of DeviceSource objects
  129651. */
  129652. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  129653. /**
  129654. * Dispose of DeviceInputSystem and other parts
  129655. */
  129656. dispose(): void;
  129657. /**
  129658. * Function to add device name to device list
  129659. * @param deviceType Enum specifying device type
  129660. * @param deviceSlot "Slot" or index that device is referenced in
  129661. */
  129662. private _addDevice;
  129663. /**
  129664. * Function to remove device name to device list
  129665. * @param deviceType Enum specifying device type
  129666. * @param deviceSlot "Slot" or index that device is referenced in
  129667. */
  129668. private _removeDevice;
  129669. /**
  129670. * Updates array storing first connected device of each type
  129671. * @param type Type of Device
  129672. */
  129673. private _updateFirstDevices;
  129674. }
  129675. }
  129676. declare module BABYLON {
  129677. /**
  129678. * Options to create the null engine
  129679. */
  129680. export class NullEngineOptions {
  129681. /**
  129682. * Render width (Default: 512)
  129683. */
  129684. renderWidth: number;
  129685. /**
  129686. * Render height (Default: 256)
  129687. */
  129688. renderHeight: number;
  129689. /**
  129690. * Texture size (Default: 512)
  129691. */
  129692. textureSize: number;
  129693. /**
  129694. * If delta time between frames should be constant
  129695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129696. */
  129697. deterministicLockstep: boolean;
  129698. /**
  129699. * Maximum about of steps between frames (Default: 4)
  129700. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129701. */
  129702. lockstepMaxSteps: number;
  129703. /**
  129704. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  129705. */
  129706. useHighPrecisionMatrix?: boolean;
  129707. }
  129708. /**
  129709. * The null engine class provides support for headless version of babylon.js.
  129710. * This can be used in server side scenario or for testing purposes
  129711. */
  129712. export class NullEngine extends Engine {
  129713. private _options;
  129714. /**
  129715. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  129716. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129717. * @returns true if engine is in deterministic lock step mode
  129718. */
  129719. isDeterministicLockStep(): boolean;
  129720. /**
  129721. * Gets the max steps when engine is running in deterministic lock step
  129722. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129723. * @returns the max steps
  129724. */
  129725. getLockstepMaxSteps(): number;
  129726. /**
  129727. * Gets the current hardware scaling level.
  129728. * By default the hardware scaling level is computed from the window device ratio.
  129729. * 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.
  129730. * @returns a number indicating the current hardware scaling level
  129731. */
  129732. getHardwareScalingLevel(): number;
  129733. constructor(options?: NullEngineOptions);
  129734. /**
  129735. * Creates a vertex buffer
  129736. * @param vertices the data for the vertex buffer
  129737. * @returns the new WebGL static buffer
  129738. */
  129739. createVertexBuffer(vertices: FloatArray): DataBuffer;
  129740. /**
  129741. * Creates a new index buffer
  129742. * @param indices defines the content of the index buffer
  129743. * @param updatable defines if the index buffer must be updatable
  129744. * @returns a new webGL buffer
  129745. */
  129746. createIndexBuffer(indices: IndicesArray): DataBuffer;
  129747. /**
  129748. * Clear the current render buffer or the current render target (if any is set up)
  129749. * @param color defines the color to use
  129750. * @param backBuffer defines if the back buffer must be cleared
  129751. * @param depth defines if the depth buffer must be cleared
  129752. * @param stencil defines if the stencil buffer must be cleared
  129753. */
  129754. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129755. /**
  129756. * Gets the current render width
  129757. * @param useScreen defines if screen size must be used (or the current render target if any)
  129758. * @returns a number defining the current render width
  129759. */
  129760. getRenderWidth(useScreen?: boolean): number;
  129761. /**
  129762. * Gets the current render height
  129763. * @param useScreen defines if screen size must be used (or the current render target if any)
  129764. * @returns a number defining the current render height
  129765. */
  129766. getRenderHeight(useScreen?: boolean): number;
  129767. /**
  129768. * Set the WebGL's viewport
  129769. * @param viewport defines the viewport element to be used
  129770. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  129771. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  129772. */
  129773. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  129774. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  129775. /**
  129776. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  129777. * @param pipelineContext defines the pipeline context to use
  129778. * @param uniformsNames defines the list of uniform names
  129779. * @returns an array of webGL uniform locations
  129780. */
  129781. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  129782. /**
  129783. * Gets the lsit of active attributes for a given webGL program
  129784. * @param pipelineContext defines the pipeline context to use
  129785. * @param attributesNames defines the list of attribute names to get
  129786. * @returns an array of indices indicating the offset of each attribute
  129787. */
  129788. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129789. /**
  129790. * Binds an effect to the webGL context
  129791. * @param effect defines the effect to bind
  129792. */
  129793. bindSamplers(effect: Effect): void;
  129794. /**
  129795. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  129796. * @param effect defines the effect to activate
  129797. */
  129798. enableEffect(effect: Effect): void;
  129799. /**
  129800. * Set various states to the webGL context
  129801. * @param culling defines backface culling state
  129802. * @param zOffset defines the value to apply to zOffset (0 by default)
  129803. * @param force defines if states must be applied even if cache is up to date
  129804. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  129805. */
  129806. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129807. /**
  129808. * Set the value of an uniform to an array of int32
  129809. * @param uniform defines the webGL uniform location where to store the value
  129810. * @param array defines the array of int32 to store
  129811. */
  129812. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129813. /**
  129814. * Set the value of an uniform to an array of int32 (stored as vec2)
  129815. * @param uniform defines the webGL uniform location where to store the value
  129816. * @param array defines the array of int32 to store
  129817. */
  129818. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129819. /**
  129820. * Set the value of an uniform to an array of int32 (stored as vec3)
  129821. * @param uniform defines the webGL uniform location where to store the value
  129822. * @param array defines the array of int32 to store
  129823. */
  129824. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129825. /**
  129826. * Set the value of an uniform to an array of int32 (stored as vec4)
  129827. * @param uniform defines the webGL uniform location where to store the value
  129828. * @param array defines the array of int32 to store
  129829. */
  129830. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129831. /**
  129832. * Set the value of an uniform to an array of float32
  129833. * @param uniform defines the webGL uniform location where to store the value
  129834. * @param array defines the array of float32 to store
  129835. */
  129836. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129837. /**
  129838. * Set the value of an uniform to an array of float32 (stored as vec2)
  129839. * @param uniform defines the webGL uniform location where to store the value
  129840. * @param array defines the array of float32 to store
  129841. */
  129842. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129843. /**
  129844. * Set the value of an uniform to an array of float32 (stored as vec3)
  129845. * @param uniform defines the webGL uniform location where to store the value
  129846. * @param array defines the array of float32 to store
  129847. */
  129848. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129849. /**
  129850. * Set the value of an uniform to an array of float32 (stored as vec4)
  129851. * @param uniform defines the webGL uniform location where to store the value
  129852. * @param array defines the array of float32 to store
  129853. */
  129854. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129855. /**
  129856. * Set the value of an uniform to an array of number
  129857. * @param uniform defines the webGL uniform location where to store the value
  129858. * @param array defines the array of number to store
  129859. */
  129860. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129861. /**
  129862. * Set the value of an uniform to an array of number (stored as vec2)
  129863. * @param uniform defines the webGL uniform location where to store the value
  129864. * @param array defines the array of number to store
  129865. */
  129866. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129867. /**
  129868. * Set the value of an uniform to an array of number (stored as vec3)
  129869. * @param uniform defines the webGL uniform location where to store the value
  129870. * @param array defines the array of number to store
  129871. */
  129872. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129873. /**
  129874. * Set the value of an uniform to an array of number (stored as vec4)
  129875. * @param uniform defines the webGL uniform location where to store the value
  129876. * @param array defines the array of number to store
  129877. */
  129878. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129879. /**
  129880. * Set the value of an uniform to an array of float32 (stored as matrices)
  129881. * @param uniform defines the webGL uniform location where to store the value
  129882. * @param matrices defines the array of float32 to store
  129883. */
  129884. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129885. /**
  129886. * Set the value of an uniform to a matrix (3x3)
  129887. * @param uniform defines the webGL uniform location where to store the value
  129888. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  129889. */
  129890. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129891. /**
  129892. * Set the value of an uniform to a matrix (2x2)
  129893. * @param uniform defines the webGL uniform location where to store the value
  129894. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  129895. */
  129896. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129897. /**
  129898. * Set the value of an uniform to a number (float)
  129899. * @param uniform defines the webGL uniform location where to store the value
  129900. * @param value defines the float number to store
  129901. */
  129902. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129903. /**
  129904. * Set the value of an uniform to a vec2
  129905. * @param uniform defines the webGL uniform location where to store the value
  129906. * @param x defines the 1st component of the value
  129907. * @param y defines the 2nd component of the value
  129908. */
  129909. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129910. /**
  129911. * Set the value of an uniform to a vec3
  129912. * @param uniform defines the webGL uniform location where to store the value
  129913. * @param x defines the 1st component of the value
  129914. * @param y defines the 2nd component of the value
  129915. * @param z defines the 3rd component of the value
  129916. */
  129917. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129918. /**
  129919. * Set the value of an uniform to a boolean
  129920. * @param uniform defines the webGL uniform location where to store the value
  129921. * @param bool defines the boolean to store
  129922. */
  129923. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129924. /**
  129925. * Set the value of an uniform to a vec4
  129926. * @param uniform defines the webGL uniform location where to store the value
  129927. * @param x defines the 1st component of the value
  129928. * @param y defines the 2nd component of the value
  129929. * @param z defines the 3rd component of the value
  129930. * @param w defines the 4th component of the value
  129931. */
  129932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129933. /**
  129934. * Sets the current alpha mode
  129935. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129936. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129938. */
  129939. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129940. /**
  129941. * Bind webGl buffers directly to the webGL context
  129942. * @param vertexBuffers defines the vertex buffer to bind
  129943. * @param indexBuffer defines the index buffer to bind
  129944. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129945. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129946. * @param effect defines the effect associated with the vertex buffer
  129947. */
  129948. bindBuffers(vertexBuffers: {
  129949. [key: string]: VertexBuffer;
  129950. }, indexBuffer: DataBuffer, effect: Effect): void;
  129951. /**
  129952. * Force the entire cache to be cleared
  129953. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129954. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129955. */
  129956. wipeCaches(bruteForce?: boolean): void;
  129957. /**
  129958. * Send a draw order
  129959. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129960. * @param indexStart defines the starting index
  129961. * @param indexCount defines the number of index to draw
  129962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129963. */
  129964. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129965. /**
  129966. * Draw a list of indexed primitives
  129967. * @param fillMode defines the primitive to use
  129968. * @param indexStart defines the starting index
  129969. * @param indexCount defines the number of index to draw
  129970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129971. */
  129972. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129973. /**
  129974. * Draw a list of unindexed primitives
  129975. * @param fillMode defines the primitive to use
  129976. * @param verticesStart defines the index of first vertex to draw
  129977. * @param verticesCount defines the count of vertices to draw
  129978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129979. */
  129980. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129981. /** @hidden */
  129982. _createTexture(): WebGLTexture;
  129983. /** @hidden */
  129984. _releaseTexture(texture: InternalTexture): void;
  129985. /**
  129986. * Usually called from Texture.ts.
  129987. * Passed information to create a WebGLTexture
  129988. * @param urlArg defines a value which contains one of the following:
  129989. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129990. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129991. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129993. * @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)
  129994. * @param scene needed for loading to the correct scene
  129995. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129996. * @param onLoad optional callback to be called upon successful completion
  129997. * @param onError optional callback to be called upon failure
  129998. * @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
  129999. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130000. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130001. * @param forcedExtension defines the extension to use to pick the right loader
  130002. * @param mimeType defines an optional mime type
  130003. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130004. */
  130005. 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;
  130006. /**
  130007. * Creates a new render target texture
  130008. * @param size defines the size of the texture
  130009. * @param options defines the options used to create the texture
  130010. * @returns a new render target texture stored in an InternalTexture
  130011. */
  130012. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130013. /**
  130014. * Update the sampling mode of a given texture
  130015. * @param samplingMode defines the required sampling mode
  130016. * @param texture defines the texture to update
  130017. */
  130018. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130019. /**
  130020. * Binds the frame buffer to the specified texture.
  130021. * @param texture The texture to render to or null for the default canvas
  130022. * @param faceIndex The face of the texture to render to in case of cube texture
  130023. * @param requiredWidth The width of the target to render to
  130024. * @param requiredHeight The height of the target to render to
  130025. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130026. * @param lodLevel defines le lod level to bind to the frame buffer
  130027. */
  130028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130029. /**
  130030. * Unbind the current render target texture from the webGL context
  130031. * @param texture defines the render target texture to unbind
  130032. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130033. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130034. */
  130035. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130036. /**
  130037. * Creates a dynamic vertex buffer
  130038. * @param vertices the data for the dynamic vertex buffer
  130039. * @returns the new WebGL dynamic buffer
  130040. */
  130041. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130042. /**
  130043. * Update the content of a dynamic texture
  130044. * @param texture defines the texture to update
  130045. * @param canvas defines the canvas containing the source
  130046. * @param invertY defines if data must be stored with Y axis inverted
  130047. * @param premulAlpha defines if alpha is stored as premultiplied
  130048. * @param format defines the format of the data
  130049. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130050. */
  130051. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130052. /**
  130053. * Gets a boolean indicating if all created effects are ready
  130054. * @returns true if all effects are ready
  130055. */
  130056. areAllEffectsReady(): boolean;
  130057. /**
  130058. * @hidden
  130059. * Get the current error code of the webGL context
  130060. * @returns the error code
  130061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130062. */
  130063. getError(): number;
  130064. /** @hidden */
  130065. _getUnpackAlignement(): number;
  130066. /** @hidden */
  130067. _unpackFlipY(value: boolean): void;
  130068. /**
  130069. * Update a dynamic index buffer
  130070. * @param indexBuffer defines the target index buffer
  130071. * @param indices defines the data to update
  130072. * @param offset defines the offset in the target index buffer where update should start
  130073. */
  130074. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130075. /**
  130076. * Updates a dynamic vertex buffer.
  130077. * @param vertexBuffer the vertex buffer to update
  130078. * @param vertices the data used to update the vertex buffer
  130079. * @param byteOffset the byte offset of the data (optional)
  130080. * @param byteLength the byte length of the data (optional)
  130081. */
  130082. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130083. /** @hidden */
  130084. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130085. /** @hidden */
  130086. _bindTexture(channel: number, texture: InternalTexture): void;
  130087. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130088. /**
  130089. * 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
  130090. */
  130091. releaseEffects(): void;
  130092. displayLoadingUI(): void;
  130093. hideLoadingUI(): void;
  130094. /** @hidden */
  130095. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130096. /** @hidden */
  130097. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130098. /** @hidden */
  130099. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130100. /** @hidden */
  130101. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130102. }
  130103. }
  130104. declare module BABYLON {
  130105. /**
  130106. * @hidden
  130107. **/
  130108. export class _TimeToken {
  130109. _startTimeQuery: Nullable<WebGLQuery>;
  130110. _endTimeQuery: Nullable<WebGLQuery>;
  130111. _timeElapsedQuery: Nullable<WebGLQuery>;
  130112. _timeElapsedQueryEnded: boolean;
  130113. }
  130114. }
  130115. declare module BABYLON {
  130116. /** @hidden */
  130117. export class _OcclusionDataStorage {
  130118. /** @hidden */
  130119. occlusionInternalRetryCounter: number;
  130120. /** @hidden */
  130121. isOcclusionQueryInProgress: boolean;
  130122. /** @hidden */
  130123. isOccluded: boolean;
  130124. /** @hidden */
  130125. occlusionRetryCount: number;
  130126. /** @hidden */
  130127. occlusionType: number;
  130128. /** @hidden */
  130129. occlusionQueryAlgorithmType: number;
  130130. }
  130131. interface Engine {
  130132. /**
  130133. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130134. * @return the new query
  130135. */
  130136. createQuery(): WebGLQuery;
  130137. /**
  130138. * Delete and release a webGL query
  130139. * @param query defines the query to delete
  130140. * @return the current engine
  130141. */
  130142. deleteQuery(query: WebGLQuery): Engine;
  130143. /**
  130144. * Check if a given query has resolved and got its value
  130145. * @param query defines the query to check
  130146. * @returns true if the query got its value
  130147. */
  130148. isQueryResultAvailable(query: WebGLQuery): boolean;
  130149. /**
  130150. * Gets the value of a given query
  130151. * @param query defines the query to check
  130152. * @returns the value of the query
  130153. */
  130154. getQueryResult(query: WebGLQuery): number;
  130155. /**
  130156. * Initiates an occlusion query
  130157. * @param algorithmType defines the algorithm to use
  130158. * @param query defines the query to use
  130159. * @returns the current engine
  130160. * @see https://doc.babylonjs.com/features/occlusionquery
  130161. */
  130162. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130163. /**
  130164. * Ends an occlusion query
  130165. * @see https://doc.babylonjs.com/features/occlusionquery
  130166. * @param algorithmType defines the algorithm to use
  130167. * @returns the current engine
  130168. */
  130169. endOcclusionQuery(algorithmType: number): Engine;
  130170. /**
  130171. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130172. * Please note that only one query can be issued at a time
  130173. * @returns a time token used to track the time span
  130174. */
  130175. startTimeQuery(): Nullable<_TimeToken>;
  130176. /**
  130177. * Ends a time query
  130178. * @param token defines the token used to measure the time span
  130179. * @returns the time spent (in ns)
  130180. */
  130181. endTimeQuery(token: _TimeToken): int;
  130182. /** @hidden */
  130183. _currentNonTimestampToken: Nullable<_TimeToken>;
  130184. /** @hidden */
  130185. _createTimeQuery(): WebGLQuery;
  130186. /** @hidden */
  130187. _deleteTimeQuery(query: WebGLQuery): void;
  130188. /** @hidden */
  130189. _getGlAlgorithmType(algorithmType: number): number;
  130190. /** @hidden */
  130191. _getTimeQueryResult(query: WebGLQuery): any;
  130192. /** @hidden */
  130193. _getTimeQueryAvailability(query: WebGLQuery): any;
  130194. }
  130195. interface AbstractMesh {
  130196. /**
  130197. * Backing filed
  130198. * @hidden
  130199. */
  130200. __occlusionDataStorage: _OcclusionDataStorage;
  130201. /**
  130202. * Access property
  130203. * @hidden
  130204. */
  130205. _occlusionDataStorage: _OcclusionDataStorage;
  130206. /**
  130207. * 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.
  130208. * The default value is -1 which means don't break the query and wait till the result
  130209. * @see https://doc.babylonjs.com/features/occlusionquery
  130210. */
  130211. occlusionRetryCount: number;
  130212. /**
  130213. * 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:
  130214. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  130215. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  130216. * * 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.
  130217. * @see https://doc.babylonjs.com/features/occlusionquery
  130218. */
  130219. occlusionType: number;
  130220. /**
  130221. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  130222. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  130223. * * 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.
  130224. * @see https://doc.babylonjs.com/features/occlusionquery
  130225. */
  130226. occlusionQueryAlgorithmType: number;
  130227. /**
  130228. * 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
  130229. * @see https://doc.babylonjs.com/features/occlusionquery
  130230. */
  130231. isOccluded: boolean;
  130232. /**
  130233. * Flag to check the progress status of the query
  130234. * @see https://doc.babylonjs.com/features/occlusionquery
  130235. */
  130236. isOcclusionQueryInProgress: boolean;
  130237. }
  130238. }
  130239. declare module BABYLON {
  130240. /** @hidden */
  130241. export var _forceTransformFeedbackToBundle: boolean;
  130242. interface Engine {
  130243. /**
  130244. * Creates a webGL transform feedback object
  130245. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  130246. * @returns the webGL transform feedback object
  130247. */
  130248. createTransformFeedback(): WebGLTransformFeedback;
  130249. /**
  130250. * Delete a webGL transform feedback object
  130251. * @param value defines the webGL transform feedback object to delete
  130252. */
  130253. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  130254. /**
  130255. * Bind a webGL transform feedback object to the webgl context
  130256. * @param value defines the webGL transform feedback object to bind
  130257. */
  130258. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  130259. /**
  130260. * Begins a transform feedback operation
  130261. * @param usePoints defines if points or triangles must be used
  130262. */
  130263. beginTransformFeedback(usePoints: boolean): void;
  130264. /**
  130265. * Ends a transform feedback operation
  130266. */
  130267. endTransformFeedback(): void;
  130268. /**
  130269. * Specify the varyings to use with transform feedback
  130270. * @param program defines the associated webGL program
  130271. * @param value defines the list of strings representing the varying names
  130272. */
  130273. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  130274. /**
  130275. * Bind a webGL buffer for a transform feedback operation
  130276. * @param value defines the webGL buffer to bind
  130277. */
  130278. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  130279. }
  130280. }
  130281. declare module BABYLON {
  130282. /**
  130283. * Class used to define an additional view for the engine
  130284. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130285. */
  130286. export class EngineView {
  130287. /** Defines the canvas where to render the view */
  130288. target: HTMLCanvasElement;
  130289. /** Defines an optional camera used to render the view (will use active camera else) */
  130290. camera?: Camera;
  130291. }
  130292. interface Engine {
  130293. /**
  130294. * Gets or sets the HTML element to use for attaching events
  130295. */
  130296. inputElement: Nullable<HTMLElement>;
  130297. /**
  130298. * Gets the current engine view
  130299. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130300. */
  130301. activeView: Nullable<EngineView>;
  130302. /** Gets or sets the list of views */
  130303. views: EngineView[];
  130304. /**
  130305. * Register a new child canvas
  130306. * @param canvas defines the canvas to register
  130307. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  130308. * @returns the associated view
  130309. */
  130310. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  130311. /**
  130312. * Remove a registered child canvas
  130313. * @param canvas defines the canvas to remove
  130314. * @returns the current engine
  130315. */
  130316. unRegisterView(canvas: HTMLCanvasElement): Engine;
  130317. }
  130318. }
  130319. declare module BABYLON {
  130320. interface Engine {
  130321. /** @hidden */
  130322. _excludedCompressedTextures: string[];
  130323. /** @hidden */
  130324. _textureFormatInUse: string;
  130325. /**
  130326. * Gets the list of texture formats supported
  130327. */
  130328. readonly texturesSupported: Array<string>;
  130329. /**
  130330. * Gets the texture format in use
  130331. */
  130332. readonly textureFormatInUse: Nullable<string>;
  130333. /**
  130334. * Set the compressed texture extensions or file names to skip.
  130335. *
  130336. * @param skippedFiles defines the list of those texture files you want to skip
  130337. * Example: [".dds", ".env", "myfile.png"]
  130338. */
  130339. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  130340. /**
  130341. * Set the compressed texture format to use, based on the formats you have, and the formats
  130342. * supported by the hardware / browser.
  130343. *
  130344. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  130345. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  130346. * to API arguments needed to compressed textures. This puts the burden on the container
  130347. * generator to house the arcane code for determining these for current & future formats.
  130348. *
  130349. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  130350. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  130351. *
  130352. * Note: The result of this call is not taken into account when a texture is base64.
  130353. *
  130354. * @param formatsAvailable defines the list of those format families you have created
  130355. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  130356. *
  130357. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  130358. * @returns The extension selected.
  130359. */
  130360. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  130361. }
  130362. }
  130363. declare module BABYLON {
  130364. /**
  130365. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  130366. */
  130367. export interface CubeMapInfo {
  130368. /**
  130369. * The pixel array for the front face.
  130370. * This is stored in format, left to right, up to down format.
  130371. */
  130372. front: Nullable<ArrayBufferView>;
  130373. /**
  130374. * The pixel array for the back face.
  130375. * This is stored in format, left to right, up to down format.
  130376. */
  130377. back: Nullable<ArrayBufferView>;
  130378. /**
  130379. * The pixel array for the left face.
  130380. * This is stored in format, left to right, up to down format.
  130381. */
  130382. left: Nullable<ArrayBufferView>;
  130383. /**
  130384. * The pixel array for the right face.
  130385. * This is stored in format, left to right, up to down format.
  130386. */
  130387. right: Nullable<ArrayBufferView>;
  130388. /**
  130389. * The pixel array for the up face.
  130390. * This is stored in format, left to right, up to down format.
  130391. */
  130392. up: Nullable<ArrayBufferView>;
  130393. /**
  130394. * The pixel array for the down face.
  130395. * This is stored in format, left to right, up to down format.
  130396. */
  130397. down: Nullable<ArrayBufferView>;
  130398. /**
  130399. * The size of the cubemap stored.
  130400. *
  130401. * Each faces will be size * size pixels.
  130402. */
  130403. size: number;
  130404. /**
  130405. * The format of the texture.
  130406. *
  130407. * RGBA, RGB.
  130408. */
  130409. format: number;
  130410. /**
  130411. * The type of the texture data.
  130412. *
  130413. * UNSIGNED_INT, FLOAT.
  130414. */
  130415. type: number;
  130416. /**
  130417. * Specifies whether the texture is in gamma space.
  130418. */
  130419. gammaSpace: boolean;
  130420. }
  130421. /**
  130422. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  130423. */
  130424. export class PanoramaToCubeMapTools {
  130425. private static FACE_LEFT;
  130426. private static FACE_RIGHT;
  130427. private static FACE_FRONT;
  130428. private static FACE_BACK;
  130429. private static FACE_DOWN;
  130430. private static FACE_UP;
  130431. /**
  130432. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  130433. *
  130434. * @param float32Array The source data.
  130435. * @param inputWidth The width of the input panorama.
  130436. * @param inputHeight The height of the input panorama.
  130437. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  130438. * @return The cubemap data
  130439. */
  130440. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  130441. private static CreateCubemapTexture;
  130442. private static CalcProjectionSpherical;
  130443. }
  130444. }
  130445. declare module BABYLON {
  130446. /**
  130447. * Helper class dealing with the extraction of spherical polynomial dataArray
  130448. * from a cube map.
  130449. */
  130450. export class CubeMapToSphericalPolynomialTools {
  130451. private static FileFaces;
  130452. /**
  130453. * Converts a texture to the according Spherical Polynomial data.
  130454. * This extracts the first 3 orders only as they are the only one used in the lighting.
  130455. *
  130456. * @param texture The texture to extract the information from.
  130457. * @return The Spherical Polynomial data.
  130458. */
  130459. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  130460. /**
  130461. * Converts a cubemap to the according Spherical Polynomial data.
  130462. * This extracts the first 3 orders only as they are the only one used in the lighting.
  130463. *
  130464. * @param cubeInfo The Cube map to extract the information from.
  130465. * @return The Spherical Polynomial data.
  130466. */
  130467. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  130468. }
  130469. }
  130470. declare module BABYLON {
  130471. interface BaseTexture {
  130472. /**
  130473. * Get the polynomial representation of the texture data.
  130474. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  130475. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  130476. */
  130477. sphericalPolynomial: Nullable<SphericalPolynomial>;
  130478. }
  130479. }
  130480. declare module BABYLON {
  130481. /** @hidden */
  130482. export var rgbdEncodePixelShader: {
  130483. name: string;
  130484. shader: string;
  130485. };
  130486. }
  130487. declare module BABYLON {
  130488. /** @hidden */
  130489. export var rgbdDecodePixelShader: {
  130490. name: string;
  130491. shader: string;
  130492. };
  130493. }
  130494. declare module BABYLON {
  130495. /**
  130496. * Raw texture data and descriptor sufficient for WebGL texture upload
  130497. */
  130498. export interface EnvironmentTextureInfo {
  130499. /**
  130500. * Version of the environment map
  130501. */
  130502. version: number;
  130503. /**
  130504. * Width of image
  130505. */
  130506. width: number;
  130507. /**
  130508. * Irradiance information stored in the file.
  130509. */
  130510. irradiance: any;
  130511. /**
  130512. * Specular information stored in the file.
  130513. */
  130514. specular: any;
  130515. }
  130516. /**
  130517. * Defines One Image in the file. It requires only the position in the file
  130518. * as well as the length.
  130519. */
  130520. interface BufferImageData {
  130521. /**
  130522. * Length of the image data.
  130523. */
  130524. length: number;
  130525. /**
  130526. * Position of the data from the null terminator delimiting the end of the JSON.
  130527. */
  130528. position: number;
  130529. }
  130530. /**
  130531. * Defines the specular data enclosed in the file.
  130532. * This corresponds to the version 1 of the data.
  130533. */
  130534. export interface EnvironmentTextureSpecularInfoV1 {
  130535. /**
  130536. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  130537. */
  130538. specularDataPosition?: number;
  130539. /**
  130540. * This contains all the images data needed to reconstruct the cubemap.
  130541. */
  130542. mipmaps: Array<BufferImageData>;
  130543. /**
  130544. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  130545. */
  130546. lodGenerationScale: number;
  130547. }
  130548. /**
  130549. * Sets of helpers addressing the serialization and deserialization of environment texture
  130550. * stored in a BabylonJS env file.
  130551. * Those files are usually stored as .env files.
  130552. */
  130553. export class EnvironmentTextureTools {
  130554. /**
  130555. * Magic number identifying the env file.
  130556. */
  130557. private static _MagicBytes;
  130558. /**
  130559. * Gets the environment info from an env file.
  130560. * @param data The array buffer containing the .env bytes.
  130561. * @returns the environment file info (the json header) if successfully parsed.
  130562. */
  130563. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  130564. /**
  130565. * Creates an environment texture from a loaded cube texture.
  130566. * @param texture defines the cube texture to convert in env file
  130567. * @return a promise containing the environment data if succesfull.
  130568. */
  130569. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  130570. /**
  130571. * Creates a JSON representation of the spherical data.
  130572. * @param texture defines the texture containing the polynomials
  130573. * @return the JSON representation of the spherical info
  130574. */
  130575. private static _CreateEnvTextureIrradiance;
  130576. /**
  130577. * Creates the ArrayBufferViews used for initializing environment texture image data.
  130578. * @param data the image data
  130579. * @param info parameters that determine what views will be created for accessing the underlying buffer
  130580. * @return the views described by info providing access to the underlying buffer
  130581. */
  130582. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  130583. /**
  130584. * Uploads the texture info contained in the env file to the GPU.
  130585. * @param texture defines the internal texture to upload to
  130586. * @param data defines the data to load
  130587. * @param info defines the texture info retrieved through the GetEnvInfo method
  130588. * @returns a promise
  130589. */
  130590. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  130591. private static _OnImageReadyAsync;
  130592. /**
  130593. * Uploads the levels of image data to the GPU.
  130594. * @param texture defines the internal texture to upload to
  130595. * @param imageData defines the array buffer views of image data [mipmap][face]
  130596. * @returns a promise
  130597. */
  130598. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  130599. /**
  130600. * Uploads spherical polynomials information to the texture.
  130601. * @param texture defines the texture we are trying to upload the information to
  130602. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  130603. */
  130604. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  130605. /** @hidden */
  130606. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /**
  130611. * Class used to inline functions in shader code
  130612. */
  130613. export class ShaderCodeInliner {
  130614. private static readonly _RegexpFindFunctionNameAndType;
  130615. private _sourceCode;
  130616. private _functionDescr;
  130617. private _numMaxIterations;
  130618. /** Gets or sets the token used to mark the functions to inline */
  130619. inlineToken: string;
  130620. /** Gets or sets the debug mode */
  130621. debug: boolean;
  130622. /** Gets the code after the inlining process */
  130623. get code(): string;
  130624. /**
  130625. * Initializes the inliner
  130626. * @param sourceCode shader code source to inline
  130627. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  130628. */
  130629. constructor(sourceCode: string, numMaxIterations?: number);
  130630. /**
  130631. * Start the processing of the shader code
  130632. */
  130633. processCode(): void;
  130634. private _collectFunctions;
  130635. private _processInlining;
  130636. private _extractBetweenMarkers;
  130637. private _skipWhitespaces;
  130638. private _removeComments;
  130639. private _replaceFunctionCallsByCode;
  130640. private _findBackward;
  130641. private _escapeRegExp;
  130642. private _replaceNames;
  130643. }
  130644. }
  130645. declare module BABYLON {
  130646. /**
  130647. * Container for accessors for natively-stored mesh data buffers.
  130648. */
  130649. class NativeDataBuffer extends DataBuffer {
  130650. /**
  130651. * Accessor value used to identify/retrieve a natively-stored index buffer.
  130652. */
  130653. nativeIndexBuffer?: any;
  130654. /**
  130655. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  130656. */
  130657. nativeVertexBuffer?: any;
  130658. }
  130659. /** @hidden */
  130660. class NativeTexture extends InternalTexture {
  130661. getInternalTexture(): InternalTexture;
  130662. getViewCount(): number;
  130663. }
  130664. /** @hidden */
  130665. export class NativeEngine extends Engine {
  130666. private readonly _native;
  130667. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  130668. private readonly INVALID_HANDLE;
  130669. getHardwareScalingLevel(): number;
  130670. constructor();
  130671. dispose(): void;
  130672. /**
  130673. * Can be used to override the current requestAnimationFrame requester.
  130674. * @hidden
  130675. */
  130676. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  130677. /**
  130678. * Override default engine behavior.
  130679. * @param color
  130680. * @param backBuffer
  130681. * @param depth
  130682. * @param stencil
  130683. */
  130684. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  130685. /**
  130686. * Gets host document
  130687. * @returns the host document object
  130688. */
  130689. getHostDocument(): Nullable<Document>;
  130690. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130691. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  130692. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  130693. recordVertexArrayObject(vertexBuffers: {
  130694. [key: string]: VertexBuffer;
  130695. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  130696. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130697. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130698. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130699. /**
  130700. * Draw a list of indexed primitives
  130701. * @param fillMode defines the primitive to use
  130702. * @param indexStart defines the starting index
  130703. * @param indexCount defines the number of index to draw
  130704. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130705. */
  130706. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130707. /**
  130708. * Draw a list of unindexed primitives
  130709. * @param fillMode defines the primitive to use
  130710. * @param verticesStart defines the index of first vertex to draw
  130711. * @param verticesCount defines the count of vertices to draw
  130712. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130713. */
  130714. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130715. createPipelineContext(): IPipelineContext;
  130716. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  130717. /** @hidden */
  130718. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130719. /** @hidden */
  130720. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130721. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130722. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130723. protected _setProgram(program: WebGLProgram): void;
  130724. _releaseEffect(effect: Effect): void;
  130725. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  130726. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  130727. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130728. bindSamplers(effect: Effect): void;
  130729. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  130730. getRenderWidth(useScreen?: boolean): number;
  130731. getRenderHeight(useScreen?: boolean): number;
  130732. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  130733. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130734. /**
  130735. * Set the z offset to apply to current rendering
  130736. * @param value defines the offset to apply
  130737. */
  130738. setZOffset(value: number): void;
  130739. /**
  130740. * Gets the current value of the zOffset
  130741. * @returns the current zOffset state
  130742. */
  130743. getZOffset(): number;
  130744. /**
  130745. * Enable or disable depth buffering
  130746. * @param enable defines the state to set
  130747. */
  130748. setDepthBuffer(enable: boolean): void;
  130749. /**
  130750. * Gets a boolean indicating if depth writing is enabled
  130751. * @returns the current depth writing state
  130752. */
  130753. getDepthWrite(): boolean;
  130754. /**
  130755. * Enable or disable depth writing
  130756. * @param enable defines the state to set
  130757. */
  130758. setDepthWrite(enable: boolean): void;
  130759. /**
  130760. * Enable or disable color writing
  130761. * @param enable defines the state to set
  130762. */
  130763. setColorWrite(enable: boolean): void;
  130764. /**
  130765. * Gets a boolean indicating if color writing is enabled
  130766. * @returns the current color writing state
  130767. */
  130768. getColorWrite(): boolean;
  130769. /**
  130770. * Sets alpha constants used by some alpha blending modes
  130771. * @param r defines the red component
  130772. * @param g defines the green component
  130773. * @param b defines the blue component
  130774. * @param a defines the alpha component
  130775. */
  130776. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130777. /**
  130778. * Sets the current alpha mode
  130779. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130780. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130781. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130782. */
  130783. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130784. /**
  130785. * Gets the current alpha mode
  130786. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130787. * @returns the current alpha mode
  130788. */
  130789. getAlphaMode(): number;
  130790. setInt(uniform: WebGLUniformLocation, int: number): void;
  130791. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130792. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130793. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130794. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130795. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130796. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130797. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130798. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130799. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130800. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130801. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130802. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130803. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130804. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130805. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130806. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130807. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130808. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130809. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130810. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130811. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130812. wipeCaches(bruteForce?: boolean): void;
  130813. _createTexture(): WebGLTexture;
  130814. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130815. /**
  130816. * Usually called from Texture.ts.
  130817. * Passed information to create a WebGLTexture
  130818. * @param url defines a value which contains one of the following:
  130819. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130820. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130821. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130822. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130823. * @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)
  130824. * @param scene needed for loading to the correct scene
  130825. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130826. * @param onLoad optional callback to be called upon successful completion
  130827. * @param onError optional callback to be called upon failure
  130828. * @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
  130829. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130830. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130831. * @param forcedExtension defines the extension to use to pick the right loader
  130832. * @param mimeType defines an optional mime type
  130833. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130834. */
  130835. 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): InternalTexture;
  130836. /**
  130837. * Creates a cube texture
  130838. * @param rootUrl defines the url where the files to load is located
  130839. * @param scene defines the current scene
  130840. * @param files defines the list of files to load (1 per face)
  130841. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130842. * @param onLoad defines an optional callback raised when the texture is loaded
  130843. * @param onError defines an optional callback raised if there is an issue to load the texture
  130844. * @param format defines the format of the data
  130845. * @param forcedExtension defines the extension to use to pick the right loader
  130846. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130847. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130848. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130849. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130850. * @returns the cube texture as an InternalTexture
  130851. */
  130852. 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;
  130853. private _getSamplingFilter;
  130854. private static _GetNativeTextureFormat;
  130855. createRenderTargetTexture(size: number | {
  130856. width: number;
  130857. height: number;
  130858. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130859. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130860. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130861. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130862. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130863. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130864. /**
  130865. * Updates a dynamic vertex buffer.
  130866. * @param vertexBuffer the vertex buffer to update
  130867. * @param data the data used to update the vertex buffer
  130868. * @param byteOffset the byte offset of the data (optional)
  130869. * @param byteLength the byte length of the data (optional)
  130870. */
  130871. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130872. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130873. private _updateAnisotropicLevel;
  130874. private _getAddressMode;
  130875. /** @hidden */
  130876. _bindTexture(channel: number, texture: InternalTexture): void;
  130877. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130878. releaseEffects(): void;
  130879. /** @hidden */
  130880. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130881. /** @hidden */
  130882. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130883. /** @hidden */
  130884. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130885. /** @hidden */
  130886. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130887. }
  130888. }
  130889. declare module BABYLON {
  130890. /**
  130891. * Gather the list of clipboard event types as constants.
  130892. */
  130893. export class ClipboardEventTypes {
  130894. /**
  130895. * The clipboard event is fired when a copy command is active (pressed).
  130896. */
  130897. static readonly COPY: number;
  130898. /**
  130899. * The clipboard event is fired when a cut command is active (pressed).
  130900. */
  130901. static readonly CUT: number;
  130902. /**
  130903. * The clipboard event is fired when a paste command is active (pressed).
  130904. */
  130905. static readonly PASTE: number;
  130906. }
  130907. /**
  130908. * This class is used to store clipboard related info for the onClipboardObservable event.
  130909. */
  130910. export class ClipboardInfo {
  130911. /**
  130912. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130913. */
  130914. type: number;
  130915. /**
  130916. * Defines the related dom event
  130917. */
  130918. event: ClipboardEvent;
  130919. /**
  130920. *Creates an instance of ClipboardInfo.
  130921. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130922. * @param event Defines the related dom event
  130923. */
  130924. constructor(
  130925. /**
  130926. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130927. */
  130928. type: number,
  130929. /**
  130930. * Defines the related dom event
  130931. */
  130932. event: ClipboardEvent);
  130933. /**
  130934. * Get the clipboard event's type from the keycode.
  130935. * @param keyCode Defines the keyCode for the current keyboard event.
  130936. * @return {number}
  130937. */
  130938. static GetTypeFromCharacter(keyCode: number): number;
  130939. }
  130940. }
  130941. declare module BABYLON {
  130942. /**
  130943. * Google Daydream controller
  130944. */
  130945. export class DaydreamController extends WebVRController {
  130946. /**
  130947. * Base Url for the controller model.
  130948. */
  130949. static MODEL_BASE_URL: string;
  130950. /**
  130951. * File name for the controller model.
  130952. */
  130953. static MODEL_FILENAME: string;
  130954. /**
  130955. * Gamepad Id prefix used to identify Daydream Controller.
  130956. */
  130957. static readonly GAMEPAD_ID_PREFIX: string;
  130958. /**
  130959. * Creates a new DaydreamController from a gamepad
  130960. * @param vrGamepad the gamepad that the controller should be created from
  130961. */
  130962. constructor(vrGamepad: any);
  130963. /**
  130964. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130965. * @param scene scene in which to add meshes
  130966. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130967. */
  130968. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130969. /**
  130970. * Called once for each button that changed state since the last frame
  130971. * @param buttonIdx Which button index changed
  130972. * @param state New state of the button
  130973. * @param changes Which properties on the state changed since last frame
  130974. */
  130975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130976. }
  130977. }
  130978. declare module BABYLON {
  130979. /**
  130980. * Gear VR Controller
  130981. */
  130982. export class GearVRController extends WebVRController {
  130983. /**
  130984. * Base Url for the controller model.
  130985. */
  130986. static MODEL_BASE_URL: string;
  130987. /**
  130988. * File name for the controller model.
  130989. */
  130990. static MODEL_FILENAME: string;
  130991. /**
  130992. * Gamepad Id prefix used to identify this controller.
  130993. */
  130994. static readonly GAMEPAD_ID_PREFIX: string;
  130995. private readonly _buttonIndexToObservableNameMap;
  130996. /**
  130997. * Creates a new GearVRController from a gamepad
  130998. * @param vrGamepad the gamepad that the controller should be created from
  130999. */
  131000. constructor(vrGamepad: any);
  131001. /**
  131002. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131003. * @param scene scene in which to add meshes
  131004. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131005. */
  131006. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131007. /**
  131008. * Called once for each button that changed state since the last frame
  131009. * @param buttonIdx Which button index changed
  131010. * @param state New state of the button
  131011. * @param changes Which properties on the state changed since last frame
  131012. */
  131013. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131014. }
  131015. }
  131016. declare module BABYLON {
  131017. /**
  131018. * Generic Controller
  131019. */
  131020. export class GenericController extends WebVRController {
  131021. /**
  131022. * Base Url for the controller model.
  131023. */
  131024. static readonly MODEL_BASE_URL: string;
  131025. /**
  131026. * File name for the controller model.
  131027. */
  131028. static readonly MODEL_FILENAME: string;
  131029. /**
  131030. * Creates a new GenericController from a gamepad
  131031. * @param vrGamepad the gamepad that the controller should be created from
  131032. */
  131033. constructor(vrGamepad: any);
  131034. /**
  131035. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131036. * @param scene scene in which to add meshes
  131037. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131038. */
  131039. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131040. /**
  131041. * Called once for each button that changed state since the last frame
  131042. * @param buttonIdx Which button index changed
  131043. * @param state New state of the button
  131044. * @param changes Which properties on the state changed since last frame
  131045. */
  131046. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131047. }
  131048. }
  131049. declare module BABYLON {
  131050. /**
  131051. * Oculus Touch Controller
  131052. */
  131053. export class OculusTouchController extends WebVRController {
  131054. /**
  131055. * Base Url for the controller model.
  131056. */
  131057. static MODEL_BASE_URL: string;
  131058. /**
  131059. * File name for the left controller model.
  131060. */
  131061. static MODEL_LEFT_FILENAME: string;
  131062. /**
  131063. * File name for the right controller model.
  131064. */
  131065. static MODEL_RIGHT_FILENAME: string;
  131066. /**
  131067. * Base Url for the Quest controller model.
  131068. */
  131069. static QUEST_MODEL_BASE_URL: string;
  131070. /**
  131071. * @hidden
  131072. * If the controllers are running on a device that needs the updated Quest controller models
  131073. */
  131074. static _IsQuest: boolean;
  131075. /**
  131076. * Fired when the secondary trigger on this controller is modified
  131077. */
  131078. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131079. /**
  131080. * Fired when the thumb rest on this controller is modified
  131081. */
  131082. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131083. /**
  131084. * Creates a new OculusTouchController from a gamepad
  131085. * @param vrGamepad the gamepad that the controller should be created from
  131086. */
  131087. constructor(vrGamepad: any);
  131088. /**
  131089. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131090. * @param scene scene in which to add meshes
  131091. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131092. */
  131093. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131094. /**
  131095. * Fired when the A button on this controller is modified
  131096. */
  131097. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131098. /**
  131099. * Fired when the B button on this controller is modified
  131100. */
  131101. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131102. /**
  131103. * Fired when the X button on this controller is modified
  131104. */
  131105. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131106. /**
  131107. * Fired when the Y button on this controller is modified
  131108. */
  131109. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131110. /**
  131111. * Called once for each button that changed state since the last frame
  131112. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131113. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131114. * 2) secondary trigger (same)
  131115. * 3) A (right) X (left), touch, pressed = value
  131116. * 4) B / Y
  131117. * 5) thumb rest
  131118. * @param buttonIdx Which button index changed
  131119. * @param state New state of the button
  131120. * @param changes Which properties on the state changed since last frame
  131121. */
  131122. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131123. }
  131124. }
  131125. declare module BABYLON {
  131126. /**
  131127. * Vive Controller
  131128. */
  131129. export class ViveController extends WebVRController {
  131130. /**
  131131. * Base Url for the controller model.
  131132. */
  131133. static MODEL_BASE_URL: string;
  131134. /**
  131135. * File name for the controller model.
  131136. */
  131137. static MODEL_FILENAME: string;
  131138. /**
  131139. * Creates a new ViveController from a gamepad
  131140. * @param vrGamepad the gamepad that the controller should be created from
  131141. */
  131142. constructor(vrGamepad: any);
  131143. /**
  131144. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131145. * @param scene scene in which to add meshes
  131146. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131147. */
  131148. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131149. /**
  131150. * Fired when the left button on this controller is modified
  131151. */
  131152. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131153. /**
  131154. * Fired when the right button on this controller is modified
  131155. */
  131156. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131157. /**
  131158. * Fired when the menu button on this controller is modified
  131159. */
  131160. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131161. /**
  131162. * Called once for each button that changed state since the last frame
  131163. * Vive mapping:
  131164. * 0: touchpad
  131165. * 1: trigger
  131166. * 2: left AND right buttons
  131167. * 3: menu button
  131168. * @param buttonIdx Which button index changed
  131169. * @param state New state of the button
  131170. * @param changes Which properties on the state changed since last frame
  131171. */
  131172. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131173. }
  131174. }
  131175. declare module BABYLON {
  131176. /**
  131177. * Defines the WindowsMotionController object that the state of the windows motion controller
  131178. */
  131179. export class WindowsMotionController extends WebVRController {
  131180. /**
  131181. * The base url used to load the left and right controller models
  131182. */
  131183. static MODEL_BASE_URL: string;
  131184. /**
  131185. * The name of the left controller model file
  131186. */
  131187. static MODEL_LEFT_FILENAME: string;
  131188. /**
  131189. * The name of the right controller model file
  131190. */
  131191. static MODEL_RIGHT_FILENAME: string;
  131192. /**
  131193. * The controller name prefix for this controller type
  131194. */
  131195. static readonly GAMEPAD_ID_PREFIX: string;
  131196. /**
  131197. * The controller id pattern for this controller type
  131198. */
  131199. private static readonly GAMEPAD_ID_PATTERN;
  131200. private _loadedMeshInfo;
  131201. protected readonly _mapping: {
  131202. buttons: string[];
  131203. buttonMeshNames: {
  131204. trigger: string;
  131205. menu: string;
  131206. grip: string;
  131207. thumbstick: string;
  131208. trackpad: string;
  131209. };
  131210. buttonObservableNames: {
  131211. trigger: string;
  131212. menu: string;
  131213. grip: string;
  131214. thumbstick: string;
  131215. trackpad: string;
  131216. };
  131217. axisMeshNames: string[];
  131218. pointingPoseMeshName: string;
  131219. };
  131220. /**
  131221. * Fired when the trackpad on this controller is clicked
  131222. */
  131223. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131224. /**
  131225. * Fired when the trackpad on this controller is modified
  131226. */
  131227. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131228. /**
  131229. * The current x and y values of this controller's trackpad
  131230. */
  131231. trackpad: StickValues;
  131232. /**
  131233. * Creates a new WindowsMotionController from a gamepad
  131234. * @param vrGamepad the gamepad that the controller should be created from
  131235. */
  131236. constructor(vrGamepad: any);
  131237. /**
  131238. * Fired when the trigger on this controller is modified
  131239. */
  131240. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131241. /**
  131242. * Fired when the menu button on this controller is modified
  131243. */
  131244. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131245. /**
  131246. * Fired when the grip button on this controller is modified
  131247. */
  131248. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131249. /**
  131250. * Fired when the thumbstick button on this controller is modified
  131251. */
  131252. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131253. /**
  131254. * Fired when the touchpad button on this controller is modified
  131255. */
  131256. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131257. /**
  131258. * Fired when the touchpad values on this controller are modified
  131259. */
  131260. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  131261. protected _updateTrackpad(): void;
  131262. /**
  131263. * Called once per frame by the engine.
  131264. */
  131265. update(): void;
  131266. /**
  131267. * Called once for each button that changed state since the last frame
  131268. * @param buttonIdx Which button index changed
  131269. * @param state New state of the button
  131270. * @param changes Which properties on the state changed since last frame
  131271. */
  131272. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131273. /**
  131274. * Moves the buttons on the controller mesh based on their current state
  131275. * @param buttonName the name of the button to move
  131276. * @param buttonValue the value of the button which determines the buttons new position
  131277. */
  131278. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  131279. /**
  131280. * Moves the axis on the controller mesh based on its current state
  131281. * @param axis the index of the axis
  131282. * @param axisValue the value of the axis which determines the meshes new position
  131283. * @hidden
  131284. */
  131285. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  131286. /**
  131287. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131288. * @param scene scene in which to add meshes
  131289. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131290. */
  131291. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  131292. /**
  131293. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  131294. * can be transformed by button presses and axes values, based on this._mapping.
  131295. *
  131296. * @param scene scene in which the meshes exist
  131297. * @param meshes list of meshes that make up the controller model to process
  131298. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  131299. */
  131300. private processModel;
  131301. private createMeshInfo;
  131302. /**
  131303. * Gets the ray of the controller in the direction the controller is pointing
  131304. * @param length the length the resulting ray should be
  131305. * @returns a ray in the direction the controller is pointing
  131306. */
  131307. getForwardRay(length?: number): Ray;
  131308. /**
  131309. * Disposes of the controller
  131310. */
  131311. dispose(): void;
  131312. }
  131313. /**
  131314. * This class represents a new windows motion controller in XR.
  131315. */
  131316. export class XRWindowsMotionController extends WindowsMotionController {
  131317. /**
  131318. * Changing the original WIndowsMotionController mapping to fir the new mapping
  131319. */
  131320. protected readonly _mapping: {
  131321. buttons: string[];
  131322. buttonMeshNames: {
  131323. trigger: string;
  131324. menu: string;
  131325. grip: string;
  131326. thumbstick: string;
  131327. trackpad: string;
  131328. };
  131329. buttonObservableNames: {
  131330. trigger: string;
  131331. menu: string;
  131332. grip: string;
  131333. thumbstick: string;
  131334. trackpad: string;
  131335. };
  131336. axisMeshNames: string[];
  131337. pointingPoseMeshName: string;
  131338. };
  131339. /**
  131340. * Construct a new XR-Based windows motion controller
  131341. *
  131342. * @param gamepadInfo the gamepad object from the browser
  131343. */
  131344. constructor(gamepadInfo: any);
  131345. /**
  131346. * holds the thumbstick values (X,Y)
  131347. */
  131348. thumbstickValues: StickValues;
  131349. /**
  131350. * Fired when the thumbstick on this controller is clicked
  131351. */
  131352. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  131353. /**
  131354. * Fired when the thumbstick on this controller is modified
  131355. */
  131356. onThumbstickValuesChangedObservable: Observable<StickValues>;
  131357. /**
  131358. * Fired when the touchpad button on this controller is modified
  131359. */
  131360. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131361. /**
  131362. * Fired when the touchpad values on this controller are modified
  131363. */
  131364. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131365. /**
  131366. * Fired when the thumbstick button on this controller is modified
  131367. * here to prevent breaking changes
  131368. */
  131369. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131370. /**
  131371. * updating the thumbstick(!) and not the trackpad.
  131372. * This is named this way due to the difference between WebVR and XR and to avoid
  131373. * changing the parent class.
  131374. */
  131375. protected _updateTrackpad(): void;
  131376. /**
  131377. * Disposes the class with joy
  131378. */
  131379. dispose(): void;
  131380. }
  131381. }
  131382. declare module BABYLON {
  131383. /**
  131384. * Class containing static functions to help procedurally build meshes
  131385. */
  131386. export class PolyhedronBuilder {
  131387. /**
  131388. * Creates a polyhedron mesh
  131389. * * 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
  131390. * * The parameter `size` (positive float, default 1) sets the polygon size
  131391. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  131392. * * 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`
  131393. * * 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
  131394. * * 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)`)
  131395. * * 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
  131396. * * 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
  131397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131400. * @param name defines the name of the mesh
  131401. * @param options defines the options used to create the mesh
  131402. * @param scene defines the hosting scene
  131403. * @returns the polyhedron mesh
  131404. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  131405. */
  131406. static CreatePolyhedron(name: string, options: {
  131407. type?: number;
  131408. size?: number;
  131409. sizeX?: number;
  131410. sizeY?: number;
  131411. sizeZ?: number;
  131412. custom?: any;
  131413. faceUV?: Vector4[];
  131414. faceColors?: Color4[];
  131415. flat?: boolean;
  131416. updatable?: boolean;
  131417. sideOrientation?: number;
  131418. frontUVs?: Vector4;
  131419. backUVs?: Vector4;
  131420. }, scene?: Nullable<Scene>): Mesh;
  131421. }
  131422. }
  131423. declare module BABYLON {
  131424. /**
  131425. * Gizmo that enables scaling a mesh along 3 axis
  131426. */
  131427. export class ScaleGizmo extends Gizmo {
  131428. /**
  131429. * Internal gizmo used for interactions on the x axis
  131430. */
  131431. xGizmo: AxisScaleGizmo;
  131432. /**
  131433. * Internal gizmo used for interactions on the y axis
  131434. */
  131435. yGizmo: AxisScaleGizmo;
  131436. /**
  131437. * Internal gizmo used for interactions on the z axis
  131438. */
  131439. zGizmo: AxisScaleGizmo;
  131440. /**
  131441. * Internal gizmo used to scale all axis equally
  131442. */
  131443. uniformScaleGizmo: AxisScaleGizmo;
  131444. private _meshAttached;
  131445. private _nodeAttached;
  131446. private _updateGizmoRotationToMatchAttachedMesh;
  131447. private _snapDistance;
  131448. private _scaleRatio;
  131449. private _uniformScalingMesh;
  131450. private _octahedron;
  131451. private _sensitivity;
  131452. /** Fires an event when any of it's sub gizmos are dragged */
  131453. onDragStartObservable: Observable<unknown>;
  131454. /** Fires an event when any of it's sub gizmos are released from dragging */
  131455. onDragEndObservable: Observable<unknown>;
  131456. get attachedMesh(): Nullable<AbstractMesh>;
  131457. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131458. get attachedNode(): Nullable<Node>;
  131459. set attachedNode(node: Nullable<Node>);
  131460. /**
  131461. * Creates a ScaleGizmo
  131462. * @param gizmoLayer The utility layer the gizmo will be added to
  131463. * @param thickness display gizmo axis thickness
  131464. */
  131465. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  131466. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131467. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131468. /**
  131469. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131470. */
  131471. set snapDistance(value: number);
  131472. get snapDistance(): number;
  131473. /**
  131474. * Ratio for the scale of the gizmo (Default: 1)
  131475. */
  131476. set scaleRatio(value: number);
  131477. get scaleRatio(): number;
  131478. /**
  131479. * Sensitivity factor for dragging (Default: 1)
  131480. */
  131481. set sensitivity(value: number);
  131482. get sensitivity(): number;
  131483. /**
  131484. * Disposes of the gizmo
  131485. */
  131486. dispose(): void;
  131487. }
  131488. }
  131489. declare module BABYLON {
  131490. /**
  131491. * Single axis scale gizmo
  131492. */
  131493. export class AxisScaleGizmo extends Gizmo {
  131494. /**
  131495. * Drag behavior responsible for the gizmos dragging interactions
  131496. */
  131497. dragBehavior: PointerDragBehavior;
  131498. private _pointerObserver;
  131499. /**
  131500. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131501. */
  131502. snapDistance: number;
  131503. /**
  131504. * Event that fires each time the gizmo snaps to a new location.
  131505. * * snapDistance is the the change in distance
  131506. */
  131507. onSnapObservable: Observable<{
  131508. snapDistance: number;
  131509. }>;
  131510. /**
  131511. * If the scaling operation should be done on all axis (default: false)
  131512. */
  131513. uniformScaling: boolean;
  131514. /**
  131515. * Custom sensitivity value for the drag strength
  131516. */
  131517. sensitivity: number;
  131518. private _isEnabled;
  131519. private _parent;
  131520. private _arrow;
  131521. private _coloredMaterial;
  131522. private _hoverMaterial;
  131523. /**
  131524. * Creates an AxisScaleGizmo
  131525. * @param gizmoLayer The utility layer the gizmo will be added to
  131526. * @param dragAxis The axis which the gizmo will be able to scale on
  131527. * @param color The color of the gizmo
  131528. * @param thickness display gizmo axis thickness
  131529. */
  131530. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  131531. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131532. /**
  131533. * If the gizmo is enabled
  131534. */
  131535. set isEnabled(value: boolean);
  131536. get isEnabled(): boolean;
  131537. /**
  131538. * Disposes of the gizmo
  131539. */
  131540. dispose(): void;
  131541. /**
  131542. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  131543. * @param mesh The mesh to replace the default mesh of the gizmo
  131544. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  131545. */
  131546. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  131547. }
  131548. }
  131549. declare module BABYLON {
  131550. /**
  131551. * Bounding box gizmo
  131552. */
  131553. export class BoundingBoxGizmo extends Gizmo {
  131554. private _lineBoundingBox;
  131555. private _rotateSpheresParent;
  131556. private _scaleBoxesParent;
  131557. private _boundingDimensions;
  131558. private _renderObserver;
  131559. private _pointerObserver;
  131560. private _scaleDragSpeed;
  131561. private _tmpQuaternion;
  131562. private _tmpVector;
  131563. private _tmpRotationMatrix;
  131564. /**
  131565. * 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)
  131566. */
  131567. ignoreChildren: boolean;
  131568. /**
  131569. * 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)
  131570. */
  131571. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  131572. /**
  131573. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  131574. */
  131575. rotationSphereSize: number;
  131576. /**
  131577. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  131578. */
  131579. scaleBoxSize: number;
  131580. /**
  131581. * 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)
  131582. */
  131583. fixedDragMeshScreenSize: boolean;
  131584. /**
  131585. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  131586. */
  131587. fixedDragMeshScreenSizeDistanceFactor: number;
  131588. /**
  131589. * Fired when a rotation sphere or scale box is dragged
  131590. */
  131591. onDragStartObservable: Observable<{}>;
  131592. /**
  131593. * Fired when a scale box is dragged
  131594. */
  131595. onScaleBoxDragObservable: Observable<{}>;
  131596. /**
  131597. * Fired when a scale box drag is ended
  131598. */
  131599. onScaleBoxDragEndObservable: Observable<{}>;
  131600. /**
  131601. * Fired when a rotation sphere is dragged
  131602. */
  131603. onRotationSphereDragObservable: Observable<{}>;
  131604. /**
  131605. * Fired when a rotation sphere drag is ended
  131606. */
  131607. onRotationSphereDragEndObservable: Observable<{}>;
  131608. /**
  131609. * 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)
  131610. */
  131611. scalePivot: Nullable<Vector3>;
  131612. /**
  131613. * Mesh used as a pivot to rotate the attached node
  131614. */
  131615. private _anchorMesh;
  131616. private _existingMeshScale;
  131617. private _dragMesh;
  131618. private pointerDragBehavior;
  131619. private coloredMaterial;
  131620. private hoverColoredMaterial;
  131621. /**
  131622. * Sets the color of the bounding box gizmo
  131623. * @param color the color to set
  131624. */
  131625. setColor(color: Color3): void;
  131626. /**
  131627. * Creates an BoundingBoxGizmo
  131628. * @param gizmoLayer The utility layer the gizmo will be added to
  131629. * @param color The color of the gizmo
  131630. */
  131631. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  131632. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  131633. private _selectNode;
  131634. /**
  131635. * Updates the bounding box information for the Gizmo
  131636. */
  131637. updateBoundingBox(): void;
  131638. private _updateRotationSpheres;
  131639. private _updateScaleBoxes;
  131640. /**
  131641. * Enables rotation on the specified axis and disables rotation on the others
  131642. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  131643. */
  131644. setEnabledRotationAxis(axis: string): void;
  131645. /**
  131646. * Enables/disables scaling
  131647. * @param enable if scaling should be enabled
  131648. * @param homogeneousScaling defines if scaling should only be homogeneous
  131649. */
  131650. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  131651. private _updateDummy;
  131652. /**
  131653. * Enables a pointer drag behavior on the bounding box of the gizmo
  131654. */
  131655. enableDragBehavior(): void;
  131656. /**
  131657. * Disposes of the gizmo
  131658. */
  131659. dispose(): void;
  131660. /**
  131661. * 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)
  131662. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  131663. * @returns the bounding box mesh with the passed in mesh as a child
  131664. */
  131665. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  131666. /**
  131667. * CustomMeshes are not supported by this gizmo
  131668. * @param mesh The mesh to replace the default mesh of the gizmo
  131669. */
  131670. setCustomMesh(mesh: Mesh): void;
  131671. }
  131672. }
  131673. declare module BABYLON {
  131674. /**
  131675. * Single plane rotation gizmo
  131676. */
  131677. export class PlaneRotationGizmo extends Gizmo {
  131678. /**
  131679. * Drag behavior responsible for the gizmos dragging interactions
  131680. */
  131681. dragBehavior: PointerDragBehavior;
  131682. private _pointerObserver;
  131683. /**
  131684. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  131685. */
  131686. snapDistance: number;
  131687. /**
  131688. * Event that fires each time the gizmo snaps to a new location.
  131689. * * snapDistance is the the change in distance
  131690. */
  131691. onSnapObservable: Observable<{
  131692. snapDistance: number;
  131693. }>;
  131694. private _isEnabled;
  131695. private _parent;
  131696. /**
  131697. * Creates a PlaneRotationGizmo
  131698. * @param gizmoLayer The utility layer the gizmo will be added to
  131699. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  131700. * @param color The color of the gizmo
  131701. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131702. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131703. * @param thickness display gizmo axis thickness
  131704. */
  131705. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  131706. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131707. /**
  131708. * If the gizmo is enabled
  131709. */
  131710. set isEnabled(value: boolean);
  131711. get isEnabled(): boolean;
  131712. /**
  131713. * Disposes of the gizmo
  131714. */
  131715. dispose(): void;
  131716. }
  131717. }
  131718. declare module BABYLON {
  131719. /**
  131720. * Gizmo that enables rotating a mesh along 3 axis
  131721. */
  131722. export class RotationGizmo extends Gizmo {
  131723. /**
  131724. * Internal gizmo used for interactions on the x axis
  131725. */
  131726. xGizmo: PlaneRotationGizmo;
  131727. /**
  131728. * Internal gizmo used for interactions on the y axis
  131729. */
  131730. yGizmo: PlaneRotationGizmo;
  131731. /**
  131732. * Internal gizmo used for interactions on the z axis
  131733. */
  131734. zGizmo: PlaneRotationGizmo;
  131735. /** Fires an event when any of it's sub gizmos are dragged */
  131736. onDragStartObservable: Observable<unknown>;
  131737. /** Fires an event when any of it's sub gizmos are released from dragging */
  131738. onDragEndObservable: Observable<unknown>;
  131739. private _meshAttached;
  131740. private _nodeAttached;
  131741. get attachedMesh(): Nullable<AbstractMesh>;
  131742. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131743. get attachedNode(): Nullable<Node>;
  131744. set attachedNode(node: Nullable<Node>);
  131745. /**
  131746. * Creates a RotationGizmo
  131747. * @param gizmoLayer The utility layer the gizmo will be added to
  131748. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131749. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131750. * @param thickness display gizmo axis thickness
  131751. */
  131752. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  131753. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131754. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131755. /**
  131756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131757. */
  131758. set snapDistance(value: number);
  131759. get snapDistance(): number;
  131760. /**
  131761. * Ratio for the scale of the gizmo (Default: 1)
  131762. */
  131763. set scaleRatio(value: number);
  131764. get scaleRatio(): number;
  131765. /**
  131766. * Disposes of the gizmo
  131767. */
  131768. dispose(): void;
  131769. /**
  131770. * CustomMeshes are not supported by this gizmo
  131771. * @param mesh The mesh to replace the default mesh of the gizmo
  131772. */
  131773. setCustomMesh(mesh: Mesh): void;
  131774. }
  131775. }
  131776. declare module BABYLON {
  131777. /**
  131778. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131779. */
  131780. export class GizmoManager implements IDisposable {
  131781. private scene;
  131782. /**
  131783. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131784. */
  131785. gizmos: {
  131786. positionGizmo: Nullable<PositionGizmo>;
  131787. rotationGizmo: Nullable<RotationGizmo>;
  131788. scaleGizmo: Nullable<ScaleGizmo>;
  131789. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131790. };
  131791. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131792. clearGizmoOnEmptyPointerEvent: boolean;
  131793. /** Fires an event when the manager is attached to a mesh */
  131794. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131795. private _gizmosEnabled;
  131796. private _pointerObserver;
  131797. private _attachedMesh;
  131798. private _boundingBoxColor;
  131799. private _defaultUtilityLayer;
  131800. private _defaultKeepDepthUtilityLayer;
  131801. private _thickness;
  131802. /**
  131803. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131804. */
  131805. boundingBoxDragBehavior: SixDofDragBehavior;
  131806. /**
  131807. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131808. */
  131809. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131810. /**
  131811. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131812. */
  131813. usePointerToAttachGizmos: boolean;
  131814. /**
  131815. * Utility layer that the bounding box gizmo belongs to
  131816. */
  131817. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131818. /**
  131819. * Utility layer that all gizmos besides bounding box belong to
  131820. */
  131821. get utilityLayer(): UtilityLayerRenderer;
  131822. /**
  131823. * Instatiates a gizmo manager
  131824. * @param scene the scene to overlay the gizmos on top of
  131825. * @param thickness display gizmo axis thickness
  131826. */
  131827. constructor(scene: Scene, thickness?: number);
  131828. /**
  131829. * Attaches a set of gizmos to the specified mesh
  131830. * @param mesh The mesh the gizmo's should be attached to
  131831. */
  131832. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131833. /**
  131834. * If the position gizmo is enabled
  131835. */
  131836. set positionGizmoEnabled(value: boolean);
  131837. get positionGizmoEnabled(): boolean;
  131838. /**
  131839. * If the rotation gizmo is enabled
  131840. */
  131841. set rotationGizmoEnabled(value: boolean);
  131842. get rotationGizmoEnabled(): boolean;
  131843. /**
  131844. * If the scale gizmo is enabled
  131845. */
  131846. set scaleGizmoEnabled(value: boolean);
  131847. get scaleGizmoEnabled(): boolean;
  131848. /**
  131849. * If the boundingBox gizmo is enabled
  131850. */
  131851. set boundingBoxGizmoEnabled(value: boolean);
  131852. get boundingBoxGizmoEnabled(): boolean;
  131853. /**
  131854. * Disposes of the gizmo manager
  131855. */
  131856. dispose(): void;
  131857. }
  131858. }
  131859. declare module BABYLON {
  131860. /**
  131861. * A directional light is defined by a direction (what a surprise!).
  131862. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131863. * 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.
  131864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131865. */
  131866. export class DirectionalLight extends ShadowLight {
  131867. private _shadowFrustumSize;
  131868. /**
  131869. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131870. */
  131871. get shadowFrustumSize(): number;
  131872. /**
  131873. * Specifies a fix frustum size for the shadow generation.
  131874. */
  131875. set shadowFrustumSize(value: number);
  131876. private _shadowOrthoScale;
  131877. /**
  131878. * Gets the shadow projection scale against the optimal computed one.
  131879. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131880. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131881. */
  131882. get shadowOrthoScale(): number;
  131883. /**
  131884. * Sets the shadow projection scale against the optimal computed one.
  131885. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131886. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131887. */
  131888. set shadowOrthoScale(value: number);
  131889. /**
  131890. * Automatically compute the projection matrix to best fit (including all the casters)
  131891. * on each frame.
  131892. */
  131893. autoUpdateExtends: boolean;
  131894. /**
  131895. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131896. * on each frame. autoUpdateExtends must be set to true for this to work
  131897. */
  131898. autoCalcShadowZBounds: boolean;
  131899. private _orthoLeft;
  131900. private _orthoRight;
  131901. private _orthoTop;
  131902. private _orthoBottom;
  131903. /**
  131904. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131905. * The directional light is emitted from everywhere in the given direction.
  131906. * It can cast shadows.
  131907. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131908. * @param name The friendly name of the light
  131909. * @param direction The direction of the light
  131910. * @param scene The scene the light belongs to
  131911. */
  131912. constructor(name: string, direction: Vector3, scene: Scene);
  131913. /**
  131914. * Returns the string "DirectionalLight".
  131915. * @return The class name
  131916. */
  131917. getClassName(): string;
  131918. /**
  131919. * Returns the integer 1.
  131920. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131921. */
  131922. getTypeID(): number;
  131923. /**
  131924. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131925. * Returns the DirectionalLight Shadow projection matrix.
  131926. */
  131927. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131928. /**
  131929. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131930. * Returns the DirectionalLight Shadow projection matrix.
  131931. */
  131932. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131933. /**
  131934. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131935. * Returns the DirectionalLight Shadow projection matrix.
  131936. */
  131937. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131938. protected _buildUniformLayout(): void;
  131939. /**
  131940. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131941. * @param effect The effect to update
  131942. * @param lightIndex The index of the light in the effect to update
  131943. * @returns The directional light
  131944. */
  131945. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131946. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131947. /**
  131948. * Gets the minZ used for shadow according to both the scene and the light.
  131949. *
  131950. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131951. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131952. * @param activeCamera The camera we are returning the min for
  131953. * @returns the depth min z
  131954. */
  131955. getDepthMinZ(activeCamera: Camera): number;
  131956. /**
  131957. * Gets the maxZ used for shadow according to both the scene and the light.
  131958. *
  131959. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131960. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131961. * @param activeCamera The camera we are returning the max for
  131962. * @returns the depth max z
  131963. */
  131964. getDepthMaxZ(activeCamera: Camera): number;
  131965. /**
  131966. * Prepares the list of defines specific to the light type.
  131967. * @param defines the list of defines
  131968. * @param lightIndex defines the index of the light for the effect
  131969. */
  131970. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131971. }
  131972. }
  131973. declare module BABYLON {
  131974. /**
  131975. * Class containing static functions to help procedurally build meshes
  131976. */
  131977. export class HemisphereBuilder {
  131978. /**
  131979. * Creates a hemisphere mesh
  131980. * @param name defines the name of the mesh
  131981. * @param options defines the options used to create the mesh
  131982. * @param scene defines the hosting scene
  131983. * @returns the hemisphere mesh
  131984. */
  131985. static CreateHemisphere(name: string, options: {
  131986. segments?: number;
  131987. diameter?: number;
  131988. sideOrientation?: number;
  131989. }, scene: any): Mesh;
  131990. }
  131991. }
  131992. declare module BABYLON {
  131993. /**
  131994. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131995. * These values define a cone of light starting from the position, emitting toward the direction.
  131996. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131997. * and the exponent defines the speed of the decay of the light with distance (reach).
  131998. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131999. */
  132000. export class SpotLight extends ShadowLight {
  132001. private _angle;
  132002. private _innerAngle;
  132003. private _cosHalfAngle;
  132004. private _lightAngleScale;
  132005. private _lightAngleOffset;
  132006. /**
  132007. * Gets the cone angle of the spot light in Radians.
  132008. */
  132009. get angle(): number;
  132010. /**
  132011. * Sets the cone angle of the spot light in Radians.
  132012. */
  132013. set angle(value: number);
  132014. /**
  132015. * Only used in gltf falloff mode, this defines the angle where
  132016. * the directional falloff will start before cutting at angle which could be seen
  132017. * as outer angle.
  132018. */
  132019. get innerAngle(): number;
  132020. /**
  132021. * Only used in gltf falloff mode, this defines the angle where
  132022. * the directional falloff will start before cutting at angle which could be seen
  132023. * as outer angle.
  132024. */
  132025. set innerAngle(value: number);
  132026. private _shadowAngleScale;
  132027. /**
  132028. * Allows scaling the angle of the light for shadow generation only.
  132029. */
  132030. get shadowAngleScale(): number;
  132031. /**
  132032. * Allows scaling the angle of the light for shadow generation only.
  132033. */
  132034. set shadowAngleScale(value: number);
  132035. /**
  132036. * The light decay speed with the distance from the emission spot.
  132037. */
  132038. exponent: number;
  132039. private _projectionTextureMatrix;
  132040. /**
  132041. * Allows reading the projecton texture
  132042. */
  132043. get projectionTextureMatrix(): Matrix;
  132044. protected _projectionTextureLightNear: number;
  132045. /**
  132046. * Gets the near clip of the Spotlight for texture projection.
  132047. */
  132048. get projectionTextureLightNear(): number;
  132049. /**
  132050. * Sets the near clip of the Spotlight for texture projection.
  132051. */
  132052. set projectionTextureLightNear(value: number);
  132053. protected _projectionTextureLightFar: number;
  132054. /**
  132055. * Gets the far clip of the Spotlight for texture projection.
  132056. */
  132057. get projectionTextureLightFar(): number;
  132058. /**
  132059. * Sets the far clip of the Spotlight for texture projection.
  132060. */
  132061. set projectionTextureLightFar(value: number);
  132062. protected _projectionTextureUpDirection: Vector3;
  132063. /**
  132064. * Gets the Up vector of the Spotlight for texture projection.
  132065. */
  132066. get projectionTextureUpDirection(): Vector3;
  132067. /**
  132068. * Sets the Up vector of the Spotlight for texture projection.
  132069. */
  132070. set projectionTextureUpDirection(value: Vector3);
  132071. private _projectionTexture;
  132072. /**
  132073. * Gets the projection texture of the light.
  132074. */
  132075. get projectionTexture(): Nullable<BaseTexture>;
  132076. /**
  132077. * Sets the projection texture of the light.
  132078. */
  132079. set projectionTexture(value: Nullable<BaseTexture>);
  132080. private _projectionTextureViewLightDirty;
  132081. private _projectionTextureProjectionLightDirty;
  132082. private _projectionTextureDirty;
  132083. private _projectionTextureViewTargetVector;
  132084. private _projectionTextureViewLightMatrix;
  132085. private _projectionTextureProjectionLightMatrix;
  132086. private _projectionTextureScalingMatrix;
  132087. /**
  132088. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132089. * It can cast shadows.
  132090. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132091. * @param name The light friendly name
  132092. * @param position The position of the spot light in the scene
  132093. * @param direction The direction of the light in the scene
  132094. * @param angle The cone angle of the light in Radians
  132095. * @param exponent The light decay speed with the distance from the emission spot
  132096. * @param scene The scene the lights belongs to
  132097. */
  132098. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132099. /**
  132100. * Returns the string "SpotLight".
  132101. * @returns the class name
  132102. */
  132103. getClassName(): string;
  132104. /**
  132105. * Returns the integer 2.
  132106. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132107. */
  132108. getTypeID(): number;
  132109. /**
  132110. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132111. */
  132112. protected _setDirection(value: Vector3): void;
  132113. /**
  132114. * Overrides the position setter to recompute the projection texture view light Matrix.
  132115. */
  132116. protected _setPosition(value: Vector3): void;
  132117. /**
  132118. * 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.
  132119. * Returns the SpotLight.
  132120. */
  132121. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132122. protected _computeProjectionTextureViewLightMatrix(): void;
  132123. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132124. /**
  132125. * Main function for light texture projection matrix computing.
  132126. */
  132127. protected _computeProjectionTextureMatrix(): void;
  132128. protected _buildUniformLayout(): void;
  132129. private _computeAngleValues;
  132130. /**
  132131. * Sets the passed Effect "effect" with the Light textures.
  132132. * @param effect The effect to update
  132133. * @param lightIndex The index of the light in the effect to update
  132134. * @returns The light
  132135. */
  132136. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132137. /**
  132138. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132139. * @param effect The effect to update
  132140. * @param lightIndex The index of the light in the effect to update
  132141. * @returns The spot light
  132142. */
  132143. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132144. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132145. /**
  132146. * Disposes the light and the associated resources.
  132147. */
  132148. dispose(): void;
  132149. /**
  132150. * Prepares the list of defines specific to the light type.
  132151. * @param defines the list of defines
  132152. * @param lightIndex defines the index of the light for the effect
  132153. */
  132154. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132155. }
  132156. }
  132157. declare module BABYLON {
  132158. /**
  132159. * Gizmo that enables viewing a light
  132160. */
  132161. export class LightGizmo extends Gizmo {
  132162. private _lightMesh;
  132163. private _material;
  132164. private _cachedPosition;
  132165. private _cachedForward;
  132166. private _attachedMeshParent;
  132167. /**
  132168. * Creates a LightGizmo
  132169. * @param gizmoLayer The utility layer the gizmo will be added to
  132170. */
  132171. constructor(gizmoLayer?: UtilityLayerRenderer);
  132172. private _light;
  132173. /**
  132174. * The light that the gizmo is attached to
  132175. */
  132176. set light(light: Nullable<Light>);
  132177. get light(): Nullable<Light>;
  132178. /**
  132179. * Gets the material used to render the light gizmo
  132180. */
  132181. get material(): StandardMaterial;
  132182. /**
  132183. * @hidden
  132184. * Updates the gizmo to match the attached mesh's position/rotation
  132185. */
  132186. protected _update(): void;
  132187. private static _Scale;
  132188. /**
  132189. * Creates the lines for a light mesh
  132190. */
  132191. private static _CreateLightLines;
  132192. /**
  132193. * Disposes of the light gizmo
  132194. */
  132195. dispose(): void;
  132196. private static _CreateHemisphericLightMesh;
  132197. private static _CreatePointLightMesh;
  132198. private static _CreateSpotLightMesh;
  132199. private static _CreateDirectionalLightMesh;
  132200. }
  132201. }
  132202. declare module BABYLON {
  132203. /** @hidden */
  132204. export var backgroundFragmentDeclaration: {
  132205. name: string;
  132206. shader: string;
  132207. };
  132208. }
  132209. declare module BABYLON {
  132210. /** @hidden */
  132211. export var backgroundUboDeclaration: {
  132212. name: string;
  132213. shader: string;
  132214. };
  132215. }
  132216. declare module BABYLON {
  132217. /** @hidden */
  132218. export var backgroundPixelShader: {
  132219. name: string;
  132220. shader: string;
  132221. };
  132222. }
  132223. declare module BABYLON {
  132224. /** @hidden */
  132225. export var backgroundVertexDeclaration: {
  132226. name: string;
  132227. shader: string;
  132228. };
  132229. }
  132230. declare module BABYLON {
  132231. /** @hidden */
  132232. export var backgroundVertexShader: {
  132233. name: string;
  132234. shader: string;
  132235. };
  132236. }
  132237. declare module BABYLON {
  132238. /**
  132239. * Background material used to create an efficient environement around your scene.
  132240. */
  132241. export class BackgroundMaterial extends PushMaterial {
  132242. /**
  132243. * Standard reflectance value at parallel view angle.
  132244. */
  132245. static StandardReflectance0: number;
  132246. /**
  132247. * Standard reflectance value at grazing angle.
  132248. */
  132249. static StandardReflectance90: number;
  132250. protected _primaryColor: Color3;
  132251. /**
  132252. * Key light Color (multiply against the environement texture)
  132253. */
  132254. primaryColor: Color3;
  132255. protected __perceptualColor: Nullable<Color3>;
  132256. /**
  132257. * Experimental Internal Use Only.
  132258. *
  132259. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  132260. * This acts as a helper to set the primary color to a more "human friendly" value.
  132261. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  132262. * output color as close as possible from the chosen value.
  132263. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  132264. * part of lighting setup.)
  132265. */
  132266. get _perceptualColor(): Nullable<Color3>;
  132267. set _perceptualColor(value: Nullable<Color3>);
  132268. protected _primaryColorShadowLevel: float;
  132269. /**
  132270. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  132271. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  132272. */
  132273. get primaryColorShadowLevel(): float;
  132274. set primaryColorShadowLevel(value: float);
  132275. protected _primaryColorHighlightLevel: float;
  132276. /**
  132277. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  132278. * The primary color is used at the level chosen to define what the white area would look.
  132279. */
  132280. get primaryColorHighlightLevel(): float;
  132281. set primaryColorHighlightLevel(value: float);
  132282. protected _reflectionTexture: Nullable<BaseTexture>;
  132283. /**
  132284. * Reflection Texture used in the material.
  132285. * Should be author in a specific way for the best result (refer to the documentation).
  132286. */
  132287. reflectionTexture: Nullable<BaseTexture>;
  132288. protected _reflectionBlur: float;
  132289. /**
  132290. * Reflection Texture level of blur.
  132291. *
  132292. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  132293. * texture twice.
  132294. */
  132295. reflectionBlur: float;
  132296. protected _diffuseTexture: Nullable<BaseTexture>;
  132297. /**
  132298. * Diffuse Texture used in the material.
  132299. * Should be author in a specific way for the best result (refer to the documentation).
  132300. */
  132301. diffuseTexture: Nullable<BaseTexture>;
  132302. protected _shadowLights: Nullable<IShadowLight[]>;
  132303. /**
  132304. * Specify the list of lights casting shadow on the material.
  132305. * All scene shadow lights will be included if null.
  132306. */
  132307. shadowLights: Nullable<IShadowLight[]>;
  132308. protected _shadowLevel: float;
  132309. /**
  132310. * Helps adjusting the shadow to a softer level if required.
  132311. * 0 means black shadows and 1 means no shadows.
  132312. */
  132313. shadowLevel: float;
  132314. protected _sceneCenter: Vector3;
  132315. /**
  132316. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  132317. * It is usually zero but might be interesting to modify according to your setup.
  132318. */
  132319. sceneCenter: Vector3;
  132320. protected _opacityFresnel: boolean;
  132321. /**
  132322. * This helps specifying that the material is falling off to the sky box at grazing angle.
  132323. * This helps ensuring a nice transition when the camera goes under the ground.
  132324. */
  132325. opacityFresnel: boolean;
  132326. protected _reflectionFresnel: boolean;
  132327. /**
  132328. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  132329. * This helps adding a mirror texture on the ground.
  132330. */
  132331. reflectionFresnel: boolean;
  132332. protected _reflectionFalloffDistance: number;
  132333. /**
  132334. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  132335. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  132336. */
  132337. reflectionFalloffDistance: number;
  132338. protected _reflectionAmount: number;
  132339. /**
  132340. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  132341. */
  132342. reflectionAmount: number;
  132343. protected _reflectionReflectance0: number;
  132344. /**
  132345. * This specifies the weight of the reflection at grazing angle.
  132346. */
  132347. reflectionReflectance0: number;
  132348. protected _reflectionReflectance90: number;
  132349. /**
  132350. * This specifies the weight of the reflection at a perpendicular point of view.
  132351. */
  132352. reflectionReflectance90: number;
  132353. /**
  132354. * Sets the reflection reflectance fresnel values according to the default standard
  132355. * empirically know to work well :-)
  132356. */
  132357. set reflectionStandardFresnelWeight(value: number);
  132358. protected _useRGBColor: boolean;
  132359. /**
  132360. * Helps to directly use the maps channels instead of their level.
  132361. */
  132362. useRGBColor: boolean;
  132363. protected _enableNoise: boolean;
  132364. /**
  132365. * This helps reducing the banding effect that could occur on the background.
  132366. */
  132367. enableNoise: boolean;
  132368. /**
  132369. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132370. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  132371. * Recommended to be keep at 1.0 except for special cases.
  132372. */
  132373. get fovMultiplier(): number;
  132374. set fovMultiplier(value: number);
  132375. private _fovMultiplier;
  132376. /**
  132377. * Enable the FOV adjustment feature controlled by fovMultiplier.
  132378. */
  132379. useEquirectangularFOV: boolean;
  132380. private _maxSimultaneousLights;
  132381. /**
  132382. * Number of Simultaneous lights allowed on the material.
  132383. */
  132384. maxSimultaneousLights: int;
  132385. private _shadowOnly;
  132386. /**
  132387. * Make the material only render shadows
  132388. */
  132389. shadowOnly: boolean;
  132390. /**
  132391. * Default configuration related to image processing available in the Background Material.
  132392. */
  132393. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132394. /**
  132395. * Keep track of the image processing observer to allow dispose and replace.
  132396. */
  132397. private _imageProcessingObserver;
  132398. /**
  132399. * Attaches a new image processing configuration to the PBR Material.
  132400. * @param configuration (if null the scene configuration will be use)
  132401. */
  132402. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132403. /**
  132404. * Gets the image processing configuration used either in this material.
  132405. */
  132406. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  132407. /**
  132408. * Sets the Default image processing configuration used either in the this material.
  132409. *
  132410. * If sets to null, the scene one is in use.
  132411. */
  132412. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  132413. /**
  132414. * Gets wether the color curves effect is enabled.
  132415. */
  132416. get cameraColorCurvesEnabled(): boolean;
  132417. /**
  132418. * Sets wether the color curves effect is enabled.
  132419. */
  132420. set cameraColorCurvesEnabled(value: boolean);
  132421. /**
  132422. * Gets wether the color grading effect is enabled.
  132423. */
  132424. get cameraColorGradingEnabled(): boolean;
  132425. /**
  132426. * Gets wether the color grading effect is enabled.
  132427. */
  132428. set cameraColorGradingEnabled(value: boolean);
  132429. /**
  132430. * Gets wether tonemapping is enabled or not.
  132431. */
  132432. get cameraToneMappingEnabled(): boolean;
  132433. /**
  132434. * Sets wether tonemapping is enabled or not
  132435. */
  132436. set cameraToneMappingEnabled(value: boolean);
  132437. /**
  132438. * The camera exposure used on this material.
  132439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132440. * This corresponds to a photographic exposure.
  132441. */
  132442. get cameraExposure(): float;
  132443. /**
  132444. * The camera exposure used on this material.
  132445. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132446. * This corresponds to a photographic exposure.
  132447. */
  132448. set cameraExposure(value: float);
  132449. /**
  132450. * Gets The camera contrast used on this material.
  132451. */
  132452. get cameraContrast(): float;
  132453. /**
  132454. * Sets The camera contrast used on this material.
  132455. */
  132456. set cameraContrast(value: float);
  132457. /**
  132458. * Gets the Color Grading 2D Lookup Texture.
  132459. */
  132460. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132461. /**
  132462. * Sets the Color Grading 2D Lookup Texture.
  132463. */
  132464. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132465. /**
  132466. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132467. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132468. * 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;
  132469. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132470. */
  132471. get cameraColorCurves(): Nullable<ColorCurves>;
  132472. /**
  132473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132475. * 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;
  132476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132477. */
  132478. set cameraColorCurves(value: Nullable<ColorCurves>);
  132479. /**
  132480. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  132481. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  132482. */
  132483. switchToBGR: boolean;
  132484. private _renderTargets;
  132485. private _reflectionControls;
  132486. private _white;
  132487. private _primaryShadowColor;
  132488. private _primaryHighlightColor;
  132489. /**
  132490. * Instantiates a Background Material in the given scene
  132491. * @param name The friendly name of the material
  132492. * @param scene The scene to add the material to
  132493. */
  132494. constructor(name: string, scene: Scene);
  132495. /**
  132496. * Gets a boolean indicating that current material needs to register RTT
  132497. */
  132498. get hasRenderTargetTextures(): boolean;
  132499. /**
  132500. * The entire material has been created in order to prevent overdraw.
  132501. * @returns false
  132502. */
  132503. needAlphaTesting(): boolean;
  132504. /**
  132505. * The entire material has been created in order to prevent overdraw.
  132506. * @returns true if blending is enable
  132507. */
  132508. needAlphaBlending(): boolean;
  132509. /**
  132510. * Checks wether the material is ready to be rendered for a given mesh.
  132511. * @param mesh The mesh to render
  132512. * @param subMesh The submesh to check against
  132513. * @param useInstances Specify wether or not the material is used with instances
  132514. * @returns true if all the dependencies are ready (Textures, Effects...)
  132515. */
  132516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132517. /**
  132518. * Compute the primary color according to the chosen perceptual color.
  132519. */
  132520. private _computePrimaryColorFromPerceptualColor;
  132521. /**
  132522. * Compute the highlights and shadow colors according to their chosen levels.
  132523. */
  132524. private _computePrimaryColors;
  132525. /**
  132526. * Build the uniform buffer used in the material.
  132527. */
  132528. buildUniformLayout(): void;
  132529. /**
  132530. * Unbind the material.
  132531. */
  132532. unbind(): void;
  132533. /**
  132534. * Bind only the world matrix to the material.
  132535. * @param world The world matrix to bind.
  132536. */
  132537. bindOnlyWorldMatrix(world: Matrix): void;
  132538. /**
  132539. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  132540. * @param world The world matrix to bind.
  132541. * @param subMesh The submesh to bind for.
  132542. */
  132543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132544. /**
  132545. * Checks to see if a texture is used in the material.
  132546. * @param texture - Base texture to use.
  132547. * @returns - Boolean specifying if a texture is used in the material.
  132548. */
  132549. hasTexture(texture: BaseTexture): boolean;
  132550. /**
  132551. * Dispose the material.
  132552. * @param forceDisposeEffect Force disposal of the associated effect.
  132553. * @param forceDisposeTextures Force disposal of the associated textures.
  132554. */
  132555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132556. /**
  132557. * Clones the material.
  132558. * @param name The cloned name.
  132559. * @returns The cloned material.
  132560. */
  132561. clone(name: string): BackgroundMaterial;
  132562. /**
  132563. * Serializes the current material to its JSON representation.
  132564. * @returns The JSON representation.
  132565. */
  132566. serialize(): any;
  132567. /**
  132568. * Gets the class name of the material
  132569. * @returns "BackgroundMaterial"
  132570. */
  132571. getClassName(): string;
  132572. /**
  132573. * Parse a JSON input to create back a background material.
  132574. * @param source The JSON data to parse
  132575. * @param scene The scene to create the parsed material in
  132576. * @param rootUrl The root url of the assets the material depends upon
  132577. * @returns the instantiated BackgroundMaterial.
  132578. */
  132579. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  132580. }
  132581. }
  132582. declare module BABYLON {
  132583. /**
  132584. * Represents the different options available during the creation of
  132585. * a Environment helper.
  132586. *
  132587. * This can control the default ground, skybox and image processing setup of your scene.
  132588. */
  132589. export interface IEnvironmentHelperOptions {
  132590. /**
  132591. * Specifies whether or not to create a ground.
  132592. * True by default.
  132593. */
  132594. createGround: boolean;
  132595. /**
  132596. * Specifies the ground size.
  132597. * 15 by default.
  132598. */
  132599. groundSize: number;
  132600. /**
  132601. * The texture used on the ground for the main color.
  132602. * Comes from the BabylonJS CDN by default.
  132603. *
  132604. * Remarks: Can be either a texture or a url.
  132605. */
  132606. groundTexture: string | BaseTexture;
  132607. /**
  132608. * The color mixed in the ground texture by default.
  132609. * BabylonJS clearColor by default.
  132610. */
  132611. groundColor: Color3;
  132612. /**
  132613. * Specifies the ground opacity.
  132614. * 1 by default.
  132615. */
  132616. groundOpacity: number;
  132617. /**
  132618. * Enables the ground to receive shadows.
  132619. * True by default.
  132620. */
  132621. enableGroundShadow: boolean;
  132622. /**
  132623. * Helps preventing the shadow to be fully black on the ground.
  132624. * 0.5 by default.
  132625. */
  132626. groundShadowLevel: number;
  132627. /**
  132628. * Creates a mirror texture attach to the ground.
  132629. * false by default.
  132630. */
  132631. enableGroundMirror: boolean;
  132632. /**
  132633. * Specifies the ground mirror size ratio.
  132634. * 0.3 by default as the default kernel is 64.
  132635. */
  132636. groundMirrorSizeRatio: number;
  132637. /**
  132638. * Specifies the ground mirror blur kernel size.
  132639. * 64 by default.
  132640. */
  132641. groundMirrorBlurKernel: number;
  132642. /**
  132643. * Specifies the ground mirror visibility amount.
  132644. * 1 by default
  132645. */
  132646. groundMirrorAmount: number;
  132647. /**
  132648. * Specifies the ground mirror reflectance weight.
  132649. * This uses the standard weight of the background material to setup the fresnel effect
  132650. * of the mirror.
  132651. * 1 by default.
  132652. */
  132653. groundMirrorFresnelWeight: number;
  132654. /**
  132655. * Specifies the ground mirror Falloff distance.
  132656. * This can helps reducing the size of the reflection.
  132657. * 0 by Default.
  132658. */
  132659. groundMirrorFallOffDistance: number;
  132660. /**
  132661. * Specifies the ground mirror texture type.
  132662. * Unsigned Int by Default.
  132663. */
  132664. groundMirrorTextureType: number;
  132665. /**
  132666. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  132667. * the shown objects.
  132668. */
  132669. groundYBias: number;
  132670. /**
  132671. * Specifies whether or not to create a skybox.
  132672. * True by default.
  132673. */
  132674. createSkybox: boolean;
  132675. /**
  132676. * Specifies the skybox size.
  132677. * 20 by default.
  132678. */
  132679. skyboxSize: number;
  132680. /**
  132681. * The texture used on the skybox for the main color.
  132682. * Comes from the BabylonJS CDN by default.
  132683. *
  132684. * Remarks: Can be either a texture or a url.
  132685. */
  132686. skyboxTexture: string | BaseTexture;
  132687. /**
  132688. * The color mixed in the skybox texture by default.
  132689. * BabylonJS clearColor by default.
  132690. */
  132691. skyboxColor: Color3;
  132692. /**
  132693. * The background rotation around the Y axis of the scene.
  132694. * This helps aligning the key lights of your scene with the background.
  132695. * 0 by default.
  132696. */
  132697. backgroundYRotation: number;
  132698. /**
  132699. * Compute automatically the size of the elements to best fit with the scene.
  132700. */
  132701. sizeAuto: boolean;
  132702. /**
  132703. * Default position of the rootMesh if autoSize is not true.
  132704. */
  132705. rootPosition: Vector3;
  132706. /**
  132707. * Sets up the image processing in the scene.
  132708. * true by default.
  132709. */
  132710. setupImageProcessing: boolean;
  132711. /**
  132712. * The texture used as your environment texture in the scene.
  132713. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  132714. *
  132715. * Remarks: Can be either a texture or a url.
  132716. */
  132717. environmentTexture: string | BaseTexture;
  132718. /**
  132719. * The value of the exposure to apply to the scene.
  132720. * 0.6 by default if setupImageProcessing is true.
  132721. */
  132722. cameraExposure: number;
  132723. /**
  132724. * The value of the contrast to apply to the scene.
  132725. * 1.6 by default if setupImageProcessing is true.
  132726. */
  132727. cameraContrast: number;
  132728. /**
  132729. * Specifies whether or not tonemapping should be enabled in the scene.
  132730. * true by default if setupImageProcessing is true.
  132731. */
  132732. toneMappingEnabled: boolean;
  132733. }
  132734. /**
  132735. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  132736. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  132737. * It also helps with the default setup of your imageProcessing configuration.
  132738. */
  132739. export class EnvironmentHelper {
  132740. /**
  132741. * Default ground texture URL.
  132742. */
  132743. private static _groundTextureCDNUrl;
  132744. /**
  132745. * Default skybox texture URL.
  132746. */
  132747. private static _skyboxTextureCDNUrl;
  132748. /**
  132749. * Default environment texture URL.
  132750. */
  132751. private static _environmentTextureCDNUrl;
  132752. /**
  132753. * Creates the default options for the helper.
  132754. */
  132755. private static _getDefaultOptions;
  132756. private _rootMesh;
  132757. /**
  132758. * Gets the root mesh created by the helper.
  132759. */
  132760. get rootMesh(): Mesh;
  132761. private _skybox;
  132762. /**
  132763. * Gets the skybox created by the helper.
  132764. */
  132765. get skybox(): Nullable<Mesh>;
  132766. private _skyboxTexture;
  132767. /**
  132768. * Gets the skybox texture created by the helper.
  132769. */
  132770. get skyboxTexture(): Nullable<BaseTexture>;
  132771. private _skyboxMaterial;
  132772. /**
  132773. * Gets the skybox material created by the helper.
  132774. */
  132775. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  132776. private _ground;
  132777. /**
  132778. * Gets the ground mesh created by the helper.
  132779. */
  132780. get ground(): Nullable<Mesh>;
  132781. private _groundTexture;
  132782. /**
  132783. * Gets the ground texture created by the helper.
  132784. */
  132785. get groundTexture(): Nullable<BaseTexture>;
  132786. private _groundMirror;
  132787. /**
  132788. * Gets the ground mirror created by the helper.
  132789. */
  132790. get groundMirror(): Nullable<MirrorTexture>;
  132791. /**
  132792. * Gets the ground mirror render list to helps pushing the meshes
  132793. * you wish in the ground reflection.
  132794. */
  132795. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132796. private _groundMaterial;
  132797. /**
  132798. * Gets the ground material created by the helper.
  132799. */
  132800. get groundMaterial(): Nullable<BackgroundMaterial>;
  132801. /**
  132802. * Stores the creation options.
  132803. */
  132804. private readonly _scene;
  132805. private _options;
  132806. /**
  132807. * This observable will be notified with any error during the creation of the environment,
  132808. * mainly texture creation errors.
  132809. */
  132810. onErrorObservable: Observable<{
  132811. message?: string;
  132812. exception?: any;
  132813. }>;
  132814. /**
  132815. * constructor
  132816. * @param options Defines the options we want to customize the helper
  132817. * @param scene The scene to add the material to
  132818. */
  132819. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132820. /**
  132821. * Updates the background according to the new options
  132822. * @param options
  132823. */
  132824. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132825. /**
  132826. * Sets the primary color of all the available elements.
  132827. * @param color the main color to affect to the ground and the background
  132828. */
  132829. setMainColor(color: Color3): void;
  132830. /**
  132831. * Setup the image processing according to the specified options.
  132832. */
  132833. private _setupImageProcessing;
  132834. /**
  132835. * Setup the environment texture according to the specified options.
  132836. */
  132837. private _setupEnvironmentTexture;
  132838. /**
  132839. * Setup the background according to the specified options.
  132840. */
  132841. private _setupBackground;
  132842. /**
  132843. * Get the scene sizes according to the setup.
  132844. */
  132845. private _getSceneSize;
  132846. /**
  132847. * Setup the ground according to the specified options.
  132848. */
  132849. private _setupGround;
  132850. /**
  132851. * Setup the ground material according to the specified options.
  132852. */
  132853. private _setupGroundMaterial;
  132854. /**
  132855. * Setup the ground diffuse texture according to the specified options.
  132856. */
  132857. private _setupGroundDiffuseTexture;
  132858. /**
  132859. * Setup the ground mirror texture according to the specified options.
  132860. */
  132861. private _setupGroundMirrorTexture;
  132862. /**
  132863. * Setup the ground to receive the mirror texture.
  132864. */
  132865. private _setupMirrorInGroundMaterial;
  132866. /**
  132867. * Setup the skybox according to the specified options.
  132868. */
  132869. private _setupSkybox;
  132870. /**
  132871. * Setup the skybox material according to the specified options.
  132872. */
  132873. private _setupSkyboxMaterial;
  132874. /**
  132875. * Setup the skybox reflection texture according to the specified options.
  132876. */
  132877. private _setupSkyboxReflectionTexture;
  132878. private _errorHandler;
  132879. /**
  132880. * Dispose all the elements created by the Helper.
  132881. */
  132882. dispose(): void;
  132883. }
  132884. }
  132885. declare module BABYLON {
  132886. /**
  132887. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132888. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132889. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132890. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132891. */
  132892. export class PhotoDome extends TransformNode {
  132893. /**
  132894. * Define the image as a Monoscopic panoramic 360 image.
  132895. */
  132896. static readonly MODE_MONOSCOPIC: number;
  132897. /**
  132898. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132899. */
  132900. static readonly MODE_TOPBOTTOM: number;
  132901. /**
  132902. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132903. */
  132904. static readonly MODE_SIDEBYSIDE: number;
  132905. private _useDirectMapping;
  132906. /**
  132907. * The texture being displayed on the sphere
  132908. */
  132909. protected _photoTexture: Texture;
  132910. /**
  132911. * Gets or sets the texture being displayed on the sphere
  132912. */
  132913. get photoTexture(): Texture;
  132914. set photoTexture(value: Texture);
  132915. /**
  132916. * Observable raised when an error occured while loading the 360 image
  132917. */
  132918. onLoadErrorObservable: Observable<string>;
  132919. /**
  132920. * The skybox material
  132921. */
  132922. protected _material: BackgroundMaterial;
  132923. /**
  132924. * The surface used for the skybox
  132925. */
  132926. protected _mesh: Mesh;
  132927. /**
  132928. * Gets the mesh used for the skybox.
  132929. */
  132930. get mesh(): Mesh;
  132931. /**
  132932. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132933. * Also see the options.resolution property.
  132934. */
  132935. get fovMultiplier(): number;
  132936. set fovMultiplier(value: number);
  132937. private _imageMode;
  132938. /**
  132939. * Gets or set the current video mode for the video. It can be:
  132940. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132941. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132942. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132943. */
  132944. get imageMode(): number;
  132945. set imageMode(value: number);
  132946. /**
  132947. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132948. * @param name Element's name, child elements will append suffixes for their own names.
  132949. * @param urlsOfPhoto defines the url of the photo to display
  132950. * @param options defines an object containing optional or exposed sub element properties
  132951. * @param onError defines a callback called when an error occured while loading the texture
  132952. */
  132953. constructor(name: string, urlOfPhoto: string, options: {
  132954. resolution?: number;
  132955. size?: number;
  132956. useDirectMapping?: boolean;
  132957. faceForward?: boolean;
  132958. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132959. private _onBeforeCameraRenderObserver;
  132960. private _changeImageMode;
  132961. /**
  132962. * Releases resources associated with this node.
  132963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132965. */
  132966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132967. }
  132968. }
  132969. declare module BABYLON {
  132970. /**
  132971. * Class used to host RGBD texture specific utilities
  132972. */
  132973. export class RGBDTextureTools {
  132974. /**
  132975. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132976. * @param texture the texture to expand.
  132977. */
  132978. static ExpandRGBDTexture(texture: Texture): void;
  132979. }
  132980. }
  132981. declare module BABYLON {
  132982. /**
  132983. * Class used to host texture specific utilities
  132984. */
  132985. export class BRDFTextureTools {
  132986. /**
  132987. * Prevents texture cache collision
  132988. */
  132989. private static _instanceNumber;
  132990. /**
  132991. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132992. * @param scene defines the hosting scene
  132993. * @returns the environment BRDF texture
  132994. */
  132995. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132996. private static _environmentBRDFBase64Texture;
  132997. }
  132998. }
  132999. declare module BABYLON {
  133000. /**
  133001. * @hidden
  133002. */
  133003. export interface IMaterialClearCoatDefines {
  133004. CLEARCOAT: boolean;
  133005. CLEARCOAT_DEFAULTIOR: boolean;
  133006. CLEARCOAT_TEXTURE: boolean;
  133007. CLEARCOAT_TEXTUREDIRECTUV: number;
  133008. CLEARCOAT_BUMP: boolean;
  133009. CLEARCOAT_BUMPDIRECTUV: number;
  133010. CLEARCOAT_TINT: boolean;
  133011. CLEARCOAT_TINT_TEXTURE: boolean;
  133012. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133013. /** @hidden */
  133014. _areTexturesDirty: boolean;
  133015. }
  133016. /**
  133017. * Define the code related to the clear coat parameters of the pbr material.
  133018. */
  133019. export class PBRClearCoatConfiguration {
  133020. /**
  133021. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133022. * The default fits with a polyurethane material.
  133023. */
  133024. private static readonly _DefaultIndexOfRefraction;
  133025. private _isEnabled;
  133026. /**
  133027. * Defines if the clear coat is enabled in the material.
  133028. */
  133029. isEnabled: boolean;
  133030. /**
  133031. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133032. */
  133033. intensity: number;
  133034. /**
  133035. * Defines the clear coat layer roughness.
  133036. */
  133037. roughness: number;
  133038. private _indexOfRefraction;
  133039. /**
  133040. * Defines the index of refraction of the clear coat.
  133041. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133042. * The default fits with a polyurethane material.
  133043. * Changing the default value is more performance intensive.
  133044. */
  133045. indexOfRefraction: number;
  133046. private _texture;
  133047. /**
  133048. * Stores the clear coat values in a texture.
  133049. */
  133050. texture: Nullable<BaseTexture>;
  133051. private _bumpTexture;
  133052. /**
  133053. * Define the clear coat specific bump texture.
  133054. */
  133055. bumpTexture: Nullable<BaseTexture>;
  133056. private _isTintEnabled;
  133057. /**
  133058. * Defines if the clear coat tint is enabled in the material.
  133059. */
  133060. isTintEnabled: boolean;
  133061. /**
  133062. * Defines the clear coat tint of the material.
  133063. * This is only use if tint is enabled
  133064. */
  133065. tintColor: Color3;
  133066. /**
  133067. * Defines the distance at which the tint color should be found in the
  133068. * clear coat media.
  133069. * This is only use if tint is enabled
  133070. */
  133071. tintColorAtDistance: number;
  133072. /**
  133073. * Defines the clear coat layer thickness.
  133074. * This is only use if tint is enabled
  133075. */
  133076. tintThickness: number;
  133077. private _tintTexture;
  133078. /**
  133079. * Stores the clear tint values in a texture.
  133080. * rgb is tint
  133081. * a is a thickness factor
  133082. */
  133083. tintTexture: Nullable<BaseTexture>;
  133084. /** @hidden */
  133085. private _internalMarkAllSubMeshesAsTexturesDirty;
  133086. /** @hidden */
  133087. _markAllSubMeshesAsTexturesDirty(): void;
  133088. /**
  133089. * Instantiate a new istance of clear coat configuration.
  133090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133091. */
  133092. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133093. /**
  133094. * Gets wehter the submesh is ready to be used or not.
  133095. * @param defines the list of "defines" to update.
  133096. * @param scene defines the scene the material belongs to.
  133097. * @param engine defines the engine the material belongs to.
  133098. * @param disableBumpMap defines wether the material disables bump or not.
  133099. * @returns - boolean indicating that the submesh is ready or not.
  133100. */
  133101. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133102. /**
  133103. * Checks to see if a texture is used in the material.
  133104. * @param defines the list of "defines" to update.
  133105. * @param scene defines the scene to the material belongs to.
  133106. */
  133107. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133108. /**
  133109. * Binds the material data.
  133110. * @param uniformBuffer defines the Uniform buffer to fill in.
  133111. * @param scene defines the scene the material belongs to.
  133112. * @param engine defines the engine the material belongs to.
  133113. * @param disableBumpMap defines wether the material disables bump or not.
  133114. * @param isFrozen defines wether the material is frozen or not.
  133115. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133116. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133117. */
  133118. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133119. /**
  133120. * Checks to see if a texture is used in the material.
  133121. * @param texture - Base texture to use.
  133122. * @returns - Boolean specifying if a texture is used in the material.
  133123. */
  133124. hasTexture(texture: BaseTexture): boolean;
  133125. /**
  133126. * Returns an array of the actively used textures.
  133127. * @param activeTextures Array of BaseTextures
  133128. */
  133129. getActiveTextures(activeTextures: BaseTexture[]): void;
  133130. /**
  133131. * Returns the animatable textures.
  133132. * @param animatables Array of animatable textures.
  133133. */
  133134. getAnimatables(animatables: IAnimatable[]): void;
  133135. /**
  133136. * Disposes the resources of the material.
  133137. * @param forceDisposeTextures - Forces the disposal of all textures.
  133138. */
  133139. dispose(forceDisposeTextures?: boolean): void;
  133140. /**
  133141. * Get the current class name of the texture useful for serialization or dynamic coding.
  133142. * @returns "PBRClearCoatConfiguration"
  133143. */
  133144. getClassName(): string;
  133145. /**
  133146. * Add fallbacks to the effect fallbacks list.
  133147. * @param defines defines the Base texture to use.
  133148. * @param fallbacks defines the current fallback list.
  133149. * @param currentRank defines the current fallback rank.
  133150. * @returns the new fallback rank.
  133151. */
  133152. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133153. /**
  133154. * Add the required uniforms to the current list.
  133155. * @param uniforms defines the current uniform list.
  133156. */
  133157. static AddUniforms(uniforms: string[]): void;
  133158. /**
  133159. * Add the required samplers to the current list.
  133160. * @param samplers defines the current sampler list.
  133161. */
  133162. static AddSamplers(samplers: string[]): void;
  133163. /**
  133164. * Add the required uniforms to the current buffer.
  133165. * @param uniformBuffer defines the current uniform buffer.
  133166. */
  133167. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133168. /**
  133169. * Makes a duplicate of the current configuration into another one.
  133170. * @param clearCoatConfiguration define the config where to copy the info
  133171. */
  133172. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133173. /**
  133174. * Serializes this clear coat configuration.
  133175. * @returns - An object with the serialized config.
  133176. */
  133177. serialize(): any;
  133178. /**
  133179. * Parses a anisotropy Configuration from a serialized object.
  133180. * @param source - Serialized object.
  133181. * @param scene Defines the scene we are parsing for
  133182. * @param rootUrl Defines the rootUrl to load from
  133183. */
  133184. parse(source: any, scene: Scene, rootUrl: string): void;
  133185. }
  133186. }
  133187. declare module BABYLON {
  133188. /**
  133189. * @hidden
  133190. */
  133191. export interface IMaterialAnisotropicDefines {
  133192. ANISOTROPIC: boolean;
  133193. ANISOTROPIC_TEXTURE: boolean;
  133194. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133195. MAINUV1: boolean;
  133196. _areTexturesDirty: boolean;
  133197. _needUVs: boolean;
  133198. }
  133199. /**
  133200. * Define the code related to the anisotropic parameters of the pbr material.
  133201. */
  133202. export class PBRAnisotropicConfiguration {
  133203. private _isEnabled;
  133204. /**
  133205. * Defines if the anisotropy is enabled in the material.
  133206. */
  133207. isEnabled: boolean;
  133208. /**
  133209. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  133210. */
  133211. intensity: number;
  133212. /**
  133213. * Defines if the effect is along the tangents, bitangents or in between.
  133214. * By default, the effect is "strectching" the highlights along the tangents.
  133215. */
  133216. direction: Vector2;
  133217. private _texture;
  133218. /**
  133219. * Stores the anisotropy values in a texture.
  133220. * rg is direction (like normal from -1 to 1)
  133221. * b is a intensity
  133222. */
  133223. texture: Nullable<BaseTexture>;
  133224. /** @hidden */
  133225. private _internalMarkAllSubMeshesAsTexturesDirty;
  133226. /** @hidden */
  133227. _markAllSubMeshesAsTexturesDirty(): void;
  133228. /**
  133229. * Instantiate a new istance of anisotropy configuration.
  133230. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133231. */
  133232. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133233. /**
  133234. * Specifies that the submesh is ready to be used.
  133235. * @param defines the list of "defines" to update.
  133236. * @param scene defines the scene the material belongs to.
  133237. * @returns - boolean indicating that the submesh is ready or not.
  133238. */
  133239. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  133240. /**
  133241. * Checks to see if a texture is used in the material.
  133242. * @param defines the list of "defines" to update.
  133243. * @param mesh the mesh we are preparing the defines for.
  133244. * @param scene defines the scene the material belongs to.
  133245. */
  133246. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  133247. /**
  133248. * Binds the material data.
  133249. * @param uniformBuffer defines the Uniform buffer to fill in.
  133250. * @param scene defines the scene the material belongs to.
  133251. * @param isFrozen defines wether the material is frozen or not.
  133252. */
  133253. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133254. /**
  133255. * Checks to see if a texture is used in the material.
  133256. * @param texture - Base texture to use.
  133257. * @returns - Boolean specifying if a texture is used in the material.
  133258. */
  133259. hasTexture(texture: BaseTexture): boolean;
  133260. /**
  133261. * Returns an array of the actively used textures.
  133262. * @param activeTextures Array of BaseTextures
  133263. */
  133264. getActiveTextures(activeTextures: BaseTexture[]): void;
  133265. /**
  133266. * Returns the animatable textures.
  133267. * @param animatables Array of animatable textures.
  133268. */
  133269. getAnimatables(animatables: IAnimatable[]): void;
  133270. /**
  133271. * Disposes the resources of the material.
  133272. * @param forceDisposeTextures - Forces the disposal of all textures.
  133273. */
  133274. dispose(forceDisposeTextures?: boolean): void;
  133275. /**
  133276. * Get the current class name of the texture useful for serialization or dynamic coding.
  133277. * @returns "PBRAnisotropicConfiguration"
  133278. */
  133279. getClassName(): string;
  133280. /**
  133281. * Add fallbacks to the effect fallbacks list.
  133282. * @param defines defines the Base texture to use.
  133283. * @param fallbacks defines the current fallback list.
  133284. * @param currentRank defines the current fallback rank.
  133285. * @returns the new fallback rank.
  133286. */
  133287. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133288. /**
  133289. * Add the required uniforms to the current list.
  133290. * @param uniforms defines the current uniform list.
  133291. */
  133292. static AddUniforms(uniforms: string[]): void;
  133293. /**
  133294. * Add the required uniforms to the current buffer.
  133295. * @param uniformBuffer defines the current uniform buffer.
  133296. */
  133297. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133298. /**
  133299. * Add the required samplers to the current list.
  133300. * @param samplers defines the current sampler list.
  133301. */
  133302. static AddSamplers(samplers: string[]): void;
  133303. /**
  133304. * Makes a duplicate of the current configuration into another one.
  133305. * @param anisotropicConfiguration define the config where to copy the info
  133306. */
  133307. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  133308. /**
  133309. * Serializes this anisotropy configuration.
  133310. * @returns - An object with the serialized config.
  133311. */
  133312. serialize(): any;
  133313. /**
  133314. * Parses a anisotropy Configuration from a serialized object.
  133315. * @param source - Serialized object.
  133316. * @param scene Defines the scene we are parsing for
  133317. * @param rootUrl Defines the rootUrl to load from
  133318. */
  133319. parse(source: any, scene: Scene, rootUrl: string): void;
  133320. }
  133321. }
  133322. declare module BABYLON {
  133323. /**
  133324. * @hidden
  133325. */
  133326. export interface IMaterialBRDFDefines {
  133327. BRDF_V_HEIGHT_CORRELATED: boolean;
  133328. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133329. SPHERICAL_HARMONICS: boolean;
  133330. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133331. /** @hidden */
  133332. _areMiscDirty: boolean;
  133333. }
  133334. /**
  133335. * Define the code related to the BRDF parameters of the pbr material.
  133336. */
  133337. export class PBRBRDFConfiguration {
  133338. /**
  133339. * Default value used for the energy conservation.
  133340. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133341. */
  133342. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  133343. /**
  133344. * Default value used for the Smith Visibility Height Correlated mode.
  133345. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133346. */
  133347. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  133348. /**
  133349. * Default value used for the IBL diffuse part.
  133350. * This can help switching back to the polynomials mode globally which is a tiny bit
  133351. * less GPU intensive at the drawback of a lower quality.
  133352. */
  133353. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  133354. /**
  133355. * Default value used for activating energy conservation for the specular workflow.
  133356. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133357. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133358. */
  133359. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  133360. private _useEnergyConservation;
  133361. /**
  133362. * Defines if the material uses energy conservation.
  133363. */
  133364. useEnergyConservation: boolean;
  133365. private _useSmithVisibilityHeightCorrelated;
  133366. /**
  133367. * LEGACY Mode set to false
  133368. * Defines if the material uses height smith correlated visibility term.
  133369. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  133370. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  133371. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  133372. * Not relying on height correlated will also disable energy conservation.
  133373. */
  133374. useSmithVisibilityHeightCorrelated: boolean;
  133375. private _useSphericalHarmonics;
  133376. /**
  133377. * LEGACY Mode set to false
  133378. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  133379. * diffuse part of the IBL.
  133380. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  133381. * to the ground truth.
  133382. */
  133383. useSphericalHarmonics: boolean;
  133384. private _useSpecularGlossinessInputEnergyConservation;
  133385. /**
  133386. * Defines if the material uses energy conservation, when the specular workflow is active.
  133387. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133388. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133389. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  133390. */
  133391. useSpecularGlossinessInputEnergyConservation: boolean;
  133392. /** @hidden */
  133393. private _internalMarkAllSubMeshesAsMiscDirty;
  133394. /** @hidden */
  133395. _markAllSubMeshesAsMiscDirty(): void;
  133396. /**
  133397. * Instantiate a new istance of clear coat configuration.
  133398. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  133399. */
  133400. constructor(markAllSubMeshesAsMiscDirty: () => void);
  133401. /**
  133402. * Checks to see if a texture is used in the material.
  133403. * @param defines the list of "defines" to update.
  133404. */
  133405. prepareDefines(defines: IMaterialBRDFDefines): void;
  133406. /**
  133407. * Get the current class name of the texture useful for serialization or dynamic coding.
  133408. * @returns "PBRClearCoatConfiguration"
  133409. */
  133410. getClassName(): string;
  133411. /**
  133412. * Makes a duplicate of the current configuration into another one.
  133413. * @param brdfConfiguration define the config where to copy the info
  133414. */
  133415. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  133416. /**
  133417. * Serializes this BRDF configuration.
  133418. * @returns - An object with the serialized config.
  133419. */
  133420. serialize(): any;
  133421. /**
  133422. * Parses a anisotropy Configuration from a serialized object.
  133423. * @param source - Serialized object.
  133424. * @param scene Defines the scene we are parsing for
  133425. * @param rootUrl Defines the rootUrl to load from
  133426. */
  133427. parse(source: any, scene: Scene, rootUrl: string): void;
  133428. }
  133429. }
  133430. declare module BABYLON {
  133431. /**
  133432. * @hidden
  133433. */
  133434. export interface IMaterialSheenDefines {
  133435. SHEEN: boolean;
  133436. SHEEN_TEXTURE: boolean;
  133437. SHEEN_TEXTUREDIRECTUV: number;
  133438. SHEEN_LINKWITHALBEDO: boolean;
  133439. SHEEN_ROUGHNESS: boolean;
  133440. SHEEN_ALBEDOSCALING: boolean;
  133441. /** @hidden */
  133442. _areTexturesDirty: boolean;
  133443. }
  133444. /**
  133445. * Define the code related to the Sheen parameters of the pbr material.
  133446. */
  133447. export class PBRSheenConfiguration {
  133448. private _isEnabled;
  133449. /**
  133450. * Defines if the material uses sheen.
  133451. */
  133452. isEnabled: boolean;
  133453. private _linkSheenWithAlbedo;
  133454. /**
  133455. * Defines if the sheen is linked to the sheen color.
  133456. */
  133457. linkSheenWithAlbedo: boolean;
  133458. /**
  133459. * Defines the sheen intensity.
  133460. */
  133461. intensity: number;
  133462. /**
  133463. * Defines the sheen color.
  133464. */
  133465. color: Color3;
  133466. private _texture;
  133467. /**
  133468. * Stores the sheen tint values in a texture.
  133469. * rgb is tint
  133470. * a is a intensity or roughness if roughness has been defined
  133471. */
  133472. texture: Nullable<BaseTexture>;
  133473. private _roughness;
  133474. /**
  133475. * Defines the sheen roughness.
  133476. * It is not taken into account if linkSheenWithAlbedo is true.
  133477. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  133478. */
  133479. roughness: Nullable<number>;
  133480. private _albedoScaling;
  133481. /**
  133482. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  133483. * It allows the strength of the sheen effect to not depend on the base color of the material,
  133484. * making it easier to setup and tweak the effect
  133485. */
  133486. albedoScaling: boolean;
  133487. /** @hidden */
  133488. private _internalMarkAllSubMeshesAsTexturesDirty;
  133489. /** @hidden */
  133490. _markAllSubMeshesAsTexturesDirty(): void;
  133491. /**
  133492. * Instantiate a new istance of clear coat configuration.
  133493. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133494. */
  133495. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133496. /**
  133497. * Specifies that the submesh is ready to be used.
  133498. * @param defines the list of "defines" to update.
  133499. * @param scene defines the scene the material belongs to.
  133500. * @returns - boolean indicating that the submesh is ready or not.
  133501. */
  133502. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  133503. /**
  133504. * Checks to see if a texture is used in the material.
  133505. * @param defines the list of "defines" to update.
  133506. * @param scene defines the scene the material belongs to.
  133507. */
  133508. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  133509. /**
  133510. * Binds the material data.
  133511. * @param uniformBuffer defines the Uniform buffer to fill in.
  133512. * @param scene defines the scene the material belongs to.
  133513. * @param isFrozen defines wether the material is frozen or not.
  133514. */
  133515. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133516. /**
  133517. * Checks to see if a texture is used in the material.
  133518. * @param texture - Base texture to use.
  133519. * @returns - Boolean specifying if a texture is used in the material.
  133520. */
  133521. hasTexture(texture: BaseTexture): boolean;
  133522. /**
  133523. * Returns an array of the actively used textures.
  133524. * @param activeTextures Array of BaseTextures
  133525. */
  133526. getActiveTextures(activeTextures: BaseTexture[]): void;
  133527. /**
  133528. * Returns the animatable textures.
  133529. * @param animatables Array of animatable textures.
  133530. */
  133531. getAnimatables(animatables: IAnimatable[]): void;
  133532. /**
  133533. * Disposes the resources of the material.
  133534. * @param forceDisposeTextures - Forces the disposal of all textures.
  133535. */
  133536. dispose(forceDisposeTextures?: boolean): void;
  133537. /**
  133538. * Get the current class name of the texture useful for serialization or dynamic coding.
  133539. * @returns "PBRSheenConfiguration"
  133540. */
  133541. getClassName(): string;
  133542. /**
  133543. * Add fallbacks to the effect fallbacks list.
  133544. * @param defines defines the Base texture to use.
  133545. * @param fallbacks defines the current fallback list.
  133546. * @param currentRank defines the current fallback rank.
  133547. * @returns the new fallback rank.
  133548. */
  133549. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133550. /**
  133551. * Add the required uniforms to the current list.
  133552. * @param uniforms defines the current uniform list.
  133553. */
  133554. static AddUniforms(uniforms: string[]): void;
  133555. /**
  133556. * Add the required uniforms to the current buffer.
  133557. * @param uniformBuffer defines the current uniform buffer.
  133558. */
  133559. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133560. /**
  133561. * Add the required samplers to the current list.
  133562. * @param samplers defines the current sampler list.
  133563. */
  133564. static AddSamplers(samplers: string[]): void;
  133565. /**
  133566. * Makes a duplicate of the current configuration into another one.
  133567. * @param sheenConfiguration define the config where to copy the info
  133568. */
  133569. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  133570. /**
  133571. * Serializes this BRDF configuration.
  133572. * @returns - An object with the serialized config.
  133573. */
  133574. serialize(): any;
  133575. /**
  133576. * Parses a anisotropy Configuration from a serialized object.
  133577. * @param source - Serialized object.
  133578. * @param scene Defines the scene we are parsing for
  133579. * @param rootUrl Defines the rootUrl to load from
  133580. */
  133581. parse(source: any, scene: Scene, rootUrl: string): void;
  133582. }
  133583. }
  133584. declare module BABYLON {
  133585. /**
  133586. * @hidden
  133587. */
  133588. export interface IMaterialSubSurfaceDefines {
  133589. SUBSURFACE: boolean;
  133590. SS_REFRACTION: boolean;
  133591. SS_TRANSLUCENCY: boolean;
  133592. SS_SCATTERING: boolean;
  133593. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133594. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133595. SS_REFRACTIONMAP_3D: boolean;
  133596. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133597. SS_LODINREFRACTIONALPHA: boolean;
  133598. SS_GAMMAREFRACTION: boolean;
  133599. SS_RGBDREFRACTION: boolean;
  133600. SS_LINEARSPECULARREFRACTION: boolean;
  133601. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133602. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133603. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133604. /** @hidden */
  133605. _areTexturesDirty: boolean;
  133606. }
  133607. /**
  133608. * Define the code related to the sub surface parameters of the pbr material.
  133609. */
  133610. export class PBRSubSurfaceConfiguration {
  133611. private _isRefractionEnabled;
  133612. /**
  133613. * Defines if the refraction is enabled in the material.
  133614. */
  133615. isRefractionEnabled: boolean;
  133616. private _isTranslucencyEnabled;
  133617. /**
  133618. * Defines if the translucency is enabled in the material.
  133619. */
  133620. isTranslucencyEnabled: boolean;
  133621. private _isScatteringEnabled;
  133622. /**
  133623. * Defines if the sub surface scattering is enabled in the material.
  133624. */
  133625. isScatteringEnabled: boolean;
  133626. private _scatteringDiffusionProfileIndex;
  133627. /**
  133628. * Diffusion profile for subsurface scattering.
  133629. * Useful for better scattering in the skins or foliages.
  133630. */
  133631. get scatteringDiffusionProfile(): Nullable<Color3>;
  133632. set scatteringDiffusionProfile(c: Nullable<Color3>);
  133633. /**
  133634. * Defines the refraction intensity of the material.
  133635. * The refraction when enabled replaces the Diffuse part of the material.
  133636. * The intensity helps transitionning between diffuse and refraction.
  133637. */
  133638. refractionIntensity: number;
  133639. /**
  133640. * Defines the translucency intensity of the material.
  133641. * When translucency has been enabled, this defines how much of the "translucency"
  133642. * is addded to the diffuse part of the material.
  133643. */
  133644. translucencyIntensity: number;
  133645. /**
  133646. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  133647. */
  133648. useAlbedoToTintRefraction: boolean;
  133649. private _thicknessTexture;
  133650. /**
  133651. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  133652. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  133653. * 0 would mean minimumThickness
  133654. * 1 would mean maximumThickness
  133655. * The other channels might be use as a mask to vary the different effects intensity.
  133656. */
  133657. thicknessTexture: Nullable<BaseTexture>;
  133658. private _refractionTexture;
  133659. /**
  133660. * Defines the texture to use for refraction.
  133661. */
  133662. refractionTexture: Nullable<BaseTexture>;
  133663. private _indexOfRefraction;
  133664. /**
  133665. * Index of refraction of the material base layer.
  133666. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133667. *
  133668. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133669. *
  133670. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133671. */
  133672. indexOfRefraction: number;
  133673. private _volumeIndexOfRefraction;
  133674. /**
  133675. * Index of refraction of the material's volume.
  133676. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133677. *
  133678. * This ONLY impacts refraction. If not provided or given a non-valid value,
  133679. * the volume will use the same IOR as the surface.
  133680. */
  133681. get volumeIndexOfRefraction(): number;
  133682. set volumeIndexOfRefraction(value: number);
  133683. private _invertRefractionY;
  133684. /**
  133685. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133686. */
  133687. invertRefractionY: boolean;
  133688. private _linkRefractionWithTransparency;
  133689. /**
  133690. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133691. * Materials half opaque for instance using refraction could benefit from this control.
  133692. */
  133693. linkRefractionWithTransparency: boolean;
  133694. /**
  133695. * Defines the minimum thickness stored in the thickness map.
  133696. * If no thickness map is defined, this value will be used to simulate thickness.
  133697. */
  133698. minimumThickness: number;
  133699. /**
  133700. * Defines the maximum thickness stored in the thickness map.
  133701. */
  133702. maximumThickness: number;
  133703. /**
  133704. * Defines the volume tint of the material.
  133705. * This is used for both translucency and scattering.
  133706. */
  133707. tintColor: Color3;
  133708. /**
  133709. * Defines the distance at which the tint color should be found in the media.
  133710. * This is used for refraction only.
  133711. */
  133712. tintColorAtDistance: number;
  133713. /**
  133714. * Defines how far each channel transmit through the media.
  133715. * It is defined as a color to simplify it selection.
  133716. */
  133717. diffusionDistance: Color3;
  133718. private _useMaskFromThicknessTexture;
  133719. /**
  133720. * Stores the intensity of the different subsurface effects in the thickness texture.
  133721. * * the green channel is the translucency intensity.
  133722. * * the blue channel is the scattering intensity.
  133723. * * the alpha channel is the refraction intensity.
  133724. */
  133725. useMaskFromThicknessTexture: boolean;
  133726. private _scene;
  133727. /** @hidden */
  133728. private _internalMarkAllSubMeshesAsTexturesDirty;
  133729. private _internalMarkScenePrePassDirty;
  133730. /** @hidden */
  133731. _markAllSubMeshesAsTexturesDirty(): void;
  133732. /** @hidden */
  133733. _markScenePrePassDirty(): void;
  133734. /**
  133735. * Instantiate a new istance of sub surface configuration.
  133736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133737. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  133738. * @param scene The scene
  133739. */
  133740. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  133741. /**
  133742. * Gets wehter the submesh is ready to be used or not.
  133743. * @param defines the list of "defines" to update.
  133744. * @param scene defines the scene the material belongs to.
  133745. * @returns - boolean indicating that the submesh is ready or not.
  133746. */
  133747. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  133748. /**
  133749. * Checks to see if a texture is used in the material.
  133750. * @param defines the list of "defines" to update.
  133751. * @param scene defines the scene to the material belongs to.
  133752. */
  133753. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  133754. /**
  133755. * Binds the material data.
  133756. * @param uniformBuffer defines the Uniform buffer to fill in.
  133757. * @param scene defines the scene the material belongs to.
  133758. * @param engine defines the engine the material belongs to.
  133759. * @param isFrozen defines whether the material is frozen or not.
  133760. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  133761. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  133762. */
  133763. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  133764. /**
  133765. * Unbinds the material from the mesh.
  133766. * @param activeEffect defines the effect that should be unbound from.
  133767. * @returns true if unbound, otherwise false
  133768. */
  133769. unbind(activeEffect: Effect): boolean;
  133770. /**
  133771. * Returns the texture used for refraction or null if none is used.
  133772. * @param scene defines the scene the material belongs to.
  133773. * @returns - Refraction texture if present. If no refraction texture and refraction
  133774. * is linked with transparency, returns environment texture. Otherwise, returns null.
  133775. */
  133776. private _getRefractionTexture;
  133777. /**
  133778. * Returns true if alpha blending should be disabled.
  133779. */
  133780. get disableAlphaBlending(): boolean;
  133781. /**
  133782. * Fills the list of render target textures.
  133783. * @param renderTargets the list of render targets to update
  133784. */
  133785. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133786. /**
  133787. * Checks to see if a texture is used in the material.
  133788. * @param texture - Base texture to use.
  133789. * @returns - Boolean specifying if a texture is used in the material.
  133790. */
  133791. hasTexture(texture: BaseTexture): boolean;
  133792. /**
  133793. * Gets a boolean indicating that current material needs to register RTT
  133794. * @returns true if this uses a render target otherwise false.
  133795. */
  133796. hasRenderTargetTextures(): boolean;
  133797. /**
  133798. * Returns an array of the actively used textures.
  133799. * @param activeTextures Array of BaseTextures
  133800. */
  133801. getActiveTextures(activeTextures: BaseTexture[]): void;
  133802. /**
  133803. * Returns the animatable textures.
  133804. * @param animatables Array of animatable textures.
  133805. */
  133806. getAnimatables(animatables: IAnimatable[]): void;
  133807. /**
  133808. * Disposes the resources of the material.
  133809. * @param forceDisposeTextures - Forces the disposal of all textures.
  133810. */
  133811. dispose(forceDisposeTextures?: boolean): void;
  133812. /**
  133813. * Get the current class name of the texture useful for serialization or dynamic coding.
  133814. * @returns "PBRSubSurfaceConfiguration"
  133815. */
  133816. getClassName(): string;
  133817. /**
  133818. * Add fallbacks to the effect fallbacks list.
  133819. * @param defines defines the Base texture to use.
  133820. * @param fallbacks defines the current fallback list.
  133821. * @param currentRank defines the current fallback rank.
  133822. * @returns the new fallback rank.
  133823. */
  133824. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133825. /**
  133826. * Add the required uniforms to the current list.
  133827. * @param uniforms defines the current uniform list.
  133828. */
  133829. static AddUniforms(uniforms: string[]): void;
  133830. /**
  133831. * Add the required samplers to the current list.
  133832. * @param samplers defines the current sampler list.
  133833. */
  133834. static AddSamplers(samplers: string[]): void;
  133835. /**
  133836. * Add the required uniforms to the current buffer.
  133837. * @param uniformBuffer defines the current uniform buffer.
  133838. */
  133839. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133840. /**
  133841. * Makes a duplicate of the current configuration into another one.
  133842. * @param configuration define the config where to copy the info
  133843. */
  133844. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133845. /**
  133846. * Serializes this Sub Surface configuration.
  133847. * @returns - An object with the serialized config.
  133848. */
  133849. serialize(): any;
  133850. /**
  133851. * Parses a anisotropy Configuration from a serialized object.
  133852. * @param source - Serialized object.
  133853. * @param scene Defines the scene we are parsing for
  133854. * @param rootUrl Defines the rootUrl to load from
  133855. */
  133856. parse(source: any, scene: Scene, rootUrl: string): void;
  133857. }
  133858. }
  133859. declare module BABYLON {
  133860. /** @hidden */
  133861. export var pbrFragmentDeclaration: {
  133862. name: string;
  133863. shader: string;
  133864. };
  133865. }
  133866. declare module BABYLON {
  133867. /** @hidden */
  133868. export var pbrUboDeclaration: {
  133869. name: string;
  133870. shader: string;
  133871. };
  133872. }
  133873. declare module BABYLON {
  133874. /** @hidden */
  133875. export var pbrFragmentExtraDeclaration: {
  133876. name: string;
  133877. shader: string;
  133878. };
  133879. }
  133880. declare module BABYLON {
  133881. /** @hidden */
  133882. export var pbrFragmentSamplersDeclaration: {
  133883. name: string;
  133884. shader: string;
  133885. };
  133886. }
  133887. declare module BABYLON {
  133888. /** @hidden */
  133889. export var importanceSampling: {
  133890. name: string;
  133891. shader: string;
  133892. };
  133893. }
  133894. declare module BABYLON {
  133895. /** @hidden */
  133896. export var pbrHelperFunctions: {
  133897. name: string;
  133898. shader: string;
  133899. };
  133900. }
  133901. declare module BABYLON {
  133902. /** @hidden */
  133903. export var harmonicsFunctions: {
  133904. name: string;
  133905. shader: string;
  133906. };
  133907. }
  133908. declare module BABYLON {
  133909. /** @hidden */
  133910. export var pbrDirectLightingSetupFunctions: {
  133911. name: string;
  133912. shader: string;
  133913. };
  133914. }
  133915. declare module BABYLON {
  133916. /** @hidden */
  133917. export var pbrDirectLightingFalloffFunctions: {
  133918. name: string;
  133919. shader: string;
  133920. };
  133921. }
  133922. declare module BABYLON {
  133923. /** @hidden */
  133924. export var pbrBRDFFunctions: {
  133925. name: string;
  133926. shader: string;
  133927. };
  133928. }
  133929. declare module BABYLON {
  133930. /** @hidden */
  133931. export var hdrFilteringFunctions: {
  133932. name: string;
  133933. shader: string;
  133934. };
  133935. }
  133936. declare module BABYLON {
  133937. /** @hidden */
  133938. export var pbrDirectLightingFunctions: {
  133939. name: string;
  133940. shader: string;
  133941. };
  133942. }
  133943. declare module BABYLON {
  133944. /** @hidden */
  133945. export var pbrIBLFunctions: {
  133946. name: string;
  133947. shader: string;
  133948. };
  133949. }
  133950. declare module BABYLON {
  133951. /** @hidden */
  133952. export var pbrBlockAlbedoOpacity: {
  133953. name: string;
  133954. shader: string;
  133955. };
  133956. }
  133957. declare module BABYLON {
  133958. /** @hidden */
  133959. export var pbrBlockReflectivity: {
  133960. name: string;
  133961. shader: string;
  133962. };
  133963. }
  133964. declare module BABYLON {
  133965. /** @hidden */
  133966. export var pbrBlockAmbientOcclusion: {
  133967. name: string;
  133968. shader: string;
  133969. };
  133970. }
  133971. declare module BABYLON {
  133972. /** @hidden */
  133973. export var pbrBlockAlphaFresnel: {
  133974. name: string;
  133975. shader: string;
  133976. };
  133977. }
  133978. declare module BABYLON {
  133979. /** @hidden */
  133980. export var pbrBlockAnisotropic: {
  133981. name: string;
  133982. shader: string;
  133983. };
  133984. }
  133985. declare module BABYLON {
  133986. /** @hidden */
  133987. export var pbrBlockReflection: {
  133988. name: string;
  133989. shader: string;
  133990. };
  133991. }
  133992. declare module BABYLON {
  133993. /** @hidden */
  133994. export var pbrBlockSheen: {
  133995. name: string;
  133996. shader: string;
  133997. };
  133998. }
  133999. declare module BABYLON {
  134000. /** @hidden */
  134001. export var pbrBlockClearcoat: {
  134002. name: string;
  134003. shader: string;
  134004. };
  134005. }
  134006. declare module BABYLON {
  134007. /** @hidden */
  134008. export var pbrBlockSubSurface: {
  134009. name: string;
  134010. shader: string;
  134011. };
  134012. }
  134013. declare module BABYLON {
  134014. /** @hidden */
  134015. export var pbrBlockNormalGeometric: {
  134016. name: string;
  134017. shader: string;
  134018. };
  134019. }
  134020. declare module BABYLON {
  134021. /** @hidden */
  134022. export var pbrBlockNormalFinal: {
  134023. name: string;
  134024. shader: string;
  134025. };
  134026. }
  134027. declare module BABYLON {
  134028. /** @hidden */
  134029. export var pbrBlockLightmapInit: {
  134030. name: string;
  134031. shader: string;
  134032. };
  134033. }
  134034. declare module BABYLON {
  134035. /** @hidden */
  134036. export var pbrBlockGeometryInfo: {
  134037. name: string;
  134038. shader: string;
  134039. };
  134040. }
  134041. declare module BABYLON {
  134042. /** @hidden */
  134043. export var pbrBlockReflectance0: {
  134044. name: string;
  134045. shader: string;
  134046. };
  134047. }
  134048. declare module BABYLON {
  134049. /** @hidden */
  134050. export var pbrBlockReflectance: {
  134051. name: string;
  134052. shader: string;
  134053. };
  134054. }
  134055. declare module BABYLON {
  134056. /** @hidden */
  134057. export var pbrBlockDirectLighting: {
  134058. name: string;
  134059. shader: string;
  134060. };
  134061. }
  134062. declare module BABYLON {
  134063. /** @hidden */
  134064. export var pbrBlockFinalLitComponents: {
  134065. name: string;
  134066. shader: string;
  134067. };
  134068. }
  134069. declare module BABYLON {
  134070. /** @hidden */
  134071. export var pbrBlockFinalUnlitComponents: {
  134072. name: string;
  134073. shader: string;
  134074. };
  134075. }
  134076. declare module BABYLON {
  134077. /** @hidden */
  134078. export var pbrBlockFinalColorComposition: {
  134079. name: string;
  134080. shader: string;
  134081. };
  134082. }
  134083. declare module BABYLON {
  134084. /** @hidden */
  134085. export var pbrBlockImageProcessing: {
  134086. name: string;
  134087. shader: string;
  134088. };
  134089. }
  134090. declare module BABYLON {
  134091. /** @hidden */
  134092. export var pbrDebug: {
  134093. name: string;
  134094. shader: string;
  134095. };
  134096. }
  134097. declare module BABYLON {
  134098. /** @hidden */
  134099. export var pbrPixelShader: {
  134100. name: string;
  134101. shader: string;
  134102. };
  134103. }
  134104. declare module BABYLON {
  134105. /** @hidden */
  134106. export var pbrVertexDeclaration: {
  134107. name: string;
  134108. shader: string;
  134109. };
  134110. }
  134111. declare module BABYLON {
  134112. /** @hidden */
  134113. export var pbrVertexShader: {
  134114. name: string;
  134115. shader: string;
  134116. };
  134117. }
  134118. declare module BABYLON {
  134119. /**
  134120. * Manages the defines for the PBR Material.
  134121. * @hidden
  134122. */
  134123. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134124. PBR: boolean;
  134125. NUM_SAMPLES: string;
  134126. REALTIME_FILTERING: boolean;
  134127. MAINUV1: boolean;
  134128. MAINUV2: boolean;
  134129. UV1: boolean;
  134130. UV2: boolean;
  134131. ALBEDO: boolean;
  134132. GAMMAALBEDO: boolean;
  134133. ALBEDODIRECTUV: number;
  134134. VERTEXCOLOR: boolean;
  134135. DETAIL: boolean;
  134136. DETAILDIRECTUV: number;
  134137. DETAIL_NORMALBLENDMETHOD: number;
  134138. AMBIENT: boolean;
  134139. AMBIENTDIRECTUV: number;
  134140. AMBIENTINGRAYSCALE: boolean;
  134141. OPACITY: boolean;
  134142. VERTEXALPHA: boolean;
  134143. OPACITYDIRECTUV: number;
  134144. OPACITYRGB: boolean;
  134145. ALPHATEST: boolean;
  134146. DEPTHPREPASS: boolean;
  134147. ALPHABLEND: boolean;
  134148. ALPHAFROMALBEDO: boolean;
  134149. ALPHATESTVALUE: string;
  134150. SPECULAROVERALPHA: boolean;
  134151. RADIANCEOVERALPHA: boolean;
  134152. ALPHAFRESNEL: boolean;
  134153. LINEARALPHAFRESNEL: boolean;
  134154. PREMULTIPLYALPHA: boolean;
  134155. EMISSIVE: boolean;
  134156. EMISSIVEDIRECTUV: number;
  134157. REFLECTIVITY: boolean;
  134158. REFLECTIVITYDIRECTUV: number;
  134159. SPECULARTERM: boolean;
  134160. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134161. MICROSURFACEAUTOMATIC: boolean;
  134162. LODBASEDMICROSFURACE: boolean;
  134163. MICROSURFACEMAP: boolean;
  134164. MICROSURFACEMAPDIRECTUV: number;
  134165. METALLICWORKFLOW: boolean;
  134166. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134167. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134168. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134169. AOSTOREINMETALMAPRED: boolean;
  134170. METALLIC_REFLECTANCE: boolean;
  134171. METALLIC_REFLECTANCEDIRECTUV: number;
  134172. ENVIRONMENTBRDF: boolean;
  134173. ENVIRONMENTBRDF_RGBD: boolean;
  134174. NORMAL: boolean;
  134175. TANGENT: boolean;
  134176. BUMP: boolean;
  134177. BUMPDIRECTUV: number;
  134178. OBJECTSPACE_NORMALMAP: boolean;
  134179. PARALLAX: boolean;
  134180. PARALLAXOCCLUSION: boolean;
  134181. NORMALXYSCALE: boolean;
  134182. LIGHTMAP: boolean;
  134183. LIGHTMAPDIRECTUV: number;
  134184. USELIGHTMAPASSHADOWMAP: boolean;
  134185. GAMMALIGHTMAP: boolean;
  134186. RGBDLIGHTMAP: boolean;
  134187. REFLECTION: boolean;
  134188. REFLECTIONMAP_3D: boolean;
  134189. REFLECTIONMAP_SPHERICAL: boolean;
  134190. REFLECTIONMAP_PLANAR: boolean;
  134191. REFLECTIONMAP_CUBIC: boolean;
  134192. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  134193. REFLECTIONMAP_PROJECTION: boolean;
  134194. REFLECTIONMAP_SKYBOX: boolean;
  134195. REFLECTIONMAP_EXPLICIT: boolean;
  134196. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  134197. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  134198. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  134199. INVERTCUBICMAP: boolean;
  134200. USESPHERICALFROMREFLECTIONMAP: boolean;
  134201. USEIRRADIANCEMAP: boolean;
  134202. SPHERICAL_HARMONICS: boolean;
  134203. USESPHERICALINVERTEX: boolean;
  134204. REFLECTIONMAP_OPPOSITEZ: boolean;
  134205. LODINREFLECTIONALPHA: boolean;
  134206. GAMMAREFLECTION: boolean;
  134207. RGBDREFLECTION: boolean;
  134208. LINEARSPECULARREFLECTION: boolean;
  134209. RADIANCEOCCLUSION: boolean;
  134210. HORIZONOCCLUSION: boolean;
  134211. INSTANCES: boolean;
  134212. THIN_INSTANCES: boolean;
  134213. PREPASS: boolean;
  134214. SCENE_MRT_COUNT: number;
  134215. NUM_BONE_INFLUENCERS: number;
  134216. BonesPerMesh: number;
  134217. BONETEXTURE: boolean;
  134218. NONUNIFORMSCALING: boolean;
  134219. MORPHTARGETS: boolean;
  134220. MORPHTARGETS_NORMAL: boolean;
  134221. MORPHTARGETS_TANGENT: boolean;
  134222. MORPHTARGETS_UV: boolean;
  134223. NUM_MORPH_INFLUENCERS: number;
  134224. IMAGEPROCESSING: boolean;
  134225. VIGNETTE: boolean;
  134226. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134227. VIGNETTEBLENDMODEOPAQUE: boolean;
  134228. TONEMAPPING: boolean;
  134229. TONEMAPPING_ACES: boolean;
  134230. CONTRAST: boolean;
  134231. COLORCURVES: boolean;
  134232. COLORGRADING: boolean;
  134233. COLORGRADING3D: boolean;
  134234. SAMPLER3DGREENDEPTH: boolean;
  134235. SAMPLER3DBGRMAP: boolean;
  134236. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134237. EXPOSURE: boolean;
  134238. MULTIVIEW: boolean;
  134239. USEPHYSICALLIGHTFALLOFF: boolean;
  134240. USEGLTFLIGHTFALLOFF: boolean;
  134241. TWOSIDEDLIGHTING: boolean;
  134242. SHADOWFLOAT: boolean;
  134243. CLIPPLANE: boolean;
  134244. CLIPPLANE2: boolean;
  134245. CLIPPLANE3: boolean;
  134246. CLIPPLANE4: boolean;
  134247. CLIPPLANE5: boolean;
  134248. CLIPPLANE6: boolean;
  134249. POINTSIZE: boolean;
  134250. FOG: boolean;
  134251. LOGARITHMICDEPTH: boolean;
  134252. FORCENORMALFORWARD: boolean;
  134253. SPECULARAA: boolean;
  134254. CLEARCOAT: boolean;
  134255. CLEARCOAT_DEFAULTIOR: boolean;
  134256. CLEARCOAT_TEXTURE: boolean;
  134257. CLEARCOAT_TEXTUREDIRECTUV: number;
  134258. CLEARCOAT_BUMP: boolean;
  134259. CLEARCOAT_BUMPDIRECTUV: number;
  134260. CLEARCOAT_TINT: boolean;
  134261. CLEARCOAT_TINT_TEXTURE: boolean;
  134262. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134263. ANISOTROPIC: boolean;
  134264. ANISOTROPIC_TEXTURE: boolean;
  134265. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134266. BRDF_V_HEIGHT_CORRELATED: boolean;
  134267. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134268. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134269. SHEEN: boolean;
  134270. SHEEN_TEXTURE: boolean;
  134271. SHEEN_TEXTUREDIRECTUV: number;
  134272. SHEEN_LINKWITHALBEDO: boolean;
  134273. SHEEN_ROUGHNESS: boolean;
  134274. SHEEN_ALBEDOSCALING: boolean;
  134275. SUBSURFACE: boolean;
  134276. SS_REFRACTION: boolean;
  134277. SS_TRANSLUCENCY: boolean;
  134278. SS_SCATTERING: boolean;
  134279. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134280. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134281. SS_REFRACTIONMAP_3D: boolean;
  134282. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134283. SS_LODINREFRACTIONALPHA: boolean;
  134284. SS_GAMMAREFRACTION: boolean;
  134285. SS_RGBDREFRACTION: boolean;
  134286. SS_LINEARSPECULARREFRACTION: boolean;
  134287. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134288. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134289. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134290. UNLIT: boolean;
  134291. DEBUGMODE: number;
  134292. /**
  134293. * Initializes the PBR Material defines.
  134294. */
  134295. constructor();
  134296. /**
  134297. * Resets the PBR Material defines.
  134298. */
  134299. reset(): void;
  134300. }
  134301. /**
  134302. * The Physically based material base class of BJS.
  134303. *
  134304. * This offers the main features of a standard PBR material.
  134305. * For more information, please refer to the documentation :
  134306. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134307. */
  134308. export abstract class PBRBaseMaterial extends PushMaterial {
  134309. /**
  134310. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134311. */
  134312. static readonly PBRMATERIAL_OPAQUE: number;
  134313. /**
  134314. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134315. */
  134316. static readonly PBRMATERIAL_ALPHATEST: number;
  134317. /**
  134318. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134319. */
  134320. static readonly PBRMATERIAL_ALPHABLEND: number;
  134321. /**
  134322. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134323. * They are also discarded below the alpha cutoff threshold to improve performances.
  134324. */
  134325. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134326. /**
  134327. * Defines the default value of how much AO map is occluding the analytical lights
  134328. * (point spot...).
  134329. */
  134330. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134331. /**
  134332. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  134333. */
  134334. static readonly LIGHTFALLOFF_PHYSICAL: number;
  134335. /**
  134336. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  134337. * to enhance interoperability with other engines.
  134338. */
  134339. static readonly LIGHTFALLOFF_GLTF: number;
  134340. /**
  134341. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  134342. * to enhance interoperability with other materials.
  134343. */
  134344. static readonly LIGHTFALLOFF_STANDARD: number;
  134345. /**
  134346. * Intensity of the direct lights e.g. the four lights available in your scene.
  134347. * This impacts both the direct diffuse and specular highlights.
  134348. */
  134349. protected _directIntensity: number;
  134350. /**
  134351. * Intensity of the emissive part of the material.
  134352. * This helps controlling the emissive effect without modifying the emissive color.
  134353. */
  134354. protected _emissiveIntensity: number;
  134355. /**
  134356. * Intensity of the environment e.g. how much the environment will light the object
  134357. * either through harmonics for rough material or through the refelction for shiny ones.
  134358. */
  134359. protected _environmentIntensity: number;
  134360. /**
  134361. * This is a special control allowing the reduction of the specular highlights coming from the
  134362. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134363. */
  134364. protected _specularIntensity: number;
  134365. /**
  134366. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  134367. */
  134368. private _lightingInfos;
  134369. /**
  134370. * Debug Control allowing disabling the bump map on this material.
  134371. */
  134372. protected _disableBumpMap: boolean;
  134373. /**
  134374. * AKA Diffuse Texture in standard nomenclature.
  134375. */
  134376. protected _albedoTexture: Nullable<BaseTexture>;
  134377. /**
  134378. * AKA Occlusion Texture in other nomenclature.
  134379. */
  134380. protected _ambientTexture: Nullable<BaseTexture>;
  134381. /**
  134382. * AKA Occlusion Texture Intensity in other nomenclature.
  134383. */
  134384. protected _ambientTextureStrength: number;
  134385. /**
  134386. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134387. * 1 means it completely occludes it
  134388. * 0 mean it has no impact
  134389. */
  134390. protected _ambientTextureImpactOnAnalyticalLights: number;
  134391. /**
  134392. * Stores the alpha values in a texture.
  134393. */
  134394. protected _opacityTexture: Nullable<BaseTexture>;
  134395. /**
  134396. * Stores the reflection values in a texture.
  134397. */
  134398. protected _reflectionTexture: Nullable<BaseTexture>;
  134399. /**
  134400. * Stores the emissive values in a texture.
  134401. */
  134402. protected _emissiveTexture: Nullable<BaseTexture>;
  134403. /**
  134404. * AKA Specular texture in other nomenclature.
  134405. */
  134406. protected _reflectivityTexture: Nullable<BaseTexture>;
  134407. /**
  134408. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134409. */
  134410. protected _metallicTexture: Nullable<BaseTexture>;
  134411. /**
  134412. * Specifies the metallic scalar of the metallic/roughness workflow.
  134413. * Can also be used to scale the metalness values of the metallic texture.
  134414. */
  134415. protected _metallic: Nullable<number>;
  134416. /**
  134417. * Specifies the roughness scalar of the metallic/roughness workflow.
  134418. * Can also be used to scale the roughness values of the metallic texture.
  134419. */
  134420. protected _roughness: Nullable<number>;
  134421. /**
  134422. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134423. * By default the indexOfrefraction is used to compute F0;
  134424. *
  134425. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134426. *
  134427. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134428. * F90 = metallicReflectanceColor;
  134429. */
  134430. protected _metallicF0Factor: number;
  134431. /**
  134432. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134433. * By default the F90 is always 1;
  134434. *
  134435. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134436. *
  134437. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134438. * F90 = metallicReflectanceColor;
  134439. */
  134440. protected _metallicReflectanceColor: Color3;
  134441. /**
  134442. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134443. * This is multiply against the scalar values defined in the material.
  134444. */
  134445. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  134446. /**
  134447. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134448. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134449. */
  134450. protected _microSurfaceTexture: Nullable<BaseTexture>;
  134451. /**
  134452. * Stores surface normal data used to displace a mesh in a texture.
  134453. */
  134454. protected _bumpTexture: Nullable<BaseTexture>;
  134455. /**
  134456. * Stores the pre-calculated light information of a mesh in a texture.
  134457. */
  134458. protected _lightmapTexture: Nullable<BaseTexture>;
  134459. /**
  134460. * The color of a material in ambient lighting.
  134461. */
  134462. protected _ambientColor: Color3;
  134463. /**
  134464. * AKA Diffuse Color in other nomenclature.
  134465. */
  134466. protected _albedoColor: Color3;
  134467. /**
  134468. * AKA Specular Color in other nomenclature.
  134469. */
  134470. protected _reflectivityColor: Color3;
  134471. /**
  134472. * The color applied when light is reflected from a material.
  134473. */
  134474. protected _reflectionColor: Color3;
  134475. /**
  134476. * The color applied when light is emitted from a material.
  134477. */
  134478. protected _emissiveColor: Color3;
  134479. /**
  134480. * AKA Glossiness in other nomenclature.
  134481. */
  134482. protected _microSurface: number;
  134483. /**
  134484. * Specifies that the material will use the light map as a show map.
  134485. */
  134486. protected _useLightmapAsShadowmap: boolean;
  134487. /**
  134488. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134489. * makes the reflect vector face the model (under horizon).
  134490. */
  134491. protected _useHorizonOcclusion: boolean;
  134492. /**
  134493. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134494. * too much the area relying on ambient texture to define their ambient occlusion.
  134495. */
  134496. protected _useRadianceOcclusion: boolean;
  134497. /**
  134498. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134499. */
  134500. protected _useAlphaFromAlbedoTexture: boolean;
  134501. /**
  134502. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  134503. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134504. */
  134505. protected _useSpecularOverAlpha: boolean;
  134506. /**
  134507. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134508. */
  134509. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134510. /**
  134511. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134512. */
  134513. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  134514. /**
  134515. * Specifies if the metallic texture contains the roughness information in its green channel.
  134516. */
  134517. protected _useRoughnessFromMetallicTextureGreen: boolean;
  134518. /**
  134519. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134520. */
  134521. protected _useMetallnessFromMetallicTextureBlue: boolean;
  134522. /**
  134523. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134524. */
  134525. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  134526. /**
  134527. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134528. */
  134529. protected _useAmbientInGrayScale: boolean;
  134530. /**
  134531. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134532. * The material will try to infer what glossiness each pixel should be.
  134533. */
  134534. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  134535. /**
  134536. * Defines the falloff type used in this material.
  134537. * It by default is Physical.
  134538. */
  134539. protected _lightFalloff: number;
  134540. /**
  134541. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134542. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134543. */
  134544. protected _useRadianceOverAlpha: boolean;
  134545. /**
  134546. * Allows using an object space normal map (instead of tangent space).
  134547. */
  134548. protected _useObjectSpaceNormalMap: boolean;
  134549. /**
  134550. * Allows using the bump map in parallax mode.
  134551. */
  134552. protected _useParallax: boolean;
  134553. /**
  134554. * Allows using the bump map in parallax occlusion mode.
  134555. */
  134556. protected _useParallaxOcclusion: boolean;
  134557. /**
  134558. * Controls the scale bias of the parallax mode.
  134559. */
  134560. protected _parallaxScaleBias: number;
  134561. /**
  134562. * If sets to true, disables all the lights affecting the material.
  134563. */
  134564. protected _disableLighting: boolean;
  134565. /**
  134566. * Number of Simultaneous lights allowed on the material.
  134567. */
  134568. protected _maxSimultaneousLights: number;
  134569. /**
  134570. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134571. */
  134572. protected _invertNormalMapX: boolean;
  134573. /**
  134574. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134575. */
  134576. protected _invertNormalMapY: boolean;
  134577. /**
  134578. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134579. */
  134580. protected _twoSidedLighting: boolean;
  134581. /**
  134582. * Defines the alpha limits in alpha test mode.
  134583. */
  134584. protected _alphaCutOff: number;
  134585. /**
  134586. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134587. */
  134588. protected _forceAlphaTest: boolean;
  134589. /**
  134590. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134591. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134592. */
  134593. protected _useAlphaFresnel: boolean;
  134594. /**
  134595. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134596. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134597. */
  134598. protected _useLinearAlphaFresnel: boolean;
  134599. /**
  134600. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  134601. * from cos thetav and roughness:
  134602. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  134603. */
  134604. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  134605. /**
  134606. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134607. */
  134608. protected _forceIrradianceInFragment: boolean;
  134609. private _realTimeFiltering;
  134610. /**
  134611. * Enables realtime filtering on the texture.
  134612. */
  134613. get realTimeFiltering(): boolean;
  134614. set realTimeFiltering(b: boolean);
  134615. private _realTimeFilteringQuality;
  134616. /**
  134617. * Quality switch for realtime filtering
  134618. */
  134619. get realTimeFilteringQuality(): number;
  134620. set realTimeFilteringQuality(n: number);
  134621. /**
  134622. * Can this material render to several textures at once
  134623. */
  134624. get canRenderToMRT(): boolean;
  134625. /**
  134626. * Force normal to face away from face.
  134627. */
  134628. protected _forceNormalForward: boolean;
  134629. /**
  134630. * Enables specular anti aliasing in the PBR shader.
  134631. * It will both interacts on the Geometry for analytical and IBL lighting.
  134632. * It also prefilter the roughness map based on the bump values.
  134633. */
  134634. protected _enableSpecularAntiAliasing: boolean;
  134635. /**
  134636. * Default configuration related to image processing available in the PBR Material.
  134637. */
  134638. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134639. /**
  134640. * Keep track of the image processing observer to allow dispose and replace.
  134641. */
  134642. private _imageProcessingObserver;
  134643. /**
  134644. * Attaches a new image processing configuration to the PBR Material.
  134645. * @param configuration
  134646. */
  134647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134648. /**
  134649. * Stores the available render targets.
  134650. */
  134651. private _renderTargets;
  134652. /**
  134653. * Sets the global ambient color for the material used in lighting calculations.
  134654. */
  134655. private _globalAmbientColor;
  134656. /**
  134657. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  134658. */
  134659. private _useLogarithmicDepth;
  134660. /**
  134661. * If set to true, no lighting calculations will be applied.
  134662. */
  134663. private _unlit;
  134664. private _debugMode;
  134665. /**
  134666. * @hidden
  134667. * This is reserved for the inspector.
  134668. * Defines the material debug mode.
  134669. * It helps seeing only some components of the material while troubleshooting.
  134670. */
  134671. debugMode: number;
  134672. /**
  134673. * @hidden
  134674. * This is reserved for the inspector.
  134675. * Specify from where on screen the debug mode should start.
  134676. * The value goes from -1 (full screen) to 1 (not visible)
  134677. * It helps with side by side comparison against the final render
  134678. * This defaults to -1
  134679. */
  134680. private debugLimit;
  134681. /**
  134682. * @hidden
  134683. * This is reserved for the inspector.
  134684. * As the default viewing range might not be enough (if the ambient is really small for instance)
  134685. * You can use the factor to better multiply the final value.
  134686. */
  134687. private debugFactor;
  134688. /**
  134689. * Defines the clear coat layer parameters for the material.
  134690. */
  134691. readonly clearCoat: PBRClearCoatConfiguration;
  134692. /**
  134693. * Defines the anisotropic parameters for the material.
  134694. */
  134695. readonly anisotropy: PBRAnisotropicConfiguration;
  134696. /**
  134697. * Defines the BRDF parameters for the material.
  134698. */
  134699. readonly brdf: PBRBRDFConfiguration;
  134700. /**
  134701. * Defines the Sheen parameters for the material.
  134702. */
  134703. readonly sheen: PBRSheenConfiguration;
  134704. /**
  134705. * Defines the SubSurface parameters for the material.
  134706. */
  134707. readonly subSurface: PBRSubSurfaceConfiguration;
  134708. /**
  134709. * Defines the detail map parameters for the material.
  134710. */
  134711. readonly detailMap: DetailMapConfiguration;
  134712. protected _rebuildInParallel: boolean;
  134713. /**
  134714. * Instantiates a new PBRMaterial instance.
  134715. *
  134716. * @param name The material name
  134717. * @param scene The scene the material will be use in.
  134718. */
  134719. constructor(name: string, scene: Scene);
  134720. /**
  134721. * Gets a boolean indicating that current material needs to register RTT
  134722. */
  134723. get hasRenderTargetTextures(): boolean;
  134724. /**
  134725. * Gets the name of the material class.
  134726. */
  134727. getClassName(): string;
  134728. /**
  134729. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134730. */
  134731. get useLogarithmicDepth(): boolean;
  134732. /**
  134733. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134734. */
  134735. set useLogarithmicDepth(value: boolean);
  134736. /**
  134737. * Returns true if alpha blending should be disabled.
  134738. */
  134739. protected get _disableAlphaBlending(): boolean;
  134740. /**
  134741. * Specifies whether or not this material should be rendered in alpha blend mode.
  134742. */
  134743. needAlphaBlending(): boolean;
  134744. /**
  134745. * Specifies whether or not this material should be rendered in alpha test mode.
  134746. */
  134747. needAlphaTesting(): boolean;
  134748. /**
  134749. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  134750. */
  134751. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  134752. /**
  134753. * Gets the texture used for the alpha test.
  134754. */
  134755. getAlphaTestTexture(): Nullable<BaseTexture>;
  134756. /**
  134757. * Specifies that the submesh is ready to be used.
  134758. * @param mesh - BJS mesh.
  134759. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  134760. * @param useInstances - Specifies that instances should be used.
  134761. * @returns - boolean indicating that the submesh is ready or not.
  134762. */
  134763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134764. /**
  134765. * Specifies if the material uses metallic roughness workflow.
  134766. * @returns boolean specifiying if the material uses metallic roughness workflow.
  134767. */
  134768. isMetallicWorkflow(): boolean;
  134769. private _prepareEffect;
  134770. private _prepareDefines;
  134771. /**
  134772. * Force shader compilation
  134773. */
  134774. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134775. /**
  134776. * Initializes the uniform buffer layout for the shader.
  134777. */
  134778. buildUniformLayout(): void;
  134779. /**
  134780. * Unbinds the material from the mesh
  134781. */
  134782. unbind(): void;
  134783. /**
  134784. * Binds the submesh data.
  134785. * @param world - The world matrix.
  134786. * @param mesh - The BJS mesh.
  134787. * @param subMesh - A submesh of the BJS mesh.
  134788. */
  134789. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134790. /**
  134791. * Returns the animatable textures.
  134792. * @returns - Array of animatable textures.
  134793. */
  134794. getAnimatables(): IAnimatable[];
  134795. /**
  134796. * Returns the texture used for reflections.
  134797. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134798. */
  134799. private _getReflectionTexture;
  134800. /**
  134801. * Returns an array of the actively used textures.
  134802. * @returns - Array of BaseTextures
  134803. */
  134804. getActiveTextures(): BaseTexture[];
  134805. /**
  134806. * Checks to see if a texture is used in the material.
  134807. * @param texture - Base texture to use.
  134808. * @returns - Boolean specifying if a texture is used in the material.
  134809. */
  134810. hasTexture(texture: BaseTexture): boolean;
  134811. /**
  134812. * Sets the required values to the prepass renderer.
  134813. * @param prePassRenderer defines the prepass renderer to setup
  134814. */
  134815. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  134816. /**
  134817. * Disposes the resources of the material.
  134818. * @param forceDisposeEffect - Forces the disposal of effects.
  134819. * @param forceDisposeTextures - Forces the disposal of all textures.
  134820. */
  134821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134822. }
  134823. }
  134824. declare module BABYLON {
  134825. /**
  134826. * The Physically based material of BJS.
  134827. *
  134828. * This offers the main features of a standard PBR material.
  134829. * For more information, please refer to the documentation :
  134830. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134831. */
  134832. export class PBRMaterial extends PBRBaseMaterial {
  134833. /**
  134834. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134835. */
  134836. static readonly PBRMATERIAL_OPAQUE: number;
  134837. /**
  134838. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134839. */
  134840. static readonly PBRMATERIAL_ALPHATEST: number;
  134841. /**
  134842. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134843. */
  134844. static readonly PBRMATERIAL_ALPHABLEND: number;
  134845. /**
  134846. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134847. * They are also discarded below the alpha cutoff threshold to improve performances.
  134848. */
  134849. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134850. /**
  134851. * Defines the default value of how much AO map is occluding the analytical lights
  134852. * (point spot...).
  134853. */
  134854. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134855. /**
  134856. * Intensity of the direct lights e.g. the four lights available in your scene.
  134857. * This impacts both the direct diffuse and specular highlights.
  134858. */
  134859. directIntensity: number;
  134860. /**
  134861. * Intensity of the emissive part of the material.
  134862. * This helps controlling the emissive effect without modifying the emissive color.
  134863. */
  134864. emissiveIntensity: number;
  134865. /**
  134866. * Intensity of the environment e.g. how much the environment will light the object
  134867. * either through harmonics for rough material or through the refelction for shiny ones.
  134868. */
  134869. environmentIntensity: number;
  134870. /**
  134871. * This is a special control allowing the reduction of the specular highlights coming from the
  134872. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134873. */
  134874. specularIntensity: number;
  134875. /**
  134876. * Debug Control allowing disabling the bump map on this material.
  134877. */
  134878. disableBumpMap: boolean;
  134879. /**
  134880. * AKA Diffuse Texture in standard nomenclature.
  134881. */
  134882. albedoTexture: BaseTexture;
  134883. /**
  134884. * AKA Occlusion Texture in other nomenclature.
  134885. */
  134886. ambientTexture: BaseTexture;
  134887. /**
  134888. * AKA Occlusion Texture Intensity in other nomenclature.
  134889. */
  134890. ambientTextureStrength: number;
  134891. /**
  134892. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134893. * 1 means it completely occludes it
  134894. * 0 mean it has no impact
  134895. */
  134896. ambientTextureImpactOnAnalyticalLights: number;
  134897. /**
  134898. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134899. */
  134900. opacityTexture: BaseTexture;
  134901. /**
  134902. * Stores the reflection values in a texture.
  134903. */
  134904. reflectionTexture: Nullable<BaseTexture>;
  134905. /**
  134906. * Stores the emissive values in a texture.
  134907. */
  134908. emissiveTexture: BaseTexture;
  134909. /**
  134910. * AKA Specular texture in other nomenclature.
  134911. */
  134912. reflectivityTexture: BaseTexture;
  134913. /**
  134914. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134915. */
  134916. metallicTexture: BaseTexture;
  134917. /**
  134918. * Specifies the metallic scalar of the metallic/roughness workflow.
  134919. * Can also be used to scale the metalness values of the metallic texture.
  134920. */
  134921. metallic: Nullable<number>;
  134922. /**
  134923. * Specifies the roughness scalar of the metallic/roughness workflow.
  134924. * Can also be used to scale the roughness values of the metallic texture.
  134925. */
  134926. roughness: Nullable<number>;
  134927. /**
  134928. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134929. * By default the indexOfrefraction is used to compute F0;
  134930. *
  134931. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134932. *
  134933. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134934. * F90 = metallicReflectanceColor;
  134935. */
  134936. metallicF0Factor: number;
  134937. /**
  134938. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134939. * By default the F90 is always 1;
  134940. *
  134941. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134942. *
  134943. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134944. * F90 = metallicReflectanceColor;
  134945. */
  134946. metallicReflectanceColor: Color3;
  134947. /**
  134948. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134949. * This is multiply against the scalar values defined in the material.
  134950. */
  134951. metallicReflectanceTexture: Nullable<BaseTexture>;
  134952. /**
  134953. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134954. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134955. */
  134956. microSurfaceTexture: BaseTexture;
  134957. /**
  134958. * Stores surface normal data used to displace a mesh in a texture.
  134959. */
  134960. bumpTexture: BaseTexture;
  134961. /**
  134962. * Stores the pre-calculated light information of a mesh in a texture.
  134963. */
  134964. lightmapTexture: BaseTexture;
  134965. /**
  134966. * Stores the refracted light information in a texture.
  134967. */
  134968. get refractionTexture(): Nullable<BaseTexture>;
  134969. set refractionTexture(value: Nullable<BaseTexture>);
  134970. /**
  134971. * The color of a material in ambient lighting.
  134972. */
  134973. ambientColor: Color3;
  134974. /**
  134975. * AKA Diffuse Color in other nomenclature.
  134976. */
  134977. albedoColor: Color3;
  134978. /**
  134979. * AKA Specular Color in other nomenclature.
  134980. */
  134981. reflectivityColor: Color3;
  134982. /**
  134983. * The color reflected from the material.
  134984. */
  134985. reflectionColor: Color3;
  134986. /**
  134987. * The color emitted from the material.
  134988. */
  134989. emissiveColor: Color3;
  134990. /**
  134991. * AKA Glossiness in other nomenclature.
  134992. */
  134993. microSurface: number;
  134994. /**
  134995. * Index of refraction of the material base layer.
  134996. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134997. *
  134998. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134999. *
  135000. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135001. */
  135002. get indexOfRefraction(): number;
  135003. set indexOfRefraction(value: number);
  135004. /**
  135005. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135006. */
  135007. get invertRefractionY(): boolean;
  135008. set invertRefractionY(value: boolean);
  135009. /**
  135010. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135011. * Materials half opaque for instance using refraction could benefit from this control.
  135012. */
  135013. get linkRefractionWithTransparency(): boolean;
  135014. set linkRefractionWithTransparency(value: boolean);
  135015. /**
  135016. * If true, the light map contains occlusion information instead of lighting info.
  135017. */
  135018. useLightmapAsShadowmap: boolean;
  135019. /**
  135020. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135021. */
  135022. useAlphaFromAlbedoTexture: boolean;
  135023. /**
  135024. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135025. */
  135026. forceAlphaTest: boolean;
  135027. /**
  135028. * Defines the alpha limits in alpha test mode.
  135029. */
  135030. alphaCutOff: number;
  135031. /**
  135032. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135033. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135034. */
  135035. useSpecularOverAlpha: boolean;
  135036. /**
  135037. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135038. */
  135039. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135040. /**
  135041. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135042. */
  135043. useRoughnessFromMetallicTextureAlpha: boolean;
  135044. /**
  135045. * Specifies if the metallic texture contains the roughness information in its green channel.
  135046. */
  135047. useRoughnessFromMetallicTextureGreen: boolean;
  135048. /**
  135049. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135050. */
  135051. useMetallnessFromMetallicTextureBlue: boolean;
  135052. /**
  135053. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135054. */
  135055. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135056. /**
  135057. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135058. */
  135059. useAmbientInGrayScale: boolean;
  135060. /**
  135061. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135062. * The material will try to infer what glossiness each pixel should be.
  135063. */
  135064. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135065. /**
  135066. * BJS is using an harcoded light falloff based on a manually sets up range.
  135067. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135068. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135069. */
  135070. get usePhysicalLightFalloff(): boolean;
  135071. /**
  135072. * BJS is using an harcoded light falloff based on a manually sets up range.
  135073. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135074. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135075. */
  135076. set usePhysicalLightFalloff(value: boolean);
  135077. /**
  135078. * In order to support the falloff compatibility with gltf, a special mode has been added
  135079. * to reproduce the gltf light falloff.
  135080. */
  135081. get useGLTFLightFalloff(): boolean;
  135082. /**
  135083. * In order to support the falloff compatibility with gltf, a special mode has been added
  135084. * to reproduce the gltf light falloff.
  135085. */
  135086. set useGLTFLightFalloff(value: boolean);
  135087. /**
  135088. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135089. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135090. */
  135091. useRadianceOverAlpha: boolean;
  135092. /**
  135093. * Allows using an object space normal map (instead of tangent space).
  135094. */
  135095. useObjectSpaceNormalMap: boolean;
  135096. /**
  135097. * Allows using the bump map in parallax mode.
  135098. */
  135099. useParallax: boolean;
  135100. /**
  135101. * Allows using the bump map in parallax occlusion mode.
  135102. */
  135103. useParallaxOcclusion: boolean;
  135104. /**
  135105. * Controls the scale bias of the parallax mode.
  135106. */
  135107. parallaxScaleBias: number;
  135108. /**
  135109. * If sets to true, disables all the lights affecting the material.
  135110. */
  135111. disableLighting: boolean;
  135112. /**
  135113. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135114. */
  135115. forceIrradianceInFragment: boolean;
  135116. /**
  135117. * Number of Simultaneous lights allowed on the material.
  135118. */
  135119. maxSimultaneousLights: number;
  135120. /**
  135121. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135122. */
  135123. invertNormalMapX: boolean;
  135124. /**
  135125. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135126. */
  135127. invertNormalMapY: boolean;
  135128. /**
  135129. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135130. */
  135131. twoSidedLighting: boolean;
  135132. /**
  135133. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135134. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135135. */
  135136. useAlphaFresnel: boolean;
  135137. /**
  135138. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135139. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135140. */
  135141. useLinearAlphaFresnel: boolean;
  135142. /**
  135143. * Let user defines the brdf lookup texture used for IBL.
  135144. * A default 8bit version is embedded but you could point at :
  135145. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135146. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135147. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135148. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135149. */
  135150. environmentBRDFTexture: Nullable<BaseTexture>;
  135151. /**
  135152. * Force normal to face away from face.
  135153. */
  135154. forceNormalForward: boolean;
  135155. /**
  135156. * Enables specular anti aliasing in the PBR shader.
  135157. * It will both interacts on the Geometry for analytical and IBL lighting.
  135158. * It also prefilter the roughness map based on the bump values.
  135159. */
  135160. enableSpecularAntiAliasing: boolean;
  135161. /**
  135162. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135163. * makes the reflect vector face the model (under horizon).
  135164. */
  135165. useHorizonOcclusion: boolean;
  135166. /**
  135167. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135168. * too much the area relying on ambient texture to define their ambient occlusion.
  135169. */
  135170. useRadianceOcclusion: boolean;
  135171. /**
  135172. * If set to true, no lighting calculations will be applied.
  135173. */
  135174. unlit: boolean;
  135175. /**
  135176. * Gets the image processing configuration used either in this material.
  135177. */
  135178. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  135179. /**
  135180. * Sets the Default image processing configuration used either in the this material.
  135181. *
  135182. * If sets to null, the scene one is in use.
  135183. */
  135184. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  135185. /**
  135186. * Gets wether the color curves effect is enabled.
  135187. */
  135188. get cameraColorCurvesEnabled(): boolean;
  135189. /**
  135190. * Sets wether the color curves effect is enabled.
  135191. */
  135192. set cameraColorCurvesEnabled(value: boolean);
  135193. /**
  135194. * Gets wether the color grading effect is enabled.
  135195. */
  135196. get cameraColorGradingEnabled(): boolean;
  135197. /**
  135198. * Gets wether the color grading effect is enabled.
  135199. */
  135200. set cameraColorGradingEnabled(value: boolean);
  135201. /**
  135202. * Gets wether tonemapping is enabled or not.
  135203. */
  135204. get cameraToneMappingEnabled(): boolean;
  135205. /**
  135206. * Sets wether tonemapping is enabled or not
  135207. */
  135208. set cameraToneMappingEnabled(value: boolean);
  135209. /**
  135210. * The camera exposure used on this material.
  135211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135212. * This corresponds to a photographic exposure.
  135213. */
  135214. get cameraExposure(): number;
  135215. /**
  135216. * The camera exposure used on this material.
  135217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135218. * This corresponds to a photographic exposure.
  135219. */
  135220. set cameraExposure(value: number);
  135221. /**
  135222. * Gets The camera contrast used on this material.
  135223. */
  135224. get cameraContrast(): number;
  135225. /**
  135226. * Sets The camera contrast used on this material.
  135227. */
  135228. set cameraContrast(value: number);
  135229. /**
  135230. * Gets the Color Grading 2D Lookup Texture.
  135231. */
  135232. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135233. /**
  135234. * Sets the Color Grading 2D Lookup Texture.
  135235. */
  135236. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135237. /**
  135238. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135239. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135240. * 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;
  135241. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135242. */
  135243. get cameraColorCurves(): Nullable<ColorCurves>;
  135244. /**
  135245. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135246. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135247. * 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;
  135248. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135249. */
  135250. set cameraColorCurves(value: Nullable<ColorCurves>);
  135251. /**
  135252. * Instantiates a new PBRMaterial instance.
  135253. *
  135254. * @param name The material name
  135255. * @param scene The scene the material will be use in.
  135256. */
  135257. constructor(name: string, scene: Scene);
  135258. /**
  135259. * Returns the name of this material class.
  135260. */
  135261. getClassName(): string;
  135262. /**
  135263. * Makes a duplicate of the current material.
  135264. * @param name - name to use for the new material.
  135265. */
  135266. clone(name: string): PBRMaterial;
  135267. /**
  135268. * Serializes this PBR Material.
  135269. * @returns - An object with the serialized material.
  135270. */
  135271. serialize(): any;
  135272. /**
  135273. * Parses a PBR Material from a serialized object.
  135274. * @param source - Serialized object.
  135275. * @param scene - BJS scene instance.
  135276. * @param rootUrl - url for the scene object
  135277. * @returns - PBRMaterial
  135278. */
  135279. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  135280. }
  135281. }
  135282. declare module BABYLON {
  135283. /**
  135284. * Direct draw surface info
  135285. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  135286. */
  135287. export interface DDSInfo {
  135288. /**
  135289. * Width of the texture
  135290. */
  135291. width: number;
  135292. /**
  135293. * Width of the texture
  135294. */
  135295. height: number;
  135296. /**
  135297. * Number of Mipmaps for the texture
  135298. * @see https://en.wikipedia.org/wiki/Mipmap
  135299. */
  135300. mipmapCount: number;
  135301. /**
  135302. * If the textures format is a known fourCC format
  135303. * @see https://www.fourcc.org/
  135304. */
  135305. isFourCC: boolean;
  135306. /**
  135307. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  135308. */
  135309. isRGB: boolean;
  135310. /**
  135311. * If the texture is a lumincance format
  135312. */
  135313. isLuminance: boolean;
  135314. /**
  135315. * If this is a cube texture
  135316. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  135317. */
  135318. isCube: boolean;
  135319. /**
  135320. * If the texture is a compressed format eg. FOURCC_DXT1
  135321. */
  135322. isCompressed: boolean;
  135323. /**
  135324. * The dxgiFormat of the texture
  135325. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  135326. */
  135327. dxgiFormat: number;
  135328. /**
  135329. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  135330. */
  135331. textureType: number;
  135332. /**
  135333. * Sphericle polynomial created for the dds texture
  135334. */
  135335. sphericalPolynomial?: SphericalPolynomial;
  135336. }
  135337. /**
  135338. * Class used to provide DDS decompression tools
  135339. */
  135340. export class DDSTools {
  135341. /**
  135342. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  135343. */
  135344. static StoreLODInAlphaChannel: boolean;
  135345. /**
  135346. * Gets DDS information from an array buffer
  135347. * @param data defines the array buffer view to read data from
  135348. * @returns the DDS information
  135349. */
  135350. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  135351. private static _FloatView;
  135352. private static _Int32View;
  135353. private static _ToHalfFloat;
  135354. private static _FromHalfFloat;
  135355. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  135356. private static _GetHalfFloatRGBAArrayBuffer;
  135357. private static _GetFloatRGBAArrayBuffer;
  135358. private static _GetFloatAsUIntRGBAArrayBuffer;
  135359. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  135360. private static _GetRGBAArrayBuffer;
  135361. private static _ExtractLongWordOrder;
  135362. private static _GetRGBArrayBuffer;
  135363. private static _GetLuminanceArrayBuffer;
  135364. /**
  135365. * Uploads DDS Levels to a Babylon Texture
  135366. * @hidden
  135367. */
  135368. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  135369. }
  135370. interface ThinEngine {
  135371. /**
  135372. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  135373. * @param rootUrl defines the url where the file to load is located
  135374. * @param scene defines the current scene
  135375. * @param lodScale defines scale to apply to the mip map selection
  135376. * @param lodOffset defines offset to apply to the mip map selection
  135377. * @param onLoad defines an optional callback raised when the texture is loaded
  135378. * @param onError defines an optional callback raised if there is an issue to load the texture
  135379. * @param format defines the format of the data
  135380. * @param forcedExtension defines the extension to use to pick the right loader
  135381. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  135382. * @returns the cube texture as an InternalTexture
  135383. */
  135384. 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;
  135385. }
  135386. }
  135387. declare module BABYLON {
  135388. /**
  135389. * Implementation of the DDS Texture Loader.
  135390. * @hidden
  135391. */
  135392. export class _DDSTextureLoader implements IInternalTextureLoader {
  135393. /**
  135394. * Defines wether the loader supports cascade loading the different faces.
  135395. */
  135396. readonly supportCascades: boolean;
  135397. /**
  135398. * This returns if the loader support the current file information.
  135399. * @param extension defines the file extension of the file being loaded
  135400. * @returns true if the loader can load the specified file
  135401. */
  135402. canLoad(extension: string): boolean;
  135403. /**
  135404. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135405. * @param data contains the texture data
  135406. * @param texture defines the BabylonJS internal texture
  135407. * @param createPolynomials will be true if polynomials have been requested
  135408. * @param onLoad defines the callback to trigger once the texture is ready
  135409. * @param onError defines the callback to trigger in case of error
  135410. */
  135411. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135412. /**
  135413. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135414. * @param data contains the texture data
  135415. * @param texture defines the BabylonJS internal texture
  135416. * @param callback defines the method to call once ready to upload
  135417. */
  135418. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  135419. }
  135420. }
  135421. declare module BABYLON {
  135422. /**
  135423. * Implementation of the ENV Texture Loader.
  135424. * @hidden
  135425. */
  135426. export class _ENVTextureLoader implements IInternalTextureLoader {
  135427. /**
  135428. * Defines wether the loader supports cascade loading the different faces.
  135429. */
  135430. readonly supportCascades: boolean;
  135431. /**
  135432. * This returns if the loader support the current file information.
  135433. * @param extension defines the file extension of the file being loaded
  135434. * @returns true if the loader can load the specified file
  135435. */
  135436. canLoad(extension: string): boolean;
  135437. /**
  135438. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135439. * @param data contains the texture data
  135440. * @param texture defines the BabylonJS internal texture
  135441. * @param createPolynomials will be true if polynomials have been requested
  135442. * @param onLoad defines the callback to trigger once the texture is ready
  135443. * @param onError defines the callback to trigger in case of error
  135444. */
  135445. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135446. /**
  135447. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135448. * @param data contains the texture data
  135449. * @param texture defines the BabylonJS internal texture
  135450. * @param callback defines the method to call once ready to upload
  135451. */
  135452. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  135453. }
  135454. }
  135455. declare module BABYLON {
  135456. /**
  135457. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  135458. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  135459. */
  135460. export class KhronosTextureContainer {
  135461. /** contents of the KTX container file */
  135462. data: ArrayBufferView;
  135463. private static HEADER_LEN;
  135464. private static COMPRESSED_2D;
  135465. private static COMPRESSED_3D;
  135466. private static TEX_2D;
  135467. private static TEX_3D;
  135468. /**
  135469. * Gets the openGL type
  135470. */
  135471. glType: number;
  135472. /**
  135473. * Gets the openGL type size
  135474. */
  135475. glTypeSize: number;
  135476. /**
  135477. * Gets the openGL format
  135478. */
  135479. glFormat: number;
  135480. /**
  135481. * Gets the openGL internal format
  135482. */
  135483. glInternalFormat: number;
  135484. /**
  135485. * Gets the base internal format
  135486. */
  135487. glBaseInternalFormat: number;
  135488. /**
  135489. * Gets image width in pixel
  135490. */
  135491. pixelWidth: number;
  135492. /**
  135493. * Gets image height in pixel
  135494. */
  135495. pixelHeight: number;
  135496. /**
  135497. * Gets image depth in pixels
  135498. */
  135499. pixelDepth: number;
  135500. /**
  135501. * Gets the number of array elements
  135502. */
  135503. numberOfArrayElements: number;
  135504. /**
  135505. * Gets the number of faces
  135506. */
  135507. numberOfFaces: number;
  135508. /**
  135509. * Gets the number of mipmap levels
  135510. */
  135511. numberOfMipmapLevels: number;
  135512. /**
  135513. * Gets the bytes of key value data
  135514. */
  135515. bytesOfKeyValueData: number;
  135516. /**
  135517. * Gets the load type
  135518. */
  135519. loadType: number;
  135520. /**
  135521. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  135522. */
  135523. isInvalid: boolean;
  135524. /**
  135525. * Creates a new KhronosTextureContainer
  135526. * @param data contents of the KTX container file
  135527. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  135528. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  135529. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  135530. */
  135531. constructor(
  135532. /** contents of the KTX container file */
  135533. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  135534. /**
  135535. * Uploads KTX content to a Babylon Texture.
  135536. * It is assumed that the texture has already been created & is currently bound
  135537. * @hidden
  135538. */
  135539. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  135540. private _upload2DCompressedLevels;
  135541. /**
  135542. * Checks if the given data starts with a KTX file identifier.
  135543. * @param data the data to check
  135544. * @returns true if the data is a KTX file or false otherwise
  135545. */
  135546. static IsValid(data: ArrayBufferView): boolean;
  135547. }
  135548. }
  135549. declare module BABYLON {
  135550. /**
  135551. * Class for loading KTX2 files
  135552. * !!! Experimental Extension Subject to Changes !!!
  135553. * @hidden
  135554. */
  135555. export class KhronosTextureContainer2 {
  135556. private static _ModulePromise;
  135557. private static _TranscodeFormat;
  135558. constructor(engine: ThinEngine);
  135559. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  135560. private _determineTranscodeFormat;
  135561. /**
  135562. * Checks if the given data starts with a KTX2 file identifier.
  135563. * @param data the data to check
  135564. * @returns true if the data is a KTX2 file or false otherwise
  135565. */
  135566. static IsValid(data: ArrayBufferView): boolean;
  135567. }
  135568. }
  135569. declare module BABYLON {
  135570. /**
  135571. * Implementation of the KTX Texture Loader.
  135572. * @hidden
  135573. */
  135574. export class _KTXTextureLoader implements IInternalTextureLoader {
  135575. /**
  135576. * Defines wether the loader supports cascade loading the different faces.
  135577. */
  135578. readonly supportCascades: boolean;
  135579. /**
  135580. * This returns if the loader support the current file information.
  135581. * @param extension defines the file extension of the file being loaded
  135582. * @param mimeType defines the optional mime type of the file being loaded
  135583. * @returns true if the loader can load the specified file
  135584. */
  135585. canLoad(extension: string, mimeType?: string): boolean;
  135586. /**
  135587. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135588. * @param data contains the texture data
  135589. * @param texture defines the BabylonJS internal texture
  135590. * @param createPolynomials will be true if polynomials have been requested
  135591. * @param onLoad defines the callback to trigger once the texture is ready
  135592. * @param onError defines the callback to trigger in case of error
  135593. */
  135594. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135595. /**
  135596. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135597. * @param data contains the texture data
  135598. * @param texture defines the BabylonJS internal texture
  135599. * @param callback defines the method to call once ready to upload
  135600. */
  135601. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  135602. }
  135603. }
  135604. declare module BABYLON {
  135605. /** @hidden */
  135606. export var _forceSceneHelpersToBundle: boolean;
  135607. interface Scene {
  135608. /**
  135609. * Creates a default light for the scene.
  135610. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  135611. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  135612. */
  135613. createDefaultLight(replace?: boolean): void;
  135614. /**
  135615. * Creates a default camera for the scene.
  135616. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  135617. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135618. * @param replace has default false, when true replaces the active camera in the scene
  135619. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  135620. */
  135621. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135622. /**
  135623. * Creates a default camera and a default light.
  135624. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  135625. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135626. * @param replace has the default false, when true replaces the active camera/light in the scene
  135627. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  135628. */
  135629. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135630. /**
  135631. * Creates a new sky box
  135632. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  135633. * @param environmentTexture defines the texture to use as environment texture
  135634. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  135635. * @param scale defines the overall scale of the skybox
  135636. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  135637. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  135638. * @returns a new mesh holding the sky box
  135639. */
  135640. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  135641. /**
  135642. * Creates a new environment
  135643. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  135644. * @param options defines the options you can use to configure the environment
  135645. * @returns the new EnvironmentHelper
  135646. */
  135647. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  135648. /**
  135649. * Creates a new VREXperienceHelper
  135650. * @see https://doc.babylonjs.com/how_to/webvr_helper
  135651. * @param webVROptions defines the options used to create the new VREXperienceHelper
  135652. * @returns a new VREXperienceHelper
  135653. */
  135654. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  135655. /**
  135656. * Creates a new WebXRDefaultExperience
  135657. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  135658. * @param options experience options
  135659. * @returns a promise for a new WebXRDefaultExperience
  135660. */
  135661. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135662. }
  135663. }
  135664. declare module BABYLON {
  135665. /**
  135666. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  135667. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  135668. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  135669. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135670. */
  135671. export class VideoDome extends TransformNode {
  135672. /**
  135673. * Define the video source as a Monoscopic panoramic 360 video.
  135674. */
  135675. static readonly MODE_MONOSCOPIC: number;
  135676. /**
  135677. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135678. */
  135679. static readonly MODE_TOPBOTTOM: number;
  135680. /**
  135681. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135682. */
  135683. static readonly MODE_SIDEBYSIDE: number;
  135684. private _halfDome;
  135685. private _useDirectMapping;
  135686. /**
  135687. * The video texture being displayed on the sphere
  135688. */
  135689. protected _videoTexture: VideoTexture;
  135690. /**
  135691. * Gets the video texture being displayed on the sphere
  135692. */
  135693. get videoTexture(): VideoTexture;
  135694. /**
  135695. * The skybox material
  135696. */
  135697. protected _material: BackgroundMaterial;
  135698. /**
  135699. * The surface used for the video dome
  135700. */
  135701. protected _mesh: Mesh;
  135702. /**
  135703. * Gets the mesh used for the video dome.
  135704. */
  135705. get mesh(): Mesh;
  135706. /**
  135707. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  135708. */
  135709. private _halfDomeMask;
  135710. /**
  135711. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135712. * Also see the options.resolution property.
  135713. */
  135714. get fovMultiplier(): number;
  135715. set fovMultiplier(value: number);
  135716. private _videoMode;
  135717. /**
  135718. * Gets or set the current video mode for the video. It can be:
  135719. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  135720. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135721. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135722. */
  135723. get videoMode(): number;
  135724. set videoMode(value: number);
  135725. /**
  135726. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  135727. *
  135728. */
  135729. get halfDome(): boolean;
  135730. /**
  135731. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135732. */
  135733. set halfDome(enabled: boolean);
  135734. /**
  135735. * Oberserver used in Stereoscopic VR Mode.
  135736. */
  135737. private _onBeforeCameraRenderObserver;
  135738. /**
  135739. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  135740. * @param name Element's name, child elements will append suffixes for their own names.
  135741. * @param urlsOrVideo defines the url(s) or the video element to use
  135742. * @param options An object containing optional or exposed sub element properties
  135743. */
  135744. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  135745. resolution?: number;
  135746. clickToPlay?: boolean;
  135747. autoPlay?: boolean;
  135748. loop?: boolean;
  135749. size?: number;
  135750. poster?: string;
  135751. faceForward?: boolean;
  135752. useDirectMapping?: boolean;
  135753. halfDomeMode?: boolean;
  135754. }, scene: Scene);
  135755. private _changeVideoMode;
  135756. /**
  135757. * Releases resources associated with this node.
  135758. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135759. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135760. */
  135761. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135762. }
  135763. }
  135764. declare module BABYLON {
  135765. /**
  135766. * This class can be used to get instrumentation data from a Babylon engine
  135767. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135768. */
  135769. export class EngineInstrumentation implements IDisposable {
  135770. /**
  135771. * Define the instrumented engine.
  135772. */
  135773. engine: Engine;
  135774. private _captureGPUFrameTime;
  135775. private _gpuFrameTimeToken;
  135776. private _gpuFrameTime;
  135777. private _captureShaderCompilationTime;
  135778. private _shaderCompilationTime;
  135779. private _onBeginFrameObserver;
  135780. private _onEndFrameObserver;
  135781. private _onBeforeShaderCompilationObserver;
  135782. private _onAfterShaderCompilationObserver;
  135783. /**
  135784. * Gets the perf counter used for GPU frame time
  135785. */
  135786. get gpuFrameTimeCounter(): PerfCounter;
  135787. /**
  135788. * Gets the GPU frame time capture status
  135789. */
  135790. get captureGPUFrameTime(): boolean;
  135791. /**
  135792. * Enable or disable the GPU frame time capture
  135793. */
  135794. set captureGPUFrameTime(value: boolean);
  135795. /**
  135796. * Gets the perf counter used for shader compilation time
  135797. */
  135798. get shaderCompilationTimeCounter(): PerfCounter;
  135799. /**
  135800. * Gets the shader compilation time capture status
  135801. */
  135802. get captureShaderCompilationTime(): boolean;
  135803. /**
  135804. * Enable or disable the shader compilation time capture
  135805. */
  135806. set captureShaderCompilationTime(value: boolean);
  135807. /**
  135808. * Instantiates a new engine instrumentation.
  135809. * This class can be used to get instrumentation data from a Babylon engine
  135810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135811. * @param engine Defines the engine to instrument
  135812. */
  135813. constructor(
  135814. /**
  135815. * Define the instrumented engine.
  135816. */
  135817. engine: Engine);
  135818. /**
  135819. * Dispose and release associated resources.
  135820. */
  135821. dispose(): void;
  135822. }
  135823. }
  135824. declare module BABYLON {
  135825. /**
  135826. * This class can be used to get instrumentation data from a Babylon engine
  135827. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135828. */
  135829. export class SceneInstrumentation implements IDisposable {
  135830. /**
  135831. * Defines the scene to instrument
  135832. */
  135833. scene: Scene;
  135834. private _captureActiveMeshesEvaluationTime;
  135835. private _activeMeshesEvaluationTime;
  135836. private _captureRenderTargetsRenderTime;
  135837. private _renderTargetsRenderTime;
  135838. private _captureFrameTime;
  135839. private _frameTime;
  135840. private _captureRenderTime;
  135841. private _renderTime;
  135842. private _captureInterFrameTime;
  135843. private _interFrameTime;
  135844. private _captureParticlesRenderTime;
  135845. private _particlesRenderTime;
  135846. private _captureSpritesRenderTime;
  135847. private _spritesRenderTime;
  135848. private _capturePhysicsTime;
  135849. private _physicsTime;
  135850. private _captureAnimationsTime;
  135851. private _animationsTime;
  135852. private _captureCameraRenderTime;
  135853. private _cameraRenderTime;
  135854. private _onBeforeActiveMeshesEvaluationObserver;
  135855. private _onAfterActiveMeshesEvaluationObserver;
  135856. private _onBeforeRenderTargetsRenderObserver;
  135857. private _onAfterRenderTargetsRenderObserver;
  135858. private _onAfterRenderObserver;
  135859. private _onBeforeDrawPhaseObserver;
  135860. private _onAfterDrawPhaseObserver;
  135861. private _onBeforeAnimationsObserver;
  135862. private _onBeforeParticlesRenderingObserver;
  135863. private _onAfterParticlesRenderingObserver;
  135864. private _onBeforeSpritesRenderingObserver;
  135865. private _onAfterSpritesRenderingObserver;
  135866. private _onBeforePhysicsObserver;
  135867. private _onAfterPhysicsObserver;
  135868. private _onAfterAnimationsObserver;
  135869. private _onBeforeCameraRenderObserver;
  135870. private _onAfterCameraRenderObserver;
  135871. /**
  135872. * Gets the perf counter used for active meshes evaluation time
  135873. */
  135874. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135875. /**
  135876. * Gets the active meshes evaluation time capture status
  135877. */
  135878. get captureActiveMeshesEvaluationTime(): boolean;
  135879. /**
  135880. * Enable or disable the active meshes evaluation time capture
  135881. */
  135882. set captureActiveMeshesEvaluationTime(value: boolean);
  135883. /**
  135884. * Gets the perf counter used for render targets render time
  135885. */
  135886. get renderTargetsRenderTimeCounter(): PerfCounter;
  135887. /**
  135888. * Gets the render targets render time capture status
  135889. */
  135890. get captureRenderTargetsRenderTime(): boolean;
  135891. /**
  135892. * Enable or disable the render targets render time capture
  135893. */
  135894. set captureRenderTargetsRenderTime(value: boolean);
  135895. /**
  135896. * Gets the perf counter used for particles render time
  135897. */
  135898. get particlesRenderTimeCounter(): PerfCounter;
  135899. /**
  135900. * Gets the particles render time capture status
  135901. */
  135902. get captureParticlesRenderTime(): boolean;
  135903. /**
  135904. * Enable or disable the particles render time capture
  135905. */
  135906. set captureParticlesRenderTime(value: boolean);
  135907. /**
  135908. * Gets the perf counter used for sprites render time
  135909. */
  135910. get spritesRenderTimeCounter(): PerfCounter;
  135911. /**
  135912. * Gets the sprites render time capture status
  135913. */
  135914. get captureSpritesRenderTime(): boolean;
  135915. /**
  135916. * Enable or disable the sprites render time capture
  135917. */
  135918. set captureSpritesRenderTime(value: boolean);
  135919. /**
  135920. * Gets the perf counter used for physics time
  135921. */
  135922. get physicsTimeCounter(): PerfCounter;
  135923. /**
  135924. * Gets the physics time capture status
  135925. */
  135926. get capturePhysicsTime(): boolean;
  135927. /**
  135928. * Enable or disable the physics time capture
  135929. */
  135930. set capturePhysicsTime(value: boolean);
  135931. /**
  135932. * Gets the perf counter used for animations time
  135933. */
  135934. get animationsTimeCounter(): PerfCounter;
  135935. /**
  135936. * Gets the animations time capture status
  135937. */
  135938. get captureAnimationsTime(): boolean;
  135939. /**
  135940. * Enable or disable the animations time capture
  135941. */
  135942. set captureAnimationsTime(value: boolean);
  135943. /**
  135944. * Gets the perf counter used for frame time capture
  135945. */
  135946. get frameTimeCounter(): PerfCounter;
  135947. /**
  135948. * Gets the frame time capture status
  135949. */
  135950. get captureFrameTime(): boolean;
  135951. /**
  135952. * Enable or disable the frame time capture
  135953. */
  135954. set captureFrameTime(value: boolean);
  135955. /**
  135956. * Gets the perf counter used for inter-frames time capture
  135957. */
  135958. get interFrameTimeCounter(): PerfCounter;
  135959. /**
  135960. * Gets the inter-frames time capture status
  135961. */
  135962. get captureInterFrameTime(): boolean;
  135963. /**
  135964. * Enable or disable the inter-frames time capture
  135965. */
  135966. set captureInterFrameTime(value: boolean);
  135967. /**
  135968. * Gets the perf counter used for render time capture
  135969. */
  135970. get renderTimeCounter(): PerfCounter;
  135971. /**
  135972. * Gets the render time capture status
  135973. */
  135974. get captureRenderTime(): boolean;
  135975. /**
  135976. * Enable or disable the render time capture
  135977. */
  135978. set captureRenderTime(value: boolean);
  135979. /**
  135980. * Gets the perf counter used for camera render time capture
  135981. */
  135982. get cameraRenderTimeCounter(): PerfCounter;
  135983. /**
  135984. * Gets the camera render time capture status
  135985. */
  135986. get captureCameraRenderTime(): boolean;
  135987. /**
  135988. * Enable or disable the camera render time capture
  135989. */
  135990. set captureCameraRenderTime(value: boolean);
  135991. /**
  135992. * Gets the perf counter used for draw calls
  135993. */
  135994. get drawCallsCounter(): PerfCounter;
  135995. /**
  135996. * Instantiates a new scene instrumentation.
  135997. * This class can be used to get instrumentation data from a Babylon engine
  135998. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135999. * @param scene Defines the scene to instrument
  136000. */
  136001. constructor(
  136002. /**
  136003. * Defines the scene to instrument
  136004. */
  136005. scene: Scene);
  136006. /**
  136007. * Dispose and release associated resources.
  136008. */
  136009. dispose(): void;
  136010. }
  136011. }
  136012. declare module BABYLON {
  136013. /** @hidden */
  136014. export var glowMapGenerationPixelShader: {
  136015. name: string;
  136016. shader: string;
  136017. };
  136018. }
  136019. declare module BABYLON {
  136020. /** @hidden */
  136021. export var glowMapGenerationVertexShader: {
  136022. name: string;
  136023. shader: string;
  136024. };
  136025. }
  136026. declare module BABYLON {
  136027. /**
  136028. * Effect layer options. This helps customizing the behaviour
  136029. * of the effect layer.
  136030. */
  136031. export interface IEffectLayerOptions {
  136032. /**
  136033. * Multiplication factor apply to the canvas size to compute the render target size
  136034. * used to generated the objects (the smaller the faster).
  136035. */
  136036. mainTextureRatio: number;
  136037. /**
  136038. * Enforces a fixed size texture to ensure effect stability across devices.
  136039. */
  136040. mainTextureFixedSize?: number;
  136041. /**
  136042. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136043. */
  136044. alphaBlendingMode: number;
  136045. /**
  136046. * The camera attached to the layer.
  136047. */
  136048. camera: Nullable<Camera>;
  136049. /**
  136050. * The rendering group to draw the layer in.
  136051. */
  136052. renderingGroupId: number;
  136053. }
  136054. /**
  136055. * The effect layer Helps adding post process effect blended with the main pass.
  136056. *
  136057. * This can be for instance use to generate glow or higlight effects on the scene.
  136058. *
  136059. * The effect layer class can not be used directly and is intented to inherited from to be
  136060. * customized per effects.
  136061. */
  136062. export abstract class EffectLayer {
  136063. private _vertexBuffers;
  136064. private _indexBuffer;
  136065. private _cachedDefines;
  136066. private _effectLayerMapGenerationEffect;
  136067. private _effectLayerOptions;
  136068. private _mergeEffect;
  136069. protected _scene: Scene;
  136070. protected _engine: Engine;
  136071. protected _maxSize: number;
  136072. protected _mainTextureDesiredSize: ISize;
  136073. protected _mainTexture: RenderTargetTexture;
  136074. protected _shouldRender: boolean;
  136075. protected _postProcesses: PostProcess[];
  136076. protected _textures: BaseTexture[];
  136077. protected _emissiveTextureAndColor: {
  136078. texture: Nullable<BaseTexture>;
  136079. color: Color4;
  136080. };
  136081. /**
  136082. * The name of the layer
  136083. */
  136084. name: string;
  136085. /**
  136086. * The clear color of the texture used to generate the glow map.
  136087. */
  136088. neutralColor: Color4;
  136089. /**
  136090. * Specifies whether the highlight layer is enabled or not.
  136091. */
  136092. isEnabled: boolean;
  136093. /**
  136094. * Gets the camera attached to the layer.
  136095. */
  136096. get camera(): Nullable<Camera>;
  136097. /**
  136098. * Gets the rendering group id the layer should render in.
  136099. */
  136100. get renderingGroupId(): number;
  136101. set renderingGroupId(renderingGroupId: number);
  136102. /**
  136103. * An event triggered when the effect layer has been disposed.
  136104. */
  136105. onDisposeObservable: Observable<EffectLayer>;
  136106. /**
  136107. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136108. */
  136109. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136110. /**
  136111. * An event triggered when the generated texture is being merged in the scene.
  136112. */
  136113. onBeforeComposeObservable: Observable<EffectLayer>;
  136114. /**
  136115. * An event triggered when the mesh is rendered into the effect render target.
  136116. */
  136117. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136118. /**
  136119. * An event triggered after the mesh has been rendered into the effect render target.
  136120. */
  136121. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136122. /**
  136123. * An event triggered when the generated texture has been merged in the scene.
  136124. */
  136125. onAfterComposeObservable: Observable<EffectLayer>;
  136126. /**
  136127. * An event triggered when the efffect layer changes its size.
  136128. */
  136129. onSizeChangedObservable: Observable<EffectLayer>;
  136130. /** @hidden */
  136131. static _SceneComponentInitialization: (scene: Scene) => void;
  136132. /**
  136133. * Instantiates a new effect Layer and references it in the scene.
  136134. * @param name The name of the layer
  136135. * @param scene The scene to use the layer in
  136136. */
  136137. constructor(
  136138. /** The Friendly of the effect in the scene */
  136139. name: string, scene: Scene);
  136140. /**
  136141. * Get the effect name of the layer.
  136142. * @return The effect name
  136143. */
  136144. abstract getEffectName(): string;
  136145. /**
  136146. * Checks for the readiness of the element composing the layer.
  136147. * @param subMesh the mesh to check for
  136148. * @param useInstances specify whether or not to use instances to render the mesh
  136149. * @return true if ready otherwise, false
  136150. */
  136151. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136152. /**
  136153. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136154. * @returns true if the effect requires stencil during the main canvas render pass.
  136155. */
  136156. abstract needStencil(): boolean;
  136157. /**
  136158. * Create the merge effect. This is the shader use to blit the information back
  136159. * to the main canvas at the end of the scene rendering.
  136160. * @returns The effect containing the shader used to merge the effect on the main canvas
  136161. */
  136162. protected abstract _createMergeEffect(): Effect;
  136163. /**
  136164. * Creates the render target textures and post processes used in the effect layer.
  136165. */
  136166. protected abstract _createTextureAndPostProcesses(): void;
  136167. /**
  136168. * Implementation specific of rendering the generating effect on the main canvas.
  136169. * @param effect The effect used to render through
  136170. */
  136171. protected abstract _internalRender(effect: Effect): void;
  136172. /**
  136173. * Sets the required values for both the emissive texture and and the main color.
  136174. */
  136175. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136176. /**
  136177. * Free any resources and references associated to a mesh.
  136178. * Internal use
  136179. * @param mesh The mesh to free.
  136180. */
  136181. abstract _disposeMesh(mesh: Mesh): void;
  136182. /**
  136183. * Serializes this layer (Glow or Highlight for example)
  136184. * @returns a serialized layer object
  136185. */
  136186. abstract serialize?(): any;
  136187. /**
  136188. * Initializes the effect layer with the required options.
  136189. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  136190. */
  136191. protected _init(options: Partial<IEffectLayerOptions>): void;
  136192. /**
  136193. * Generates the index buffer of the full screen quad blending to the main canvas.
  136194. */
  136195. private _generateIndexBuffer;
  136196. /**
  136197. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  136198. */
  136199. private _generateVertexBuffer;
  136200. /**
  136201. * Sets the main texture desired size which is the closest power of two
  136202. * of the engine canvas size.
  136203. */
  136204. private _setMainTextureSize;
  136205. /**
  136206. * Creates the main texture for the effect layer.
  136207. */
  136208. protected _createMainTexture(): void;
  136209. /**
  136210. * Adds specific effects defines.
  136211. * @param defines The defines to add specifics to.
  136212. */
  136213. protected _addCustomEffectDefines(defines: string[]): void;
  136214. /**
  136215. * Checks for the readiness of the element composing the layer.
  136216. * @param subMesh the mesh to check for
  136217. * @param useInstances specify whether or not to use instances to render the mesh
  136218. * @param emissiveTexture the associated emissive texture used to generate the glow
  136219. * @return true if ready otherwise, false
  136220. */
  136221. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  136222. /**
  136223. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  136224. */
  136225. render(): void;
  136226. /**
  136227. * Determine if a given mesh will be used in the current effect.
  136228. * @param mesh mesh to test
  136229. * @returns true if the mesh will be used
  136230. */
  136231. hasMesh(mesh: AbstractMesh): boolean;
  136232. /**
  136233. * Returns true if the layer contains information to display, otherwise false.
  136234. * @returns true if the glow layer should be rendered
  136235. */
  136236. shouldRender(): boolean;
  136237. /**
  136238. * Returns true if the mesh should render, otherwise false.
  136239. * @param mesh The mesh to render
  136240. * @returns true if it should render otherwise false
  136241. */
  136242. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  136243. /**
  136244. * Returns true if the mesh can be rendered, otherwise false.
  136245. * @param mesh The mesh to render
  136246. * @param material The material used on the mesh
  136247. * @returns true if it can be rendered otherwise false
  136248. */
  136249. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136250. /**
  136251. * Returns true if the mesh should render, otherwise false.
  136252. * @param mesh The mesh to render
  136253. * @returns true if it should render otherwise false
  136254. */
  136255. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  136256. /**
  136257. * Renders the submesh passed in parameter to the generation map.
  136258. */
  136259. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  136260. /**
  136261. * Defines whether the current material of the mesh should be use to render the effect.
  136262. * @param mesh defines the current mesh to render
  136263. */
  136264. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136265. /**
  136266. * Rebuild the required buffers.
  136267. * @hidden Internal use only.
  136268. */
  136269. _rebuild(): void;
  136270. /**
  136271. * Dispose only the render target textures and post process.
  136272. */
  136273. private _disposeTextureAndPostProcesses;
  136274. /**
  136275. * Dispose the highlight layer and free resources.
  136276. */
  136277. dispose(): void;
  136278. /**
  136279. * Gets the class name of the effect layer
  136280. * @returns the string with the class name of the effect layer
  136281. */
  136282. getClassName(): string;
  136283. /**
  136284. * Creates an effect layer from parsed effect layer data
  136285. * @param parsedEffectLayer defines effect layer data
  136286. * @param scene defines the current scene
  136287. * @param rootUrl defines the root URL containing the effect layer information
  136288. * @returns a parsed effect Layer
  136289. */
  136290. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  136291. }
  136292. }
  136293. declare module BABYLON {
  136294. interface AbstractScene {
  136295. /**
  136296. * The list of effect layers (highlights/glow) added to the scene
  136297. * @see https://doc.babylonjs.com/how_to/highlight_layer
  136298. * @see https://doc.babylonjs.com/how_to/glow_layer
  136299. */
  136300. effectLayers: Array<EffectLayer>;
  136301. /**
  136302. * Removes the given effect layer from this scene.
  136303. * @param toRemove defines the effect layer to remove
  136304. * @returns the index of the removed effect layer
  136305. */
  136306. removeEffectLayer(toRemove: EffectLayer): number;
  136307. /**
  136308. * Adds the given effect layer to this scene
  136309. * @param newEffectLayer defines the effect layer to add
  136310. */
  136311. addEffectLayer(newEffectLayer: EffectLayer): void;
  136312. }
  136313. /**
  136314. * Defines the layer scene component responsible to manage any effect layers
  136315. * in a given scene.
  136316. */
  136317. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  136318. /**
  136319. * The component name helpfull to identify the component in the list of scene components.
  136320. */
  136321. readonly name: string;
  136322. /**
  136323. * The scene the component belongs to.
  136324. */
  136325. scene: Scene;
  136326. private _engine;
  136327. private _renderEffects;
  136328. private _needStencil;
  136329. private _previousStencilState;
  136330. /**
  136331. * Creates a new instance of the component for the given scene
  136332. * @param scene Defines the scene to register the component in
  136333. */
  136334. constructor(scene: Scene);
  136335. /**
  136336. * Registers the component in a given scene
  136337. */
  136338. register(): void;
  136339. /**
  136340. * Rebuilds the elements related to this component in case of
  136341. * context lost for instance.
  136342. */
  136343. rebuild(): void;
  136344. /**
  136345. * Serializes the component data to the specified json object
  136346. * @param serializationObject The object to serialize to
  136347. */
  136348. serialize(serializationObject: any): void;
  136349. /**
  136350. * Adds all the elements from the container to the scene
  136351. * @param container the container holding the elements
  136352. */
  136353. addFromContainer(container: AbstractScene): void;
  136354. /**
  136355. * Removes all the elements in the container from the scene
  136356. * @param container contains the elements to remove
  136357. * @param dispose if the removed element should be disposed (default: false)
  136358. */
  136359. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136360. /**
  136361. * Disposes the component and the associated ressources.
  136362. */
  136363. dispose(): void;
  136364. private _isReadyForMesh;
  136365. private _renderMainTexture;
  136366. private _setStencil;
  136367. private _setStencilBack;
  136368. private _draw;
  136369. private _drawCamera;
  136370. private _drawRenderingGroup;
  136371. }
  136372. }
  136373. declare module BABYLON {
  136374. /** @hidden */
  136375. export var glowMapMergePixelShader: {
  136376. name: string;
  136377. shader: string;
  136378. };
  136379. }
  136380. declare module BABYLON {
  136381. /** @hidden */
  136382. export var glowMapMergeVertexShader: {
  136383. name: string;
  136384. shader: string;
  136385. };
  136386. }
  136387. declare module BABYLON {
  136388. interface AbstractScene {
  136389. /**
  136390. * Return a the first highlight layer of the scene with a given name.
  136391. * @param name The name of the highlight layer to look for.
  136392. * @return The highlight layer if found otherwise null.
  136393. */
  136394. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  136395. }
  136396. /**
  136397. * Glow layer options. This helps customizing the behaviour
  136398. * of the glow layer.
  136399. */
  136400. export interface IGlowLayerOptions {
  136401. /**
  136402. * Multiplication factor apply to the canvas size to compute the render target size
  136403. * used to generated the glowing objects (the smaller the faster).
  136404. */
  136405. mainTextureRatio: number;
  136406. /**
  136407. * Enforces a fixed size texture to ensure resize independant blur.
  136408. */
  136409. mainTextureFixedSize?: number;
  136410. /**
  136411. * How big is the kernel of the blur texture.
  136412. */
  136413. blurKernelSize: number;
  136414. /**
  136415. * The camera attached to the layer.
  136416. */
  136417. camera: Nullable<Camera>;
  136418. /**
  136419. * Enable MSAA by chosing the number of samples.
  136420. */
  136421. mainTextureSamples?: number;
  136422. /**
  136423. * The rendering group to draw the layer in.
  136424. */
  136425. renderingGroupId: number;
  136426. }
  136427. /**
  136428. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  136429. *
  136430. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  136431. *
  136432. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  136433. */
  136434. export class GlowLayer extends EffectLayer {
  136435. /**
  136436. * Effect Name of the layer.
  136437. */
  136438. static readonly EffectName: string;
  136439. /**
  136440. * The default blur kernel size used for the glow.
  136441. */
  136442. static DefaultBlurKernelSize: number;
  136443. /**
  136444. * The default texture size ratio used for the glow.
  136445. */
  136446. static DefaultTextureRatio: number;
  136447. /**
  136448. * Sets the kernel size of the blur.
  136449. */
  136450. set blurKernelSize(value: number);
  136451. /**
  136452. * Gets the kernel size of the blur.
  136453. */
  136454. get blurKernelSize(): number;
  136455. /**
  136456. * Sets the glow intensity.
  136457. */
  136458. set intensity(value: number);
  136459. /**
  136460. * Gets the glow intensity.
  136461. */
  136462. get intensity(): number;
  136463. private _options;
  136464. private _intensity;
  136465. private _horizontalBlurPostprocess1;
  136466. private _verticalBlurPostprocess1;
  136467. private _horizontalBlurPostprocess2;
  136468. private _verticalBlurPostprocess2;
  136469. private _blurTexture1;
  136470. private _blurTexture2;
  136471. private _postProcesses1;
  136472. private _postProcesses2;
  136473. private _includedOnlyMeshes;
  136474. private _excludedMeshes;
  136475. private _meshesUsingTheirOwnMaterials;
  136476. /**
  136477. * Callback used to let the user override the color selection on a per mesh basis
  136478. */
  136479. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  136480. /**
  136481. * Callback used to let the user override the texture selection on a per mesh basis
  136482. */
  136483. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  136484. /**
  136485. * Instantiates a new glow Layer and references it to the scene.
  136486. * @param name The name of the layer
  136487. * @param scene The scene to use the layer in
  136488. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  136489. */
  136490. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  136491. /**
  136492. * Get the effect name of the layer.
  136493. * @return The effect name
  136494. */
  136495. getEffectName(): string;
  136496. /**
  136497. * Create the merge effect. This is the shader use to blit the information back
  136498. * to the main canvas at the end of the scene rendering.
  136499. */
  136500. protected _createMergeEffect(): Effect;
  136501. /**
  136502. * Creates the render target textures and post processes used in the glow layer.
  136503. */
  136504. protected _createTextureAndPostProcesses(): void;
  136505. /**
  136506. * Checks for the readiness of the element composing the layer.
  136507. * @param subMesh the mesh to check for
  136508. * @param useInstances specify wether or not to use instances to render the mesh
  136509. * @param emissiveTexture the associated emissive texture used to generate the glow
  136510. * @return true if ready otherwise, false
  136511. */
  136512. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136513. /**
  136514. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136515. */
  136516. needStencil(): boolean;
  136517. /**
  136518. * Returns true if the mesh can be rendered, otherwise false.
  136519. * @param mesh The mesh to render
  136520. * @param material The material used on the mesh
  136521. * @returns true if it can be rendered otherwise false
  136522. */
  136523. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136524. /**
  136525. * Implementation specific of rendering the generating effect on the main canvas.
  136526. * @param effect The effect used to render through
  136527. */
  136528. protected _internalRender(effect: Effect): void;
  136529. /**
  136530. * Sets the required values for both the emissive texture and and the main color.
  136531. */
  136532. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136533. /**
  136534. * Returns true if the mesh should render, otherwise false.
  136535. * @param mesh The mesh to render
  136536. * @returns true if it should render otherwise false
  136537. */
  136538. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136539. /**
  136540. * Adds specific effects defines.
  136541. * @param defines The defines to add specifics to.
  136542. */
  136543. protected _addCustomEffectDefines(defines: string[]): void;
  136544. /**
  136545. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  136546. * @param mesh The mesh to exclude from the glow layer
  136547. */
  136548. addExcludedMesh(mesh: Mesh): void;
  136549. /**
  136550. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  136551. * @param mesh The mesh to remove
  136552. */
  136553. removeExcludedMesh(mesh: Mesh): void;
  136554. /**
  136555. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  136556. * @param mesh The mesh to include in the glow layer
  136557. */
  136558. addIncludedOnlyMesh(mesh: Mesh): void;
  136559. /**
  136560. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  136561. * @param mesh The mesh to remove
  136562. */
  136563. removeIncludedOnlyMesh(mesh: Mesh): void;
  136564. /**
  136565. * Determine if a given mesh will be used in the glow layer
  136566. * @param mesh The mesh to test
  136567. * @returns true if the mesh will be highlighted by the current glow layer
  136568. */
  136569. hasMesh(mesh: AbstractMesh): boolean;
  136570. /**
  136571. * Defines whether the current material of the mesh should be use to render the effect.
  136572. * @param mesh defines the current mesh to render
  136573. */
  136574. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136575. /**
  136576. * Add a mesh to be rendered through its own material and not with emissive only.
  136577. * @param mesh The mesh for which we need to use its material
  136578. */
  136579. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  136580. /**
  136581. * Remove a mesh from being rendered through its own material and not with emissive only.
  136582. * @param mesh The mesh for which we need to not use its material
  136583. */
  136584. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  136585. /**
  136586. * Free any resources and references associated to a mesh.
  136587. * Internal use
  136588. * @param mesh The mesh to free.
  136589. * @hidden
  136590. */
  136591. _disposeMesh(mesh: Mesh): void;
  136592. /**
  136593. * Gets the class name of the effect layer
  136594. * @returns the string with the class name of the effect layer
  136595. */
  136596. getClassName(): string;
  136597. /**
  136598. * Serializes this glow layer
  136599. * @returns a serialized glow layer object
  136600. */
  136601. serialize(): any;
  136602. /**
  136603. * Creates a Glow Layer from parsed glow layer data
  136604. * @param parsedGlowLayer defines glow layer data
  136605. * @param scene defines the current scene
  136606. * @param rootUrl defines the root URL containing the glow layer information
  136607. * @returns a parsed Glow Layer
  136608. */
  136609. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  136610. }
  136611. }
  136612. declare module BABYLON {
  136613. /** @hidden */
  136614. export var glowBlurPostProcessPixelShader: {
  136615. name: string;
  136616. shader: string;
  136617. };
  136618. }
  136619. declare module BABYLON {
  136620. interface AbstractScene {
  136621. /**
  136622. * Return a the first highlight layer of the scene with a given name.
  136623. * @param name The name of the highlight layer to look for.
  136624. * @return The highlight layer if found otherwise null.
  136625. */
  136626. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  136627. }
  136628. /**
  136629. * Highlight layer options. This helps customizing the behaviour
  136630. * of the highlight layer.
  136631. */
  136632. export interface IHighlightLayerOptions {
  136633. /**
  136634. * Multiplication factor apply to the canvas size to compute the render target size
  136635. * used to generated the glowing objects (the smaller the faster).
  136636. */
  136637. mainTextureRatio: number;
  136638. /**
  136639. * Enforces a fixed size texture to ensure resize independant blur.
  136640. */
  136641. mainTextureFixedSize?: number;
  136642. /**
  136643. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  136644. * of the picture to blur (the smaller the faster).
  136645. */
  136646. blurTextureSizeRatio: number;
  136647. /**
  136648. * How big in texel of the blur texture is the vertical blur.
  136649. */
  136650. blurVerticalSize: number;
  136651. /**
  136652. * How big in texel of the blur texture is the horizontal blur.
  136653. */
  136654. blurHorizontalSize: number;
  136655. /**
  136656. * Alpha blending mode used to apply the blur. Default is combine.
  136657. */
  136658. alphaBlendingMode: number;
  136659. /**
  136660. * The camera attached to the layer.
  136661. */
  136662. camera: Nullable<Camera>;
  136663. /**
  136664. * Should we display highlight as a solid stroke?
  136665. */
  136666. isStroke?: boolean;
  136667. /**
  136668. * The rendering group to draw the layer in.
  136669. */
  136670. renderingGroupId: number;
  136671. }
  136672. /**
  136673. * The highlight layer Helps adding a glow effect around a mesh.
  136674. *
  136675. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  136676. * glowy meshes to your scene.
  136677. *
  136678. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  136679. */
  136680. export class HighlightLayer extends EffectLayer {
  136681. name: string;
  136682. /**
  136683. * Effect Name of the highlight layer.
  136684. */
  136685. static readonly EffectName: string;
  136686. /**
  136687. * The neutral color used during the preparation of the glow effect.
  136688. * This is black by default as the blend operation is a blend operation.
  136689. */
  136690. static NeutralColor: Color4;
  136691. /**
  136692. * Stencil value used for glowing meshes.
  136693. */
  136694. static GlowingMeshStencilReference: number;
  136695. /**
  136696. * Stencil value used for the other meshes in the scene.
  136697. */
  136698. static NormalMeshStencilReference: number;
  136699. /**
  136700. * Specifies whether or not the inner glow is ACTIVE in the layer.
  136701. */
  136702. innerGlow: boolean;
  136703. /**
  136704. * Specifies whether or not the outer glow is ACTIVE in the layer.
  136705. */
  136706. outerGlow: boolean;
  136707. /**
  136708. * Specifies the horizontal size of the blur.
  136709. */
  136710. set blurHorizontalSize(value: number);
  136711. /**
  136712. * Specifies the vertical size of the blur.
  136713. */
  136714. set blurVerticalSize(value: number);
  136715. /**
  136716. * Gets the horizontal size of the blur.
  136717. */
  136718. get blurHorizontalSize(): number;
  136719. /**
  136720. * Gets the vertical size of the blur.
  136721. */
  136722. get blurVerticalSize(): number;
  136723. /**
  136724. * An event triggered when the highlight layer is being blurred.
  136725. */
  136726. onBeforeBlurObservable: Observable<HighlightLayer>;
  136727. /**
  136728. * An event triggered when the highlight layer has been blurred.
  136729. */
  136730. onAfterBlurObservable: Observable<HighlightLayer>;
  136731. private _instanceGlowingMeshStencilReference;
  136732. private _options;
  136733. private _downSamplePostprocess;
  136734. private _horizontalBlurPostprocess;
  136735. private _verticalBlurPostprocess;
  136736. private _blurTexture;
  136737. private _meshes;
  136738. private _excludedMeshes;
  136739. /**
  136740. * Instantiates a new highlight Layer and references it to the scene..
  136741. * @param name The name of the layer
  136742. * @param scene The scene to use the layer in
  136743. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  136744. */
  136745. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  136746. /**
  136747. * Get the effect name of the layer.
  136748. * @return The effect name
  136749. */
  136750. getEffectName(): string;
  136751. /**
  136752. * Create the merge effect. This is the shader use to blit the information back
  136753. * to the main canvas at the end of the scene rendering.
  136754. */
  136755. protected _createMergeEffect(): Effect;
  136756. /**
  136757. * Creates the render target textures and post processes used in the highlight layer.
  136758. */
  136759. protected _createTextureAndPostProcesses(): void;
  136760. /**
  136761. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  136762. */
  136763. needStencil(): boolean;
  136764. /**
  136765. * Checks for the readiness of the element composing the layer.
  136766. * @param subMesh the mesh to check for
  136767. * @param useInstances specify wether or not to use instances to render the mesh
  136768. * @param emissiveTexture the associated emissive texture used to generate the glow
  136769. * @return true if ready otherwise, false
  136770. */
  136771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136772. /**
  136773. * Implementation specific of rendering the generating effect on the main canvas.
  136774. * @param effect The effect used to render through
  136775. */
  136776. protected _internalRender(effect: Effect): void;
  136777. /**
  136778. * Returns true if the layer contains information to display, otherwise false.
  136779. */
  136780. shouldRender(): boolean;
  136781. /**
  136782. * Returns true if the mesh should render, otherwise false.
  136783. * @param mesh The mesh to render
  136784. * @returns true if it should render otherwise false
  136785. */
  136786. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136787. /**
  136788. * Returns true if the mesh can be rendered, otherwise false.
  136789. * @param mesh The mesh to render
  136790. * @param material The material used on the mesh
  136791. * @returns true if it can be rendered otherwise false
  136792. */
  136793. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136794. /**
  136795. * Adds specific effects defines.
  136796. * @param defines The defines to add specifics to.
  136797. */
  136798. protected _addCustomEffectDefines(defines: string[]): void;
  136799. /**
  136800. * Sets the required values for both the emissive texture and and the main color.
  136801. */
  136802. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136803. /**
  136804. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136805. * @param mesh The mesh to exclude from the highlight layer
  136806. */
  136807. addExcludedMesh(mesh: Mesh): void;
  136808. /**
  136809. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136810. * @param mesh The mesh to highlight
  136811. */
  136812. removeExcludedMesh(mesh: Mesh): void;
  136813. /**
  136814. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136815. * @param mesh mesh to test
  136816. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136817. */
  136818. hasMesh(mesh: AbstractMesh): boolean;
  136819. /**
  136820. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136821. * @param mesh The mesh to highlight
  136822. * @param color The color of the highlight
  136823. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136824. */
  136825. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136826. /**
  136827. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136828. * @param mesh The mesh to highlight
  136829. */
  136830. removeMesh(mesh: Mesh): void;
  136831. /**
  136832. * Remove all the meshes currently referenced in the highlight layer
  136833. */
  136834. removeAllMeshes(): void;
  136835. /**
  136836. * Force the stencil to the normal expected value for none glowing parts
  136837. */
  136838. private _defaultStencilReference;
  136839. /**
  136840. * Free any resources and references associated to a mesh.
  136841. * Internal use
  136842. * @param mesh The mesh to free.
  136843. * @hidden
  136844. */
  136845. _disposeMesh(mesh: Mesh): void;
  136846. /**
  136847. * Dispose the highlight layer and free resources.
  136848. */
  136849. dispose(): void;
  136850. /**
  136851. * Gets the class name of the effect layer
  136852. * @returns the string with the class name of the effect layer
  136853. */
  136854. getClassName(): string;
  136855. /**
  136856. * Serializes this Highlight layer
  136857. * @returns a serialized Highlight layer object
  136858. */
  136859. serialize(): any;
  136860. /**
  136861. * Creates a Highlight layer from parsed Highlight layer data
  136862. * @param parsedHightlightLayer defines the Highlight layer data
  136863. * @param scene defines the current scene
  136864. * @param rootUrl defines the root URL containing the Highlight layer information
  136865. * @returns a parsed Highlight layer
  136866. */
  136867. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136868. }
  136869. }
  136870. declare module BABYLON {
  136871. interface AbstractScene {
  136872. /**
  136873. * The list of layers (background and foreground) of the scene
  136874. */
  136875. layers: Array<Layer>;
  136876. }
  136877. /**
  136878. * Defines the layer scene component responsible to manage any layers
  136879. * in a given scene.
  136880. */
  136881. export class LayerSceneComponent implements ISceneComponent {
  136882. /**
  136883. * The component name helpfull to identify the component in the list of scene components.
  136884. */
  136885. readonly name: string;
  136886. /**
  136887. * The scene the component belongs to.
  136888. */
  136889. scene: Scene;
  136890. private _engine;
  136891. /**
  136892. * Creates a new instance of the component for the given scene
  136893. * @param scene Defines the scene to register the component in
  136894. */
  136895. constructor(scene: Scene);
  136896. /**
  136897. * Registers the component in a given scene
  136898. */
  136899. register(): void;
  136900. /**
  136901. * Rebuilds the elements related to this component in case of
  136902. * context lost for instance.
  136903. */
  136904. rebuild(): void;
  136905. /**
  136906. * Disposes the component and the associated ressources.
  136907. */
  136908. dispose(): void;
  136909. private _draw;
  136910. private _drawCameraPredicate;
  136911. private _drawCameraBackground;
  136912. private _drawCameraForeground;
  136913. private _drawRenderTargetPredicate;
  136914. private _drawRenderTargetBackground;
  136915. private _drawRenderTargetForeground;
  136916. /**
  136917. * Adds all the elements from the container to the scene
  136918. * @param container the container holding the elements
  136919. */
  136920. addFromContainer(container: AbstractScene): void;
  136921. /**
  136922. * Removes all the elements in the container from the scene
  136923. * @param container contains the elements to remove
  136924. * @param dispose if the removed element should be disposed (default: false)
  136925. */
  136926. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136927. }
  136928. }
  136929. declare module BABYLON {
  136930. /** @hidden */
  136931. export var layerPixelShader: {
  136932. name: string;
  136933. shader: string;
  136934. };
  136935. }
  136936. declare module BABYLON {
  136937. /** @hidden */
  136938. export var layerVertexShader: {
  136939. name: string;
  136940. shader: string;
  136941. };
  136942. }
  136943. declare module BABYLON {
  136944. /**
  136945. * This represents a full screen 2d layer.
  136946. * This can be useful to display a picture in the background of your scene for instance.
  136947. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136948. */
  136949. export class Layer {
  136950. /**
  136951. * Define the name of the layer.
  136952. */
  136953. name: string;
  136954. /**
  136955. * Define the texture the layer should display.
  136956. */
  136957. texture: Nullable<Texture>;
  136958. /**
  136959. * Is the layer in background or foreground.
  136960. */
  136961. isBackground: boolean;
  136962. /**
  136963. * Define the color of the layer (instead of texture).
  136964. */
  136965. color: Color4;
  136966. /**
  136967. * Define the scale of the layer in order to zoom in out of the texture.
  136968. */
  136969. scale: Vector2;
  136970. /**
  136971. * Define an offset for the layer in order to shift the texture.
  136972. */
  136973. offset: Vector2;
  136974. /**
  136975. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136976. */
  136977. alphaBlendingMode: number;
  136978. /**
  136979. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136980. * Alpha test will not mix with the background color in case of transparency.
  136981. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136982. */
  136983. alphaTest: boolean;
  136984. /**
  136985. * Define a mask to restrict the layer to only some of the scene cameras.
  136986. */
  136987. layerMask: number;
  136988. /**
  136989. * Define the list of render target the layer is visible into.
  136990. */
  136991. renderTargetTextures: RenderTargetTexture[];
  136992. /**
  136993. * Define if the layer is only used in renderTarget or if it also
  136994. * renders in the main frame buffer of the canvas.
  136995. */
  136996. renderOnlyInRenderTargetTextures: boolean;
  136997. private _scene;
  136998. private _vertexBuffers;
  136999. private _indexBuffer;
  137000. private _effect;
  137001. private _previousDefines;
  137002. /**
  137003. * An event triggered when the layer is disposed.
  137004. */
  137005. onDisposeObservable: Observable<Layer>;
  137006. private _onDisposeObserver;
  137007. /**
  137008. * Back compatibility with callback before the onDisposeObservable existed.
  137009. * The set callback will be triggered when the layer has been disposed.
  137010. */
  137011. set onDispose(callback: () => void);
  137012. /**
  137013. * An event triggered before rendering the scene
  137014. */
  137015. onBeforeRenderObservable: Observable<Layer>;
  137016. private _onBeforeRenderObserver;
  137017. /**
  137018. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137019. * The set callback will be triggered just before rendering the layer.
  137020. */
  137021. set onBeforeRender(callback: () => void);
  137022. /**
  137023. * An event triggered after rendering the scene
  137024. */
  137025. onAfterRenderObservable: Observable<Layer>;
  137026. private _onAfterRenderObserver;
  137027. /**
  137028. * Back compatibility with callback before the onAfterRenderObservable existed.
  137029. * The set callback will be triggered just after rendering the layer.
  137030. */
  137031. set onAfterRender(callback: () => void);
  137032. /**
  137033. * Instantiates a new layer.
  137034. * This represents a full screen 2d layer.
  137035. * This can be useful to display a picture in the background of your scene for instance.
  137036. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137037. * @param name Define the name of the layer in the scene
  137038. * @param imgUrl Define the url of the texture to display in the layer
  137039. * @param scene Define the scene the layer belongs to
  137040. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137041. * @param color Defines a color for the layer
  137042. */
  137043. constructor(
  137044. /**
  137045. * Define the name of the layer.
  137046. */
  137047. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137048. private _createIndexBuffer;
  137049. /** @hidden */
  137050. _rebuild(): void;
  137051. /**
  137052. * Renders the layer in the scene.
  137053. */
  137054. render(): void;
  137055. /**
  137056. * Disposes and releases the associated ressources.
  137057. */
  137058. dispose(): void;
  137059. }
  137060. }
  137061. declare module BABYLON {
  137062. /** @hidden */
  137063. export var lensFlarePixelShader: {
  137064. name: string;
  137065. shader: string;
  137066. };
  137067. }
  137068. declare module BABYLON {
  137069. /** @hidden */
  137070. export var lensFlareVertexShader: {
  137071. name: string;
  137072. shader: string;
  137073. };
  137074. }
  137075. declare module BABYLON {
  137076. /**
  137077. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137078. * It is usually composed of several `lensFlare`.
  137079. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137080. */
  137081. export class LensFlareSystem {
  137082. /**
  137083. * Define the name of the lens flare system
  137084. */
  137085. name: string;
  137086. /**
  137087. * List of lens flares used in this system.
  137088. */
  137089. lensFlares: LensFlare[];
  137090. /**
  137091. * Define a limit from the border the lens flare can be visible.
  137092. */
  137093. borderLimit: number;
  137094. /**
  137095. * Define a viewport border we do not want to see the lens flare in.
  137096. */
  137097. viewportBorder: number;
  137098. /**
  137099. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137100. */
  137101. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137102. /**
  137103. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137104. */
  137105. layerMask: number;
  137106. /**
  137107. * Define the id of the lens flare system in the scene.
  137108. * (equal to name by default)
  137109. */
  137110. id: string;
  137111. private _scene;
  137112. private _emitter;
  137113. private _vertexBuffers;
  137114. private _indexBuffer;
  137115. private _effect;
  137116. private _positionX;
  137117. private _positionY;
  137118. private _isEnabled;
  137119. /** @hidden */
  137120. static _SceneComponentInitialization: (scene: Scene) => void;
  137121. /**
  137122. * Instantiates a lens flare system.
  137123. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137124. * It is usually composed of several `lensFlare`.
  137125. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137126. * @param name Define the name of the lens flare system in the scene
  137127. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137128. * @param scene Define the scene the lens flare system belongs to
  137129. */
  137130. constructor(
  137131. /**
  137132. * Define the name of the lens flare system
  137133. */
  137134. name: string, emitter: any, scene: Scene);
  137135. /**
  137136. * Define if the lens flare system is enabled.
  137137. */
  137138. get isEnabled(): boolean;
  137139. set isEnabled(value: boolean);
  137140. /**
  137141. * Get the scene the effects belongs to.
  137142. * @returns the scene holding the lens flare system
  137143. */
  137144. getScene(): Scene;
  137145. /**
  137146. * Get the emitter of the lens flare system.
  137147. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137148. * @returns the emitter of the lens flare system
  137149. */
  137150. getEmitter(): any;
  137151. /**
  137152. * Set the emitter of the lens flare system.
  137153. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137154. * @param newEmitter Define the new emitter of the system
  137155. */
  137156. setEmitter(newEmitter: any): void;
  137157. /**
  137158. * Get the lens flare system emitter position.
  137159. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137160. * @returns the position
  137161. */
  137162. getEmitterPosition(): Vector3;
  137163. /**
  137164. * @hidden
  137165. */
  137166. computeEffectivePosition(globalViewport: Viewport): boolean;
  137167. /** @hidden */
  137168. _isVisible(): boolean;
  137169. /**
  137170. * @hidden
  137171. */
  137172. render(): boolean;
  137173. /**
  137174. * Dispose and release the lens flare with its associated resources.
  137175. */
  137176. dispose(): void;
  137177. /**
  137178. * Parse a lens flare system from a JSON repressentation
  137179. * @param parsedLensFlareSystem Define the JSON to parse
  137180. * @param scene Define the scene the parsed system should be instantiated in
  137181. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  137182. * @returns the parsed system
  137183. */
  137184. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  137185. /**
  137186. * Serialize the current Lens Flare System into a JSON representation.
  137187. * @returns the serialized JSON
  137188. */
  137189. serialize(): any;
  137190. }
  137191. }
  137192. declare module BABYLON {
  137193. /**
  137194. * This represents one of the lens effect in a `lensFlareSystem`.
  137195. * It controls one of the indiviual texture used in the effect.
  137196. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137197. */
  137198. export class LensFlare {
  137199. /**
  137200. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137201. */
  137202. size: number;
  137203. /**
  137204. * 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.
  137205. */
  137206. position: number;
  137207. /**
  137208. * Define the lens color.
  137209. */
  137210. color: Color3;
  137211. /**
  137212. * Define the lens texture.
  137213. */
  137214. texture: Nullable<Texture>;
  137215. /**
  137216. * Define the alpha mode to render this particular lens.
  137217. */
  137218. alphaMode: number;
  137219. private _system;
  137220. /**
  137221. * Creates a new Lens Flare.
  137222. * This represents one of the lens effect in a `lensFlareSystem`.
  137223. * It controls one of the indiviual texture used in the effect.
  137224. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137225. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  137226. * @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.
  137227. * @param color Define the lens color
  137228. * @param imgUrl Define the lens texture url
  137229. * @param system Define the `lensFlareSystem` this flare is part of
  137230. * @returns The newly created Lens Flare
  137231. */
  137232. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  137233. /**
  137234. * Instantiates a new Lens Flare.
  137235. * This represents one of the lens effect in a `lensFlareSystem`.
  137236. * It controls one of the indiviual texture used in the effect.
  137237. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137238. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  137239. * @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.
  137240. * @param color Define the lens color
  137241. * @param imgUrl Define the lens texture url
  137242. * @param system Define the `lensFlareSystem` this flare is part of
  137243. */
  137244. constructor(
  137245. /**
  137246. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137247. */
  137248. size: number,
  137249. /**
  137250. * 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.
  137251. */
  137252. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  137253. /**
  137254. * Dispose and release the lens flare with its associated resources.
  137255. */
  137256. dispose(): void;
  137257. }
  137258. }
  137259. declare module BABYLON {
  137260. interface AbstractScene {
  137261. /**
  137262. * The list of lens flare system added to the scene
  137263. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137264. */
  137265. lensFlareSystems: Array<LensFlareSystem>;
  137266. /**
  137267. * Removes the given lens flare system from this scene.
  137268. * @param toRemove The lens flare system to remove
  137269. * @returns The index of the removed lens flare system
  137270. */
  137271. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  137272. /**
  137273. * Adds the given lens flare system to this scene
  137274. * @param newLensFlareSystem The lens flare system to add
  137275. */
  137276. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  137277. /**
  137278. * Gets a lens flare system using its name
  137279. * @param name defines the name to look for
  137280. * @returns the lens flare system or null if not found
  137281. */
  137282. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  137283. /**
  137284. * Gets a lens flare system using its id
  137285. * @param id defines the id to look for
  137286. * @returns the lens flare system or null if not found
  137287. */
  137288. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  137289. }
  137290. /**
  137291. * Defines the lens flare scene component responsible to manage any lens flares
  137292. * in a given scene.
  137293. */
  137294. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  137295. /**
  137296. * The component name helpfull to identify the component in the list of scene components.
  137297. */
  137298. readonly name: string;
  137299. /**
  137300. * The scene the component belongs to.
  137301. */
  137302. scene: Scene;
  137303. /**
  137304. * Creates a new instance of the component for the given scene
  137305. * @param scene Defines the scene to register the component in
  137306. */
  137307. constructor(scene: Scene);
  137308. /**
  137309. * Registers the component in a given scene
  137310. */
  137311. register(): void;
  137312. /**
  137313. * Rebuilds the elements related to this component in case of
  137314. * context lost for instance.
  137315. */
  137316. rebuild(): void;
  137317. /**
  137318. * Adds all the elements from the container to the scene
  137319. * @param container the container holding the elements
  137320. */
  137321. addFromContainer(container: AbstractScene): void;
  137322. /**
  137323. * Removes all the elements in the container from the scene
  137324. * @param container contains the elements to remove
  137325. * @param dispose if the removed element should be disposed (default: false)
  137326. */
  137327. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137328. /**
  137329. * Serializes the component data to the specified json object
  137330. * @param serializationObject The object to serialize to
  137331. */
  137332. serialize(serializationObject: any): void;
  137333. /**
  137334. * Disposes the component and the associated ressources.
  137335. */
  137336. dispose(): void;
  137337. private _draw;
  137338. }
  137339. }
  137340. declare module BABYLON {
  137341. /** @hidden */
  137342. export var depthPixelShader: {
  137343. name: string;
  137344. shader: string;
  137345. };
  137346. }
  137347. declare module BABYLON {
  137348. /** @hidden */
  137349. export var depthVertexShader: {
  137350. name: string;
  137351. shader: string;
  137352. };
  137353. }
  137354. declare module BABYLON {
  137355. /**
  137356. * This represents a depth renderer in Babylon.
  137357. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  137358. */
  137359. export class DepthRenderer {
  137360. private _scene;
  137361. private _depthMap;
  137362. private _effect;
  137363. private readonly _storeNonLinearDepth;
  137364. private readonly _clearColor;
  137365. /** Get if the depth renderer is using packed depth or not */
  137366. readonly isPacked: boolean;
  137367. private _cachedDefines;
  137368. private _camera;
  137369. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  137370. enabled: boolean;
  137371. /**
  137372. * Specifiess that the depth renderer will only be used within
  137373. * the camera it is created for.
  137374. * This can help forcing its rendering during the camera processing.
  137375. */
  137376. useOnlyInActiveCamera: boolean;
  137377. /** @hidden */
  137378. static _SceneComponentInitialization: (scene: Scene) => void;
  137379. /**
  137380. * Instantiates a depth renderer
  137381. * @param scene The scene the renderer belongs to
  137382. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  137383. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  137384. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  137385. */
  137386. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  137387. /**
  137388. * Creates the depth rendering effect and checks if the effect is ready.
  137389. * @param subMesh The submesh to be used to render the depth map of
  137390. * @param useInstances If multiple world instances should be used
  137391. * @returns if the depth renderer is ready to render the depth map
  137392. */
  137393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137394. /**
  137395. * Gets the texture which the depth map will be written to.
  137396. * @returns The depth map texture
  137397. */
  137398. getDepthMap(): RenderTargetTexture;
  137399. /**
  137400. * Disposes of the depth renderer.
  137401. */
  137402. dispose(): void;
  137403. }
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var minmaxReduxPixelShader: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /**
  137414. * This class computes a min/max reduction from a texture: it means it computes the minimum
  137415. * and maximum values from all values of the texture.
  137416. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  137417. * The source values are read from the red channel of the texture.
  137418. */
  137419. export class MinMaxReducer {
  137420. /**
  137421. * Observable triggered when the computation has been performed
  137422. */
  137423. onAfterReductionPerformed: Observable<{
  137424. min: number;
  137425. max: number;
  137426. }>;
  137427. protected _camera: Camera;
  137428. protected _sourceTexture: Nullable<RenderTargetTexture>;
  137429. protected _reductionSteps: Nullable<Array<PostProcess>>;
  137430. protected _postProcessManager: PostProcessManager;
  137431. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  137432. protected _forceFullscreenViewport: boolean;
  137433. /**
  137434. * Creates a min/max reducer
  137435. * @param camera The camera to use for the post processes
  137436. */
  137437. constructor(camera: Camera);
  137438. /**
  137439. * Gets the texture used to read the values from.
  137440. */
  137441. get sourceTexture(): Nullable<RenderTargetTexture>;
  137442. /**
  137443. * Sets the source texture to read the values from.
  137444. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  137445. * because in such textures '1' value must not be taken into account to compute the maximum
  137446. * as this value is used to clear the texture.
  137447. * Note that the computation is not activated by calling this function, you must call activate() for that!
  137448. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  137449. * @param depthRedux Indicates if the texture is a depth texture or not
  137450. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  137451. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  137452. */
  137453. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  137454. /**
  137455. * Defines the refresh rate of the computation.
  137456. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137457. */
  137458. get refreshRate(): number;
  137459. set refreshRate(value: number);
  137460. protected _activated: boolean;
  137461. /**
  137462. * Gets the activation status of the reducer
  137463. */
  137464. get activated(): boolean;
  137465. /**
  137466. * Activates the reduction computation.
  137467. * When activated, the observers registered in onAfterReductionPerformed are
  137468. * called after the compuation is performed
  137469. */
  137470. activate(): void;
  137471. /**
  137472. * Deactivates the reduction computation.
  137473. */
  137474. deactivate(): void;
  137475. /**
  137476. * Disposes the min/max reducer
  137477. * @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.
  137478. */
  137479. dispose(disposeAll?: boolean): void;
  137480. }
  137481. }
  137482. declare module BABYLON {
  137483. /**
  137484. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  137485. */
  137486. export class DepthReducer extends MinMaxReducer {
  137487. private _depthRenderer;
  137488. private _depthRendererId;
  137489. /**
  137490. * Gets the depth renderer used for the computation.
  137491. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  137492. */
  137493. get depthRenderer(): Nullable<DepthRenderer>;
  137494. /**
  137495. * Creates a depth reducer
  137496. * @param camera The camera used to render the depth texture
  137497. */
  137498. constructor(camera: Camera);
  137499. /**
  137500. * Sets the depth renderer to use to generate the depth map
  137501. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  137502. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  137503. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  137504. */
  137505. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  137506. /** @hidden */
  137507. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  137508. /**
  137509. * Activates the reduction computation.
  137510. * When activated, the observers registered in onAfterReductionPerformed are
  137511. * called after the compuation is performed
  137512. */
  137513. activate(): void;
  137514. /**
  137515. * Deactivates the reduction computation.
  137516. */
  137517. deactivate(): void;
  137518. /**
  137519. * Disposes the depth reducer
  137520. * @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.
  137521. */
  137522. dispose(disposeAll?: boolean): void;
  137523. }
  137524. }
  137525. declare module BABYLON {
  137526. /**
  137527. * A CSM implementation allowing casting shadows on large scenes.
  137528. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137529. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  137530. */
  137531. export class CascadedShadowGenerator extends ShadowGenerator {
  137532. private static readonly frustumCornersNDCSpace;
  137533. /**
  137534. * Name of the CSM class
  137535. */
  137536. static CLASSNAME: string;
  137537. /**
  137538. * Defines the default number of cascades used by the CSM.
  137539. */
  137540. static readonly DEFAULT_CASCADES_COUNT: number;
  137541. /**
  137542. * Defines the minimum number of cascades used by the CSM.
  137543. */
  137544. static readonly MIN_CASCADES_COUNT: number;
  137545. /**
  137546. * Defines the maximum number of cascades used by the CSM.
  137547. */
  137548. static readonly MAX_CASCADES_COUNT: number;
  137549. protected _validateFilter(filter: number): number;
  137550. /**
  137551. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  137552. */
  137553. penumbraDarkness: number;
  137554. private _numCascades;
  137555. /**
  137556. * Gets or set the number of cascades used by the CSM.
  137557. */
  137558. get numCascades(): number;
  137559. set numCascades(value: number);
  137560. /**
  137561. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  137562. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  137563. */
  137564. stabilizeCascades: boolean;
  137565. private _freezeShadowCastersBoundingInfo;
  137566. private _freezeShadowCastersBoundingInfoObservable;
  137567. /**
  137568. * Enables or disables the shadow casters bounding info computation.
  137569. * If your shadow casters don't move, you can disable this feature.
  137570. * If it is enabled, the bounding box computation is done every frame.
  137571. */
  137572. get freezeShadowCastersBoundingInfo(): boolean;
  137573. set freezeShadowCastersBoundingInfo(freeze: boolean);
  137574. private _scbiMin;
  137575. private _scbiMax;
  137576. protected _computeShadowCastersBoundingInfo(): void;
  137577. protected _shadowCastersBoundingInfo: BoundingInfo;
  137578. /**
  137579. * Gets or sets the shadow casters bounding info.
  137580. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  137581. * so that the system won't overwrite the bounds you provide
  137582. */
  137583. get shadowCastersBoundingInfo(): BoundingInfo;
  137584. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  137585. protected _breaksAreDirty: boolean;
  137586. protected _minDistance: number;
  137587. protected _maxDistance: number;
  137588. /**
  137589. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  137590. *
  137591. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  137592. * If you don't know these values, simply leave them to their defaults and don't call this function.
  137593. * @param min minimal distance for the breaks (default to 0.)
  137594. * @param max maximal distance for the breaks (default to 1.)
  137595. */
  137596. setMinMaxDistance(min: number, max: number): void;
  137597. /** Gets the minimal distance used in the cascade break computation */
  137598. get minDistance(): number;
  137599. /** Gets the maximal distance used in the cascade break computation */
  137600. get maxDistance(): number;
  137601. /**
  137602. * Gets the class name of that object
  137603. * @returns "CascadedShadowGenerator"
  137604. */
  137605. getClassName(): string;
  137606. private _cascadeMinExtents;
  137607. private _cascadeMaxExtents;
  137608. /**
  137609. * Gets a cascade minimum extents
  137610. * @param cascadeIndex index of the cascade
  137611. * @returns the minimum cascade extents
  137612. */
  137613. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  137614. /**
  137615. * Gets a cascade maximum extents
  137616. * @param cascadeIndex index of the cascade
  137617. * @returns the maximum cascade extents
  137618. */
  137619. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  137620. private _cascades;
  137621. private _currentLayer;
  137622. private _viewSpaceFrustumsZ;
  137623. private _viewMatrices;
  137624. private _projectionMatrices;
  137625. private _transformMatrices;
  137626. private _transformMatricesAsArray;
  137627. private _frustumLengths;
  137628. private _lightSizeUVCorrection;
  137629. private _depthCorrection;
  137630. private _frustumCornersWorldSpace;
  137631. private _frustumCenter;
  137632. private _shadowCameraPos;
  137633. private _shadowMaxZ;
  137634. /**
  137635. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  137636. * It defaults to camera.maxZ
  137637. */
  137638. get shadowMaxZ(): number;
  137639. /**
  137640. * Sets the shadow max z distance.
  137641. */
  137642. set shadowMaxZ(value: number);
  137643. protected _debug: boolean;
  137644. /**
  137645. * Gets or sets the debug flag.
  137646. * When enabled, the cascades are materialized by different colors on the screen.
  137647. */
  137648. get debug(): boolean;
  137649. set debug(dbg: boolean);
  137650. private _depthClamp;
  137651. /**
  137652. * Gets or sets the depth clamping value.
  137653. *
  137654. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  137655. * to account for the shadow casters far away.
  137656. *
  137657. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  137658. */
  137659. get depthClamp(): boolean;
  137660. set depthClamp(value: boolean);
  137661. private _cascadeBlendPercentage;
  137662. /**
  137663. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  137664. * It defaults to 0.1 (10% blending).
  137665. */
  137666. get cascadeBlendPercentage(): number;
  137667. set cascadeBlendPercentage(value: number);
  137668. private _lambda;
  137669. /**
  137670. * Gets or set the lambda parameter.
  137671. * This parameter is used to split the camera frustum and create the cascades.
  137672. * 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.
  137673. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  137674. */
  137675. get lambda(): number;
  137676. set lambda(value: number);
  137677. /**
  137678. * Gets the view matrix corresponding to a given cascade
  137679. * @param cascadeNum cascade to retrieve the view matrix from
  137680. * @returns the cascade view matrix
  137681. */
  137682. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  137683. /**
  137684. * Gets the projection matrix corresponding to a given cascade
  137685. * @param cascadeNum cascade to retrieve the projection matrix from
  137686. * @returns the cascade projection matrix
  137687. */
  137688. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  137689. /**
  137690. * Gets the transformation matrix corresponding to a given cascade
  137691. * @param cascadeNum cascade to retrieve the transformation matrix from
  137692. * @returns the cascade transformation matrix
  137693. */
  137694. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  137695. private _depthRenderer;
  137696. /**
  137697. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  137698. *
  137699. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  137700. *
  137701. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  137702. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  137703. * @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
  137704. */
  137705. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  137706. private _depthReducer;
  137707. private _autoCalcDepthBounds;
  137708. /**
  137709. * Gets or sets the autoCalcDepthBounds property.
  137710. *
  137711. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  137712. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  137713. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  137714. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  137715. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  137716. */
  137717. get autoCalcDepthBounds(): boolean;
  137718. set autoCalcDepthBounds(value: boolean);
  137719. /**
  137720. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  137721. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137722. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  137723. * for setting the refresh rate on the renderer yourself!
  137724. */
  137725. get autoCalcDepthBoundsRefreshRate(): number;
  137726. set autoCalcDepthBoundsRefreshRate(value: number);
  137727. /**
  137728. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  137729. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  137730. * you change the camera near/far planes!
  137731. */
  137732. splitFrustum(): void;
  137733. private _splitFrustum;
  137734. private _computeMatrices;
  137735. private _computeFrustumInWorldSpace;
  137736. private _computeCascadeFrustum;
  137737. /**
  137738. * Support test.
  137739. */
  137740. static get IsSupported(): boolean;
  137741. /** @hidden */
  137742. static _SceneComponentInitialization: (scene: Scene) => void;
  137743. /**
  137744. * Creates a Cascaded Shadow Generator object.
  137745. * A ShadowGenerator is the required tool to use the shadows.
  137746. * Each directional light casting shadows needs to use its own ShadowGenerator.
  137747. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137748. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  137749. * @param light The directional light object generating the shadows.
  137750. * @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.
  137751. */
  137752. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  137753. protected _initializeGenerator(): void;
  137754. protected _createTargetRenderTexture(): void;
  137755. protected _initializeShadowMap(): void;
  137756. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  137757. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  137758. /**
  137759. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  137760. * @param defines Defines of the material we want to update
  137761. * @param lightIndex Index of the light in the enabled light list of the material
  137762. */
  137763. prepareDefines(defines: any, lightIndex: number): void;
  137764. /**
  137765. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  137766. * defined in the generator but impacting the effect).
  137767. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  137768. * @param effect The effect we are binfing the information for
  137769. */
  137770. bindShadowLight(lightIndex: string, effect: Effect): void;
  137771. /**
  137772. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  137773. * (eq to view projection * shadow projection matrices)
  137774. * @returns The transform matrix used to create the shadow map
  137775. */
  137776. getTransformMatrix(): Matrix;
  137777. /**
  137778. * Disposes the ShadowGenerator.
  137779. * Returns nothing.
  137780. */
  137781. dispose(): void;
  137782. /**
  137783. * Serializes the shadow generator setup to a json object.
  137784. * @returns The serialized JSON object
  137785. */
  137786. serialize(): any;
  137787. /**
  137788. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137789. * @param parsedShadowGenerator The JSON object to parse
  137790. * @param scene The scene to create the shadow map for
  137791. * @returns The parsed shadow generator
  137792. */
  137793. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137794. }
  137795. }
  137796. declare module BABYLON {
  137797. /**
  137798. * Defines the shadow generator component responsible to manage any shadow generators
  137799. * in a given scene.
  137800. */
  137801. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137802. /**
  137803. * The component name helpfull to identify the component in the list of scene components.
  137804. */
  137805. readonly name: string;
  137806. /**
  137807. * The scene the component belongs to.
  137808. */
  137809. scene: Scene;
  137810. /**
  137811. * Creates a new instance of the component for the given scene
  137812. * @param scene Defines the scene to register the component in
  137813. */
  137814. constructor(scene: Scene);
  137815. /**
  137816. * Registers the component in a given scene
  137817. */
  137818. register(): void;
  137819. /**
  137820. * Rebuilds the elements related to this component in case of
  137821. * context lost for instance.
  137822. */
  137823. rebuild(): void;
  137824. /**
  137825. * Serializes the component data to the specified json object
  137826. * @param serializationObject The object to serialize to
  137827. */
  137828. serialize(serializationObject: any): void;
  137829. /**
  137830. * Adds all the elements from the container to the scene
  137831. * @param container the container holding the elements
  137832. */
  137833. addFromContainer(container: AbstractScene): void;
  137834. /**
  137835. * Removes all the elements in the container from the scene
  137836. * @param container contains the elements to remove
  137837. * @param dispose if the removed element should be disposed (default: false)
  137838. */
  137839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137840. /**
  137841. * Rebuilds the elements related to this component in case of
  137842. * context lost for instance.
  137843. */
  137844. dispose(): void;
  137845. private _gatherRenderTargets;
  137846. }
  137847. }
  137848. declare module BABYLON {
  137849. /**
  137850. * A point light is a light defined by an unique point in world space.
  137851. * The light is emitted in every direction from this point.
  137852. * A good example of a point light is a standard light bulb.
  137853. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137854. */
  137855. export class PointLight extends ShadowLight {
  137856. private _shadowAngle;
  137857. /**
  137858. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137859. * This specifies what angle the shadow will use to be created.
  137860. *
  137861. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137862. */
  137863. get shadowAngle(): number;
  137864. /**
  137865. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137866. * This specifies what angle the shadow will use to be created.
  137867. *
  137868. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137869. */
  137870. set shadowAngle(value: number);
  137871. /**
  137872. * Gets the direction if it has been set.
  137873. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137874. */
  137875. get direction(): Vector3;
  137876. /**
  137877. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137878. */
  137879. set direction(value: Vector3);
  137880. /**
  137881. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137882. * A PointLight emits the light in every direction.
  137883. * It can cast shadows.
  137884. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137885. * ```javascript
  137886. * var pointLight = new PointLight("pl", camera.position, scene);
  137887. * ```
  137888. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137889. * @param name The light friendly name
  137890. * @param position The position of the point light in the scene
  137891. * @param scene The scene the lights belongs to
  137892. */
  137893. constructor(name: string, position: Vector3, scene: Scene);
  137894. /**
  137895. * Returns the string "PointLight"
  137896. * @returns the class name
  137897. */
  137898. getClassName(): string;
  137899. /**
  137900. * Returns the integer 0.
  137901. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137902. */
  137903. getTypeID(): number;
  137904. /**
  137905. * Specifies wether or not the shadowmap should be a cube texture.
  137906. * @returns true if the shadowmap needs to be a cube texture.
  137907. */
  137908. needCube(): boolean;
  137909. /**
  137910. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137911. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137912. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137913. */
  137914. getShadowDirection(faceIndex?: number): Vector3;
  137915. /**
  137916. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137917. * - fov = PI / 2
  137918. * - aspect ratio : 1.0
  137919. * - z-near and far equal to the active camera minZ and maxZ.
  137920. * Returns the PointLight.
  137921. */
  137922. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137923. protected _buildUniformLayout(): void;
  137924. /**
  137925. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137926. * @param effect The effect to update
  137927. * @param lightIndex The index of the light in the effect to update
  137928. * @returns The point light
  137929. */
  137930. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137931. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137932. /**
  137933. * Prepares the list of defines specific to the light type.
  137934. * @param defines the list of defines
  137935. * @param lightIndex defines the index of the light for the effect
  137936. */
  137937. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137938. }
  137939. }
  137940. declare module BABYLON {
  137941. /**
  137942. * Header information of HDR texture files.
  137943. */
  137944. export interface HDRInfo {
  137945. /**
  137946. * The height of the texture in pixels.
  137947. */
  137948. height: number;
  137949. /**
  137950. * The width of the texture in pixels.
  137951. */
  137952. width: number;
  137953. /**
  137954. * The index of the beginning of the data in the binary file.
  137955. */
  137956. dataPosition: number;
  137957. }
  137958. /**
  137959. * This groups tools to convert HDR texture to native colors array.
  137960. */
  137961. export class HDRTools {
  137962. private static Ldexp;
  137963. private static Rgbe2float;
  137964. private static readStringLine;
  137965. /**
  137966. * Reads header information from an RGBE texture stored in a native array.
  137967. * More information on this format are available here:
  137968. * https://en.wikipedia.org/wiki/RGBE_image_format
  137969. *
  137970. * @param uint8array The binary file stored in native array.
  137971. * @return The header information.
  137972. */
  137973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137974. /**
  137975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137976. * This RGBE texture needs to store the information as a panorama.
  137977. *
  137978. * More information on this format are available here:
  137979. * https://en.wikipedia.org/wiki/RGBE_image_format
  137980. *
  137981. * @param buffer The binary file stored in an array buffer.
  137982. * @param size The expected size of the extracted cubemap.
  137983. * @return The Cube Map information.
  137984. */
  137985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137986. /**
  137987. * Returns the pixels data extracted from an RGBE texture.
  137988. * This pixels will be stored left to right up to down in the R G B order in one array.
  137989. *
  137990. * More information on this format are available here:
  137991. * https://en.wikipedia.org/wiki/RGBE_image_format
  137992. *
  137993. * @param uint8array The binary file stored in an array buffer.
  137994. * @param hdrInfo The header information of the file.
  137995. * @return The pixels data in RGB right to left up to down order.
  137996. */
  137997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137998. private static RGBE_ReadPixels_RLE;
  137999. private static RGBE_ReadPixels_NOT_RLE;
  138000. }
  138001. }
  138002. declare module BABYLON {
  138003. /**
  138004. * Effect Render Options
  138005. */
  138006. export interface IEffectRendererOptions {
  138007. /**
  138008. * Defines the vertices positions.
  138009. */
  138010. positions?: number[];
  138011. /**
  138012. * Defines the indices.
  138013. */
  138014. indices?: number[];
  138015. }
  138016. /**
  138017. * Helper class to render one or more effects.
  138018. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138019. */
  138020. export class EffectRenderer {
  138021. private engine;
  138022. private static _DefaultOptions;
  138023. private _vertexBuffers;
  138024. private _indexBuffer;
  138025. private _fullscreenViewport;
  138026. /**
  138027. * Creates an effect renderer
  138028. * @param engine the engine to use for rendering
  138029. * @param options defines the options of the effect renderer
  138030. */
  138031. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138032. /**
  138033. * Sets the current viewport in normalized coordinates 0-1
  138034. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138035. */
  138036. setViewport(viewport?: Viewport): void;
  138037. /**
  138038. * Binds the embedded attributes buffer to the effect.
  138039. * @param effect Defines the effect to bind the attributes for
  138040. */
  138041. bindBuffers(effect: Effect): void;
  138042. /**
  138043. * Sets the current effect wrapper to use during draw.
  138044. * The effect needs to be ready before calling this api.
  138045. * This also sets the default full screen position attribute.
  138046. * @param effectWrapper Defines the effect to draw with
  138047. */
  138048. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138049. /**
  138050. * Restores engine states
  138051. */
  138052. restoreStates(): void;
  138053. /**
  138054. * Draws a full screen quad.
  138055. */
  138056. draw(): void;
  138057. private isRenderTargetTexture;
  138058. /**
  138059. * renders one or more effects to a specified texture
  138060. * @param effectWrapper the effect to renderer
  138061. * @param outputTexture texture to draw to, if null it will render to the screen.
  138062. */
  138063. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138064. /**
  138065. * Disposes of the effect renderer
  138066. */
  138067. dispose(): void;
  138068. }
  138069. /**
  138070. * Options to create an EffectWrapper
  138071. */
  138072. interface EffectWrapperCreationOptions {
  138073. /**
  138074. * Engine to use to create the effect
  138075. */
  138076. engine: ThinEngine;
  138077. /**
  138078. * Fragment shader for the effect
  138079. */
  138080. fragmentShader: string;
  138081. /**
  138082. * Use the shader store instead of direct source code
  138083. */
  138084. useShaderStore?: boolean;
  138085. /**
  138086. * Vertex shader for the effect
  138087. */
  138088. vertexShader?: string;
  138089. /**
  138090. * Attributes to use in the shader
  138091. */
  138092. attributeNames?: Array<string>;
  138093. /**
  138094. * Uniforms to use in the shader
  138095. */
  138096. uniformNames?: Array<string>;
  138097. /**
  138098. * Texture sampler names to use in the shader
  138099. */
  138100. samplerNames?: Array<string>;
  138101. /**
  138102. * Defines to use in the shader
  138103. */
  138104. defines?: Array<string>;
  138105. /**
  138106. * Callback when effect is compiled
  138107. */
  138108. onCompiled?: Nullable<(effect: Effect) => void>;
  138109. /**
  138110. * The friendly name of the effect displayed in Spector.
  138111. */
  138112. name?: string;
  138113. }
  138114. /**
  138115. * Wraps an effect to be used for rendering
  138116. */
  138117. export class EffectWrapper {
  138118. /**
  138119. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138120. */
  138121. onApplyObservable: Observable<{}>;
  138122. /**
  138123. * The underlying effect
  138124. */
  138125. effect: Effect;
  138126. /**
  138127. * Creates an effect to be renderer
  138128. * @param creationOptions options to create the effect
  138129. */
  138130. constructor(creationOptions: EffectWrapperCreationOptions);
  138131. /**
  138132. * Disposes of the effect wrapper
  138133. */
  138134. dispose(): void;
  138135. }
  138136. }
  138137. declare module BABYLON {
  138138. /** @hidden */
  138139. export var hdrFilteringVertexShader: {
  138140. name: string;
  138141. shader: string;
  138142. };
  138143. }
  138144. declare module BABYLON {
  138145. /** @hidden */
  138146. export var hdrFilteringPixelShader: {
  138147. name: string;
  138148. shader: string;
  138149. };
  138150. }
  138151. declare module BABYLON {
  138152. /**
  138153. * Options for texture filtering
  138154. */
  138155. interface IHDRFilteringOptions {
  138156. /**
  138157. * Scales pixel intensity for the input HDR map.
  138158. */
  138159. hdrScale?: number;
  138160. /**
  138161. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138162. */
  138163. quality?: number;
  138164. }
  138165. /**
  138166. * Filters HDR maps to get correct renderings of PBR reflections
  138167. */
  138168. export class HDRFiltering {
  138169. private _engine;
  138170. private _effectRenderer;
  138171. private _effectWrapper;
  138172. private _lodGenerationOffset;
  138173. private _lodGenerationScale;
  138174. /**
  138175. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  138176. * you care about baking speed.
  138177. */
  138178. quality: number;
  138179. /**
  138180. * Scales pixel intensity for the input HDR map.
  138181. */
  138182. hdrScale: number;
  138183. /**
  138184. * Instantiates HDR filter for reflection maps
  138185. *
  138186. * @param engine Thin engine
  138187. * @param options Options
  138188. */
  138189. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  138190. private _createRenderTarget;
  138191. private _prefilterInternal;
  138192. private _createEffect;
  138193. /**
  138194. * Get a value indicating if the filter is ready to be used
  138195. * @param texture Texture to filter
  138196. * @returns true if the filter is ready
  138197. */
  138198. isReady(texture: BaseTexture): boolean;
  138199. /**
  138200. * Prefilters a cube texture to have mipmap levels representing roughness values.
  138201. * Prefiltering will be invoked at the end of next rendering pass.
  138202. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  138203. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  138204. * @param texture Texture to filter
  138205. * @param onFinished Callback when filtering is done
  138206. * @return Promise called when prefiltering is done
  138207. */
  138208. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  138209. }
  138210. }
  138211. declare module BABYLON {
  138212. /**
  138213. * This represents a texture coming from an HDR input.
  138214. *
  138215. * The only supported format is currently panorama picture stored in RGBE format.
  138216. * Example of such files can be found on HDRLib: http://hdrlib.com/
  138217. */
  138218. export class HDRCubeTexture extends BaseTexture {
  138219. private static _facesMapping;
  138220. private _generateHarmonics;
  138221. private _noMipmap;
  138222. private _prefilterOnLoad;
  138223. private _textureMatrix;
  138224. private _size;
  138225. private _onLoad;
  138226. private _onError;
  138227. /**
  138228. * The texture URL.
  138229. */
  138230. url: string;
  138231. /**
  138232. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  138233. */
  138234. coordinatesMode: number;
  138235. protected _isBlocking: boolean;
  138236. /**
  138237. * Sets wether or not the texture is blocking during loading.
  138238. */
  138239. set isBlocking(value: boolean);
  138240. /**
  138241. * Gets wether or not the texture is blocking during loading.
  138242. */
  138243. get isBlocking(): boolean;
  138244. protected _rotationY: number;
  138245. /**
  138246. * Sets texture matrix rotation angle around Y axis in radians.
  138247. */
  138248. set rotationY(value: number);
  138249. /**
  138250. * Gets texture matrix rotation angle around Y axis radians.
  138251. */
  138252. get rotationY(): number;
  138253. /**
  138254. * Gets or sets the center of the bounding box associated with the cube texture
  138255. * It must define where the camera used to render the texture was set
  138256. */
  138257. boundingBoxPosition: Vector3;
  138258. private _boundingBoxSize;
  138259. /**
  138260. * Gets or sets the size of the bounding box associated with the cube texture
  138261. * When defined, the cubemap will switch to local mode
  138262. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  138263. * @example https://www.babylonjs-playground.com/#RNASML
  138264. */
  138265. set boundingBoxSize(value: Vector3);
  138266. get boundingBoxSize(): Vector3;
  138267. /**
  138268. * Instantiates an HDRTexture from the following parameters.
  138269. *
  138270. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  138271. * @param sceneOrEngine The scene or engine the texture will be used in
  138272. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138273. * @param noMipmap Forces to not generate the mipmap if true
  138274. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  138275. * @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)
  138276. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  138277. */
  138278. 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>);
  138279. /**
  138280. * Get the current class name of the texture useful for serialization or dynamic coding.
  138281. * @returns "HDRCubeTexture"
  138282. */
  138283. getClassName(): string;
  138284. /**
  138285. * Occurs when the file is raw .hdr file.
  138286. */
  138287. private loadTexture;
  138288. clone(): HDRCubeTexture;
  138289. delayLoad(): void;
  138290. /**
  138291. * Get the texture reflection matrix used to rotate/transform the reflection.
  138292. * @returns the reflection matrix
  138293. */
  138294. getReflectionTextureMatrix(): Matrix;
  138295. /**
  138296. * Set the texture reflection matrix used to rotate/transform the reflection.
  138297. * @param value Define the reflection matrix to set
  138298. */
  138299. setReflectionTextureMatrix(value: Matrix): void;
  138300. /**
  138301. * Parses a JSON representation of an HDR Texture in order to create the texture
  138302. * @param parsedTexture Define the JSON representation
  138303. * @param scene Define the scene the texture should be created in
  138304. * @param rootUrl Define the root url in case we need to load relative dependencies
  138305. * @returns the newly created texture after parsing
  138306. */
  138307. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  138308. serialize(): any;
  138309. }
  138310. }
  138311. declare module BABYLON {
  138312. /**
  138313. * Class used to control physics engine
  138314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138315. */
  138316. export class PhysicsEngine implements IPhysicsEngine {
  138317. private _physicsPlugin;
  138318. /**
  138319. * Global value used to control the smallest number supported by the simulation
  138320. */
  138321. static Epsilon: number;
  138322. private _impostors;
  138323. private _joints;
  138324. private _subTimeStep;
  138325. /**
  138326. * Gets the gravity vector used by the simulation
  138327. */
  138328. gravity: Vector3;
  138329. /**
  138330. * Factory used to create the default physics plugin.
  138331. * @returns The default physics plugin
  138332. */
  138333. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  138334. /**
  138335. * Creates a new Physics Engine
  138336. * @param gravity defines the gravity vector used by the simulation
  138337. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  138338. */
  138339. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  138340. /**
  138341. * Sets the gravity vector used by the simulation
  138342. * @param gravity defines the gravity vector to use
  138343. */
  138344. setGravity(gravity: Vector3): void;
  138345. /**
  138346. * Set the time step of the physics engine.
  138347. * Default is 1/60.
  138348. * To slow it down, enter 1/600 for example.
  138349. * To speed it up, 1/30
  138350. * @param newTimeStep defines the new timestep to apply to this world.
  138351. */
  138352. setTimeStep(newTimeStep?: number): void;
  138353. /**
  138354. * Get the time step of the physics engine.
  138355. * @returns the current time step
  138356. */
  138357. getTimeStep(): number;
  138358. /**
  138359. * Set the sub time step of the physics engine.
  138360. * Default is 0 meaning there is no sub steps
  138361. * To increase physics resolution precision, set a small value (like 1 ms)
  138362. * @param subTimeStep defines the new sub timestep used for physics resolution.
  138363. */
  138364. setSubTimeStep(subTimeStep?: number): void;
  138365. /**
  138366. * Get the sub time step of the physics engine.
  138367. * @returns the current sub time step
  138368. */
  138369. getSubTimeStep(): number;
  138370. /**
  138371. * Release all resources
  138372. */
  138373. dispose(): void;
  138374. /**
  138375. * Gets the name of the current physics plugin
  138376. * @returns the name of the plugin
  138377. */
  138378. getPhysicsPluginName(): string;
  138379. /**
  138380. * Adding a new impostor for the impostor tracking.
  138381. * This will be done by the impostor itself.
  138382. * @param impostor the impostor to add
  138383. */
  138384. addImpostor(impostor: PhysicsImpostor): void;
  138385. /**
  138386. * Remove an impostor from the engine.
  138387. * This impostor and its mesh will not longer be updated by the physics engine.
  138388. * @param impostor the impostor to remove
  138389. */
  138390. removeImpostor(impostor: PhysicsImpostor): void;
  138391. /**
  138392. * Add a joint to the physics engine
  138393. * @param mainImpostor defines the main impostor to which the joint is added.
  138394. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  138395. * @param joint defines the joint that will connect both impostors.
  138396. */
  138397. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138398. /**
  138399. * Removes a joint from the simulation
  138400. * @param mainImpostor defines the impostor used with the joint
  138401. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  138402. * @param joint defines the joint to remove
  138403. */
  138404. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138405. /**
  138406. * Called by the scene. No need to call it.
  138407. * @param delta defines the timespam between frames
  138408. */
  138409. _step(delta: number): void;
  138410. /**
  138411. * Gets the current plugin used to run the simulation
  138412. * @returns current plugin
  138413. */
  138414. getPhysicsPlugin(): IPhysicsEnginePlugin;
  138415. /**
  138416. * Gets the list of physic impostors
  138417. * @returns an array of PhysicsImpostor
  138418. */
  138419. getImpostors(): Array<PhysicsImpostor>;
  138420. /**
  138421. * Gets the impostor for a physics enabled object
  138422. * @param object defines the object impersonated by the impostor
  138423. * @returns the PhysicsImpostor or null if not found
  138424. */
  138425. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  138426. /**
  138427. * Gets the impostor for a physics body object
  138428. * @param body defines physics body used by the impostor
  138429. * @returns the PhysicsImpostor or null if not found
  138430. */
  138431. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  138432. /**
  138433. * Does a raycast in the physics world
  138434. * @param from when should the ray start?
  138435. * @param to when should the ray end?
  138436. * @returns PhysicsRaycastResult
  138437. */
  138438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138439. }
  138440. }
  138441. declare module BABYLON {
  138442. /** @hidden */
  138443. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  138444. private _useDeltaForWorldStep;
  138445. world: any;
  138446. name: string;
  138447. private _physicsMaterials;
  138448. private _fixedTimeStep;
  138449. private _cannonRaycastResult;
  138450. private _raycastResult;
  138451. private _physicsBodysToRemoveAfterStep;
  138452. private _firstFrame;
  138453. BJSCANNON: any;
  138454. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  138455. setGravity(gravity: Vector3): void;
  138456. setTimeStep(timeStep: number): void;
  138457. getTimeStep(): number;
  138458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138459. private _removeMarkedPhysicsBodiesFromWorld;
  138460. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138461. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138462. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138463. private _processChildMeshes;
  138464. removePhysicsBody(impostor: PhysicsImpostor): void;
  138465. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138466. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138467. private _addMaterial;
  138468. private _checkWithEpsilon;
  138469. private _createShape;
  138470. private _createHeightmap;
  138471. private _minus90X;
  138472. private _plus90X;
  138473. private _tmpPosition;
  138474. private _tmpDeltaPosition;
  138475. private _tmpUnityRotation;
  138476. private _updatePhysicsBodyTransformation;
  138477. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138478. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138479. isSupported(): boolean;
  138480. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138481. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138482. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138483. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138484. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138485. getBodyMass(impostor: PhysicsImpostor): number;
  138486. getBodyFriction(impostor: PhysicsImpostor): number;
  138487. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138488. getBodyRestitution(impostor: PhysicsImpostor): number;
  138489. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138490. sleepBody(impostor: PhysicsImpostor): void;
  138491. wakeUpBody(impostor: PhysicsImpostor): void;
  138492. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  138493. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138494. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138495. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138496. getRadius(impostor: PhysicsImpostor): number;
  138497. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138498. dispose(): void;
  138499. private _extendNamespace;
  138500. /**
  138501. * Does a raycast in the physics world
  138502. * @param from when should the ray start?
  138503. * @param to when should the ray end?
  138504. * @returns PhysicsRaycastResult
  138505. */
  138506. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138507. }
  138508. }
  138509. declare module BABYLON {
  138510. /** @hidden */
  138511. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  138512. private _useDeltaForWorldStep;
  138513. world: any;
  138514. name: string;
  138515. BJSOIMO: any;
  138516. private _raycastResult;
  138517. private _fixedTimeStep;
  138518. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  138519. setGravity(gravity: Vector3): void;
  138520. setTimeStep(timeStep: number): void;
  138521. getTimeStep(): number;
  138522. private _tmpImpostorsArray;
  138523. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138524. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138525. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138526. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138527. private _tmpPositionVector;
  138528. removePhysicsBody(impostor: PhysicsImpostor): void;
  138529. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138530. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138531. isSupported(): boolean;
  138532. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138533. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138534. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138535. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138536. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138537. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138538. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138539. getBodyMass(impostor: PhysicsImpostor): number;
  138540. getBodyFriction(impostor: PhysicsImpostor): number;
  138541. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138542. getBodyRestitution(impostor: PhysicsImpostor): number;
  138543. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138544. sleepBody(impostor: PhysicsImpostor): void;
  138545. wakeUpBody(impostor: PhysicsImpostor): void;
  138546. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138547. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  138548. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  138549. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138550. getRadius(impostor: PhysicsImpostor): number;
  138551. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138552. dispose(): void;
  138553. /**
  138554. * Does a raycast in the physics world
  138555. * @param from when should the ray start?
  138556. * @param to when should the ray end?
  138557. * @returns PhysicsRaycastResult
  138558. */
  138559. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138560. }
  138561. }
  138562. declare module BABYLON {
  138563. /**
  138564. * Class containing static functions to help procedurally build meshes
  138565. */
  138566. export class RibbonBuilder {
  138567. /**
  138568. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138569. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  138570. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  138571. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  138572. * * 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
  138573. * * 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
  138574. * * 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
  138575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138578. * * 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
  138579. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138580. * * 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
  138581. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138583. * @param name defines the name of the mesh
  138584. * @param options defines the options used to create the mesh
  138585. * @param scene defines the hosting scene
  138586. * @returns the ribbon mesh
  138587. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138589. */
  138590. static CreateRibbon(name: string, options: {
  138591. pathArray: Vector3[][];
  138592. closeArray?: boolean;
  138593. closePath?: boolean;
  138594. offset?: number;
  138595. updatable?: boolean;
  138596. sideOrientation?: number;
  138597. frontUVs?: Vector4;
  138598. backUVs?: Vector4;
  138599. instance?: Mesh;
  138600. invertUV?: boolean;
  138601. uvs?: Vector2[];
  138602. colors?: Color4[];
  138603. }, scene?: Nullable<Scene>): Mesh;
  138604. }
  138605. }
  138606. declare module BABYLON {
  138607. /**
  138608. * Class containing static functions to help procedurally build meshes
  138609. */
  138610. export class ShapeBuilder {
  138611. /**
  138612. * 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.
  138613. * * 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.
  138614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138615. * * 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.
  138616. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  138617. * * 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
  138618. * * 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
  138619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  138620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  138623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138624. * @param name defines the name of the mesh
  138625. * @param options defines the options used to create the mesh
  138626. * @param scene defines the hosting scene
  138627. * @returns the extruded shape mesh
  138628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138630. */
  138631. static ExtrudeShape(name: string, options: {
  138632. shape: Vector3[];
  138633. path: Vector3[];
  138634. scale?: number;
  138635. rotation?: number;
  138636. cap?: number;
  138637. updatable?: boolean;
  138638. sideOrientation?: number;
  138639. frontUVs?: Vector4;
  138640. backUVs?: Vector4;
  138641. instance?: Mesh;
  138642. invertUV?: boolean;
  138643. }, scene?: Nullable<Scene>): Mesh;
  138644. /**
  138645. * Creates an custom extruded shape mesh.
  138646. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  138647. * * 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.
  138648. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138649. * * 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
  138650. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  138651. * * 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
  138652. * * It must returns a float value that will be the scale value applied to the shape on each path point
  138653. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  138654. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  138655. * * 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
  138656. * * 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
  138657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  138658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138662. * @param name defines the name of the mesh
  138663. * @param options defines the options used to create the mesh
  138664. * @param scene defines the hosting scene
  138665. * @returns the custom extruded shape mesh
  138666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  138667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138669. */
  138670. static ExtrudeShapeCustom(name: string, options: {
  138671. shape: Vector3[];
  138672. path: Vector3[];
  138673. scaleFunction?: any;
  138674. rotationFunction?: any;
  138675. ribbonCloseArray?: boolean;
  138676. ribbonClosePath?: boolean;
  138677. cap?: number;
  138678. updatable?: boolean;
  138679. sideOrientation?: number;
  138680. frontUVs?: Vector4;
  138681. backUVs?: Vector4;
  138682. instance?: Mesh;
  138683. invertUV?: boolean;
  138684. }, scene?: Nullable<Scene>): Mesh;
  138685. private static _ExtrudeShapeGeneric;
  138686. }
  138687. }
  138688. declare module BABYLON {
  138689. /**
  138690. * AmmoJS Physics plugin
  138691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138692. * @see https://github.com/kripken/ammo.js/
  138693. */
  138694. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  138695. private _useDeltaForWorldStep;
  138696. /**
  138697. * Reference to the Ammo library
  138698. */
  138699. bjsAMMO: any;
  138700. /**
  138701. * Created ammoJS world which physics bodies are added to
  138702. */
  138703. world: any;
  138704. /**
  138705. * Name of the plugin
  138706. */
  138707. name: string;
  138708. private _timeStep;
  138709. private _fixedTimeStep;
  138710. private _maxSteps;
  138711. private _tmpQuaternion;
  138712. private _tmpAmmoTransform;
  138713. private _tmpAmmoQuaternion;
  138714. private _tmpAmmoConcreteContactResultCallback;
  138715. private _collisionConfiguration;
  138716. private _dispatcher;
  138717. private _overlappingPairCache;
  138718. private _solver;
  138719. private _softBodySolver;
  138720. private _tmpAmmoVectorA;
  138721. private _tmpAmmoVectorB;
  138722. private _tmpAmmoVectorC;
  138723. private _tmpAmmoVectorD;
  138724. private _tmpContactCallbackResult;
  138725. private _tmpAmmoVectorRCA;
  138726. private _tmpAmmoVectorRCB;
  138727. private _raycastResult;
  138728. private static readonly DISABLE_COLLISION_FLAG;
  138729. private static readonly KINEMATIC_FLAG;
  138730. private static readonly DISABLE_DEACTIVATION_FLAG;
  138731. /**
  138732. * Initializes the ammoJS plugin
  138733. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  138734. * @param ammoInjection can be used to inject your own ammo reference
  138735. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  138736. */
  138737. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  138738. /**
  138739. * Sets the gravity of the physics world (m/(s^2))
  138740. * @param gravity Gravity to set
  138741. */
  138742. setGravity(gravity: Vector3): void;
  138743. /**
  138744. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  138745. * @param timeStep timestep to use in seconds
  138746. */
  138747. setTimeStep(timeStep: number): void;
  138748. /**
  138749. * 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)
  138750. * @param fixedTimeStep fixedTimeStep to use in seconds
  138751. */
  138752. setFixedTimeStep(fixedTimeStep: number): void;
  138753. /**
  138754. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  138755. * @param maxSteps the maximum number of steps by the physics engine per frame
  138756. */
  138757. setMaxSteps(maxSteps: number): void;
  138758. /**
  138759. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  138760. * @returns the current timestep in seconds
  138761. */
  138762. getTimeStep(): number;
  138763. /**
  138764. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  138765. */
  138766. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  138767. private _isImpostorInContact;
  138768. private _isImpostorPairInContact;
  138769. private _stepSimulation;
  138770. /**
  138771. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  138772. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  138773. * After the step the babylon meshes are set to the position of the physics imposters
  138774. * @param delta amount of time to step forward
  138775. * @param impostors array of imposters to update before/after the step
  138776. */
  138777. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138778. /**
  138779. * Update babylon mesh to match physics world object
  138780. * @param impostor imposter to match
  138781. */
  138782. private _afterSoftStep;
  138783. /**
  138784. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138785. * @param impostor imposter to match
  138786. */
  138787. private _ropeStep;
  138788. /**
  138789. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138790. * @param impostor imposter to match
  138791. */
  138792. private _softbodyOrClothStep;
  138793. private _tmpMatrix;
  138794. /**
  138795. * Applies an impulse on the imposter
  138796. * @param impostor imposter to apply impulse to
  138797. * @param force amount of force to be applied to the imposter
  138798. * @param contactPoint the location to apply the impulse on the imposter
  138799. */
  138800. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138801. /**
  138802. * Applies a force on the imposter
  138803. * @param impostor imposter to apply force
  138804. * @param force amount of force to be applied to the imposter
  138805. * @param contactPoint the location to apply the force on the imposter
  138806. */
  138807. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138808. /**
  138809. * Creates a physics body using the plugin
  138810. * @param impostor the imposter to create the physics body on
  138811. */
  138812. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138813. /**
  138814. * Removes the physics body from the imposter and disposes of the body's memory
  138815. * @param impostor imposter to remove the physics body from
  138816. */
  138817. removePhysicsBody(impostor: PhysicsImpostor): void;
  138818. /**
  138819. * Generates a joint
  138820. * @param impostorJoint the imposter joint to create the joint with
  138821. */
  138822. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138823. /**
  138824. * Removes a joint
  138825. * @param impostorJoint the imposter joint to remove the joint from
  138826. */
  138827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138828. private _addMeshVerts;
  138829. /**
  138830. * Initialise the soft body vertices to match its object's (mesh) vertices
  138831. * Softbody vertices (nodes) are in world space and to match this
  138832. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138833. * @param impostor to create the softbody for
  138834. */
  138835. private _softVertexData;
  138836. /**
  138837. * Create an impostor's soft body
  138838. * @param impostor to create the softbody for
  138839. */
  138840. private _createSoftbody;
  138841. /**
  138842. * Create cloth for an impostor
  138843. * @param impostor to create the softbody for
  138844. */
  138845. private _createCloth;
  138846. /**
  138847. * Create rope for an impostor
  138848. * @param impostor to create the softbody for
  138849. */
  138850. private _createRope;
  138851. /**
  138852. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138853. * @param impostor to create the custom physics shape for
  138854. */
  138855. private _createCustom;
  138856. private _addHullVerts;
  138857. private _createShape;
  138858. /**
  138859. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138860. * @param impostor imposter containing the physics body and babylon object
  138861. */
  138862. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138863. /**
  138864. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138865. * @param impostor imposter containing the physics body and babylon object
  138866. * @param newPosition new position
  138867. * @param newRotation new rotation
  138868. */
  138869. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138870. /**
  138871. * If this plugin is supported
  138872. * @returns true if its supported
  138873. */
  138874. isSupported(): boolean;
  138875. /**
  138876. * Sets the linear velocity of the physics body
  138877. * @param impostor imposter to set the velocity on
  138878. * @param velocity velocity to set
  138879. */
  138880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138881. /**
  138882. * Sets the angular velocity of the physics body
  138883. * @param impostor imposter to set the velocity on
  138884. * @param velocity velocity to set
  138885. */
  138886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138887. /**
  138888. * gets the linear velocity
  138889. * @param impostor imposter to get linear velocity from
  138890. * @returns linear velocity
  138891. */
  138892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138893. /**
  138894. * gets the angular velocity
  138895. * @param impostor imposter to get angular velocity from
  138896. * @returns angular velocity
  138897. */
  138898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138899. /**
  138900. * Sets the mass of physics body
  138901. * @param impostor imposter to set the mass on
  138902. * @param mass mass to set
  138903. */
  138904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138905. /**
  138906. * Gets the mass of the physics body
  138907. * @param impostor imposter to get the mass from
  138908. * @returns mass
  138909. */
  138910. getBodyMass(impostor: PhysicsImpostor): number;
  138911. /**
  138912. * Gets friction of the impostor
  138913. * @param impostor impostor to get friction from
  138914. * @returns friction value
  138915. */
  138916. getBodyFriction(impostor: PhysicsImpostor): number;
  138917. /**
  138918. * Sets friction of the impostor
  138919. * @param impostor impostor to set friction on
  138920. * @param friction friction value
  138921. */
  138922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138923. /**
  138924. * Gets restitution of the impostor
  138925. * @param impostor impostor to get restitution from
  138926. * @returns restitution value
  138927. */
  138928. getBodyRestitution(impostor: PhysicsImpostor): number;
  138929. /**
  138930. * Sets resitution of the impostor
  138931. * @param impostor impostor to set resitution on
  138932. * @param restitution resitution value
  138933. */
  138934. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138935. /**
  138936. * Gets pressure inside the impostor
  138937. * @param impostor impostor to get pressure from
  138938. * @returns pressure value
  138939. */
  138940. getBodyPressure(impostor: PhysicsImpostor): number;
  138941. /**
  138942. * Sets pressure inside a soft body impostor
  138943. * Cloth and rope must remain 0 pressure
  138944. * @param impostor impostor to set pressure on
  138945. * @param pressure pressure value
  138946. */
  138947. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138948. /**
  138949. * Gets stiffness of the impostor
  138950. * @param impostor impostor to get stiffness from
  138951. * @returns pressure value
  138952. */
  138953. getBodyStiffness(impostor: PhysicsImpostor): number;
  138954. /**
  138955. * Sets stiffness of the impostor
  138956. * @param impostor impostor to set stiffness on
  138957. * @param stiffness stiffness value from 0 to 1
  138958. */
  138959. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138960. /**
  138961. * Gets velocityIterations of the impostor
  138962. * @param impostor impostor to get velocity iterations from
  138963. * @returns velocityIterations value
  138964. */
  138965. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138966. /**
  138967. * Sets velocityIterations of the impostor
  138968. * @param impostor impostor to set velocity iterations on
  138969. * @param velocityIterations velocityIterations value
  138970. */
  138971. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138972. /**
  138973. * Gets positionIterations of the impostor
  138974. * @param impostor impostor to get position iterations from
  138975. * @returns positionIterations value
  138976. */
  138977. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138978. /**
  138979. * Sets positionIterations of the impostor
  138980. * @param impostor impostor to set position on
  138981. * @param positionIterations positionIterations value
  138982. */
  138983. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138984. /**
  138985. * Append an anchor to a cloth object
  138986. * @param impostor is the cloth impostor to add anchor to
  138987. * @param otherImpostor is the rigid impostor to anchor to
  138988. * @param width ratio across width from 0 to 1
  138989. * @param height ratio up height from 0 to 1
  138990. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138991. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138992. */
  138993. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138994. /**
  138995. * Append an hook to a rope object
  138996. * @param impostor is the rope impostor to add hook to
  138997. * @param otherImpostor is the rigid impostor to hook to
  138998. * @param length ratio along the rope from 0 to 1
  138999. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139000. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139001. */
  139002. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139003. /**
  139004. * Sleeps the physics body and stops it from being active
  139005. * @param impostor impostor to sleep
  139006. */
  139007. sleepBody(impostor: PhysicsImpostor): void;
  139008. /**
  139009. * Activates the physics body
  139010. * @param impostor impostor to activate
  139011. */
  139012. wakeUpBody(impostor: PhysicsImpostor): void;
  139013. /**
  139014. * Updates the distance parameters of the joint
  139015. * @param joint joint to update
  139016. * @param maxDistance maximum distance of the joint
  139017. * @param minDistance minimum distance of the joint
  139018. */
  139019. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139020. /**
  139021. * Sets a motor on the joint
  139022. * @param joint joint to set motor on
  139023. * @param speed speed of the motor
  139024. * @param maxForce maximum force of the motor
  139025. * @param motorIndex index of the motor
  139026. */
  139027. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139028. /**
  139029. * Sets the motors limit
  139030. * @param joint joint to set limit on
  139031. * @param upperLimit upper limit
  139032. * @param lowerLimit lower limit
  139033. */
  139034. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139035. /**
  139036. * Syncs the position and rotation of a mesh with the impostor
  139037. * @param mesh mesh to sync
  139038. * @param impostor impostor to update the mesh with
  139039. */
  139040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139041. /**
  139042. * Gets the radius of the impostor
  139043. * @param impostor impostor to get radius from
  139044. * @returns the radius
  139045. */
  139046. getRadius(impostor: PhysicsImpostor): number;
  139047. /**
  139048. * Gets the box size of the impostor
  139049. * @param impostor impostor to get box size from
  139050. * @param result the resulting box size
  139051. */
  139052. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139053. /**
  139054. * Disposes of the impostor
  139055. */
  139056. dispose(): void;
  139057. /**
  139058. * Does a raycast in the physics world
  139059. * @param from when should the ray start?
  139060. * @param to when should the ray end?
  139061. * @returns PhysicsRaycastResult
  139062. */
  139063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139064. }
  139065. }
  139066. declare module BABYLON {
  139067. interface AbstractScene {
  139068. /**
  139069. * The list of reflection probes added to the scene
  139070. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139071. */
  139072. reflectionProbes: Array<ReflectionProbe>;
  139073. /**
  139074. * Removes the given reflection probe from this scene.
  139075. * @param toRemove The reflection probe to remove
  139076. * @returns The index of the removed reflection probe
  139077. */
  139078. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139079. /**
  139080. * Adds the given reflection probe to this scene.
  139081. * @param newReflectionProbe The reflection probe to add
  139082. */
  139083. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139084. }
  139085. /**
  139086. * Class used to generate realtime reflection / refraction cube textures
  139087. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139088. */
  139089. export class ReflectionProbe {
  139090. /** defines the name of the probe */
  139091. name: string;
  139092. private _scene;
  139093. private _renderTargetTexture;
  139094. private _projectionMatrix;
  139095. private _viewMatrix;
  139096. private _target;
  139097. private _add;
  139098. private _attachedMesh;
  139099. private _invertYAxis;
  139100. /** Gets or sets probe position (center of the cube map) */
  139101. position: Vector3;
  139102. /**
  139103. * Creates a new reflection probe
  139104. * @param name defines the name of the probe
  139105. * @param size defines the texture resolution (for each face)
  139106. * @param scene defines the hosting scene
  139107. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139108. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139109. */
  139110. constructor(
  139111. /** defines the name of the probe */
  139112. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139113. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139114. get samples(): number;
  139115. set samples(value: number);
  139116. /** Gets or sets the refresh rate to use (on every frame by default) */
  139117. get refreshRate(): number;
  139118. set refreshRate(value: number);
  139119. /**
  139120. * Gets the hosting scene
  139121. * @returns a Scene
  139122. */
  139123. getScene(): Scene;
  139124. /** Gets the internal CubeTexture used to render to */
  139125. get cubeTexture(): RenderTargetTexture;
  139126. /** Gets the list of meshes to render */
  139127. get renderList(): Nullable<AbstractMesh[]>;
  139128. /**
  139129. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139130. * @param mesh defines the mesh to attach to
  139131. */
  139132. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139133. /**
  139134. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139135. * @param renderingGroupId The rendering group id corresponding to its index
  139136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139137. */
  139138. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139139. /**
  139140. * Clean all associated resources
  139141. */
  139142. dispose(): void;
  139143. /**
  139144. * Converts the reflection probe information to a readable string for debug purpose.
  139145. * @param fullDetails Supports for multiple levels of logging within scene loading
  139146. * @returns the human readable reflection probe info
  139147. */
  139148. toString(fullDetails?: boolean): string;
  139149. /**
  139150. * Get the class name of the relfection probe.
  139151. * @returns "ReflectionProbe"
  139152. */
  139153. getClassName(): string;
  139154. /**
  139155. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139156. * @returns The JSON representation of the texture
  139157. */
  139158. serialize(): any;
  139159. /**
  139160. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139161. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139162. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139163. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139164. * @returns The parsed reflection probe if successful
  139165. */
  139166. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139167. }
  139168. }
  139169. declare module BABYLON {
  139170. /** @hidden */
  139171. export var _BabylonLoaderRegistered: boolean;
  139172. /**
  139173. * Helps setting up some configuration for the babylon file loader.
  139174. */
  139175. export class BabylonFileLoaderConfiguration {
  139176. /**
  139177. * The loader does not allow injecting custom physix engine into the plugins.
  139178. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139179. * So you could set this variable to your engine import to make it work.
  139180. */
  139181. static LoaderInjectedPhysicsEngine: any;
  139182. }
  139183. }
  139184. declare module BABYLON {
  139185. /**
  139186. * The Physically based simple base material of BJS.
  139187. *
  139188. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139189. * It is used as the base class for both the specGloss and metalRough conventions.
  139190. */
  139191. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139192. /**
  139193. * Number of Simultaneous lights allowed on the material.
  139194. */
  139195. maxSimultaneousLights: number;
  139196. /**
  139197. * If sets to true, disables all the lights affecting the material.
  139198. */
  139199. disableLighting: boolean;
  139200. /**
  139201. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139202. */
  139203. environmentTexture: BaseTexture;
  139204. /**
  139205. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139206. */
  139207. invertNormalMapX: boolean;
  139208. /**
  139209. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139210. */
  139211. invertNormalMapY: boolean;
  139212. /**
  139213. * Normal map used in the model.
  139214. */
  139215. normalTexture: BaseTexture;
  139216. /**
  139217. * Emissivie color used to self-illuminate the model.
  139218. */
  139219. emissiveColor: Color3;
  139220. /**
  139221. * Emissivie texture used to self-illuminate the model.
  139222. */
  139223. emissiveTexture: BaseTexture;
  139224. /**
  139225. * Occlusion Channel Strenght.
  139226. */
  139227. occlusionStrength: number;
  139228. /**
  139229. * Occlusion Texture of the material (adding extra occlusion effects).
  139230. */
  139231. occlusionTexture: BaseTexture;
  139232. /**
  139233. * Defines the alpha limits in alpha test mode.
  139234. */
  139235. alphaCutOff: number;
  139236. /**
  139237. * Gets the current double sided mode.
  139238. */
  139239. get doubleSided(): boolean;
  139240. /**
  139241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139242. */
  139243. set doubleSided(value: boolean);
  139244. /**
  139245. * Stores the pre-calculated light information of a mesh in a texture.
  139246. */
  139247. lightmapTexture: BaseTexture;
  139248. /**
  139249. * If true, the light map contains occlusion information instead of lighting info.
  139250. */
  139251. useLightmapAsShadowmap: boolean;
  139252. /**
  139253. * Instantiates a new PBRMaterial instance.
  139254. *
  139255. * @param name The material name
  139256. * @param scene The scene the material will be use in.
  139257. */
  139258. constructor(name: string, scene: Scene);
  139259. getClassName(): string;
  139260. }
  139261. }
  139262. declare module BABYLON {
  139263. /**
  139264. * The PBR material of BJS following the metal roughness convention.
  139265. *
  139266. * This fits to the PBR convention in the GLTF definition:
  139267. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139268. */
  139269. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139270. /**
  139271. * The base color has two different interpretations depending on the value of metalness.
  139272. * When the material is a metal, the base color is the specific measured reflectance value
  139273. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139274. * of the material.
  139275. */
  139276. baseColor: Color3;
  139277. /**
  139278. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139279. * well as opacity information in the alpha channel.
  139280. */
  139281. baseTexture: BaseTexture;
  139282. /**
  139283. * Specifies the metallic scalar value of the material.
  139284. * Can also be used to scale the metalness values of the metallic texture.
  139285. */
  139286. metallic: number;
  139287. /**
  139288. * Specifies the roughness scalar value of the material.
  139289. * Can also be used to scale the roughness values of the metallic texture.
  139290. */
  139291. roughness: number;
  139292. /**
  139293. * Texture containing both the metallic value in the B channel and the
  139294. * roughness value in the G channel to keep better precision.
  139295. */
  139296. metallicRoughnessTexture: BaseTexture;
  139297. /**
  139298. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139299. *
  139300. * @param name The material name
  139301. * @param scene The scene the material will be use in.
  139302. */
  139303. constructor(name: string, scene: Scene);
  139304. /**
  139305. * Return the currrent class name of the material.
  139306. */
  139307. getClassName(): string;
  139308. /**
  139309. * Makes a duplicate of the current material.
  139310. * @param name - name to use for the new material.
  139311. */
  139312. clone(name: string): PBRMetallicRoughnessMaterial;
  139313. /**
  139314. * Serialize the material to a parsable JSON object.
  139315. */
  139316. serialize(): any;
  139317. /**
  139318. * Parses a JSON object correponding to the serialize function.
  139319. */
  139320. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  139321. }
  139322. }
  139323. declare module BABYLON {
  139324. /**
  139325. * The PBR material of BJS following the specular glossiness convention.
  139326. *
  139327. * This fits to the PBR convention in the GLTF definition:
  139328. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  139329. */
  139330. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  139331. /**
  139332. * Specifies the diffuse color of the material.
  139333. */
  139334. diffuseColor: Color3;
  139335. /**
  139336. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  139337. * channel.
  139338. */
  139339. diffuseTexture: BaseTexture;
  139340. /**
  139341. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  139342. */
  139343. specularColor: Color3;
  139344. /**
  139345. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  139346. */
  139347. glossiness: number;
  139348. /**
  139349. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  139350. */
  139351. specularGlossinessTexture: BaseTexture;
  139352. /**
  139353. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  139354. *
  139355. * @param name The material name
  139356. * @param scene The scene the material will be use in.
  139357. */
  139358. constructor(name: string, scene: Scene);
  139359. /**
  139360. * Return the currrent class name of the material.
  139361. */
  139362. getClassName(): string;
  139363. /**
  139364. * Makes a duplicate of the current material.
  139365. * @param name - name to use for the new material.
  139366. */
  139367. clone(name: string): PBRSpecularGlossinessMaterial;
  139368. /**
  139369. * Serialize the material to a parsable JSON object.
  139370. */
  139371. serialize(): any;
  139372. /**
  139373. * Parses a JSON object correponding to the serialize function.
  139374. */
  139375. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  139376. }
  139377. }
  139378. declare module BABYLON {
  139379. /**
  139380. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  139381. * It can help converting any input color in a desired output one. This can then be used to create effects
  139382. * from sepia, black and white to sixties or futuristic rendering...
  139383. *
  139384. * The only supported format is currently 3dl.
  139385. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  139386. */
  139387. export class ColorGradingTexture extends BaseTexture {
  139388. /**
  139389. * The texture URL.
  139390. */
  139391. url: string;
  139392. /**
  139393. * Empty line regex stored for GC.
  139394. */
  139395. private static _noneEmptyLineRegex;
  139396. private _textureMatrix;
  139397. private _onLoad;
  139398. /**
  139399. * Instantiates a ColorGradingTexture from the following parameters.
  139400. *
  139401. * @param url The location of the color gradind data (currently only supporting 3dl)
  139402. * @param sceneOrEngine The scene or engine the texture will be used in
  139403. * @param onLoad defines a callback triggered when the texture has been loaded
  139404. */
  139405. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  139406. /**
  139407. * Fires the onload event from the constructor if requested.
  139408. */
  139409. private _triggerOnLoad;
  139410. /**
  139411. * Returns the texture matrix used in most of the material.
  139412. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  139413. */
  139414. getTextureMatrix(): Matrix;
  139415. /**
  139416. * Occurs when the file being loaded is a .3dl LUT file.
  139417. */
  139418. private load3dlTexture;
  139419. /**
  139420. * Starts the loading process of the texture.
  139421. */
  139422. private loadTexture;
  139423. /**
  139424. * Clones the color gradind texture.
  139425. */
  139426. clone(): ColorGradingTexture;
  139427. /**
  139428. * Called during delayed load for textures.
  139429. */
  139430. delayLoad(): void;
  139431. /**
  139432. * Parses a color grading texture serialized by Babylon.
  139433. * @param parsedTexture The texture information being parsedTexture
  139434. * @param scene The scene to load the texture in
  139435. * @param rootUrl The root url of the data assets to load
  139436. * @return A color gradind texture
  139437. */
  139438. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  139439. /**
  139440. * Serializes the LUT texture to json format.
  139441. */
  139442. serialize(): any;
  139443. }
  139444. }
  139445. declare module BABYLON {
  139446. /**
  139447. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  139448. */
  139449. export class EquiRectangularCubeTexture extends BaseTexture {
  139450. /** The six faces of the cube. */
  139451. private static _FacesMapping;
  139452. private _noMipmap;
  139453. private _onLoad;
  139454. private _onError;
  139455. /** The size of the cubemap. */
  139456. private _size;
  139457. /** The buffer of the image. */
  139458. private _buffer;
  139459. /** The width of the input image. */
  139460. private _width;
  139461. /** The height of the input image. */
  139462. private _height;
  139463. /** The URL to the image. */
  139464. url: string;
  139465. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  139466. coordinatesMode: number;
  139467. /**
  139468. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  139469. * @param url The location of the image
  139470. * @param scene The scene the texture will be used in
  139471. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139472. * @param noMipmap Forces to not generate the mipmap if true
  139473. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  139474. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  139475. * @param onLoad — defines a callback called when texture is loaded
  139476. * @param onError — defines a callback called if there is an error
  139477. */
  139478. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  139479. /**
  139480. * Load the image data, by putting the image on a canvas and extracting its buffer.
  139481. */
  139482. private loadImage;
  139483. /**
  139484. * Convert the image buffer into a cubemap and create a CubeTexture.
  139485. */
  139486. private loadTexture;
  139487. /**
  139488. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  139489. * @param buffer The ArrayBuffer that should be converted.
  139490. * @returns The buffer as Float32Array.
  139491. */
  139492. private getFloat32ArrayFromArrayBuffer;
  139493. /**
  139494. * Get the current class name of the texture useful for serialization or dynamic coding.
  139495. * @returns "EquiRectangularCubeTexture"
  139496. */
  139497. getClassName(): string;
  139498. /**
  139499. * Create a clone of the current EquiRectangularCubeTexture and return it.
  139500. * @returns A clone of the current EquiRectangularCubeTexture.
  139501. */
  139502. clone(): EquiRectangularCubeTexture;
  139503. }
  139504. }
  139505. declare module BABYLON {
  139506. /**
  139507. * Defines the options related to the creation of an HtmlElementTexture
  139508. */
  139509. export interface IHtmlElementTextureOptions {
  139510. /**
  139511. * Defines wether mip maps should be created or not.
  139512. */
  139513. generateMipMaps?: boolean;
  139514. /**
  139515. * Defines the sampling mode of the texture.
  139516. */
  139517. samplingMode?: number;
  139518. /**
  139519. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  139520. */
  139521. engine: Nullable<ThinEngine>;
  139522. /**
  139523. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  139524. */
  139525. scene: Nullable<Scene>;
  139526. }
  139527. /**
  139528. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  139529. * To be as efficient as possible depending on your constraints nothing aside the first upload
  139530. * is automatically managed.
  139531. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  139532. * in your application.
  139533. *
  139534. * As the update is not automatic, you need to call them manually.
  139535. */
  139536. export class HtmlElementTexture extends BaseTexture {
  139537. /**
  139538. * The texture URL.
  139539. */
  139540. element: HTMLVideoElement | HTMLCanvasElement;
  139541. private static readonly DefaultOptions;
  139542. private _textureMatrix;
  139543. private _isVideo;
  139544. private _generateMipMaps;
  139545. private _samplingMode;
  139546. /**
  139547. * Instantiates a HtmlElementTexture from the following parameters.
  139548. *
  139549. * @param name Defines the name of the texture
  139550. * @param element Defines the video or canvas the texture is filled with
  139551. * @param options Defines the other none mandatory texture creation options
  139552. */
  139553. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  139554. private _createInternalTexture;
  139555. /**
  139556. * Returns the texture matrix used in most of the material.
  139557. */
  139558. getTextureMatrix(): Matrix;
  139559. /**
  139560. * Updates the content of the texture.
  139561. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  139562. */
  139563. update(invertY?: Nullable<boolean>): void;
  139564. }
  139565. }
  139566. declare module BABYLON {
  139567. /**
  139568. * Based on jsTGALoader - Javascript loader for TGA file
  139569. * By Vincent Thibault
  139570. * @see http://blog.robrowser.com/javascript-tga-loader.html
  139571. */
  139572. export class TGATools {
  139573. private static _TYPE_INDEXED;
  139574. private static _TYPE_RGB;
  139575. private static _TYPE_GREY;
  139576. private static _TYPE_RLE_INDEXED;
  139577. private static _TYPE_RLE_RGB;
  139578. private static _TYPE_RLE_GREY;
  139579. private static _ORIGIN_MASK;
  139580. private static _ORIGIN_SHIFT;
  139581. private static _ORIGIN_BL;
  139582. private static _ORIGIN_BR;
  139583. private static _ORIGIN_UL;
  139584. private static _ORIGIN_UR;
  139585. /**
  139586. * Gets the header of a TGA file
  139587. * @param data defines the TGA data
  139588. * @returns the header
  139589. */
  139590. static GetTGAHeader(data: Uint8Array): any;
  139591. /**
  139592. * Uploads TGA content to a Babylon Texture
  139593. * @hidden
  139594. */
  139595. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  139596. /** @hidden */
  139597. 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;
  139598. /** @hidden */
  139599. 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;
  139600. /** @hidden */
  139601. 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;
  139602. /** @hidden */
  139603. 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;
  139604. /** @hidden */
  139605. 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;
  139606. /** @hidden */
  139607. 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;
  139608. }
  139609. }
  139610. declare module BABYLON {
  139611. /**
  139612. * Implementation of the TGA Texture Loader.
  139613. * @hidden
  139614. */
  139615. export class _TGATextureLoader implements IInternalTextureLoader {
  139616. /**
  139617. * Defines wether the loader supports cascade loading the different faces.
  139618. */
  139619. readonly supportCascades: boolean;
  139620. /**
  139621. * This returns if the loader support the current file information.
  139622. * @param extension defines the file extension of the file being loaded
  139623. * @returns true if the loader can load the specified file
  139624. */
  139625. canLoad(extension: string): boolean;
  139626. /**
  139627. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139628. * @param data contains the texture data
  139629. * @param texture defines the BabylonJS internal texture
  139630. * @param createPolynomials will be true if polynomials have been requested
  139631. * @param onLoad defines the callback to trigger once the texture is ready
  139632. * @param onError defines the callback to trigger in case of error
  139633. */
  139634. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139635. /**
  139636. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139637. * @param data contains the texture data
  139638. * @param texture defines the BabylonJS internal texture
  139639. * @param callback defines the method to call once ready to upload
  139640. */
  139641. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139642. }
  139643. }
  139644. declare module BABYLON {
  139645. /**
  139646. * Info about the .basis files
  139647. */
  139648. class BasisFileInfo {
  139649. /**
  139650. * If the file has alpha
  139651. */
  139652. hasAlpha: boolean;
  139653. /**
  139654. * Info about each image of the basis file
  139655. */
  139656. images: Array<{
  139657. levels: Array<{
  139658. width: number;
  139659. height: number;
  139660. transcodedPixels: ArrayBufferView;
  139661. }>;
  139662. }>;
  139663. }
  139664. /**
  139665. * Result of transcoding a basis file
  139666. */
  139667. class TranscodeResult {
  139668. /**
  139669. * Info about the .basis file
  139670. */
  139671. fileInfo: BasisFileInfo;
  139672. /**
  139673. * Format to use when loading the file
  139674. */
  139675. format: number;
  139676. }
  139677. /**
  139678. * Configuration options for the Basis transcoder
  139679. */
  139680. export class BasisTranscodeConfiguration {
  139681. /**
  139682. * Supported compression formats used to determine the supported output format of the transcoder
  139683. */
  139684. supportedCompressionFormats?: {
  139685. /**
  139686. * etc1 compression format
  139687. */
  139688. etc1?: boolean;
  139689. /**
  139690. * s3tc compression format
  139691. */
  139692. s3tc?: boolean;
  139693. /**
  139694. * pvrtc compression format
  139695. */
  139696. pvrtc?: boolean;
  139697. /**
  139698. * etc2 compression format
  139699. */
  139700. etc2?: boolean;
  139701. };
  139702. /**
  139703. * If mipmap levels should be loaded for transcoded images (Default: true)
  139704. */
  139705. loadMipmapLevels?: boolean;
  139706. /**
  139707. * Index of a single image to load (Default: all images)
  139708. */
  139709. loadSingleImage?: number;
  139710. }
  139711. /**
  139712. * Used to load .Basis files
  139713. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  139714. */
  139715. export class BasisTools {
  139716. private static _IgnoreSupportedFormats;
  139717. /**
  139718. * URL to use when loading the basis transcoder
  139719. */
  139720. static JSModuleURL: string;
  139721. /**
  139722. * URL to use when loading the wasm module for the transcoder
  139723. */
  139724. static WasmModuleURL: string;
  139725. /**
  139726. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  139727. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  139728. * @returns internal format corresponding to the Basis format
  139729. */
  139730. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  139731. private static _WorkerPromise;
  139732. private static _Worker;
  139733. private static _actionId;
  139734. private static _CreateWorkerAsync;
  139735. /**
  139736. * Transcodes a loaded image file to compressed pixel data
  139737. * @param data image data to transcode
  139738. * @param config configuration options for the transcoding
  139739. * @returns a promise resulting in the transcoded image
  139740. */
  139741. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  139742. /**
  139743. * Loads a texture from the transcode result
  139744. * @param texture texture load to
  139745. * @param transcodeResult the result of transcoding the basis file to load from
  139746. */
  139747. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  139748. }
  139749. }
  139750. declare module BABYLON {
  139751. /**
  139752. * Loader for .basis file format
  139753. */
  139754. export class _BasisTextureLoader implements IInternalTextureLoader {
  139755. /**
  139756. * Defines whether the loader supports cascade loading the different faces.
  139757. */
  139758. readonly supportCascades: boolean;
  139759. /**
  139760. * This returns if the loader support the current file information.
  139761. * @param extension defines the file extension of the file being loaded
  139762. * @returns true if the loader can load the specified file
  139763. */
  139764. canLoad(extension: string): boolean;
  139765. /**
  139766. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139767. * @param data contains the texture data
  139768. * @param texture defines the BabylonJS internal texture
  139769. * @param createPolynomials will be true if polynomials have been requested
  139770. * @param onLoad defines the callback to trigger once the texture is ready
  139771. * @param onError defines the callback to trigger in case of error
  139772. */
  139773. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139774. /**
  139775. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139776. * @param data contains the texture data
  139777. * @param texture defines the BabylonJS internal texture
  139778. * @param callback defines the method to call once ready to upload
  139779. */
  139780. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139781. }
  139782. }
  139783. declare module BABYLON {
  139784. /**
  139785. * Defines the basic options interface of a TexturePacker Frame
  139786. */
  139787. export interface ITexturePackerFrame {
  139788. /**
  139789. * The frame ID
  139790. */
  139791. id: number;
  139792. /**
  139793. * The frames Scale
  139794. */
  139795. scale: Vector2;
  139796. /**
  139797. * The Frames offset
  139798. */
  139799. offset: Vector2;
  139800. }
  139801. /**
  139802. * This is a support class for frame Data on texture packer sets.
  139803. */
  139804. export class TexturePackerFrame implements ITexturePackerFrame {
  139805. /**
  139806. * The frame ID
  139807. */
  139808. id: number;
  139809. /**
  139810. * The frames Scale
  139811. */
  139812. scale: Vector2;
  139813. /**
  139814. * The Frames offset
  139815. */
  139816. offset: Vector2;
  139817. /**
  139818. * Initializes a texture package frame.
  139819. * @param id The numerical frame identifier
  139820. * @param scale Scalar Vector2 for UV frame
  139821. * @param offset Vector2 for the frame position in UV units.
  139822. * @returns TexturePackerFrame
  139823. */
  139824. constructor(id: number, scale: Vector2, offset: Vector2);
  139825. }
  139826. }
  139827. declare module BABYLON {
  139828. /**
  139829. * Defines the basic options interface of a TexturePacker
  139830. */
  139831. export interface ITexturePackerOptions {
  139832. /**
  139833. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139834. */
  139835. map?: string[];
  139836. /**
  139837. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139838. */
  139839. uvsIn?: string;
  139840. /**
  139841. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139842. */
  139843. uvsOut?: string;
  139844. /**
  139845. * number representing the layout style. Defaults to LAYOUT_STRIP
  139846. */
  139847. layout?: number;
  139848. /**
  139849. * number of columns if using custom column count layout(2). This defaults to 4.
  139850. */
  139851. colnum?: number;
  139852. /**
  139853. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139854. */
  139855. updateInputMeshes?: boolean;
  139856. /**
  139857. * boolean flag to dispose all the source textures. Defaults to true.
  139858. */
  139859. disposeSources?: boolean;
  139860. /**
  139861. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139862. */
  139863. fillBlanks?: boolean;
  139864. /**
  139865. * string value representing the context fill style color. Defaults to 'black'.
  139866. */
  139867. customFillColor?: string;
  139868. /**
  139869. * Width and Height Value of each Frame in the TexturePacker Sets
  139870. */
  139871. frameSize?: number;
  139872. /**
  139873. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139874. */
  139875. paddingRatio?: number;
  139876. /**
  139877. * Number that declares the fill method for the padding gutter.
  139878. */
  139879. paddingMode?: number;
  139880. /**
  139881. * If in SUBUV_COLOR padding mode what color to use.
  139882. */
  139883. paddingColor?: Color3 | Color4;
  139884. }
  139885. /**
  139886. * Defines the basic interface of a TexturePacker JSON File
  139887. */
  139888. export interface ITexturePackerJSON {
  139889. /**
  139890. * The frame ID
  139891. */
  139892. name: string;
  139893. /**
  139894. * The base64 channel data
  139895. */
  139896. sets: any;
  139897. /**
  139898. * The options of the Packer
  139899. */
  139900. options: ITexturePackerOptions;
  139901. /**
  139902. * The frame data of the Packer
  139903. */
  139904. frames: Array<number>;
  139905. }
  139906. /**
  139907. * This is a support class that generates a series of packed texture sets.
  139908. * @see https://doc.babylonjs.com/babylon101/materials
  139909. */
  139910. export class TexturePacker {
  139911. /** Packer Layout Constant 0 */
  139912. static readonly LAYOUT_STRIP: number;
  139913. /** Packer Layout Constant 1 */
  139914. static readonly LAYOUT_POWER2: number;
  139915. /** Packer Layout Constant 2 */
  139916. static readonly LAYOUT_COLNUM: number;
  139917. /** Packer Layout Constant 0 */
  139918. static readonly SUBUV_WRAP: number;
  139919. /** Packer Layout Constant 1 */
  139920. static readonly SUBUV_EXTEND: number;
  139921. /** Packer Layout Constant 2 */
  139922. static readonly SUBUV_COLOR: number;
  139923. /** The Name of the Texture Package */
  139924. name: string;
  139925. /** The scene scope of the TexturePacker */
  139926. scene: Scene;
  139927. /** The Meshes to target */
  139928. meshes: AbstractMesh[];
  139929. /** Arguments passed with the Constructor */
  139930. options: ITexturePackerOptions;
  139931. /** The promise that is started upon initialization */
  139932. promise: Nullable<Promise<TexturePacker | string>>;
  139933. /** The Container object for the channel sets that are generated */
  139934. sets: object;
  139935. /** The Container array for the frames that are generated */
  139936. frames: TexturePackerFrame[];
  139937. /** The expected number of textures the system is parsing. */
  139938. private _expecting;
  139939. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139940. private _paddingValue;
  139941. /**
  139942. * Initializes a texture package series from an array of meshes or a single mesh.
  139943. * @param name The name of the package
  139944. * @param meshes The target meshes to compose the package from
  139945. * @param options The arguments that texture packer should follow while building.
  139946. * @param scene The scene which the textures are scoped to.
  139947. * @returns TexturePacker
  139948. */
  139949. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139950. /**
  139951. * Starts the package process
  139952. * @param resolve The promises resolution function
  139953. * @returns TexturePacker
  139954. */
  139955. private _createFrames;
  139956. /**
  139957. * Calculates the Size of the Channel Sets
  139958. * @returns Vector2
  139959. */
  139960. private _calculateSize;
  139961. /**
  139962. * Calculates the UV data for the frames.
  139963. * @param baseSize the base frameSize
  139964. * @param padding the base frame padding
  139965. * @param dtSize size of the Dynamic Texture for that channel
  139966. * @param dtUnits is 1/dtSize
  139967. * @param update flag to update the input meshes
  139968. */
  139969. private _calculateMeshUVFrames;
  139970. /**
  139971. * Calculates the frames Offset.
  139972. * @param index of the frame
  139973. * @returns Vector2
  139974. */
  139975. private _getFrameOffset;
  139976. /**
  139977. * Updates a Mesh to the frame data
  139978. * @param mesh that is the target
  139979. * @param frameID or the frame index
  139980. */
  139981. private _updateMeshUV;
  139982. /**
  139983. * Updates a Meshes materials to use the texture packer channels
  139984. * @param m is the mesh to target
  139985. * @param force all channels on the packer to be set.
  139986. */
  139987. private _updateTextureReferences;
  139988. /**
  139989. * Public method to set a Mesh to a frame
  139990. * @param m that is the target
  139991. * @param frameID or the frame index
  139992. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139993. */
  139994. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139995. /**
  139996. * Starts the async promise to compile the texture packer.
  139997. * @returns Promise<void>
  139998. */
  139999. processAsync(): Promise<void>;
  140000. /**
  140001. * Disposes all textures associated with this packer
  140002. */
  140003. dispose(): void;
  140004. /**
  140005. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140006. * @param imageType is the image type to use.
  140007. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140008. */
  140009. download(imageType?: string, quality?: number): void;
  140010. /**
  140011. * Public method to load a texturePacker JSON file.
  140012. * @param data of the JSON file in string format.
  140013. */
  140014. updateFromJSON(data: string): void;
  140015. }
  140016. }
  140017. declare module BABYLON {
  140018. /**
  140019. * 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.
  140020. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140021. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140022. */
  140023. export class CustomProceduralTexture extends ProceduralTexture {
  140024. private _animate;
  140025. private _time;
  140026. private _config;
  140027. private _texturePath;
  140028. /**
  140029. * Instantiates a new Custom Procedural Texture.
  140030. * 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.
  140031. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140032. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140033. * @param name Define the name of the texture
  140034. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140035. * @param size Define the size of the texture to create
  140036. * @param scene Define the scene the texture belongs to
  140037. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140038. * @param generateMipMaps Define if the texture should creates mip maps or not
  140039. */
  140040. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140041. private _loadJson;
  140042. /**
  140043. * Is the texture ready to be used ? (rendered at least once)
  140044. * @returns true if ready, otherwise, false.
  140045. */
  140046. isReady(): boolean;
  140047. /**
  140048. * Render the texture to its associated render target.
  140049. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140050. */
  140051. render(useCameraPostProcess?: boolean): void;
  140052. /**
  140053. * Update the list of dependant textures samplers in the shader.
  140054. */
  140055. updateTextures(): void;
  140056. /**
  140057. * Update the uniform values of the procedural texture in the shader.
  140058. */
  140059. updateShaderUniforms(): void;
  140060. /**
  140061. * Define if the texture animates or not.
  140062. */
  140063. get animate(): boolean;
  140064. set animate(value: boolean);
  140065. }
  140066. }
  140067. declare module BABYLON {
  140068. /** @hidden */
  140069. export var noisePixelShader: {
  140070. name: string;
  140071. shader: string;
  140072. };
  140073. }
  140074. declare module BABYLON {
  140075. /**
  140076. * Class used to generate noise procedural textures
  140077. */
  140078. export class NoiseProceduralTexture extends ProceduralTexture {
  140079. private _time;
  140080. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140081. brightness: number;
  140082. /** Defines the number of octaves to process */
  140083. octaves: number;
  140084. /** Defines the level of persistence (0.8 by default) */
  140085. persistence: number;
  140086. /** Gets or sets animation speed factor (default is 1) */
  140087. animationSpeedFactor: number;
  140088. /**
  140089. * Creates a new NoiseProceduralTexture
  140090. * @param name defines the name fo the texture
  140091. * @param size defines the size of the texture (default is 256)
  140092. * @param scene defines the hosting scene
  140093. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140094. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140095. */
  140096. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140097. private _updateShaderUniforms;
  140098. protected _getDefines(): string;
  140099. /** Generate the current state of the procedural texture */
  140100. render(useCameraPostProcess?: boolean): void;
  140101. /**
  140102. * Serializes this noise procedural texture
  140103. * @returns a serialized noise procedural texture object
  140104. */
  140105. serialize(): any;
  140106. /**
  140107. * Clone the texture.
  140108. * @returns the cloned texture
  140109. */
  140110. clone(): NoiseProceduralTexture;
  140111. /**
  140112. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140113. * @param parsedTexture defines parsed texture data
  140114. * @param scene defines the current scene
  140115. * @param rootUrl defines the root URL containing noise procedural texture information
  140116. * @returns a parsed NoiseProceduralTexture
  140117. */
  140118. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140119. }
  140120. }
  140121. declare module BABYLON {
  140122. /**
  140123. * Raw cube texture where the raw buffers are passed in
  140124. */
  140125. export class RawCubeTexture extends CubeTexture {
  140126. /**
  140127. * Creates a cube texture where the raw buffers are passed in.
  140128. * @param scene defines the scene the texture is attached to
  140129. * @param data defines the array of data to use to create each face
  140130. * @param size defines the size of the textures
  140131. * @param format defines the format of the data
  140132. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140133. * @param generateMipMaps defines if the engine should generate the mip levels
  140134. * @param invertY defines if data must be stored with Y axis inverted
  140135. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140136. * @param compression defines the compression used (null by default)
  140137. */
  140138. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140139. /**
  140140. * Updates the raw cube texture.
  140141. * @param data defines the data to store
  140142. * @param format defines the data format
  140143. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140144. * @param invertY defines if data must be stored with Y axis inverted
  140145. * @param compression defines the compression used (null by default)
  140146. * @param level defines which level of the texture to update
  140147. */
  140148. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140149. /**
  140150. * Updates a raw cube texture with RGBD encoded data.
  140151. * @param data defines the array of data [mipmap][face] to use to create each face
  140152. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140153. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140154. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140155. * @returns a promsie that resolves when the operation is complete
  140156. */
  140157. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140158. /**
  140159. * Clones the raw cube texture.
  140160. * @return a new cube texture
  140161. */
  140162. clone(): CubeTexture;
  140163. /** @hidden */
  140164. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140165. }
  140166. }
  140167. declare module BABYLON {
  140168. /**
  140169. * Class used to store 2D array textures containing user data
  140170. */
  140171. export class RawTexture2DArray extends Texture {
  140172. /** Gets or sets the texture format to use */
  140173. format: number;
  140174. /**
  140175. * Create a new RawTexture2DArray
  140176. * @param data defines the data of the texture
  140177. * @param width defines the width of the texture
  140178. * @param height defines the height of the texture
  140179. * @param depth defines the number of layers of the texture
  140180. * @param format defines the texture format to use
  140181. * @param scene defines the hosting scene
  140182. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140183. * @param invertY defines if texture must be stored with Y axis inverted
  140184. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140185. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140186. */
  140187. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140188. /** Gets or sets the texture format to use */
  140189. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140190. /**
  140191. * Update the texture with new data
  140192. * @param data defines the data to store in the texture
  140193. */
  140194. update(data: ArrayBufferView): void;
  140195. }
  140196. }
  140197. declare module BABYLON {
  140198. /**
  140199. * Class used to store 3D textures containing user data
  140200. */
  140201. export class RawTexture3D extends Texture {
  140202. /** Gets or sets the texture format to use */
  140203. format: number;
  140204. /**
  140205. * Create a new RawTexture3D
  140206. * @param data defines the data of the texture
  140207. * @param width defines the width of the texture
  140208. * @param height defines the height of the texture
  140209. * @param depth defines the depth of the texture
  140210. * @param format defines the texture format to use
  140211. * @param scene defines the hosting scene
  140212. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140213. * @param invertY defines if texture must be stored with Y axis inverted
  140214. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140215. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140216. */
  140217. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140218. /** Gets or sets the texture format to use */
  140219. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140220. /**
  140221. * Update the texture with new data
  140222. * @param data defines the data to store in the texture
  140223. */
  140224. update(data: ArrayBufferView): void;
  140225. }
  140226. }
  140227. declare module BABYLON {
  140228. /**
  140229. * Creates a refraction texture used by refraction channel of the standard material.
  140230. * It is like a mirror but to see through a material.
  140231. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140232. */
  140233. export class RefractionTexture extends RenderTargetTexture {
  140234. /**
  140235. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140236. * 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.
  140237. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140238. */
  140239. refractionPlane: Plane;
  140240. /**
  140241. * Define how deep under the surface we should see.
  140242. */
  140243. depth: number;
  140244. /**
  140245. * Creates a refraction texture used by refraction channel of the standard material.
  140246. * It is like a mirror but to see through a material.
  140247. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140248. * @param name Define the texture name
  140249. * @param size Define the size of the underlying texture
  140250. * @param scene Define the scene the refraction belongs to
  140251. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140252. */
  140253. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140254. /**
  140255. * Clone the refraction texture.
  140256. * @returns the cloned texture
  140257. */
  140258. clone(): RefractionTexture;
  140259. /**
  140260. * Serialize the texture to a JSON representation you could use in Parse later on
  140261. * @returns the serialized JSON representation
  140262. */
  140263. serialize(): any;
  140264. }
  140265. }
  140266. declare module BABYLON {
  140267. /**
  140268. * Block used to add support for vertex skinning (bones)
  140269. */
  140270. export class BonesBlock extends NodeMaterialBlock {
  140271. /**
  140272. * Creates a new BonesBlock
  140273. * @param name defines the block name
  140274. */
  140275. constructor(name: string);
  140276. /**
  140277. * Initialize the block and prepare the context for build
  140278. * @param state defines the state that will be used for the build
  140279. */
  140280. initialize(state: NodeMaterialBuildState): void;
  140281. /**
  140282. * Gets the current class name
  140283. * @returns the class name
  140284. */
  140285. getClassName(): string;
  140286. /**
  140287. * Gets the matrix indices input component
  140288. */
  140289. get matricesIndices(): NodeMaterialConnectionPoint;
  140290. /**
  140291. * Gets the matrix weights input component
  140292. */
  140293. get matricesWeights(): NodeMaterialConnectionPoint;
  140294. /**
  140295. * Gets the extra matrix indices input component
  140296. */
  140297. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140298. /**
  140299. * Gets the extra matrix weights input component
  140300. */
  140301. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  140302. /**
  140303. * Gets the world input component
  140304. */
  140305. get world(): NodeMaterialConnectionPoint;
  140306. /**
  140307. * Gets the output component
  140308. */
  140309. get output(): NodeMaterialConnectionPoint;
  140310. autoConfigure(material: NodeMaterial): void;
  140311. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  140312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140314. protected _buildBlock(state: NodeMaterialBuildState): this;
  140315. }
  140316. }
  140317. declare module BABYLON {
  140318. /**
  140319. * Block used to add support for instances
  140320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  140321. */
  140322. export class InstancesBlock extends NodeMaterialBlock {
  140323. /**
  140324. * Creates a new InstancesBlock
  140325. * @param name defines the block name
  140326. */
  140327. constructor(name: string);
  140328. /**
  140329. * Gets the current class name
  140330. * @returns the class name
  140331. */
  140332. getClassName(): string;
  140333. /**
  140334. * Gets the first world row input component
  140335. */
  140336. get world0(): NodeMaterialConnectionPoint;
  140337. /**
  140338. * Gets the second world row input component
  140339. */
  140340. get world1(): NodeMaterialConnectionPoint;
  140341. /**
  140342. * Gets the third world row input component
  140343. */
  140344. get world2(): NodeMaterialConnectionPoint;
  140345. /**
  140346. * Gets the forth world row input component
  140347. */
  140348. get world3(): NodeMaterialConnectionPoint;
  140349. /**
  140350. * Gets the world input component
  140351. */
  140352. get world(): NodeMaterialConnectionPoint;
  140353. /**
  140354. * Gets the output component
  140355. */
  140356. get output(): NodeMaterialConnectionPoint;
  140357. /**
  140358. * Gets the isntanceID component
  140359. */
  140360. get instanceID(): NodeMaterialConnectionPoint;
  140361. autoConfigure(material: NodeMaterial): void;
  140362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  140363. protected _buildBlock(state: NodeMaterialBuildState): this;
  140364. }
  140365. }
  140366. declare module BABYLON {
  140367. /**
  140368. * Block used to add morph targets support to vertex shader
  140369. */
  140370. export class MorphTargetsBlock extends NodeMaterialBlock {
  140371. private _repeatableContentAnchor;
  140372. /**
  140373. * Create a new MorphTargetsBlock
  140374. * @param name defines the block name
  140375. */
  140376. constructor(name: string);
  140377. /**
  140378. * Gets the current class name
  140379. * @returns the class name
  140380. */
  140381. getClassName(): string;
  140382. /**
  140383. * Gets the position input component
  140384. */
  140385. get position(): NodeMaterialConnectionPoint;
  140386. /**
  140387. * Gets the normal input component
  140388. */
  140389. get normal(): NodeMaterialConnectionPoint;
  140390. /**
  140391. * Gets the tangent input component
  140392. */
  140393. get tangent(): NodeMaterialConnectionPoint;
  140394. /**
  140395. * Gets the tangent input component
  140396. */
  140397. get uv(): NodeMaterialConnectionPoint;
  140398. /**
  140399. * Gets the position output component
  140400. */
  140401. get positionOutput(): NodeMaterialConnectionPoint;
  140402. /**
  140403. * Gets the normal output component
  140404. */
  140405. get normalOutput(): NodeMaterialConnectionPoint;
  140406. /**
  140407. * Gets the tangent output component
  140408. */
  140409. get tangentOutput(): NodeMaterialConnectionPoint;
  140410. /**
  140411. * Gets the tangent output component
  140412. */
  140413. get uvOutput(): NodeMaterialConnectionPoint;
  140414. initialize(state: NodeMaterialBuildState): void;
  140415. autoConfigure(material: NodeMaterial): void;
  140416. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140417. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140418. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  140419. protected _buildBlock(state: NodeMaterialBuildState): this;
  140420. }
  140421. }
  140422. declare module BABYLON {
  140423. /**
  140424. * Block used to get data information from a light
  140425. */
  140426. export class LightInformationBlock extends NodeMaterialBlock {
  140427. private _lightDataUniformName;
  140428. private _lightColorUniformName;
  140429. private _lightTypeDefineName;
  140430. /**
  140431. * Gets or sets the light associated with this block
  140432. */
  140433. light: Nullable<Light>;
  140434. /**
  140435. * Creates a new LightInformationBlock
  140436. * @param name defines the block name
  140437. */
  140438. constructor(name: string);
  140439. /**
  140440. * Gets the current class name
  140441. * @returns the class name
  140442. */
  140443. getClassName(): string;
  140444. /**
  140445. * Gets the world position input component
  140446. */
  140447. get worldPosition(): NodeMaterialConnectionPoint;
  140448. /**
  140449. * Gets the direction output component
  140450. */
  140451. get direction(): NodeMaterialConnectionPoint;
  140452. /**
  140453. * Gets the direction output component
  140454. */
  140455. get color(): NodeMaterialConnectionPoint;
  140456. /**
  140457. * Gets the direction output component
  140458. */
  140459. get intensity(): NodeMaterialConnectionPoint;
  140460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140462. protected _buildBlock(state: NodeMaterialBuildState): this;
  140463. serialize(): any;
  140464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140465. }
  140466. }
  140467. declare module BABYLON {
  140468. /**
  140469. * Block used to add image processing support to fragment shader
  140470. */
  140471. export class ImageProcessingBlock extends NodeMaterialBlock {
  140472. /**
  140473. * Create a new ImageProcessingBlock
  140474. * @param name defines the block name
  140475. */
  140476. constructor(name: string);
  140477. /**
  140478. * Gets the current class name
  140479. * @returns the class name
  140480. */
  140481. getClassName(): string;
  140482. /**
  140483. * Gets the color input component
  140484. */
  140485. get color(): NodeMaterialConnectionPoint;
  140486. /**
  140487. * Gets the output component
  140488. */
  140489. get output(): NodeMaterialConnectionPoint;
  140490. /**
  140491. * Initialize the block and prepare the context for build
  140492. * @param state defines the state that will be used for the build
  140493. */
  140494. initialize(state: NodeMaterialBuildState): void;
  140495. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  140496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140498. protected _buildBlock(state: NodeMaterialBuildState): this;
  140499. }
  140500. }
  140501. declare module BABYLON {
  140502. /**
  140503. * Block used to pertub normals based on a normal map
  140504. */
  140505. export class PerturbNormalBlock extends NodeMaterialBlock {
  140506. private _tangentSpaceParameterName;
  140507. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140508. invertX: boolean;
  140509. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  140510. invertY: boolean;
  140511. /**
  140512. * Create a new PerturbNormalBlock
  140513. * @param name defines the block name
  140514. */
  140515. constructor(name: string);
  140516. /**
  140517. * Gets the current class name
  140518. * @returns the class name
  140519. */
  140520. getClassName(): string;
  140521. /**
  140522. * Gets the world position input component
  140523. */
  140524. get worldPosition(): NodeMaterialConnectionPoint;
  140525. /**
  140526. * Gets the world normal input component
  140527. */
  140528. get worldNormal(): NodeMaterialConnectionPoint;
  140529. /**
  140530. * Gets the world tangent input component
  140531. */
  140532. get worldTangent(): NodeMaterialConnectionPoint;
  140533. /**
  140534. * Gets the uv input component
  140535. */
  140536. get uv(): NodeMaterialConnectionPoint;
  140537. /**
  140538. * Gets the normal map color input component
  140539. */
  140540. get normalMapColor(): NodeMaterialConnectionPoint;
  140541. /**
  140542. * Gets the strength input component
  140543. */
  140544. get strength(): NodeMaterialConnectionPoint;
  140545. /**
  140546. * Gets the output component
  140547. */
  140548. get output(): NodeMaterialConnectionPoint;
  140549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140551. autoConfigure(material: NodeMaterial): void;
  140552. protected _buildBlock(state: NodeMaterialBuildState): this;
  140553. protected _dumpPropertiesCode(): string;
  140554. serialize(): any;
  140555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140556. }
  140557. }
  140558. declare module BABYLON {
  140559. /**
  140560. * Block used to discard a pixel if a value is smaller than a cutoff
  140561. */
  140562. export class DiscardBlock extends NodeMaterialBlock {
  140563. /**
  140564. * Create a new DiscardBlock
  140565. * @param name defines the block name
  140566. */
  140567. constructor(name: string);
  140568. /**
  140569. * Gets the current class name
  140570. * @returns the class name
  140571. */
  140572. getClassName(): string;
  140573. /**
  140574. * Gets the color input component
  140575. */
  140576. get value(): NodeMaterialConnectionPoint;
  140577. /**
  140578. * Gets the cutoff input component
  140579. */
  140580. get cutoff(): NodeMaterialConnectionPoint;
  140581. protected _buildBlock(state: NodeMaterialBuildState): this;
  140582. }
  140583. }
  140584. declare module BABYLON {
  140585. /**
  140586. * Block used to test if the fragment shader is front facing
  140587. */
  140588. export class FrontFacingBlock extends NodeMaterialBlock {
  140589. /**
  140590. * Creates a new FrontFacingBlock
  140591. * @param name defines the block name
  140592. */
  140593. constructor(name: string);
  140594. /**
  140595. * Gets the current class name
  140596. * @returns the class name
  140597. */
  140598. getClassName(): string;
  140599. /**
  140600. * Gets the output component
  140601. */
  140602. get output(): NodeMaterialConnectionPoint;
  140603. protected _buildBlock(state: NodeMaterialBuildState): this;
  140604. }
  140605. }
  140606. declare module BABYLON {
  140607. /**
  140608. * Block used to get the derivative value on x and y of a given input
  140609. */
  140610. export class DerivativeBlock extends NodeMaterialBlock {
  140611. /**
  140612. * Create a new DerivativeBlock
  140613. * @param name defines the block name
  140614. */
  140615. constructor(name: string);
  140616. /**
  140617. * Gets the current class name
  140618. * @returns the class name
  140619. */
  140620. getClassName(): string;
  140621. /**
  140622. * Gets the input component
  140623. */
  140624. get input(): NodeMaterialConnectionPoint;
  140625. /**
  140626. * Gets the derivative output on x
  140627. */
  140628. get dx(): NodeMaterialConnectionPoint;
  140629. /**
  140630. * Gets the derivative output on y
  140631. */
  140632. get dy(): NodeMaterialConnectionPoint;
  140633. protected _buildBlock(state: NodeMaterialBuildState): this;
  140634. }
  140635. }
  140636. declare module BABYLON {
  140637. /**
  140638. * Block used to make gl_FragCoord available
  140639. */
  140640. export class FragCoordBlock extends NodeMaterialBlock {
  140641. /**
  140642. * Creates a new FragCoordBlock
  140643. * @param name defines the block name
  140644. */
  140645. constructor(name: string);
  140646. /**
  140647. * Gets the current class name
  140648. * @returns the class name
  140649. */
  140650. getClassName(): string;
  140651. /**
  140652. * Gets the xy component
  140653. */
  140654. get xy(): NodeMaterialConnectionPoint;
  140655. /**
  140656. * Gets the xyz component
  140657. */
  140658. get xyz(): NodeMaterialConnectionPoint;
  140659. /**
  140660. * Gets the xyzw component
  140661. */
  140662. get xyzw(): NodeMaterialConnectionPoint;
  140663. /**
  140664. * Gets the x component
  140665. */
  140666. get x(): NodeMaterialConnectionPoint;
  140667. /**
  140668. * Gets the y component
  140669. */
  140670. get y(): NodeMaterialConnectionPoint;
  140671. /**
  140672. * Gets the z component
  140673. */
  140674. get z(): NodeMaterialConnectionPoint;
  140675. /**
  140676. * Gets the w component
  140677. */
  140678. get output(): NodeMaterialConnectionPoint;
  140679. protected writeOutputs(state: NodeMaterialBuildState): string;
  140680. protected _buildBlock(state: NodeMaterialBuildState): this;
  140681. }
  140682. }
  140683. declare module BABYLON {
  140684. /**
  140685. * Block used to get the screen sizes
  140686. */
  140687. export class ScreenSizeBlock extends NodeMaterialBlock {
  140688. private _varName;
  140689. private _scene;
  140690. /**
  140691. * Creates a new ScreenSizeBlock
  140692. * @param name defines the block name
  140693. */
  140694. constructor(name: string);
  140695. /**
  140696. * Gets the current class name
  140697. * @returns the class name
  140698. */
  140699. getClassName(): string;
  140700. /**
  140701. * Gets the xy component
  140702. */
  140703. get xy(): NodeMaterialConnectionPoint;
  140704. /**
  140705. * Gets the x component
  140706. */
  140707. get x(): NodeMaterialConnectionPoint;
  140708. /**
  140709. * Gets the y component
  140710. */
  140711. get y(): NodeMaterialConnectionPoint;
  140712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140713. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  140714. protected _buildBlock(state: NodeMaterialBuildState): this;
  140715. }
  140716. }
  140717. declare module BABYLON {
  140718. /**
  140719. * Block used to add support for scene fog
  140720. */
  140721. export class FogBlock extends NodeMaterialBlock {
  140722. private _fogDistanceName;
  140723. private _fogParameters;
  140724. /**
  140725. * Create a new FogBlock
  140726. * @param name defines the block name
  140727. */
  140728. constructor(name: string);
  140729. /**
  140730. * Gets the current class name
  140731. * @returns the class name
  140732. */
  140733. getClassName(): string;
  140734. /**
  140735. * Gets the world position input component
  140736. */
  140737. get worldPosition(): NodeMaterialConnectionPoint;
  140738. /**
  140739. * Gets the view input component
  140740. */
  140741. get view(): NodeMaterialConnectionPoint;
  140742. /**
  140743. * Gets the color input component
  140744. */
  140745. get input(): NodeMaterialConnectionPoint;
  140746. /**
  140747. * Gets the fog color input component
  140748. */
  140749. get fogColor(): NodeMaterialConnectionPoint;
  140750. /**
  140751. * Gets the output component
  140752. */
  140753. get output(): NodeMaterialConnectionPoint;
  140754. autoConfigure(material: NodeMaterial): void;
  140755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140757. protected _buildBlock(state: NodeMaterialBuildState): this;
  140758. }
  140759. }
  140760. declare module BABYLON {
  140761. /**
  140762. * Block used to add light in the fragment shader
  140763. */
  140764. export class LightBlock extends NodeMaterialBlock {
  140765. private _lightId;
  140766. /**
  140767. * Gets or sets the light associated with this block
  140768. */
  140769. light: Nullable<Light>;
  140770. /**
  140771. * Create a new LightBlock
  140772. * @param name defines the block name
  140773. */
  140774. constructor(name: string);
  140775. /**
  140776. * Gets the current class name
  140777. * @returns the class name
  140778. */
  140779. getClassName(): string;
  140780. /**
  140781. * Gets the world position input component
  140782. */
  140783. get worldPosition(): NodeMaterialConnectionPoint;
  140784. /**
  140785. * Gets the world normal input component
  140786. */
  140787. get worldNormal(): NodeMaterialConnectionPoint;
  140788. /**
  140789. * Gets the camera (or eye) position component
  140790. */
  140791. get cameraPosition(): NodeMaterialConnectionPoint;
  140792. /**
  140793. * Gets the glossiness component
  140794. */
  140795. get glossiness(): NodeMaterialConnectionPoint;
  140796. /**
  140797. * Gets the glossinness power component
  140798. */
  140799. get glossPower(): NodeMaterialConnectionPoint;
  140800. /**
  140801. * Gets the diffuse color component
  140802. */
  140803. get diffuseColor(): NodeMaterialConnectionPoint;
  140804. /**
  140805. * Gets the specular color component
  140806. */
  140807. get specularColor(): NodeMaterialConnectionPoint;
  140808. /**
  140809. * Gets the diffuse output component
  140810. */
  140811. get diffuseOutput(): NodeMaterialConnectionPoint;
  140812. /**
  140813. * Gets the specular output component
  140814. */
  140815. get specularOutput(): NodeMaterialConnectionPoint;
  140816. /**
  140817. * Gets the shadow output component
  140818. */
  140819. get shadow(): NodeMaterialConnectionPoint;
  140820. autoConfigure(material: NodeMaterial): void;
  140821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140822. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140823. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140824. private _injectVertexCode;
  140825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140826. serialize(): any;
  140827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140828. }
  140829. }
  140830. declare module BABYLON {
  140831. /**
  140832. * Block used to read a reflection texture from a sampler
  140833. */
  140834. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140835. /**
  140836. * Create a new ReflectionTextureBlock
  140837. * @param name defines the block name
  140838. */
  140839. constructor(name: string);
  140840. /**
  140841. * Gets the current class name
  140842. * @returns the class name
  140843. */
  140844. getClassName(): string;
  140845. /**
  140846. * Gets the world position input component
  140847. */
  140848. get position(): NodeMaterialConnectionPoint;
  140849. /**
  140850. * Gets the world position input component
  140851. */
  140852. get worldPosition(): NodeMaterialConnectionPoint;
  140853. /**
  140854. * Gets the world normal input component
  140855. */
  140856. get worldNormal(): NodeMaterialConnectionPoint;
  140857. /**
  140858. * Gets the world input component
  140859. */
  140860. get world(): NodeMaterialConnectionPoint;
  140861. /**
  140862. * Gets the camera (or eye) position component
  140863. */
  140864. get cameraPosition(): NodeMaterialConnectionPoint;
  140865. /**
  140866. * Gets the view input component
  140867. */
  140868. get view(): NodeMaterialConnectionPoint;
  140869. /**
  140870. * Gets the rgb output component
  140871. */
  140872. get rgb(): NodeMaterialConnectionPoint;
  140873. /**
  140874. * Gets the rgba output component
  140875. */
  140876. get rgba(): NodeMaterialConnectionPoint;
  140877. /**
  140878. * Gets the r output component
  140879. */
  140880. get r(): NodeMaterialConnectionPoint;
  140881. /**
  140882. * Gets the g output component
  140883. */
  140884. get g(): NodeMaterialConnectionPoint;
  140885. /**
  140886. * Gets the b output component
  140887. */
  140888. get b(): NodeMaterialConnectionPoint;
  140889. /**
  140890. * Gets the a output component
  140891. */
  140892. get a(): NodeMaterialConnectionPoint;
  140893. autoConfigure(material: NodeMaterial): void;
  140894. protected _buildBlock(state: NodeMaterialBuildState): this;
  140895. }
  140896. }
  140897. declare module BABYLON {
  140898. /**
  140899. * Block used to add 2 vectors
  140900. */
  140901. export class AddBlock extends NodeMaterialBlock {
  140902. /**
  140903. * Creates a new AddBlock
  140904. * @param name defines the block name
  140905. */
  140906. constructor(name: string);
  140907. /**
  140908. * Gets the current class name
  140909. * @returns the class name
  140910. */
  140911. getClassName(): string;
  140912. /**
  140913. * Gets the left operand input component
  140914. */
  140915. get left(): NodeMaterialConnectionPoint;
  140916. /**
  140917. * Gets the right operand input component
  140918. */
  140919. get right(): NodeMaterialConnectionPoint;
  140920. /**
  140921. * Gets the output component
  140922. */
  140923. get output(): NodeMaterialConnectionPoint;
  140924. protected _buildBlock(state: NodeMaterialBuildState): this;
  140925. }
  140926. }
  140927. declare module BABYLON {
  140928. /**
  140929. * Block used to scale a vector by a float
  140930. */
  140931. export class ScaleBlock extends NodeMaterialBlock {
  140932. /**
  140933. * Creates a new ScaleBlock
  140934. * @param name defines the block name
  140935. */
  140936. constructor(name: string);
  140937. /**
  140938. * Gets the current class name
  140939. * @returns the class name
  140940. */
  140941. getClassName(): string;
  140942. /**
  140943. * Gets the input component
  140944. */
  140945. get input(): NodeMaterialConnectionPoint;
  140946. /**
  140947. * Gets the factor input component
  140948. */
  140949. get factor(): NodeMaterialConnectionPoint;
  140950. /**
  140951. * Gets the output component
  140952. */
  140953. get output(): NodeMaterialConnectionPoint;
  140954. protected _buildBlock(state: NodeMaterialBuildState): this;
  140955. }
  140956. }
  140957. declare module BABYLON {
  140958. /**
  140959. * Block used to clamp a float
  140960. */
  140961. export class ClampBlock extends NodeMaterialBlock {
  140962. /** Gets or sets the minimum range */
  140963. minimum: number;
  140964. /** Gets or sets the maximum range */
  140965. maximum: number;
  140966. /**
  140967. * Creates a new ClampBlock
  140968. * @param name defines the block name
  140969. */
  140970. constructor(name: string);
  140971. /**
  140972. * Gets the current class name
  140973. * @returns the class name
  140974. */
  140975. getClassName(): string;
  140976. /**
  140977. * Gets the value input component
  140978. */
  140979. get value(): NodeMaterialConnectionPoint;
  140980. /**
  140981. * Gets the output component
  140982. */
  140983. get output(): NodeMaterialConnectionPoint;
  140984. protected _buildBlock(state: NodeMaterialBuildState): this;
  140985. protected _dumpPropertiesCode(): string;
  140986. serialize(): any;
  140987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140988. }
  140989. }
  140990. declare module BABYLON {
  140991. /**
  140992. * Block used to apply a cross product between 2 vectors
  140993. */
  140994. export class CrossBlock extends NodeMaterialBlock {
  140995. /**
  140996. * Creates a new CrossBlock
  140997. * @param name defines the block name
  140998. */
  140999. constructor(name: string);
  141000. /**
  141001. * Gets the current class name
  141002. * @returns the class name
  141003. */
  141004. getClassName(): string;
  141005. /**
  141006. * Gets the left operand input component
  141007. */
  141008. get left(): NodeMaterialConnectionPoint;
  141009. /**
  141010. * Gets the right operand input component
  141011. */
  141012. get right(): NodeMaterialConnectionPoint;
  141013. /**
  141014. * Gets the output component
  141015. */
  141016. get output(): NodeMaterialConnectionPoint;
  141017. protected _buildBlock(state: NodeMaterialBuildState): this;
  141018. }
  141019. }
  141020. declare module BABYLON {
  141021. /**
  141022. * Block used to apply a dot product between 2 vectors
  141023. */
  141024. export class DotBlock extends NodeMaterialBlock {
  141025. /**
  141026. * Creates a new DotBlock
  141027. * @param name defines the block name
  141028. */
  141029. constructor(name: string);
  141030. /**
  141031. * Gets the current class name
  141032. * @returns the class name
  141033. */
  141034. getClassName(): string;
  141035. /**
  141036. * Gets the left operand input component
  141037. */
  141038. get left(): NodeMaterialConnectionPoint;
  141039. /**
  141040. * Gets the right operand input component
  141041. */
  141042. get right(): NodeMaterialConnectionPoint;
  141043. /**
  141044. * Gets the output component
  141045. */
  141046. get output(): NodeMaterialConnectionPoint;
  141047. protected _buildBlock(state: NodeMaterialBuildState): this;
  141048. }
  141049. }
  141050. declare module BABYLON {
  141051. /**
  141052. * Block used to normalize a vector
  141053. */
  141054. export class NormalizeBlock extends NodeMaterialBlock {
  141055. /**
  141056. * Creates a new NormalizeBlock
  141057. * @param name defines the block name
  141058. */
  141059. constructor(name: string);
  141060. /**
  141061. * Gets the current class name
  141062. * @returns the class name
  141063. */
  141064. getClassName(): string;
  141065. /**
  141066. * Gets the input component
  141067. */
  141068. get input(): NodeMaterialConnectionPoint;
  141069. /**
  141070. * Gets the output component
  141071. */
  141072. get output(): NodeMaterialConnectionPoint;
  141073. protected _buildBlock(state: NodeMaterialBuildState): this;
  141074. }
  141075. }
  141076. declare module BABYLON {
  141077. /**
  141078. * Operations supported by the Trigonometry block
  141079. */
  141080. export enum TrigonometryBlockOperations {
  141081. /** Cos */
  141082. Cos = 0,
  141083. /** Sin */
  141084. Sin = 1,
  141085. /** Abs */
  141086. Abs = 2,
  141087. /** Exp */
  141088. Exp = 3,
  141089. /** Exp2 */
  141090. Exp2 = 4,
  141091. /** Round */
  141092. Round = 5,
  141093. /** Floor */
  141094. Floor = 6,
  141095. /** Ceiling */
  141096. Ceiling = 7,
  141097. /** Square root */
  141098. Sqrt = 8,
  141099. /** Log */
  141100. Log = 9,
  141101. /** Tangent */
  141102. Tan = 10,
  141103. /** Arc tangent */
  141104. ArcTan = 11,
  141105. /** Arc cosinus */
  141106. ArcCos = 12,
  141107. /** Arc sinus */
  141108. ArcSin = 13,
  141109. /** Fraction */
  141110. Fract = 14,
  141111. /** Sign */
  141112. Sign = 15,
  141113. /** To radians (from degrees) */
  141114. Radians = 16,
  141115. /** To degrees (from radians) */
  141116. Degrees = 17
  141117. }
  141118. /**
  141119. * Block used to apply trigonometry operation to floats
  141120. */
  141121. export class TrigonometryBlock extends NodeMaterialBlock {
  141122. /**
  141123. * Gets or sets the operation applied by the block
  141124. */
  141125. operation: TrigonometryBlockOperations;
  141126. /**
  141127. * Creates a new TrigonometryBlock
  141128. * @param name defines the block name
  141129. */
  141130. constructor(name: string);
  141131. /**
  141132. * Gets the current class name
  141133. * @returns the class name
  141134. */
  141135. getClassName(): string;
  141136. /**
  141137. * Gets the input component
  141138. */
  141139. get input(): NodeMaterialConnectionPoint;
  141140. /**
  141141. * Gets the output component
  141142. */
  141143. get output(): NodeMaterialConnectionPoint;
  141144. protected _buildBlock(state: NodeMaterialBuildState): this;
  141145. serialize(): any;
  141146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141147. protected _dumpPropertiesCode(): string;
  141148. }
  141149. }
  141150. declare module BABYLON {
  141151. /**
  141152. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141153. */
  141154. export class ColorMergerBlock extends NodeMaterialBlock {
  141155. /**
  141156. * Create a new ColorMergerBlock
  141157. * @param name defines the block name
  141158. */
  141159. constructor(name: string);
  141160. /**
  141161. * Gets the current class name
  141162. * @returns the class name
  141163. */
  141164. getClassName(): string;
  141165. /**
  141166. * Gets the rgb component (input)
  141167. */
  141168. get rgbIn(): NodeMaterialConnectionPoint;
  141169. /**
  141170. * Gets the r component (input)
  141171. */
  141172. get r(): NodeMaterialConnectionPoint;
  141173. /**
  141174. * Gets the g component (input)
  141175. */
  141176. get g(): NodeMaterialConnectionPoint;
  141177. /**
  141178. * Gets the b component (input)
  141179. */
  141180. get b(): NodeMaterialConnectionPoint;
  141181. /**
  141182. * Gets the a component (input)
  141183. */
  141184. get a(): NodeMaterialConnectionPoint;
  141185. /**
  141186. * Gets the rgba component (output)
  141187. */
  141188. get rgba(): NodeMaterialConnectionPoint;
  141189. /**
  141190. * Gets the rgb component (output)
  141191. */
  141192. get rgbOut(): NodeMaterialConnectionPoint;
  141193. /**
  141194. * Gets the rgb component (output)
  141195. * @deprecated Please use rgbOut instead.
  141196. */
  141197. get rgb(): NodeMaterialConnectionPoint;
  141198. protected _buildBlock(state: NodeMaterialBuildState): this;
  141199. }
  141200. }
  141201. declare module BABYLON {
  141202. /**
  141203. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141204. */
  141205. export class VectorSplitterBlock extends NodeMaterialBlock {
  141206. /**
  141207. * Create a new VectorSplitterBlock
  141208. * @param name defines the block name
  141209. */
  141210. constructor(name: string);
  141211. /**
  141212. * Gets the current class name
  141213. * @returns the class name
  141214. */
  141215. getClassName(): string;
  141216. /**
  141217. * Gets the xyzw component (input)
  141218. */
  141219. get xyzw(): NodeMaterialConnectionPoint;
  141220. /**
  141221. * Gets the xyz component (input)
  141222. */
  141223. get xyzIn(): NodeMaterialConnectionPoint;
  141224. /**
  141225. * Gets the xy component (input)
  141226. */
  141227. get xyIn(): NodeMaterialConnectionPoint;
  141228. /**
  141229. * Gets the xyz component (output)
  141230. */
  141231. get xyzOut(): NodeMaterialConnectionPoint;
  141232. /**
  141233. * Gets the xy component (output)
  141234. */
  141235. get xyOut(): NodeMaterialConnectionPoint;
  141236. /**
  141237. * Gets the x component (output)
  141238. */
  141239. get x(): NodeMaterialConnectionPoint;
  141240. /**
  141241. * Gets the y component (output)
  141242. */
  141243. get y(): NodeMaterialConnectionPoint;
  141244. /**
  141245. * Gets the z component (output)
  141246. */
  141247. get z(): NodeMaterialConnectionPoint;
  141248. /**
  141249. * Gets the w component (output)
  141250. */
  141251. get w(): NodeMaterialConnectionPoint;
  141252. protected _inputRename(name: string): string;
  141253. protected _outputRename(name: string): string;
  141254. protected _buildBlock(state: NodeMaterialBuildState): this;
  141255. }
  141256. }
  141257. declare module BABYLON {
  141258. /**
  141259. * Block used to lerp between 2 values
  141260. */
  141261. export class LerpBlock extends NodeMaterialBlock {
  141262. /**
  141263. * Creates a new LerpBlock
  141264. * @param name defines the block name
  141265. */
  141266. constructor(name: string);
  141267. /**
  141268. * Gets the current class name
  141269. * @returns the class name
  141270. */
  141271. getClassName(): string;
  141272. /**
  141273. * Gets the left operand input component
  141274. */
  141275. get left(): NodeMaterialConnectionPoint;
  141276. /**
  141277. * Gets the right operand input component
  141278. */
  141279. get right(): NodeMaterialConnectionPoint;
  141280. /**
  141281. * Gets the gradient operand input component
  141282. */
  141283. get gradient(): NodeMaterialConnectionPoint;
  141284. /**
  141285. * Gets the output component
  141286. */
  141287. get output(): NodeMaterialConnectionPoint;
  141288. protected _buildBlock(state: NodeMaterialBuildState): this;
  141289. }
  141290. }
  141291. declare module BABYLON {
  141292. /**
  141293. * Block used to divide 2 vectors
  141294. */
  141295. export class DivideBlock extends NodeMaterialBlock {
  141296. /**
  141297. * Creates a new DivideBlock
  141298. * @param name defines the block name
  141299. */
  141300. constructor(name: string);
  141301. /**
  141302. * Gets the current class name
  141303. * @returns the class name
  141304. */
  141305. getClassName(): string;
  141306. /**
  141307. * Gets the left operand input component
  141308. */
  141309. get left(): NodeMaterialConnectionPoint;
  141310. /**
  141311. * Gets the right operand input component
  141312. */
  141313. get right(): NodeMaterialConnectionPoint;
  141314. /**
  141315. * Gets the output component
  141316. */
  141317. get output(): NodeMaterialConnectionPoint;
  141318. protected _buildBlock(state: NodeMaterialBuildState): this;
  141319. }
  141320. }
  141321. declare module BABYLON {
  141322. /**
  141323. * Block used to subtract 2 vectors
  141324. */
  141325. export class SubtractBlock extends NodeMaterialBlock {
  141326. /**
  141327. * Creates a new SubtractBlock
  141328. * @param name defines the block name
  141329. */
  141330. constructor(name: string);
  141331. /**
  141332. * Gets the current class name
  141333. * @returns the class name
  141334. */
  141335. getClassName(): string;
  141336. /**
  141337. * Gets the left operand input component
  141338. */
  141339. get left(): NodeMaterialConnectionPoint;
  141340. /**
  141341. * Gets the right operand input component
  141342. */
  141343. get right(): NodeMaterialConnectionPoint;
  141344. /**
  141345. * Gets the output component
  141346. */
  141347. get output(): NodeMaterialConnectionPoint;
  141348. protected _buildBlock(state: NodeMaterialBuildState): this;
  141349. }
  141350. }
  141351. declare module BABYLON {
  141352. /**
  141353. * Block used to step a value
  141354. */
  141355. export class StepBlock extends NodeMaterialBlock {
  141356. /**
  141357. * Creates a new StepBlock
  141358. * @param name defines the block name
  141359. */
  141360. constructor(name: string);
  141361. /**
  141362. * Gets the current class name
  141363. * @returns the class name
  141364. */
  141365. getClassName(): string;
  141366. /**
  141367. * Gets the value operand input component
  141368. */
  141369. get value(): NodeMaterialConnectionPoint;
  141370. /**
  141371. * Gets the edge operand input component
  141372. */
  141373. get edge(): NodeMaterialConnectionPoint;
  141374. /**
  141375. * Gets the output component
  141376. */
  141377. get output(): NodeMaterialConnectionPoint;
  141378. protected _buildBlock(state: NodeMaterialBuildState): this;
  141379. }
  141380. }
  141381. declare module BABYLON {
  141382. /**
  141383. * Block used to get the opposite (1 - x) of a value
  141384. */
  141385. export class OneMinusBlock extends NodeMaterialBlock {
  141386. /**
  141387. * Creates a new OneMinusBlock
  141388. * @param name defines the block name
  141389. */
  141390. constructor(name: string);
  141391. /**
  141392. * Gets the current class name
  141393. * @returns the class name
  141394. */
  141395. getClassName(): string;
  141396. /**
  141397. * Gets the input component
  141398. */
  141399. get input(): NodeMaterialConnectionPoint;
  141400. /**
  141401. * Gets the output component
  141402. */
  141403. get output(): NodeMaterialConnectionPoint;
  141404. protected _buildBlock(state: NodeMaterialBuildState): this;
  141405. }
  141406. }
  141407. declare module BABYLON {
  141408. /**
  141409. * Block used to get the view direction
  141410. */
  141411. export class ViewDirectionBlock extends NodeMaterialBlock {
  141412. /**
  141413. * Creates a new ViewDirectionBlock
  141414. * @param name defines the block name
  141415. */
  141416. constructor(name: string);
  141417. /**
  141418. * Gets the current class name
  141419. * @returns the class name
  141420. */
  141421. getClassName(): string;
  141422. /**
  141423. * Gets the world position component
  141424. */
  141425. get worldPosition(): NodeMaterialConnectionPoint;
  141426. /**
  141427. * Gets the camera position component
  141428. */
  141429. get cameraPosition(): NodeMaterialConnectionPoint;
  141430. /**
  141431. * Gets the output component
  141432. */
  141433. get output(): NodeMaterialConnectionPoint;
  141434. autoConfigure(material: NodeMaterial): void;
  141435. protected _buildBlock(state: NodeMaterialBuildState): this;
  141436. }
  141437. }
  141438. declare module BABYLON {
  141439. /**
  141440. * Block used to compute fresnel value
  141441. */
  141442. export class FresnelBlock extends NodeMaterialBlock {
  141443. /**
  141444. * Create a new FresnelBlock
  141445. * @param name defines the block name
  141446. */
  141447. constructor(name: string);
  141448. /**
  141449. * Gets the current class name
  141450. * @returns the class name
  141451. */
  141452. getClassName(): string;
  141453. /**
  141454. * Gets the world normal input component
  141455. */
  141456. get worldNormal(): NodeMaterialConnectionPoint;
  141457. /**
  141458. * Gets the view direction input component
  141459. */
  141460. get viewDirection(): NodeMaterialConnectionPoint;
  141461. /**
  141462. * Gets the bias input component
  141463. */
  141464. get bias(): NodeMaterialConnectionPoint;
  141465. /**
  141466. * Gets the camera (or eye) position component
  141467. */
  141468. get power(): NodeMaterialConnectionPoint;
  141469. /**
  141470. * Gets the fresnel output component
  141471. */
  141472. get fresnel(): NodeMaterialConnectionPoint;
  141473. autoConfigure(material: NodeMaterial): void;
  141474. protected _buildBlock(state: NodeMaterialBuildState): this;
  141475. }
  141476. }
  141477. declare module BABYLON {
  141478. /**
  141479. * Block used to get the max of 2 values
  141480. */
  141481. export class MaxBlock extends NodeMaterialBlock {
  141482. /**
  141483. * Creates a new MaxBlock
  141484. * @param name defines the block name
  141485. */
  141486. constructor(name: string);
  141487. /**
  141488. * Gets the current class name
  141489. * @returns the class name
  141490. */
  141491. getClassName(): string;
  141492. /**
  141493. * Gets the left operand input component
  141494. */
  141495. get left(): NodeMaterialConnectionPoint;
  141496. /**
  141497. * Gets the right operand input component
  141498. */
  141499. get right(): NodeMaterialConnectionPoint;
  141500. /**
  141501. * Gets the output component
  141502. */
  141503. get output(): NodeMaterialConnectionPoint;
  141504. protected _buildBlock(state: NodeMaterialBuildState): this;
  141505. }
  141506. }
  141507. declare module BABYLON {
  141508. /**
  141509. * Block used to get the min of 2 values
  141510. */
  141511. export class MinBlock extends NodeMaterialBlock {
  141512. /**
  141513. * Creates a new MinBlock
  141514. * @param name defines the block name
  141515. */
  141516. constructor(name: string);
  141517. /**
  141518. * Gets the current class name
  141519. * @returns the class name
  141520. */
  141521. getClassName(): string;
  141522. /**
  141523. * Gets the left operand input component
  141524. */
  141525. get left(): NodeMaterialConnectionPoint;
  141526. /**
  141527. * Gets the right operand input component
  141528. */
  141529. get right(): NodeMaterialConnectionPoint;
  141530. /**
  141531. * Gets the output component
  141532. */
  141533. get output(): NodeMaterialConnectionPoint;
  141534. protected _buildBlock(state: NodeMaterialBuildState): this;
  141535. }
  141536. }
  141537. declare module BABYLON {
  141538. /**
  141539. * Block used to get the distance between 2 values
  141540. */
  141541. export class DistanceBlock extends NodeMaterialBlock {
  141542. /**
  141543. * Creates a new DistanceBlock
  141544. * @param name defines the block name
  141545. */
  141546. constructor(name: string);
  141547. /**
  141548. * Gets the current class name
  141549. * @returns the class name
  141550. */
  141551. getClassName(): string;
  141552. /**
  141553. * Gets the left operand input component
  141554. */
  141555. get left(): NodeMaterialConnectionPoint;
  141556. /**
  141557. * Gets the right operand input component
  141558. */
  141559. get right(): NodeMaterialConnectionPoint;
  141560. /**
  141561. * Gets the output component
  141562. */
  141563. get output(): NodeMaterialConnectionPoint;
  141564. protected _buildBlock(state: NodeMaterialBuildState): this;
  141565. }
  141566. }
  141567. declare module BABYLON {
  141568. /**
  141569. * Block used to get the length of a vector
  141570. */
  141571. export class LengthBlock extends NodeMaterialBlock {
  141572. /**
  141573. * Creates a new LengthBlock
  141574. * @param name defines the block name
  141575. */
  141576. constructor(name: string);
  141577. /**
  141578. * Gets the current class name
  141579. * @returns the class name
  141580. */
  141581. getClassName(): string;
  141582. /**
  141583. * Gets the value input component
  141584. */
  141585. get value(): NodeMaterialConnectionPoint;
  141586. /**
  141587. * Gets the output component
  141588. */
  141589. get output(): NodeMaterialConnectionPoint;
  141590. protected _buildBlock(state: NodeMaterialBuildState): this;
  141591. }
  141592. }
  141593. declare module BABYLON {
  141594. /**
  141595. * Block used to get negative version of a value (i.e. x * -1)
  141596. */
  141597. export class NegateBlock extends NodeMaterialBlock {
  141598. /**
  141599. * Creates a new NegateBlock
  141600. * @param name defines the block name
  141601. */
  141602. constructor(name: string);
  141603. /**
  141604. * Gets the current class name
  141605. * @returns the class name
  141606. */
  141607. getClassName(): string;
  141608. /**
  141609. * Gets the value input component
  141610. */
  141611. get value(): NodeMaterialConnectionPoint;
  141612. /**
  141613. * Gets the output component
  141614. */
  141615. get output(): NodeMaterialConnectionPoint;
  141616. protected _buildBlock(state: NodeMaterialBuildState): this;
  141617. }
  141618. }
  141619. declare module BABYLON {
  141620. /**
  141621. * Block used to get the value of the first parameter raised to the power of the second
  141622. */
  141623. export class PowBlock extends NodeMaterialBlock {
  141624. /**
  141625. * Creates a new PowBlock
  141626. * @param name defines the block name
  141627. */
  141628. constructor(name: string);
  141629. /**
  141630. * Gets the current class name
  141631. * @returns the class name
  141632. */
  141633. getClassName(): string;
  141634. /**
  141635. * Gets the value operand input component
  141636. */
  141637. get value(): NodeMaterialConnectionPoint;
  141638. /**
  141639. * Gets the power operand input component
  141640. */
  141641. get power(): NodeMaterialConnectionPoint;
  141642. /**
  141643. * Gets the output component
  141644. */
  141645. get output(): NodeMaterialConnectionPoint;
  141646. protected _buildBlock(state: NodeMaterialBuildState): this;
  141647. }
  141648. }
  141649. declare module BABYLON {
  141650. /**
  141651. * Block used to get a random number
  141652. */
  141653. export class RandomNumberBlock extends NodeMaterialBlock {
  141654. /**
  141655. * Creates a new RandomNumberBlock
  141656. * @param name defines the block name
  141657. */
  141658. constructor(name: string);
  141659. /**
  141660. * Gets the current class name
  141661. * @returns the class name
  141662. */
  141663. getClassName(): string;
  141664. /**
  141665. * Gets the seed input component
  141666. */
  141667. get seed(): NodeMaterialConnectionPoint;
  141668. /**
  141669. * Gets the output component
  141670. */
  141671. get output(): NodeMaterialConnectionPoint;
  141672. protected _buildBlock(state: NodeMaterialBuildState): this;
  141673. }
  141674. }
  141675. declare module BABYLON {
  141676. /**
  141677. * Block used to compute arc tangent of 2 values
  141678. */
  141679. export class ArcTan2Block extends NodeMaterialBlock {
  141680. /**
  141681. * Creates a new ArcTan2Block
  141682. * @param name defines the block name
  141683. */
  141684. constructor(name: string);
  141685. /**
  141686. * Gets the current class name
  141687. * @returns the class name
  141688. */
  141689. getClassName(): string;
  141690. /**
  141691. * Gets the x operand input component
  141692. */
  141693. get x(): NodeMaterialConnectionPoint;
  141694. /**
  141695. * Gets the y operand input component
  141696. */
  141697. get y(): NodeMaterialConnectionPoint;
  141698. /**
  141699. * Gets the output component
  141700. */
  141701. get output(): NodeMaterialConnectionPoint;
  141702. protected _buildBlock(state: NodeMaterialBuildState): this;
  141703. }
  141704. }
  141705. declare module BABYLON {
  141706. /**
  141707. * Block used to smooth step a value
  141708. */
  141709. export class SmoothStepBlock extends NodeMaterialBlock {
  141710. /**
  141711. * Creates a new SmoothStepBlock
  141712. * @param name defines the block name
  141713. */
  141714. constructor(name: string);
  141715. /**
  141716. * Gets the current class name
  141717. * @returns the class name
  141718. */
  141719. getClassName(): string;
  141720. /**
  141721. * Gets the value operand input component
  141722. */
  141723. get value(): NodeMaterialConnectionPoint;
  141724. /**
  141725. * Gets the first edge operand input component
  141726. */
  141727. get edge0(): NodeMaterialConnectionPoint;
  141728. /**
  141729. * Gets the second edge operand input component
  141730. */
  141731. get edge1(): NodeMaterialConnectionPoint;
  141732. /**
  141733. * Gets the output component
  141734. */
  141735. get output(): NodeMaterialConnectionPoint;
  141736. protected _buildBlock(state: NodeMaterialBuildState): this;
  141737. }
  141738. }
  141739. declare module BABYLON {
  141740. /**
  141741. * Block used to get the reciprocal (1 / x) of a value
  141742. */
  141743. export class ReciprocalBlock extends NodeMaterialBlock {
  141744. /**
  141745. * Creates a new ReciprocalBlock
  141746. * @param name defines the block name
  141747. */
  141748. constructor(name: string);
  141749. /**
  141750. * Gets the current class name
  141751. * @returns the class name
  141752. */
  141753. getClassName(): string;
  141754. /**
  141755. * Gets the input component
  141756. */
  141757. get input(): NodeMaterialConnectionPoint;
  141758. /**
  141759. * Gets the output component
  141760. */
  141761. get output(): NodeMaterialConnectionPoint;
  141762. protected _buildBlock(state: NodeMaterialBuildState): this;
  141763. }
  141764. }
  141765. declare module BABYLON {
  141766. /**
  141767. * Block used to replace a color by another one
  141768. */
  141769. export class ReplaceColorBlock extends NodeMaterialBlock {
  141770. /**
  141771. * Creates a new ReplaceColorBlock
  141772. * @param name defines the block name
  141773. */
  141774. constructor(name: string);
  141775. /**
  141776. * Gets the current class name
  141777. * @returns the class name
  141778. */
  141779. getClassName(): string;
  141780. /**
  141781. * Gets the value input component
  141782. */
  141783. get value(): NodeMaterialConnectionPoint;
  141784. /**
  141785. * Gets the reference input component
  141786. */
  141787. get reference(): NodeMaterialConnectionPoint;
  141788. /**
  141789. * Gets the distance input component
  141790. */
  141791. get distance(): NodeMaterialConnectionPoint;
  141792. /**
  141793. * Gets the replacement input component
  141794. */
  141795. get replacement(): NodeMaterialConnectionPoint;
  141796. /**
  141797. * Gets the output component
  141798. */
  141799. get output(): NodeMaterialConnectionPoint;
  141800. protected _buildBlock(state: NodeMaterialBuildState): this;
  141801. }
  141802. }
  141803. declare module BABYLON {
  141804. /**
  141805. * Block used to posterize a value
  141806. * @see https://en.wikipedia.org/wiki/Posterization
  141807. */
  141808. export class PosterizeBlock extends NodeMaterialBlock {
  141809. /**
  141810. * Creates a new PosterizeBlock
  141811. * @param name defines the block name
  141812. */
  141813. constructor(name: string);
  141814. /**
  141815. * Gets the current class name
  141816. * @returns the class name
  141817. */
  141818. getClassName(): string;
  141819. /**
  141820. * Gets the value input component
  141821. */
  141822. get value(): NodeMaterialConnectionPoint;
  141823. /**
  141824. * Gets the steps input component
  141825. */
  141826. get steps(): NodeMaterialConnectionPoint;
  141827. /**
  141828. * Gets the output component
  141829. */
  141830. get output(): NodeMaterialConnectionPoint;
  141831. protected _buildBlock(state: NodeMaterialBuildState): this;
  141832. }
  141833. }
  141834. declare module BABYLON {
  141835. /**
  141836. * Operations supported by the Wave block
  141837. */
  141838. export enum WaveBlockKind {
  141839. /** SawTooth */
  141840. SawTooth = 0,
  141841. /** Square */
  141842. Square = 1,
  141843. /** Triangle */
  141844. Triangle = 2
  141845. }
  141846. /**
  141847. * Block used to apply wave operation to floats
  141848. */
  141849. export class WaveBlock extends NodeMaterialBlock {
  141850. /**
  141851. * Gets or sets the kibnd of wave to be applied by the block
  141852. */
  141853. kind: WaveBlockKind;
  141854. /**
  141855. * Creates a new WaveBlock
  141856. * @param name defines the block name
  141857. */
  141858. constructor(name: string);
  141859. /**
  141860. * Gets the current class name
  141861. * @returns the class name
  141862. */
  141863. getClassName(): string;
  141864. /**
  141865. * Gets the input component
  141866. */
  141867. get input(): NodeMaterialConnectionPoint;
  141868. /**
  141869. * Gets the output component
  141870. */
  141871. get output(): NodeMaterialConnectionPoint;
  141872. protected _buildBlock(state: NodeMaterialBuildState): this;
  141873. serialize(): any;
  141874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141875. }
  141876. }
  141877. declare module BABYLON {
  141878. /**
  141879. * Class used to store a color step for the GradientBlock
  141880. */
  141881. export class GradientBlockColorStep {
  141882. /**
  141883. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141884. */
  141885. step: number;
  141886. /**
  141887. * Gets or sets the color associated with this step
  141888. */
  141889. color: Color3;
  141890. /**
  141891. * Creates a new GradientBlockColorStep
  141892. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141893. * @param color defines the color associated with this step
  141894. */
  141895. constructor(
  141896. /**
  141897. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141898. */
  141899. step: number,
  141900. /**
  141901. * Gets or sets the color associated with this step
  141902. */
  141903. color: Color3);
  141904. }
  141905. /**
  141906. * Block used to return a color from a gradient based on an input value between 0 and 1
  141907. */
  141908. export class GradientBlock extends NodeMaterialBlock {
  141909. /**
  141910. * Gets or sets the list of color steps
  141911. */
  141912. colorSteps: GradientBlockColorStep[];
  141913. /**
  141914. * Creates a new GradientBlock
  141915. * @param name defines the block name
  141916. */
  141917. constructor(name: string);
  141918. /**
  141919. * Gets the current class name
  141920. * @returns the class name
  141921. */
  141922. getClassName(): string;
  141923. /**
  141924. * Gets the gradient input component
  141925. */
  141926. get gradient(): NodeMaterialConnectionPoint;
  141927. /**
  141928. * Gets the output component
  141929. */
  141930. get output(): NodeMaterialConnectionPoint;
  141931. private _writeColorConstant;
  141932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141933. serialize(): any;
  141934. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141935. protected _dumpPropertiesCode(): string;
  141936. }
  141937. }
  141938. declare module BABYLON {
  141939. /**
  141940. * Block used to normalize lerp between 2 values
  141941. */
  141942. export class NLerpBlock extends NodeMaterialBlock {
  141943. /**
  141944. * Creates a new NLerpBlock
  141945. * @param name defines the block name
  141946. */
  141947. constructor(name: string);
  141948. /**
  141949. * Gets the current class name
  141950. * @returns the class name
  141951. */
  141952. getClassName(): string;
  141953. /**
  141954. * Gets the left operand input component
  141955. */
  141956. get left(): NodeMaterialConnectionPoint;
  141957. /**
  141958. * Gets the right operand input component
  141959. */
  141960. get right(): NodeMaterialConnectionPoint;
  141961. /**
  141962. * Gets the gradient operand input component
  141963. */
  141964. get gradient(): NodeMaterialConnectionPoint;
  141965. /**
  141966. * Gets the output component
  141967. */
  141968. get output(): NodeMaterialConnectionPoint;
  141969. protected _buildBlock(state: NodeMaterialBuildState): this;
  141970. }
  141971. }
  141972. declare module BABYLON {
  141973. /**
  141974. * block used to Generate a Worley Noise 3D Noise Pattern
  141975. */
  141976. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141977. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141978. manhattanDistance: boolean;
  141979. /**
  141980. * Creates a new WorleyNoise3DBlock
  141981. * @param name defines the block name
  141982. */
  141983. constructor(name: string);
  141984. /**
  141985. * Gets the current class name
  141986. * @returns the class name
  141987. */
  141988. getClassName(): string;
  141989. /**
  141990. * Gets the seed input component
  141991. */
  141992. get seed(): NodeMaterialConnectionPoint;
  141993. /**
  141994. * Gets the jitter input component
  141995. */
  141996. get jitter(): NodeMaterialConnectionPoint;
  141997. /**
  141998. * Gets the output component
  141999. */
  142000. get output(): NodeMaterialConnectionPoint;
  142001. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142002. /**
  142003. * Exposes the properties to the UI?
  142004. */
  142005. protected _dumpPropertiesCode(): string;
  142006. /**
  142007. * Exposes the properties to the Seralize?
  142008. */
  142009. serialize(): any;
  142010. /**
  142011. * Exposes the properties to the deseralize?
  142012. */
  142013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142014. }
  142015. }
  142016. declare module BABYLON {
  142017. /**
  142018. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142019. */
  142020. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142021. /**
  142022. * Creates a new SimplexPerlin3DBlock
  142023. * @param name defines the block name
  142024. */
  142025. constructor(name: string);
  142026. /**
  142027. * Gets the current class name
  142028. * @returns the class name
  142029. */
  142030. getClassName(): string;
  142031. /**
  142032. * Gets the seed operand input component
  142033. */
  142034. get seed(): NodeMaterialConnectionPoint;
  142035. /**
  142036. * Gets the output component
  142037. */
  142038. get output(): NodeMaterialConnectionPoint;
  142039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142040. }
  142041. }
  142042. declare module BABYLON {
  142043. /**
  142044. * Block used to blend normals
  142045. */
  142046. export class NormalBlendBlock extends NodeMaterialBlock {
  142047. /**
  142048. * Creates a new NormalBlendBlock
  142049. * @param name defines the block name
  142050. */
  142051. constructor(name: string);
  142052. /**
  142053. * Gets the current class name
  142054. * @returns the class name
  142055. */
  142056. getClassName(): string;
  142057. /**
  142058. * Gets the first input component
  142059. */
  142060. get normalMap0(): NodeMaterialConnectionPoint;
  142061. /**
  142062. * Gets the second input component
  142063. */
  142064. get normalMap1(): NodeMaterialConnectionPoint;
  142065. /**
  142066. * Gets the output component
  142067. */
  142068. get output(): NodeMaterialConnectionPoint;
  142069. protected _buildBlock(state: NodeMaterialBuildState): this;
  142070. }
  142071. }
  142072. declare module BABYLON {
  142073. /**
  142074. * Block used to rotate a 2d vector by a given angle
  142075. */
  142076. export class Rotate2dBlock extends NodeMaterialBlock {
  142077. /**
  142078. * Creates a new Rotate2dBlock
  142079. * @param name defines the block name
  142080. */
  142081. constructor(name: string);
  142082. /**
  142083. * Gets the current class name
  142084. * @returns the class name
  142085. */
  142086. getClassName(): string;
  142087. /**
  142088. * Gets the input vector
  142089. */
  142090. get input(): NodeMaterialConnectionPoint;
  142091. /**
  142092. * Gets the input angle
  142093. */
  142094. get angle(): NodeMaterialConnectionPoint;
  142095. /**
  142096. * Gets the output component
  142097. */
  142098. get output(): NodeMaterialConnectionPoint;
  142099. autoConfigure(material: NodeMaterial): void;
  142100. protected _buildBlock(state: NodeMaterialBuildState): this;
  142101. }
  142102. }
  142103. declare module BABYLON {
  142104. /**
  142105. * Block used to get the reflected vector from a direction and a normal
  142106. */
  142107. export class ReflectBlock extends NodeMaterialBlock {
  142108. /**
  142109. * Creates a new ReflectBlock
  142110. * @param name defines the block name
  142111. */
  142112. constructor(name: string);
  142113. /**
  142114. * Gets the current class name
  142115. * @returns the class name
  142116. */
  142117. getClassName(): string;
  142118. /**
  142119. * Gets the incident component
  142120. */
  142121. get incident(): NodeMaterialConnectionPoint;
  142122. /**
  142123. * Gets the normal component
  142124. */
  142125. get normal(): NodeMaterialConnectionPoint;
  142126. /**
  142127. * Gets the output component
  142128. */
  142129. get output(): NodeMaterialConnectionPoint;
  142130. protected _buildBlock(state: NodeMaterialBuildState): this;
  142131. }
  142132. }
  142133. declare module BABYLON {
  142134. /**
  142135. * Block used to get the refracted vector from a direction and a normal
  142136. */
  142137. export class RefractBlock extends NodeMaterialBlock {
  142138. /**
  142139. * Creates a new RefractBlock
  142140. * @param name defines the block name
  142141. */
  142142. constructor(name: string);
  142143. /**
  142144. * Gets the current class name
  142145. * @returns the class name
  142146. */
  142147. getClassName(): string;
  142148. /**
  142149. * Gets the incident component
  142150. */
  142151. get incident(): NodeMaterialConnectionPoint;
  142152. /**
  142153. * Gets the normal component
  142154. */
  142155. get normal(): NodeMaterialConnectionPoint;
  142156. /**
  142157. * Gets the index of refraction component
  142158. */
  142159. get ior(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the output component
  142162. */
  142163. get output(): NodeMaterialConnectionPoint;
  142164. protected _buildBlock(state: NodeMaterialBuildState): this;
  142165. }
  142166. }
  142167. declare module BABYLON {
  142168. /**
  142169. * Block used to desaturate a color
  142170. */
  142171. export class DesaturateBlock extends NodeMaterialBlock {
  142172. /**
  142173. * Creates a new DesaturateBlock
  142174. * @param name defines the block name
  142175. */
  142176. constructor(name: string);
  142177. /**
  142178. * Gets the current class name
  142179. * @returns the class name
  142180. */
  142181. getClassName(): string;
  142182. /**
  142183. * Gets the color operand input component
  142184. */
  142185. get color(): NodeMaterialConnectionPoint;
  142186. /**
  142187. * Gets the level operand input component
  142188. */
  142189. get level(): NodeMaterialConnectionPoint;
  142190. /**
  142191. * Gets the output component
  142192. */
  142193. get output(): NodeMaterialConnectionPoint;
  142194. protected _buildBlock(state: NodeMaterialBuildState): this;
  142195. }
  142196. }
  142197. declare module BABYLON {
  142198. /**
  142199. * Block used to implement the ambient occlusion module of the PBR material
  142200. */
  142201. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142202. /**
  142203. * Create a new AmbientOcclusionBlock
  142204. * @param name defines the block name
  142205. */
  142206. constructor(name: string);
  142207. /**
  142208. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142209. */
  142210. useAmbientInGrayScale: boolean;
  142211. /**
  142212. * Initialize the block and prepare the context for build
  142213. * @param state defines the state that will be used for the build
  142214. */
  142215. initialize(state: NodeMaterialBuildState): void;
  142216. /**
  142217. * Gets the current class name
  142218. * @returns the class name
  142219. */
  142220. getClassName(): string;
  142221. /**
  142222. * Gets the texture input component
  142223. */
  142224. get texture(): NodeMaterialConnectionPoint;
  142225. /**
  142226. * Gets the texture intensity component
  142227. */
  142228. get intensity(): NodeMaterialConnectionPoint;
  142229. /**
  142230. * Gets the direct light intensity input component
  142231. */
  142232. get directLightIntensity(): NodeMaterialConnectionPoint;
  142233. /**
  142234. * Gets the ambient occlusion object output component
  142235. */
  142236. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142237. /**
  142238. * Gets the main code of the block (fragment side)
  142239. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142240. * @returns the shader code
  142241. */
  142242. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142244. protected _buildBlock(state: NodeMaterialBuildState): this;
  142245. protected _dumpPropertiesCode(): string;
  142246. serialize(): any;
  142247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142248. }
  142249. }
  142250. declare module BABYLON {
  142251. /**
  142252. * Block used to implement the reflection module of the PBR material
  142253. */
  142254. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142255. /** @hidden */
  142256. _defineLODReflectionAlpha: string;
  142257. /** @hidden */
  142258. _defineLinearSpecularReflection: string;
  142259. private _vEnvironmentIrradianceName;
  142260. /** @hidden */
  142261. _vReflectionMicrosurfaceInfosName: string;
  142262. /** @hidden */
  142263. _vReflectionInfosName: string;
  142264. /** @hidden */
  142265. _vReflectionFilteringInfoName: string;
  142266. private _scene;
  142267. /**
  142268. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142269. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142270. * It's less burden on the user side in the editor part.
  142271. */
  142272. /** @hidden */
  142273. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142274. /** @hidden */
  142275. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142276. /** @hidden */
  142277. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142278. /**
  142279. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142280. * diffuse part of the IBL.
  142281. */
  142282. useSphericalHarmonics: boolean;
  142283. /**
  142284. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142285. */
  142286. forceIrradianceInFragment: boolean;
  142287. /**
  142288. * Create a new ReflectionBlock
  142289. * @param name defines the block name
  142290. */
  142291. constructor(name: string);
  142292. /**
  142293. * Gets the current class name
  142294. * @returns the class name
  142295. */
  142296. getClassName(): string;
  142297. /**
  142298. * Gets the position input component
  142299. */
  142300. get position(): NodeMaterialConnectionPoint;
  142301. /**
  142302. * Gets the world position input component
  142303. */
  142304. get worldPosition(): NodeMaterialConnectionPoint;
  142305. /**
  142306. * Gets the world normal input component
  142307. */
  142308. get worldNormal(): NodeMaterialConnectionPoint;
  142309. /**
  142310. * Gets the world input component
  142311. */
  142312. get world(): NodeMaterialConnectionPoint;
  142313. /**
  142314. * Gets the camera (or eye) position component
  142315. */
  142316. get cameraPosition(): NodeMaterialConnectionPoint;
  142317. /**
  142318. * Gets the view input component
  142319. */
  142320. get view(): NodeMaterialConnectionPoint;
  142321. /**
  142322. * Gets the color input component
  142323. */
  142324. get color(): NodeMaterialConnectionPoint;
  142325. /**
  142326. * Gets the reflection object output component
  142327. */
  142328. get reflection(): NodeMaterialConnectionPoint;
  142329. /**
  142330. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  142331. */
  142332. get hasTexture(): boolean;
  142333. /**
  142334. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  142335. */
  142336. get reflectionColor(): string;
  142337. protected _getTexture(): Nullable<BaseTexture>;
  142338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142339. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142340. /**
  142341. * Gets the code to inject in the vertex shader
  142342. * @param state current state of the node material building
  142343. * @returns the shader code
  142344. */
  142345. handleVertexSide(state: NodeMaterialBuildState): string;
  142346. /**
  142347. * Gets the main code of the block (fragment side)
  142348. * @param state current state of the node material building
  142349. * @param normalVarName name of the existing variable corresponding to the normal
  142350. * @returns the shader code
  142351. */
  142352. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  142353. protected _buildBlock(state: NodeMaterialBuildState): this;
  142354. protected _dumpPropertiesCode(): string;
  142355. serialize(): any;
  142356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142357. }
  142358. }
  142359. declare module BABYLON {
  142360. /**
  142361. * Block used to implement the sheen module of the PBR material
  142362. */
  142363. export class SheenBlock extends NodeMaterialBlock {
  142364. /**
  142365. * Create a new SheenBlock
  142366. * @param name defines the block name
  142367. */
  142368. constructor(name: string);
  142369. /**
  142370. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  142371. * It allows the strength of the sheen effect to not depend on the base color of the material,
  142372. * making it easier to setup and tweak the effect
  142373. */
  142374. albedoScaling: boolean;
  142375. /**
  142376. * Defines if the sheen is linked to the sheen color.
  142377. */
  142378. linkSheenWithAlbedo: boolean;
  142379. /**
  142380. * Initialize the block and prepare the context for build
  142381. * @param state defines the state that will be used for the build
  142382. */
  142383. initialize(state: NodeMaterialBuildState): void;
  142384. /**
  142385. * Gets the current class name
  142386. * @returns the class name
  142387. */
  142388. getClassName(): string;
  142389. /**
  142390. * Gets the intensity input component
  142391. */
  142392. get intensity(): NodeMaterialConnectionPoint;
  142393. /**
  142394. * Gets the color input component
  142395. */
  142396. get color(): NodeMaterialConnectionPoint;
  142397. /**
  142398. * Gets the roughness input component
  142399. */
  142400. get roughness(): NodeMaterialConnectionPoint;
  142401. /**
  142402. * Gets the sheen object output component
  142403. */
  142404. get sheen(): NodeMaterialConnectionPoint;
  142405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142406. /**
  142407. * Gets the main code of the block (fragment side)
  142408. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142409. * @returns the shader code
  142410. */
  142411. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  142412. protected _buildBlock(state: NodeMaterialBuildState): this;
  142413. protected _dumpPropertiesCode(): string;
  142414. serialize(): any;
  142415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142416. }
  142417. }
  142418. declare module BABYLON {
  142419. /**
  142420. * Block used to implement the reflectivity module of the PBR material
  142421. */
  142422. export class ReflectivityBlock extends NodeMaterialBlock {
  142423. private _metallicReflectanceColor;
  142424. private _metallicF0Factor;
  142425. /** @hidden */
  142426. _vMetallicReflectanceFactorsName: string;
  142427. /**
  142428. * The property below is set by the main PBR block prior to calling methods of this class.
  142429. */
  142430. /** @hidden */
  142431. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  142432. /**
  142433. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  142434. */
  142435. useAmbientOcclusionFromMetallicTextureRed: boolean;
  142436. /**
  142437. * Specifies if the metallic texture contains the metallness information in its blue channel.
  142438. */
  142439. useMetallnessFromMetallicTextureBlue: boolean;
  142440. /**
  142441. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  142442. */
  142443. useRoughnessFromMetallicTextureAlpha: boolean;
  142444. /**
  142445. * Specifies if the metallic texture contains the roughness information in its green channel.
  142446. */
  142447. useRoughnessFromMetallicTextureGreen: boolean;
  142448. /**
  142449. * Create a new ReflectivityBlock
  142450. * @param name defines the block name
  142451. */
  142452. constructor(name: string);
  142453. /**
  142454. * Initialize the block and prepare the context for build
  142455. * @param state defines the state that will be used for the build
  142456. */
  142457. initialize(state: NodeMaterialBuildState): void;
  142458. /**
  142459. * Gets the current class name
  142460. * @returns the class name
  142461. */
  142462. getClassName(): string;
  142463. /**
  142464. * Gets the metallic input component
  142465. */
  142466. get metallic(): NodeMaterialConnectionPoint;
  142467. /**
  142468. * Gets the roughness input component
  142469. */
  142470. get roughness(): NodeMaterialConnectionPoint;
  142471. /**
  142472. * Gets the texture input component
  142473. */
  142474. get texture(): NodeMaterialConnectionPoint;
  142475. /**
  142476. * Gets the reflectivity object output component
  142477. */
  142478. get reflectivity(): NodeMaterialConnectionPoint;
  142479. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142480. /**
  142481. * Gets the main code of the block (fragment side)
  142482. * @param state current state of the node material building
  142483. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  142484. * @returns the shader code
  142485. */
  142486. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  142487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142488. protected _buildBlock(state: NodeMaterialBuildState): this;
  142489. protected _dumpPropertiesCode(): string;
  142490. serialize(): any;
  142491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142492. }
  142493. }
  142494. declare module BABYLON {
  142495. /**
  142496. * Block used to implement the anisotropy module of the PBR material
  142497. */
  142498. export class AnisotropyBlock extends NodeMaterialBlock {
  142499. /**
  142500. * The two properties below are set by the main PBR block prior to calling methods of this class.
  142501. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142502. * It's less burden on the user side in the editor part.
  142503. */
  142504. /** @hidden */
  142505. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142506. /** @hidden */
  142507. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142508. /**
  142509. * Create a new AnisotropyBlock
  142510. * @param name defines the block name
  142511. */
  142512. constructor(name: string);
  142513. /**
  142514. * Initialize the block and prepare the context for build
  142515. * @param state defines the state that will be used for the build
  142516. */
  142517. initialize(state: NodeMaterialBuildState): void;
  142518. /**
  142519. * Gets the current class name
  142520. * @returns the class name
  142521. */
  142522. getClassName(): string;
  142523. /**
  142524. * Gets the intensity input component
  142525. */
  142526. get intensity(): NodeMaterialConnectionPoint;
  142527. /**
  142528. * Gets the direction input component
  142529. */
  142530. get direction(): NodeMaterialConnectionPoint;
  142531. /**
  142532. * Gets the texture input component
  142533. */
  142534. get texture(): NodeMaterialConnectionPoint;
  142535. /**
  142536. * Gets the uv input component
  142537. */
  142538. get uv(): NodeMaterialConnectionPoint;
  142539. /**
  142540. * Gets the worldTangent input component
  142541. */
  142542. get worldTangent(): NodeMaterialConnectionPoint;
  142543. /**
  142544. * Gets the anisotropy object output component
  142545. */
  142546. get anisotropy(): NodeMaterialConnectionPoint;
  142547. private _generateTBNSpace;
  142548. /**
  142549. * Gets the main code of the block (fragment side)
  142550. * @param state current state of the node material building
  142551. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142552. * @returns the shader code
  142553. */
  142554. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  142555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142556. protected _buildBlock(state: NodeMaterialBuildState): this;
  142557. }
  142558. }
  142559. declare module BABYLON {
  142560. /**
  142561. * Block used to implement the clear coat module of the PBR material
  142562. */
  142563. export class ClearCoatBlock extends NodeMaterialBlock {
  142564. private _scene;
  142565. /**
  142566. * Create a new ClearCoatBlock
  142567. * @param name defines the block name
  142568. */
  142569. constructor(name: string);
  142570. /**
  142571. * Initialize the block and prepare the context for build
  142572. * @param state defines the state that will be used for the build
  142573. */
  142574. initialize(state: NodeMaterialBuildState): void;
  142575. /**
  142576. * Gets the current class name
  142577. * @returns the class name
  142578. */
  142579. getClassName(): string;
  142580. /**
  142581. * Gets the intensity input component
  142582. */
  142583. get intensity(): NodeMaterialConnectionPoint;
  142584. /**
  142585. * Gets the roughness input component
  142586. */
  142587. get roughness(): NodeMaterialConnectionPoint;
  142588. /**
  142589. * Gets the ior input component
  142590. */
  142591. get ior(): NodeMaterialConnectionPoint;
  142592. /**
  142593. * Gets the texture input component
  142594. */
  142595. get texture(): NodeMaterialConnectionPoint;
  142596. /**
  142597. * Gets the bump texture input component
  142598. */
  142599. get bumpTexture(): NodeMaterialConnectionPoint;
  142600. /**
  142601. * Gets the uv input component
  142602. */
  142603. get uv(): NodeMaterialConnectionPoint;
  142604. /**
  142605. * Gets the tint color input component
  142606. */
  142607. get tintColor(): NodeMaterialConnectionPoint;
  142608. /**
  142609. * Gets the tint "at distance" input component
  142610. */
  142611. get tintAtDistance(): NodeMaterialConnectionPoint;
  142612. /**
  142613. * Gets the tint thickness input component
  142614. */
  142615. get tintThickness(): NodeMaterialConnectionPoint;
  142616. /**
  142617. * Gets the world tangent input component
  142618. */
  142619. get worldTangent(): NodeMaterialConnectionPoint;
  142620. /**
  142621. * Gets the clear coat object output component
  142622. */
  142623. get clearcoat(): NodeMaterialConnectionPoint;
  142624. autoConfigure(material: NodeMaterial): void;
  142625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142627. private _generateTBNSpace;
  142628. /**
  142629. * Gets the main code of the block (fragment side)
  142630. * @param state current state of the node material building
  142631. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  142632. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142633. * @param worldPosVarName name of the variable holding the world position
  142634. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142635. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  142636. * @param worldNormalVarName name of the variable holding the world normal
  142637. * @returns the shader code
  142638. */
  142639. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  142640. protected _buildBlock(state: NodeMaterialBuildState): this;
  142641. }
  142642. }
  142643. declare module BABYLON {
  142644. /**
  142645. * Block used to implement the sub surface module of the PBR material
  142646. */
  142647. export class SubSurfaceBlock extends NodeMaterialBlock {
  142648. /**
  142649. * Create a new SubSurfaceBlock
  142650. * @param name defines the block name
  142651. */
  142652. constructor(name: string);
  142653. /**
  142654. * Stores the intensity of the different subsurface effects in the thickness texture.
  142655. * * the green channel is the translucency intensity.
  142656. * * the blue channel is the scattering intensity.
  142657. * * the alpha channel is the refraction intensity.
  142658. */
  142659. useMaskFromThicknessTexture: boolean;
  142660. /**
  142661. * Initialize the block and prepare the context for build
  142662. * @param state defines the state that will be used for the build
  142663. */
  142664. initialize(state: NodeMaterialBuildState): void;
  142665. /**
  142666. * Gets the current class name
  142667. * @returns the class name
  142668. */
  142669. getClassName(): string;
  142670. /**
  142671. * Gets the min thickness input component
  142672. */
  142673. get minThickness(): NodeMaterialConnectionPoint;
  142674. /**
  142675. * Gets the max thickness input component
  142676. */
  142677. get maxThickness(): NodeMaterialConnectionPoint;
  142678. /**
  142679. * Gets the thickness texture component
  142680. */
  142681. get thicknessTexture(): NodeMaterialConnectionPoint;
  142682. /**
  142683. * Gets the tint color input component
  142684. */
  142685. get tintColor(): NodeMaterialConnectionPoint;
  142686. /**
  142687. * Gets the translucency intensity input component
  142688. */
  142689. get translucencyIntensity(): NodeMaterialConnectionPoint;
  142690. /**
  142691. * Gets the translucency diffusion distance input component
  142692. */
  142693. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  142694. /**
  142695. * Gets the refraction object parameters
  142696. */
  142697. get refraction(): NodeMaterialConnectionPoint;
  142698. /**
  142699. * Gets the sub surface object output component
  142700. */
  142701. get subsurface(): NodeMaterialConnectionPoint;
  142702. autoConfigure(material: NodeMaterial): void;
  142703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142704. /**
  142705. * Gets the main code of the block (fragment side)
  142706. * @param state current state of the node material building
  142707. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  142708. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142709. * @param worldPosVarName name of the variable holding the world position
  142710. * @returns the shader code
  142711. */
  142712. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  142713. protected _buildBlock(state: NodeMaterialBuildState): this;
  142714. }
  142715. }
  142716. declare module BABYLON {
  142717. /**
  142718. * Block used to implement the PBR metallic/roughness model
  142719. */
  142720. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  142721. /**
  142722. * Gets or sets the light associated with this block
  142723. */
  142724. light: Nullable<Light>;
  142725. private _lightId;
  142726. private _scene;
  142727. private _environmentBRDFTexture;
  142728. private _environmentBrdfSamplerName;
  142729. private _vNormalWName;
  142730. private _invertNormalName;
  142731. /**
  142732. * Create a new ReflectionBlock
  142733. * @param name defines the block name
  142734. */
  142735. constructor(name: string);
  142736. /**
  142737. * Intensity of the direct lights e.g. the four lights available in your scene.
  142738. * This impacts both the direct diffuse and specular highlights.
  142739. */
  142740. directIntensity: number;
  142741. /**
  142742. * Intensity of the environment e.g. how much the environment will light the object
  142743. * either through harmonics for rough material or through the refelction for shiny ones.
  142744. */
  142745. environmentIntensity: number;
  142746. /**
  142747. * This is a special control allowing the reduction of the specular highlights coming from the
  142748. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  142749. */
  142750. specularIntensity: number;
  142751. /**
  142752. * Defines the falloff type used in this material.
  142753. * It by default is Physical.
  142754. */
  142755. lightFalloff: number;
  142756. /**
  142757. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  142758. */
  142759. useAlphaFromAlbedoTexture: boolean;
  142760. /**
  142761. * Specifies that alpha test should be used
  142762. */
  142763. useAlphaTest: boolean;
  142764. /**
  142765. * Defines the alpha limits in alpha test mode.
  142766. */
  142767. alphaTestCutoff: number;
  142768. /**
  142769. * Specifies that alpha blending should be used
  142770. */
  142771. useAlphaBlending: boolean;
  142772. /**
  142773. * Defines if the alpha value should be determined via the rgb values.
  142774. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  142775. */
  142776. opacityRGB: boolean;
  142777. /**
  142778. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  142779. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  142780. */
  142781. useRadianceOverAlpha: boolean;
  142782. /**
  142783. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142784. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142785. */
  142786. useSpecularOverAlpha: boolean;
  142787. /**
  142788. * Enables specular anti aliasing in the PBR shader.
  142789. * It will both interacts on the Geometry for analytical and IBL lighting.
  142790. * It also prefilter the roughness map based on the bump values.
  142791. */
  142792. enableSpecularAntiAliasing: boolean;
  142793. /**
  142794. * Enables realtime filtering on the texture.
  142795. */
  142796. realTimeFiltering: boolean;
  142797. /**
  142798. * Quality switch for realtime filtering
  142799. */
  142800. realTimeFilteringQuality: number;
  142801. /**
  142802. * Defines if the material uses energy conservation.
  142803. */
  142804. useEnergyConservation: boolean;
  142805. /**
  142806. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142807. * too much the area relying on ambient texture to define their ambient occlusion.
  142808. */
  142809. useRadianceOcclusion: boolean;
  142810. /**
  142811. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142812. * makes the reflect vector face the model (under horizon).
  142813. */
  142814. useHorizonOcclusion: boolean;
  142815. /**
  142816. * If set to true, no lighting calculations will be applied.
  142817. */
  142818. unlit: boolean;
  142819. /**
  142820. * Force normal to face away from face.
  142821. */
  142822. forceNormalForward: boolean;
  142823. /**
  142824. * Defines the material debug mode.
  142825. * It helps seeing only some components of the material while troubleshooting.
  142826. */
  142827. debugMode: number;
  142828. /**
  142829. * Specify from where on screen the debug mode should start.
  142830. * The value goes from -1 (full screen) to 1 (not visible)
  142831. * It helps with side by side comparison against the final render
  142832. * This defaults to 0
  142833. */
  142834. debugLimit: number;
  142835. /**
  142836. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142837. * You can use the factor to better multiply the final value.
  142838. */
  142839. debugFactor: number;
  142840. /**
  142841. * Initialize the block and prepare the context for build
  142842. * @param state defines the state that will be used for the build
  142843. */
  142844. initialize(state: NodeMaterialBuildState): void;
  142845. /**
  142846. * Gets the current class name
  142847. * @returns the class name
  142848. */
  142849. getClassName(): string;
  142850. /**
  142851. * Gets the world position input component
  142852. */
  142853. get worldPosition(): NodeMaterialConnectionPoint;
  142854. /**
  142855. * Gets the world normal input component
  142856. */
  142857. get worldNormal(): NodeMaterialConnectionPoint;
  142858. /**
  142859. * Gets the perturbed normal input component
  142860. */
  142861. get perturbedNormal(): NodeMaterialConnectionPoint;
  142862. /**
  142863. * Gets the camera position input component
  142864. */
  142865. get cameraPosition(): NodeMaterialConnectionPoint;
  142866. /**
  142867. * Gets the base color input component
  142868. */
  142869. get baseColor(): NodeMaterialConnectionPoint;
  142870. /**
  142871. * Gets the opacity texture input component
  142872. */
  142873. get opacityTexture(): NodeMaterialConnectionPoint;
  142874. /**
  142875. * Gets the ambient color input component
  142876. */
  142877. get ambientColor(): NodeMaterialConnectionPoint;
  142878. /**
  142879. * Gets the reflectivity object parameters
  142880. */
  142881. get reflectivity(): NodeMaterialConnectionPoint;
  142882. /**
  142883. * Gets the ambient occlusion object parameters
  142884. */
  142885. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142886. /**
  142887. * Gets the reflection object parameters
  142888. */
  142889. get reflection(): NodeMaterialConnectionPoint;
  142890. /**
  142891. * Gets the sheen object parameters
  142892. */
  142893. get sheen(): NodeMaterialConnectionPoint;
  142894. /**
  142895. * Gets the clear coat object parameters
  142896. */
  142897. get clearcoat(): NodeMaterialConnectionPoint;
  142898. /**
  142899. * Gets the sub surface object parameters
  142900. */
  142901. get subsurface(): NodeMaterialConnectionPoint;
  142902. /**
  142903. * Gets the anisotropy object parameters
  142904. */
  142905. get anisotropy(): NodeMaterialConnectionPoint;
  142906. /**
  142907. * Gets the ambient output component
  142908. */
  142909. get ambient(): NodeMaterialConnectionPoint;
  142910. /**
  142911. * Gets the diffuse output component
  142912. */
  142913. get diffuse(): NodeMaterialConnectionPoint;
  142914. /**
  142915. * Gets the specular output component
  142916. */
  142917. get specular(): NodeMaterialConnectionPoint;
  142918. /**
  142919. * Gets the sheen output component
  142920. */
  142921. get sheenDir(): NodeMaterialConnectionPoint;
  142922. /**
  142923. * Gets the clear coat output component
  142924. */
  142925. get clearcoatDir(): NodeMaterialConnectionPoint;
  142926. /**
  142927. * Gets the indirect diffuse output component
  142928. */
  142929. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142930. /**
  142931. * Gets the indirect specular output component
  142932. */
  142933. get specularIndirect(): NodeMaterialConnectionPoint;
  142934. /**
  142935. * Gets the indirect sheen output component
  142936. */
  142937. get sheenIndirect(): NodeMaterialConnectionPoint;
  142938. /**
  142939. * Gets the indirect clear coat output component
  142940. */
  142941. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142942. /**
  142943. * Gets the refraction output component
  142944. */
  142945. get refraction(): NodeMaterialConnectionPoint;
  142946. /**
  142947. * Gets the global lighting output component
  142948. */
  142949. get lighting(): NodeMaterialConnectionPoint;
  142950. /**
  142951. * Gets the shadow output component
  142952. */
  142953. get shadow(): NodeMaterialConnectionPoint;
  142954. /**
  142955. * Gets the alpha output component
  142956. */
  142957. get alpha(): NodeMaterialConnectionPoint;
  142958. autoConfigure(material: NodeMaterial): void;
  142959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142960. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142962. private _injectVertexCode;
  142963. /**
  142964. * Gets the code corresponding to the albedo/opacity module
  142965. * @returns the shader code
  142966. */
  142967. getAlbedoOpacityCode(): string;
  142968. protected _buildBlock(state: NodeMaterialBuildState): this;
  142969. protected _dumpPropertiesCode(): string;
  142970. serialize(): any;
  142971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142972. }
  142973. }
  142974. declare module BABYLON {
  142975. /**
  142976. * Block used to compute value of one parameter modulo another
  142977. */
  142978. export class ModBlock extends NodeMaterialBlock {
  142979. /**
  142980. * Creates a new ModBlock
  142981. * @param name defines the block name
  142982. */
  142983. constructor(name: string);
  142984. /**
  142985. * Gets the current class name
  142986. * @returns the class name
  142987. */
  142988. getClassName(): string;
  142989. /**
  142990. * Gets the left operand input component
  142991. */
  142992. get left(): NodeMaterialConnectionPoint;
  142993. /**
  142994. * Gets the right operand input component
  142995. */
  142996. get right(): NodeMaterialConnectionPoint;
  142997. /**
  142998. * Gets the output component
  142999. */
  143000. get output(): NodeMaterialConnectionPoint;
  143001. protected _buildBlock(state: NodeMaterialBuildState): this;
  143002. }
  143003. }
  143004. declare module BABYLON {
  143005. /**
  143006. * Helper class to push actions to a pool of workers.
  143007. */
  143008. export class WorkerPool implements IDisposable {
  143009. private _workerInfos;
  143010. private _pendingActions;
  143011. /**
  143012. * Constructor
  143013. * @param workers Array of workers to use for actions
  143014. */
  143015. constructor(workers: Array<Worker>);
  143016. /**
  143017. * Terminates all workers and clears any pending actions.
  143018. */
  143019. dispose(): void;
  143020. /**
  143021. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143022. * pended until a worker has completed its action.
  143023. * @param action The action to perform. Call onComplete when the action is complete.
  143024. */
  143025. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143026. private _execute;
  143027. }
  143028. }
  143029. declare module BABYLON {
  143030. /**
  143031. * Configuration for Draco compression
  143032. */
  143033. export interface IDracoCompressionConfiguration {
  143034. /**
  143035. * Configuration for the decoder.
  143036. */
  143037. decoder: {
  143038. /**
  143039. * The url to the WebAssembly module.
  143040. */
  143041. wasmUrl?: string;
  143042. /**
  143043. * The url to the WebAssembly binary.
  143044. */
  143045. wasmBinaryUrl?: string;
  143046. /**
  143047. * The url to the fallback JavaScript module.
  143048. */
  143049. fallbackUrl?: string;
  143050. };
  143051. }
  143052. /**
  143053. * Draco compression (https://google.github.io/draco/)
  143054. *
  143055. * This class wraps the Draco module.
  143056. *
  143057. * **Encoder**
  143058. *
  143059. * The encoder is not currently implemented.
  143060. *
  143061. * **Decoder**
  143062. *
  143063. * 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.
  143064. *
  143065. * To update the configuration, use the following code:
  143066. * ```javascript
  143067. * DracoCompression.Configuration = {
  143068. * decoder: {
  143069. * wasmUrl: "<url to the WebAssembly library>",
  143070. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143071. * fallbackUrl: "<url to the fallback JavaScript library>",
  143072. * }
  143073. * };
  143074. * ```
  143075. *
  143076. * 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.
  143077. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143078. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143079. *
  143080. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143081. * ```javascript
  143082. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143083. * ```
  143084. *
  143085. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143086. */
  143087. export class DracoCompression implements IDisposable {
  143088. private _workerPoolPromise?;
  143089. private _decoderModulePromise?;
  143090. /**
  143091. * The configuration. Defaults to the following urls:
  143092. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143093. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143094. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143095. */
  143096. static Configuration: IDracoCompressionConfiguration;
  143097. /**
  143098. * Returns true if the decoder configuration is available.
  143099. */
  143100. static get DecoderAvailable(): boolean;
  143101. /**
  143102. * Default number of workers to create when creating the draco compression object.
  143103. */
  143104. static DefaultNumWorkers: number;
  143105. private static GetDefaultNumWorkers;
  143106. private static _Default;
  143107. /**
  143108. * Default instance for the draco compression object.
  143109. */
  143110. static get Default(): DracoCompression;
  143111. /**
  143112. * Constructor
  143113. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143114. */
  143115. constructor(numWorkers?: number);
  143116. /**
  143117. * Stop all async operations and release resources.
  143118. */
  143119. dispose(): void;
  143120. /**
  143121. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143122. * @returns a promise that resolves when ready
  143123. */
  143124. whenReadyAsync(): Promise<void>;
  143125. /**
  143126. * Decode Draco compressed mesh data to vertex data.
  143127. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143128. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143129. * @returns A promise that resolves with the decoded vertex data
  143130. */
  143131. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143132. [kind: string]: number;
  143133. }): Promise<VertexData>;
  143134. }
  143135. }
  143136. declare module BABYLON {
  143137. /**
  143138. * Class for building Constructive Solid Geometry
  143139. */
  143140. export class CSG {
  143141. private polygons;
  143142. /**
  143143. * The world matrix
  143144. */
  143145. matrix: Matrix;
  143146. /**
  143147. * Stores the position
  143148. */
  143149. position: Vector3;
  143150. /**
  143151. * Stores the rotation
  143152. */
  143153. rotation: Vector3;
  143154. /**
  143155. * Stores the rotation quaternion
  143156. */
  143157. rotationQuaternion: Nullable<Quaternion>;
  143158. /**
  143159. * Stores the scaling vector
  143160. */
  143161. scaling: Vector3;
  143162. /**
  143163. * Convert the Mesh to CSG
  143164. * @param mesh The Mesh to convert to CSG
  143165. * @returns A new CSG from the Mesh
  143166. */
  143167. static FromMesh(mesh: Mesh): CSG;
  143168. /**
  143169. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143170. * @param polygons Polygons used to construct a CSG solid
  143171. */
  143172. private static FromPolygons;
  143173. /**
  143174. * Clones, or makes a deep copy, of the CSG
  143175. * @returns A new CSG
  143176. */
  143177. clone(): CSG;
  143178. /**
  143179. * Unions this CSG with another CSG
  143180. * @param csg The CSG to union against this CSG
  143181. * @returns The unioned CSG
  143182. */
  143183. union(csg: CSG): CSG;
  143184. /**
  143185. * Unions this CSG with another CSG in place
  143186. * @param csg The CSG to union against this CSG
  143187. */
  143188. unionInPlace(csg: CSG): void;
  143189. /**
  143190. * Subtracts this CSG with another CSG
  143191. * @param csg The CSG to subtract against this CSG
  143192. * @returns A new CSG
  143193. */
  143194. subtract(csg: CSG): CSG;
  143195. /**
  143196. * Subtracts this CSG with another CSG in place
  143197. * @param csg The CSG to subtact against this CSG
  143198. */
  143199. subtractInPlace(csg: CSG): void;
  143200. /**
  143201. * Intersect this CSG with another CSG
  143202. * @param csg The CSG to intersect against this CSG
  143203. * @returns A new CSG
  143204. */
  143205. intersect(csg: CSG): CSG;
  143206. /**
  143207. * Intersects this CSG with another CSG in place
  143208. * @param csg The CSG to intersect against this CSG
  143209. */
  143210. intersectInPlace(csg: CSG): void;
  143211. /**
  143212. * Return a new CSG solid with solid and empty space switched. This solid is
  143213. * not modified.
  143214. * @returns A new CSG solid with solid and empty space switched
  143215. */
  143216. inverse(): CSG;
  143217. /**
  143218. * Inverses the CSG in place
  143219. */
  143220. inverseInPlace(): void;
  143221. /**
  143222. * This is used to keep meshes transformations so they can be restored
  143223. * when we build back a Babylon Mesh
  143224. * NB : All CSG operations are performed in world coordinates
  143225. * @param csg The CSG to copy the transform attributes from
  143226. * @returns This CSG
  143227. */
  143228. copyTransformAttributes(csg: CSG): CSG;
  143229. /**
  143230. * Build Raw mesh from CSG
  143231. * Coordinates here are in world space
  143232. * @param name The name of the mesh geometry
  143233. * @param scene The Scene
  143234. * @param keepSubMeshes Specifies if the submeshes should be kept
  143235. * @returns A new Mesh
  143236. */
  143237. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143238. /**
  143239. * Build Mesh from CSG taking material and transforms into account
  143240. * @param name The name of the Mesh
  143241. * @param material The material of the Mesh
  143242. * @param scene The Scene
  143243. * @param keepSubMeshes Specifies if submeshes should be kept
  143244. * @returns The new Mesh
  143245. */
  143246. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143247. }
  143248. }
  143249. declare module BABYLON {
  143250. /**
  143251. * Class used to create a trail following a mesh
  143252. */
  143253. export class TrailMesh extends Mesh {
  143254. private _generator;
  143255. private _autoStart;
  143256. private _running;
  143257. private _diameter;
  143258. private _length;
  143259. private _sectionPolygonPointsCount;
  143260. private _sectionVectors;
  143261. private _sectionNormalVectors;
  143262. private _beforeRenderObserver;
  143263. /**
  143264. * @constructor
  143265. * @param name The value used by scene.getMeshByName() to do a lookup.
  143266. * @param generator The mesh or transform node to generate a trail.
  143267. * @param scene The scene to add this mesh to.
  143268. * @param diameter Diameter of trailing mesh. Default is 1.
  143269. * @param length Length of trailing mesh. Default is 60.
  143270. * @param autoStart Automatically start trailing mesh. Default true.
  143271. */
  143272. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143273. /**
  143274. * "TrailMesh"
  143275. * @returns "TrailMesh"
  143276. */
  143277. getClassName(): string;
  143278. private _createMesh;
  143279. /**
  143280. * Start trailing mesh.
  143281. */
  143282. start(): void;
  143283. /**
  143284. * Stop trailing mesh.
  143285. */
  143286. stop(): void;
  143287. /**
  143288. * Update trailing mesh geometry.
  143289. */
  143290. update(): void;
  143291. /**
  143292. * Returns a new TrailMesh object.
  143293. * @param name is a string, the name given to the new mesh
  143294. * @param newGenerator use new generator object for cloned trail mesh
  143295. * @returns a new mesh
  143296. */
  143297. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143298. /**
  143299. * Serializes this trail mesh
  143300. * @param serializationObject object to write serialization to
  143301. */
  143302. serialize(serializationObject: any): void;
  143303. /**
  143304. * Parses a serialized trail mesh
  143305. * @param parsedMesh the serialized mesh
  143306. * @param scene the scene to create the trail mesh in
  143307. * @returns the created trail mesh
  143308. */
  143309. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  143310. }
  143311. }
  143312. declare module BABYLON {
  143313. /**
  143314. * Class containing static functions to help procedurally build meshes
  143315. */
  143316. export class TiledBoxBuilder {
  143317. /**
  143318. * Creates a box mesh
  143319. * 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)
  143320. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143324. * @param name defines the name of the mesh
  143325. * @param options defines the options used to create the mesh
  143326. * @param scene defines the hosting scene
  143327. * @returns the box mesh
  143328. */
  143329. static CreateTiledBox(name: string, options: {
  143330. pattern?: number;
  143331. width?: number;
  143332. height?: number;
  143333. depth?: number;
  143334. tileSize?: number;
  143335. tileWidth?: number;
  143336. tileHeight?: number;
  143337. alignHorizontal?: number;
  143338. alignVertical?: number;
  143339. faceUV?: Vector4[];
  143340. faceColors?: Color4[];
  143341. sideOrientation?: number;
  143342. updatable?: boolean;
  143343. }, scene?: Nullable<Scene>): Mesh;
  143344. }
  143345. }
  143346. declare module BABYLON {
  143347. /**
  143348. * Class containing static functions to help procedurally build meshes
  143349. */
  143350. export class TorusKnotBuilder {
  143351. /**
  143352. * Creates a torus knot mesh
  143353. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143354. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143355. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143356. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143360. * @param name defines the name of the mesh
  143361. * @param options defines the options used to create the mesh
  143362. * @param scene defines the hosting scene
  143363. * @returns the torus knot mesh
  143364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143365. */
  143366. static CreateTorusKnot(name: string, options: {
  143367. radius?: number;
  143368. tube?: number;
  143369. radialSegments?: number;
  143370. tubularSegments?: number;
  143371. p?: number;
  143372. q?: number;
  143373. updatable?: boolean;
  143374. sideOrientation?: number;
  143375. frontUVs?: Vector4;
  143376. backUVs?: Vector4;
  143377. }, scene: any): Mesh;
  143378. }
  143379. }
  143380. declare module BABYLON {
  143381. /**
  143382. * Polygon
  143383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  143384. */
  143385. export class Polygon {
  143386. /**
  143387. * Creates a rectangle
  143388. * @param xmin bottom X coord
  143389. * @param ymin bottom Y coord
  143390. * @param xmax top X coord
  143391. * @param ymax top Y coord
  143392. * @returns points that make the resulting rectation
  143393. */
  143394. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  143395. /**
  143396. * Creates a circle
  143397. * @param radius radius of circle
  143398. * @param cx scale in x
  143399. * @param cy scale in y
  143400. * @param numberOfSides number of sides that make up the circle
  143401. * @returns points that make the resulting circle
  143402. */
  143403. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  143404. /**
  143405. * Creates a polygon from input string
  143406. * @param input Input polygon data
  143407. * @returns the parsed points
  143408. */
  143409. static Parse(input: string): Vector2[];
  143410. /**
  143411. * Starts building a polygon from x and y coordinates
  143412. * @param x x coordinate
  143413. * @param y y coordinate
  143414. * @returns the started path2
  143415. */
  143416. static StartingAt(x: number, y: number): Path2;
  143417. }
  143418. /**
  143419. * Builds a polygon
  143420. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  143421. */
  143422. export class PolygonMeshBuilder {
  143423. private _points;
  143424. private _outlinepoints;
  143425. private _holes;
  143426. private _name;
  143427. private _scene;
  143428. private _epoints;
  143429. private _eholes;
  143430. private _addToepoint;
  143431. /**
  143432. * Babylon reference to the earcut plugin.
  143433. */
  143434. bjsEarcut: any;
  143435. /**
  143436. * Creates a PolygonMeshBuilder
  143437. * @param name name of the builder
  143438. * @param contours Path of the polygon
  143439. * @param scene scene to add to when creating the mesh
  143440. * @param earcutInjection can be used to inject your own earcut reference
  143441. */
  143442. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  143443. /**
  143444. * Adds a whole within the polygon
  143445. * @param hole Array of points defining the hole
  143446. * @returns this
  143447. */
  143448. addHole(hole: Vector2[]): PolygonMeshBuilder;
  143449. /**
  143450. * Creates the polygon
  143451. * @param updatable If the mesh should be updatable
  143452. * @param depth The depth of the mesh created
  143453. * @returns the created mesh
  143454. */
  143455. build(updatable?: boolean, depth?: number): Mesh;
  143456. /**
  143457. * Creates the polygon
  143458. * @param depth The depth of the mesh created
  143459. * @returns the created VertexData
  143460. */
  143461. buildVertexData(depth?: number): VertexData;
  143462. /**
  143463. * Adds a side to the polygon
  143464. * @param positions points that make the polygon
  143465. * @param normals normals of the polygon
  143466. * @param uvs uvs of the polygon
  143467. * @param indices indices of the polygon
  143468. * @param bounds bounds of the polygon
  143469. * @param points points of the polygon
  143470. * @param depth depth of the polygon
  143471. * @param flip flip of the polygon
  143472. */
  143473. private addSide;
  143474. }
  143475. }
  143476. declare module BABYLON {
  143477. /**
  143478. * Class containing static functions to help procedurally build meshes
  143479. */
  143480. export class PolygonBuilder {
  143481. /**
  143482. * Creates a polygon mesh
  143483. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143484. * * 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
  143485. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143488. * * Remember you can only change the shape positions, not their number when updating a polygon
  143489. * @param name defines the name of the mesh
  143490. * @param options defines the options used to create the mesh
  143491. * @param scene defines the hosting scene
  143492. * @param earcutInjection can be used to inject your own earcut reference
  143493. * @returns the polygon mesh
  143494. */
  143495. static CreatePolygon(name: string, options: {
  143496. shape: Vector3[];
  143497. holes?: Vector3[][];
  143498. depth?: number;
  143499. faceUV?: Vector4[];
  143500. faceColors?: Color4[];
  143501. updatable?: boolean;
  143502. sideOrientation?: number;
  143503. frontUVs?: Vector4;
  143504. backUVs?: Vector4;
  143505. wrap?: boolean;
  143506. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143507. /**
  143508. * Creates an extruded polygon mesh, with depth in the Y direction.
  143509. * * 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)
  143510. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143511. * @param name defines the name of the mesh
  143512. * @param options defines the options used to create the mesh
  143513. * @param scene defines the hosting scene
  143514. * @param earcutInjection can be used to inject your own earcut reference
  143515. * @returns the polygon mesh
  143516. */
  143517. static ExtrudePolygon(name: string, options: {
  143518. shape: Vector3[];
  143519. holes?: Vector3[][];
  143520. depth?: number;
  143521. faceUV?: Vector4[];
  143522. faceColors?: Color4[];
  143523. updatable?: boolean;
  143524. sideOrientation?: number;
  143525. frontUVs?: Vector4;
  143526. backUVs?: Vector4;
  143527. wrap?: boolean;
  143528. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143529. }
  143530. }
  143531. declare module BABYLON {
  143532. /**
  143533. * Class containing static functions to help procedurally build meshes
  143534. */
  143535. export class LatheBuilder {
  143536. /**
  143537. * Creates lathe mesh.
  143538. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143539. * * 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
  143540. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143541. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143542. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143543. * * 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
  143544. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143545. * * 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
  143546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143550. * @param name defines the name of the mesh
  143551. * @param options defines the options used to create the mesh
  143552. * @param scene defines the hosting scene
  143553. * @returns the lathe mesh
  143554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143555. */
  143556. static CreateLathe(name: string, options: {
  143557. shape: Vector3[];
  143558. radius?: number;
  143559. tessellation?: number;
  143560. clip?: number;
  143561. arc?: number;
  143562. closed?: boolean;
  143563. updatable?: boolean;
  143564. sideOrientation?: number;
  143565. frontUVs?: Vector4;
  143566. backUVs?: Vector4;
  143567. cap?: number;
  143568. invertUV?: boolean;
  143569. }, scene?: Nullable<Scene>): Mesh;
  143570. }
  143571. }
  143572. declare module BABYLON {
  143573. /**
  143574. * Class containing static functions to help procedurally build meshes
  143575. */
  143576. export class TiledPlaneBuilder {
  143577. /**
  143578. * Creates a tiled plane mesh
  143579. * * The parameter `pattern` will, depending on value, do nothing or
  143580. * * * flip (reflect about central vertical) alternate tiles across and up
  143581. * * * flip every tile on alternate rows
  143582. * * * rotate (180 degs) alternate tiles across and up
  143583. * * * rotate every tile on alternate rows
  143584. * * * flip and rotate alternate tiles across and up
  143585. * * * flip and rotate every tile on alternate rows
  143586. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  143587. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  143588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143590. * * 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)
  143591. * * 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)
  143592. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143593. * @param name defines the name of the mesh
  143594. * @param options defines the options used to create the mesh
  143595. * @param scene defines the hosting scene
  143596. * @returns the box mesh
  143597. */
  143598. static CreateTiledPlane(name: string, options: {
  143599. pattern?: number;
  143600. tileSize?: number;
  143601. tileWidth?: number;
  143602. tileHeight?: number;
  143603. size?: number;
  143604. width?: number;
  143605. height?: number;
  143606. alignHorizontal?: number;
  143607. alignVertical?: number;
  143608. sideOrientation?: number;
  143609. frontUVs?: Vector4;
  143610. backUVs?: Vector4;
  143611. updatable?: boolean;
  143612. }, scene?: Nullable<Scene>): Mesh;
  143613. }
  143614. }
  143615. declare module BABYLON {
  143616. /**
  143617. * Class containing static functions to help procedurally build meshes
  143618. */
  143619. export class TubeBuilder {
  143620. /**
  143621. * Creates a tube mesh.
  143622. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143623. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143624. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143625. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143626. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143627. * * 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)
  143628. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143629. * * 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
  143630. * * 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
  143631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143635. * @param name defines the name of the mesh
  143636. * @param options defines the options used to create the mesh
  143637. * @param scene defines the hosting scene
  143638. * @returns the tube mesh
  143639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143640. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143641. */
  143642. static CreateTube(name: string, options: {
  143643. path: Vector3[];
  143644. radius?: number;
  143645. tessellation?: number;
  143646. radiusFunction?: {
  143647. (i: number, distance: number): number;
  143648. };
  143649. cap?: number;
  143650. arc?: number;
  143651. updatable?: boolean;
  143652. sideOrientation?: number;
  143653. frontUVs?: Vector4;
  143654. backUVs?: Vector4;
  143655. instance?: Mesh;
  143656. invertUV?: boolean;
  143657. }, scene?: Nullable<Scene>): Mesh;
  143658. }
  143659. }
  143660. declare module BABYLON {
  143661. /**
  143662. * Class containing static functions to help procedurally build meshes
  143663. */
  143664. export class IcoSphereBuilder {
  143665. /**
  143666. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143667. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143668. * * 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`)
  143669. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143670. * * 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
  143671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143674. * @param name defines the name of the mesh
  143675. * @param options defines the options used to create the mesh
  143676. * @param scene defines the hosting scene
  143677. * @returns the icosahedron mesh
  143678. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143679. */
  143680. static CreateIcoSphere(name: string, options: {
  143681. radius?: number;
  143682. radiusX?: number;
  143683. radiusY?: number;
  143684. radiusZ?: number;
  143685. flat?: boolean;
  143686. subdivisions?: number;
  143687. sideOrientation?: number;
  143688. frontUVs?: Vector4;
  143689. backUVs?: Vector4;
  143690. updatable?: boolean;
  143691. }, scene?: Nullable<Scene>): Mesh;
  143692. }
  143693. }
  143694. declare module BABYLON {
  143695. /**
  143696. * Class containing static functions to help procedurally build meshes
  143697. */
  143698. export class DecalBuilder {
  143699. /**
  143700. * Creates a decal mesh.
  143701. * 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
  143702. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143703. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143704. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143705. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143706. * @param name defines the name of the mesh
  143707. * @param sourceMesh defines the mesh where the decal must be applied
  143708. * @param options defines the options used to create the mesh
  143709. * @param scene defines the hosting scene
  143710. * @returns the decal mesh
  143711. * @see https://doc.babylonjs.com/how_to/decals
  143712. */
  143713. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143714. position?: Vector3;
  143715. normal?: Vector3;
  143716. size?: Vector3;
  143717. angle?: number;
  143718. }): Mesh;
  143719. }
  143720. }
  143721. declare module BABYLON {
  143722. /**
  143723. * Class containing static functions to help procedurally build meshes
  143724. */
  143725. export class MeshBuilder {
  143726. /**
  143727. * Creates a box mesh
  143728. * * The parameter `size` sets the size (float) of each box side (default 1)
  143729. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  143730. * * 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)
  143731. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143735. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143736. * @param name defines the name of the mesh
  143737. * @param options defines the options used to create the mesh
  143738. * @param scene defines the hosting scene
  143739. * @returns the box mesh
  143740. */
  143741. static CreateBox(name: string, options: {
  143742. size?: number;
  143743. width?: number;
  143744. height?: number;
  143745. depth?: number;
  143746. faceUV?: Vector4[];
  143747. faceColors?: Color4[];
  143748. sideOrientation?: number;
  143749. frontUVs?: Vector4;
  143750. backUVs?: Vector4;
  143751. wrap?: boolean;
  143752. topBaseAt?: number;
  143753. bottomBaseAt?: number;
  143754. updatable?: boolean;
  143755. }, scene?: Nullable<Scene>): Mesh;
  143756. /**
  143757. * Creates a tiled box mesh
  143758. * * faceTiles sets the pattern, tile size and number of tiles for a face
  143759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143760. * @param name defines the name of the mesh
  143761. * @param options defines the options used to create the mesh
  143762. * @param scene defines the hosting scene
  143763. * @returns the tiled box mesh
  143764. */
  143765. static CreateTiledBox(name: string, options: {
  143766. pattern?: number;
  143767. size?: number;
  143768. width?: number;
  143769. height?: number;
  143770. depth: number;
  143771. tileSize?: number;
  143772. tileWidth?: number;
  143773. tileHeight?: number;
  143774. faceUV?: Vector4[];
  143775. faceColors?: Color4[];
  143776. alignHorizontal?: number;
  143777. alignVertical?: number;
  143778. sideOrientation?: number;
  143779. updatable?: boolean;
  143780. }, scene?: Nullable<Scene>): Mesh;
  143781. /**
  143782. * Creates a sphere mesh
  143783. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143784. * * 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`)
  143785. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143786. * * 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
  143787. * * 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)
  143788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143791. * @param name defines the name of the mesh
  143792. * @param options defines the options used to create the mesh
  143793. * @param scene defines the hosting scene
  143794. * @returns the sphere mesh
  143795. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143796. */
  143797. static CreateSphere(name: string, options: {
  143798. segments?: number;
  143799. diameter?: number;
  143800. diameterX?: number;
  143801. diameterY?: number;
  143802. diameterZ?: number;
  143803. arc?: number;
  143804. slice?: number;
  143805. sideOrientation?: number;
  143806. frontUVs?: Vector4;
  143807. backUVs?: Vector4;
  143808. updatable?: boolean;
  143809. }, scene?: Nullable<Scene>): Mesh;
  143810. /**
  143811. * Creates a plane polygonal mesh. By default, this is a disc
  143812. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143813. * * 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
  143814. * * 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
  143815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143818. * @param name defines the name of the mesh
  143819. * @param options defines the options used to create the mesh
  143820. * @param scene defines the hosting scene
  143821. * @returns the plane polygonal mesh
  143822. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143823. */
  143824. static CreateDisc(name: string, options: {
  143825. radius?: number;
  143826. tessellation?: number;
  143827. arc?: number;
  143828. updatable?: boolean;
  143829. sideOrientation?: number;
  143830. frontUVs?: Vector4;
  143831. backUVs?: Vector4;
  143832. }, scene?: Nullable<Scene>): Mesh;
  143833. /**
  143834. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143835. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143836. * * 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`)
  143837. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143838. * * 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
  143839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143842. * @param name defines the name of the mesh
  143843. * @param options defines the options used to create the mesh
  143844. * @param scene defines the hosting scene
  143845. * @returns the icosahedron mesh
  143846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143847. */
  143848. static CreateIcoSphere(name: string, options: {
  143849. radius?: number;
  143850. radiusX?: number;
  143851. radiusY?: number;
  143852. radiusZ?: number;
  143853. flat?: boolean;
  143854. subdivisions?: number;
  143855. sideOrientation?: number;
  143856. frontUVs?: Vector4;
  143857. backUVs?: Vector4;
  143858. updatable?: boolean;
  143859. }, scene?: Nullable<Scene>): Mesh;
  143860. /**
  143861. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143862. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143863. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143864. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143865. * * 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
  143866. * * 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
  143867. * * 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
  143868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143871. * * 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
  143872. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143873. * * 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
  143874. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143876. * @param name defines the name of the mesh
  143877. * @param options defines the options used to create the mesh
  143878. * @param scene defines the hosting scene
  143879. * @returns the ribbon mesh
  143880. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143882. */
  143883. static CreateRibbon(name: string, options: {
  143884. pathArray: Vector3[][];
  143885. closeArray?: boolean;
  143886. closePath?: boolean;
  143887. offset?: number;
  143888. updatable?: boolean;
  143889. sideOrientation?: number;
  143890. frontUVs?: Vector4;
  143891. backUVs?: Vector4;
  143892. instance?: Mesh;
  143893. invertUV?: boolean;
  143894. uvs?: Vector2[];
  143895. colors?: Color4[];
  143896. }, scene?: Nullable<Scene>): Mesh;
  143897. /**
  143898. * Creates a cylinder or a cone mesh
  143899. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143900. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143901. * * 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.
  143902. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143903. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143904. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143905. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143906. * * 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).
  143907. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143908. * * 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).
  143909. * * 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
  143910. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143911. * * 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
  143912. * * 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.
  143913. * * If `enclose` is false, a ring surface is one element.
  143914. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143915. * * 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
  143916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143919. * @param name defines the name of the mesh
  143920. * @param options defines the options used to create the mesh
  143921. * @param scene defines the hosting scene
  143922. * @returns the cylinder mesh
  143923. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143924. */
  143925. static CreateCylinder(name: string, options: {
  143926. height?: number;
  143927. diameterTop?: number;
  143928. diameterBottom?: number;
  143929. diameter?: number;
  143930. tessellation?: number;
  143931. subdivisions?: number;
  143932. arc?: number;
  143933. faceColors?: Color4[];
  143934. faceUV?: Vector4[];
  143935. updatable?: boolean;
  143936. hasRings?: boolean;
  143937. enclose?: boolean;
  143938. cap?: number;
  143939. sideOrientation?: number;
  143940. frontUVs?: Vector4;
  143941. backUVs?: Vector4;
  143942. }, scene?: Nullable<Scene>): Mesh;
  143943. /**
  143944. * Creates a torus mesh
  143945. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143946. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143947. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143951. * @param name defines the name of the mesh
  143952. * @param options defines the options used to create the mesh
  143953. * @param scene defines the hosting scene
  143954. * @returns the torus mesh
  143955. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143956. */
  143957. static CreateTorus(name: string, options: {
  143958. diameter?: number;
  143959. thickness?: number;
  143960. tessellation?: number;
  143961. updatable?: boolean;
  143962. sideOrientation?: number;
  143963. frontUVs?: Vector4;
  143964. backUVs?: Vector4;
  143965. }, scene?: Nullable<Scene>): Mesh;
  143966. /**
  143967. * Creates a torus knot mesh
  143968. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143969. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143970. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143971. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143975. * @param name defines the name of the mesh
  143976. * @param options defines the options used to create the mesh
  143977. * @param scene defines the hosting scene
  143978. * @returns the torus knot mesh
  143979. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143980. */
  143981. static CreateTorusKnot(name: string, options: {
  143982. radius?: number;
  143983. tube?: number;
  143984. radialSegments?: number;
  143985. tubularSegments?: number;
  143986. p?: number;
  143987. q?: number;
  143988. updatable?: boolean;
  143989. sideOrientation?: number;
  143990. frontUVs?: Vector4;
  143991. backUVs?: Vector4;
  143992. }, scene?: Nullable<Scene>): Mesh;
  143993. /**
  143994. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143995. * * 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
  143996. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143997. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143998. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143999. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144000. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144001. * * 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
  144002. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144005. * @param name defines the name of the new line system
  144006. * @param options defines the options used to create the line system
  144007. * @param scene defines the hosting scene
  144008. * @returns a new line system mesh
  144009. */
  144010. static CreateLineSystem(name: string, options: {
  144011. lines: Vector3[][];
  144012. updatable?: boolean;
  144013. instance?: Nullable<LinesMesh>;
  144014. colors?: Nullable<Color4[][]>;
  144015. useVertexAlpha?: boolean;
  144016. }, scene: Nullable<Scene>): LinesMesh;
  144017. /**
  144018. * Creates a line mesh
  144019. * 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
  144020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144021. * * The parameter `points` is an array successive Vector3
  144022. * * 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
  144023. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144025. * * When updating an instance, remember that only point positions can change, not the number of points
  144026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144028. * @param name defines the name of the new line system
  144029. * @param options defines the options used to create the line system
  144030. * @param scene defines the hosting scene
  144031. * @returns a new line mesh
  144032. */
  144033. static CreateLines(name: string, options: {
  144034. points: Vector3[];
  144035. updatable?: boolean;
  144036. instance?: Nullable<LinesMesh>;
  144037. colors?: Color4[];
  144038. useVertexAlpha?: boolean;
  144039. }, scene?: Nullable<Scene>): LinesMesh;
  144040. /**
  144041. * Creates a dashed line mesh
  144042. * * 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
  144043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144044. * * The parameter `points` is an array successive Vector3
  144045. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144046. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144047. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144048. * * 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
  144049. * * When updating an instance, remember that only point positions can change, not the number of points
  144050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144051. * @param name defines the name of the mesh
  144052. * @param options defines the options used to create the mesh
  144053. * @param scene defines the hosting scene
  144054. * @returns the dashed line mesh
  144055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144056. */
  144057. static CreateDashedLines(name: string, options: {
  144058. points: Vector3[];
  144059. dashSize?: number;
  144060. gapSize?: number;
  144061. dashNb?: number;
  144062. updatable?: boolean;
  144063. instance?: LinesMesh;
  144064. }, scene?: Nullable<Scene>): LinesMesh;
  144065. /**
  144066. * 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.
  144067. * * 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.
  144068. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144069. * * 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.
  144070. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144071. * * 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
  144072. * * 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
  144073. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144078. * @param name defines the name of the mesh
  144079. * @param options defines the options used to create the mesh
  144080. * @param scene defines the hosting scene
  144081. * @returns the extruded shape mesh
  144082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144084. */
  144085. static ExtrudeShape(name: string, options: {
  144086. shape: Vector3[];
  144087. path: Vector3[];
  144088. scale?: number;
  144089. rotation?: number;
  144090. cap?: number;
  144091. updatable?: boolean;
  144092. sideOrientation?: number;
  144093. frontUVs?: Vector4;
  144094. backUVs?: Vector4;
  144095. instance?: Mesh;
  144096. invertUV?: boolean;
  144097. }, scene?: Nullable<Scene>): Mesh;
  144098. /**
  144099. * Creates an custom extruded shape mesh.
  144100. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144101. * * 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.
  144102. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144103. * * 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
  144104. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144105. * * 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
  144106. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144107. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144108. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144109. * * 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
  144110. * * 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
  144111. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144116. * @param name defines the name of the mesh
  144117. * @param options defines the options used to create the mesh
  144118. * @param scene defines the hosting scene
  144119. * @returns the custom extruded shape mesh
  144120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144123. */
  144124. static ExtrudeShapeCustom(name: string, options: {
  144125. shape: Vector3[];
  144126. path: Vector3[];
  144127. scaleFunction?: any;
  144128. rotationFunction?: any;
  144129. ribbonCloseArray?: boolean;
  144130. ribbonClosePath?: boolean;
  144131. cap?: number;
  144132. updatable?: boolean;
  144133. sideOrientation?: number;
  144134. frontUVs?: Vector4;
  144135. backUVs?: Vector4;
  144136. instance?: Mesh;
  144137. invertUV?: boolean;
  144138. }, scene?: Nullable<Scene>): Mesh;
  144139. /**
  144140. * Creates lathe mesh.
  144141. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144142. * * 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
  144143. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144144. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144145. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144146. * * 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
  144147. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144148. * * 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
  144149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144153. * @param name defines the name of the mesh
  144154. * @param options defines the options used to create the mesh
  144155. * @param scene defines the hosting scene
  144156. * @returns the lathe mesh
  144157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144158. */
  144159. static CreateLathe(name: string, options: {
  144160. shape: Vector3[];
  144161. radius?: number;
  144162. tessellation?: number;
  144163. clip?: number;
  144164. arc?: number;
  144165. closed?: boolean;
  144166. updatable?: boolean;
  144167. sideOrientation?: number;
  144168. frontUVs?: Vector4;
  144169. backUVs?: Vector4;
  144170. cap?: number;
  144171. invertUV?: boolean;
  144172. }, scene?: Nullable<Scene>): Mesh;
  144173. /**
  144174. * Creates a tiled plane mesh
  144175. * * You can set a limited pattern arrangement with the tiles
  144176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144179. * @param name defines the name of the mesh
  144180. * @param options defines the options used to create the mesh
  144181. * @param scene defines the hosting scene
  144182. * @returns the plane mesh
  144183. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144184. */
  144185. static CreateTiledPlane(name: string, options: {
  144186. pattern?: number;
  144187. tileSize?: number;
  144188. tileWidth?: number;
  144189. tileHeight?: number;
  144190. size?: number;
  144191. width?: number;
  144192. height?: number;
  144193. alignHorizontal?: number;
  144194. alignVertical?: number;
  144195. sideOrientation?: number;
  144196. frontUVs?: Vector4;
  144197. backUVs?: Vector4;
  144198. updatable?: boolean;
  144199. }, scene?: Nullable<Scene>): Mesh;
  144200. /**
  144201. * Creates a plane mesh
  144202. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144203. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144204. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144208. * @param name defines the name of the mesh
  144209. * @param options defines the options used to create the mesh
  144210. * @param scene defines the hosting scene
  144211. * @returns the plane mesh
  144212. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144213. */
  144214. static CreatePlane(name: string, options: {
  144215. size?: number;
  144216. width?: number;
  144217. height?: number;
  144218. sideOrientation?: number;
  144219. frontUVs?: Vector4;
  144220. backUVs?: Vector4;
  144221. updatable?: boolean;
  144222. sourcePlane?: Plane;
  144223. }, scene?: Nullable<Scene>): Mesh;
  144224. /**
  144225. * Creates a ground mesh
  144226. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144227. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144229. * @param name defines the name of the mesh
  144230. * @param options defines the options used to create the mesh
  144231. * @param scene defines the hosting scene
  144232. * @returns the ground mesh
  144233. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144234. */
  144235. static CreateGround(name: string, options: {
  144236. width?: number;
  144237. height?: number;
  144238. subdivisions?: number;
  144239. subdivisionsX?: number;
  144240. subdivisionsY?: number;
  144241. updatable?: boolean;
  144242. }, scene?: Nullable<Scene>): Mesh;
  144243. /**
  144244. * Creates a tiled ground mesh
  144245. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144246. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144247. * * 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
  144248. * * 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
  144249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144250. * @param name defines the name of the mesh
  144251. * @param options defines the options used to create the mesh
  144252. * @param scene defines the hosting scene
  144253. * @returns the tiled ground mesh
  144254. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144255. */
  144256. static CreateTiledGround(name: string, options: {
  144257. xmin: number;
  144258. zmin: number;
  144259. xmax: number;
  144260. zmax: number;
  144261. subdivisions?: {
  144262. w: number;
  144263. h: number;
  144264. };
  144265. precision?: {
  144266. w: number;
  144267. h: number;
  144268. };
  144269. updatable?: boolean;
  144270. }, scene?: Nullable<Scene>): Mesh;
  144271. /**
  144272. * Creates a ground mesh from a height map
  144273. * * The parameter `url` sets the URL of the height map image resource.
  144274. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144275. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144276. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144277. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144278. * * 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.
  144279. * * 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).
  144280. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144282. * @param name defines the name of the mesh
  144283. * @param url defines the url to the height map
  144284. * @param options defines the options used to create the mesh
  144285. * @param scene defines the hosting scene
  144286. * @returns the ground mesh
  144287. * @see https://doc.babylonjs.com/babylon101/height_map
  144288. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144289. */
  144290. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144291. width?: number;
  144292. height?: number;
  144293. subdivisions?: number;
  144294. minHeight?: number;
  144295. maxHeight?: number;
  144296. colorFilter?: Color3;
  144297. alphaFilter?: number;
  144298. updatable?: boolean;
  144299. onReady?: (mesh: GroundMesh) => void;
  144300. }, scene?: Nullable<Scene>): GroundMesh;
  144301. /**
  144302. * Creates a polygon mesh
  144303. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144304. * * 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
  144305. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144308. * * Remember you can only change the shape positions, not their number when updating a polygon
  144309. * @param name defines the name of the mesh
  144310. * @param options defines the options used to create the mesh
  144311. * @param scene defines the hosting scene
  144312. * @param earcutInjection can be used to inject your own earcut reference
  144313. * @returns the polygon mesh
  144314. */
  144315. static CreatePolygon(name: string, options: {
  144316. shape: Vector3[];
  144317. holes?: Vector3[][];
  144318. depth?: number;
  144319. faceUV?: Vector4[];
  144320. faceColors?: Color4[];
  144321. updatable?: boolean;
  144322. sideOrientation?: number;
  144323. frontUVs?: Vector4;
  144324. backUVs?: Vector4;
  144325. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144326. /**
  144327. * Creates an extruded polygon mesh, with depth in the Y direction.
  144328. * * 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)
  144329. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144330. * @param name defines the name of the mesh
  144331. * @param options defines the options used to create the mesh
  144332. * @param scene defines the hosting scene
  144333. * @param earcutInjection can be used to inject your own earcut reference
  144334. * @returns the polygon mesh
  144335. */
  144336. static ExtrudePolygon(name: string, options: {
  144337. shape: Vector3[];
  144338. holes?: Vector3[][];
  144339. depth?: number;
  144340. faceUV?: Vector4[];
  144341. faceColors?: Color4[];
  144342. updatable?: boolean;
  144343. sideOrientation?: number;
  144344. frontUVs?: Vector4;
  144345. backUVs?: Vector4;
  144346. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144347. /**
  144348. * Creates a tube mesh.
  144349. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144350. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144351. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144352. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144353. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144354. * * 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)
  144355. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144356. * * 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
  144357. * * 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
  144358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144362. * @param name defines the name of the mesh
  144363. * @param options defines the options used to create the mesh
  144364. * @param scene defines the hosting scene
  144365. * @returns the tube mesh
  144366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144367. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144368. */
  144369. static CreateTube(name: string, options: {
  144370. path: Vector3[];
  144371. radius?: number;
  144372. tessellation?: number;
  144373. radiusFunction?: {
  144374. (i: number, distance: number): number;
  144375. };
  144376. cap?: number;
  144377. arc?: number;
  144378. updatable?: boolean;
  144379. sideOrientation?: number;
  144380. frontUVs?: Vector4;
  144381. backUVs?: Vector4;
  144382. instance?: Mesh;
  144383. invertUV?: boolean;
  144384. }, scene?: Nullable<Scene>): Mesh;
  144385. /**
  144386. * Creates a polyhedron mesh
  144387. * * 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
  144388. * * The parameter `size` (positive float, default 1) sets the polygon size
  144389. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  144390. * * 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`
  144391. * * 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
  144392. * * 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)`)
  144393. * * 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
  144394. * * 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
  144395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144398. * @param name defines the name of the mesh
  144399. * @param options defines the options used to create the mesh
  144400. * @param scene defines the hosting scene
  144401. * @returns the polyhedron mesh
  144402. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  144403. */
  144404. static CreatePolyhedron(name: string, options: {
  144405. type?: number;
  144406. size?: number;
  144407. sizeX?: number;
  144408. sizeY?: number;
  144409. sizeZ?: number;
  144410. custom?: any;
  144411. faceUV?: Vector4[];
  144412. faceColors?: Color4[];
  144413. flat?: boolean;
  144414. updatable?: boolean;
  144415. sideOrientation?: number;
  144416. frontUVs?: Vector4;
  144417. backUVs?: Vector4;
  144418. }, scene?: Nullable<Scene>): Mesh;
  144419. /**
  144420. * Creates a decal mesh.
  144421. * 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
  144422. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144423. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144424. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144425. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144426. * @param name defines the name of the mesh
  144427. * @param sourceMesh defines the mesh where the decal must be applied
  144428. * @param options defines the options used to create the mesh
  144429. * @param scene defines the hosting scene
  144430. * @returns the decal mesh
  144431. * @see https://doc.babylonjs.com/how_to/decals
  144432. */
  144433. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144434. position?: Vector3;
  144435. normal?: Vector3;
  144436. size?: Vector3;
  144437. angle?: number;
  144438. }): Mesh;
  144439. }
  144440. }
  144441. declare module BABYLON {
  144442. /**
  144443. * A simplifier interface for future simplification implementations
  144444. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144445. */
  144446. export interface ISimplifier {
  144447. /**
  144448. * Simplification of a given mesh according to the given settings.
  144449. * Since this requires computation, it is assumed that the function runs async.
  144450. * @param settings The settings of the simplification, including quality and distance
  144451. * @param successCallback A callback that will be called after the mesh was simplified.
  144452. * @param errorCallback in case of an error, this callback will be called. optional.
  144453. */
  144454. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  144455. }
  144456. /**
  144457. * Expected simplification settings.
  144458. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  144459. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144460. */
  144461. export interface ISimplificationSettings {
  144462. /**
  144463. * Gets or sets the expected quality
  144464. */
  144465. quality: number;
  144466. /**
  144467. * Gets or sets the distance when this optimized version should be used
  144468. */
  144469. distance: number;
  144470. /**
  144471. * Gets an already optimized mesh
  144472. */
  144473. optimizeMesh?: boolean;
  144474. }
  144475. /**
  144476. * Class used to specify simplification options
  144477. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144478. */
  144479. export class SimplificationSettings implements ISimplificationSettings {
  144480. /** expected quality */
  144481. quality: number;
  144482. /** distance when this optimized version should be used */
  144483. distance: number;
  144484. /** already optimized mesh */
  144485. optimizeMesh?: boolean | undefined;
  144486. /**
  144487. * Creates a SimplificationSettings
  144488. * @param quality expected quality
  144489. * @param distance distance when this optimized version should be used
  144490. * @param optimizeMesh already optimized mesh
  144491. */
  144492. constructor(
  144493. /** expected quality */
  144494. quality: number,
  144495. /** distance when this optimized version should be used */
  144496. distance: number,
  144497. /** already optimized mesh */
  144498. optimizeMesh?: boolean | undefined);
  144499. }
  144500. /**
  144501. * Interface used to define a simplification task
  144502. */
  144503. export interface ISimplificationTask {
  144504. /**
  144505. * Array of settings
  144506. */
  144507. settings: Array<ISimplificationSettings>;
  144508. /**
  144509. * Simplification type
  144510. */
  144511. simplificationType: SimplificationType;
  144512. /**
  144513. * Mesh to simplify
  144514. */
  144515. mesh: Mesh;
  144516. /**
  144517. * Callback called on success
  144518. */
  144519. successCallback?: () => void;
  144520. /**
  144521. * Defines if parallel processing can be used
  144522. */
  144523. parallelProcessing: boolean;
  144524. }
  144525. /**
  144526. * Queue used to order the simplification tasks
  144527. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144528. */
  144529. export class SimplificationQueue {
  144530. private _simplificationArray;
  144531. /**
  144532. * Gets a boolean indicating that the process is still running
  144533. */
  144534. running: boolean;
  144535. /**
  144536. * Creates a new queue
  144537. */
  144538. constructor();
  144539. /**
  144540. * Adds a new simplification task
  144541. * @param task defines a task to add
  144542. */
  144543. addTask(task: ISimplificationTask): void;
  144544. /**
  144545. * Execute next task
  144546. */
  144547. executeNext(): void;
  144548. /**
  144549. * Execute a simplification task
  144550. * @param task defines the task to run
  144551. */
  144552. runSimplification(task: ISimplificationTask): void;
  144553. private getSimplifier;
  144554. }
  144555. /**
  144556. * The implemented types of simplification
  144557. * At the moment only Quadratic Error Decimation is implemented
  144558. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144559. */
  144560. export enum SimplificationType {
  144561. /** Quadratic error decimation */
  144562. QUADRATIC = 0
  144563. }
  144564. /**
  144565. * An implementation of the Quadratic Error simplification algorithm.
  144566. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  144567. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  144568. * @author RaananW
  144569. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144570. */
  144571. export class QuadraticErrorSimplification implements ISimplifier {
  144572. private _mesh;
  144573. private triangles;
  144574. private vertices;
  144575. private references;
  144576. private _reconstructedMesh;
  144577. /** Gets or sets the number pf sync interations */
  144578. syncIterations: number;
  144579. /** Gets or sets the aggressiveness of the simplifier */
  144580. aggressiveness: number;
  144581. /** Gets or sets the number of allowed iterations for decimation */
  144582. decimationIterations: number;
  144583. /** Gets or sets the espilon to use for bounding box computation */
  144584. boundingBoxEpsilon: number;
  144585. /**
  144586. * Creates a new QuadraticErrorSimplification
  144587. * @param _mesh defines the target mesh
  144588. */
  144589. constructor(_mesh: Mesh);
  144590. /**
  144591. * Simplification of a given mesh according to the given settings.
  144592. * Since this requires computation, it is assumed that the function runs async.
  144593. * @param settings The settings of the simplification, including quality and distance
  144594. * @param successCallback A callback that will be called after the mesh was simplified.
  144595. */
  144596. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  144597. private runDecimation;
  144598. private initWithMesh;
  144599. private init;
  144600. private reconstructMesh;
  144601. private initDecimatedMesh;
  144602. private isFlipped;
  144603. private updateTriangles;
  144604. private identifyBorder;
  144605. private updateMesh;
  144606. private vertexError;
  144607. private calculateError;
  144608. }
  144609. }
  144610. declare module BABYLON {
  144611. interface Scene {
  144612. /** @hidden (Backing field) */
  144613. _simplificationQueue: SimplificationQueue;
  144614. /**
  144615. * Gets or sets the simplification queue attached to the scene
  144616. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144617. */
  144618. simplificationQueue: SimplificationQueue;
  144619. }
  144620. interface Mesh {
  144621. /**
  144622. * Simplify the mesh according to the given array of settings.
  144623. * Function will return immediately and will simplify async
  144624. * @param settings a collection of simplification settings
  144625. * @param parallelProcessing should all levels calculate parallel or one after the other
  144626. * @param simplificationType the type of simplification to run
  144627. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  144628. * @returns the current mesh
  144629. */
  144630. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  144631. }
  144632. /**
  144633. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  144634. * created in a scene
  144635. */
  144636. export class SimplicationQueueSceneComponent implements ISceneComponent {
  144637. /**
  144638. * The component name helpfull to identify the component in the list of scene components.
  144639. */
  144640. readonly name: string;
  144641. /**
  144642. * The scene the component belongs to.
  144643. */
  144644. scene: Scene;
  144645. /**
  144646. * Creates a new instance of the component for the given scene
  144647. * @param scene Defines the scene to register the component in
  144648. */
  144649. constructor(scene: Scene);
  144650. /**
  144651. * Registers the component in a given scene
  144652. */
  144653. register(): void;
  144654. /**
  144655. * Rebuilds the elements related to this component in case of
  144656. * context lost for instance.
  144657. */
  144658. rebuild(): void;
  144659. /**
  144660. * Disposes the component and the associated ressources
  144661. */
  144662. dispose(): void;
  144663. private _beforeCameraUpdate;
  144664. }
  144665. }
  144666. declare module BABYLON {
  144667. interface Mesh {
  144668. /**
  144669. * Creates a new thin instance
  144670. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  144671. * @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
  144672. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  144673. */
  144674. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  144675. /**
  144676. * Adds the transformation (matrix) of the current mesh as a thin instance
  144677. * @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
  144678. * @returns the thin instance index number
  144679. */
  144680. thinInstanceAddSelf(refresh: boolean): number;
  144681. /**
  144682. * Registers a custom attribute to be used with thin instances
  144683. * @param kind name of the attribute
  144684. * @param stride size in floats of the attribute
  144685. */
  144686. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  144687. /**
  144688. * Sets the matrix of a thin instance
  144689. * @param index index of the thin instance
  144690. * @param matrix matrix to set
  144691. * @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
  144692. */
  144693. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  144694. /**
  144695. * Sets the value of a custom attribute for a thin instance
  144696. * @param kind name of the attribute
  144697. * @param index index of the thin instance
  144698. * @param value value to set
  144699. * @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
  144700. */
  144701. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  144702. /**
  144703. * 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.
  144704. */
  144705. thinInstanceCount: number;
  144706. /**
  144707. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  144708. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  144709. * @param buffer buffer to set
  144710. * @param stride size in floats of each value of the buffer
  144711. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  144712. */
  144713. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  144714. /**
  144715. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  144716. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  144717. */
  144718. thinInstanceBufferUpdated(kind: string): void;
  144719. /**
  144720. * Refreshes the bounding info, taking into account all the thin instances defined
  144721. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  144722. */
  144723. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  144724. /** @hidden */
  144725. _thinInstanceInitializeUserStorage(): void;
  144726. /** @hidden */
  144727. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  144728. /** @hidden */
  144729. _userThinInstanceBuffersStorage: {
  144730. data: {
  144731. [key: string]: Float32Array;
  144732. };
  144733. sizes: {
  144734. [key: string]: number;
  144735. };
  144736. vertexBuffers: {
  144737. [key: string]: Nullable<VertexBuffer>;
  144738. };
  144739. strides: {
  144740. [key: string]: number;
  144741. };
  144742. };
  144743. }
  144744. }
  144745. declare module BABYLON {
  144746. /**
  144747. * Navigation plugin interface to add navigation constrained by a navigation mesh
  144748. */
  144749. export interface INavigationEnginePlugin {
  144750. /**
  144751. * plugin name
  144752. */
  144753. name: string;
  144754. /**
  144755. * Creates a navigation mesh
  144756. * @param meshes array of all the geometry used to compute the navigatio mesh
  144757. * @param parameters bunch of parameters used to filter geometry
  144758. */
  144759. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144760. /**
  144761. * Create a navigation mesh debug mesh
  144762. * @param scene is where the mesh will be added
  144763. * @returns debug display mesh
  144764. */
  144765. createDebugNavMesh(scene: Scene): Mesh;
  144766. /**
  144767. * Get a navigation mesh constrained position, closest to the parameter position
  144768. * @param position world position
  144769. * @returns the closest point to position constrained by the navigation mesh
  144770. */
  144771. getClosestPoint(position: Vector3): Vector3;
  144772. /**
  144773. * Get a navigation mesh constrained position, closest to the parameter position
  144774. * @param position world position
  144775. * @param result output the closest point to position constrained by the navigation mesh
  144776. */
  144777. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144778. /**
  144779. * Get a navigation mesh constrained position, within a particular radius
  144780. * @param position world position
  144781. * @param maxRadius the maximum distance to the constrained world position
  144782. * @returns the closest point to position constrained by the navigation mesh
  144783. */
  144784. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144785. /**
  144786. * Get a navigation mesh constrained position, within a particular radius
  144787. * @param position world position
  144788. * @param maxRadius the maximum distance to the constrained world position
  144789. * @param result output the closest point to position constrained by the navigation mesh
  144790. */
  144791. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144792. /**
  144793. * Compute the final position from a segment made of destination-position
  144794. * @param position world position
  144795. * @param destination world position
  144796. * @returns the resulting point along the navmesh
  144797. */
  144798. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144799. /**
  144800. * Compute the final position from a segment made of destination-position
  144801. * @param position world position
  144802. * @param destination world position
  144803. * @param result output the resulting point along the navmesh
  144804. */
  144805. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144806. /**
  144807. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144808. * @param start world position
  144809. * @param end world position
  144810. * @returns array containing world position composing the path
  144811. */
  144812. computePath(start: Vector3, end: Vector3): Vector3[];
  144813. /**
  144814. * If this plugin is supported
  144815. * @returns true if plugin is supported
  144816. */
  144817. isSupported(): boolean;
  144818. /**
  144819. * Create a new Crowd so you can add agents
  144820. * @param maxAgents the maximum agent count in the crowd
  144821. * @param maxAgentRadius the maximum radius an agent can have
  144822. * @param scene to attach the crowd to
  144823. * @returns the crowd you can add agents to
  144824. */
  144825. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144826. /**
  144827. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144828. * The queries will try to find a solution within those bounds
  144829. * default is (1,1,1)
  144830. * @param extent x,y,z value that define the extent around the queries point of reference
  144831. */
  144832. setDefaultQueryExtent(extent: Vector3): void;
  144833. /**
  144834. * Get the Bounding box extent specified by setDefaultQueryExtent
  144835. * @returns the box extent values
  144836. */
  144837. getDefaultQueryExtent(): Vector3;
  144838. /**
  144839. * build the navmesh from a previously saved state using getNavmeshData
  144840. * @param data the Uint8Array returned by getNavmeshData
  144841. */
  144842. buildFromNavmeshData(data: Uint8Array): void;
  144843. /**
  144844. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144845. * @returns data the Uint8Array that can be saved and reused
  144846. */
  144847. getNavmeshData(): Uint8Array;
  144848. /**
  144849. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144850. * @param result output the box extent values
  144851. */
  144852. getDefaultQueryExtentToRef(result: Vector3): void;
  144853. /**
  144854. * Release all resources
  144855. */
  144856. dispose(): void;
  144857. }
  144858. /**
  144859. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144860. */
  144861. export interface ICrowd {
  144862. /**
  144863. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144864. * You can attach anything to that node. The node position is updated in the scene update tick.
  144865. * @param pos world position that will be constrained by the navigation mesh
  144866. * @param parameters agent parameters
  144867. * @param transform hooked to the agent that will be update by the scene
  144868. * @returns agent index
  144869. */
  144870. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144871. /**
  144872. * Returns the agent position in world space
  144873. * @param index agent index returned by addAgent
  144874. * @returns world space position
  144875. */
  144876. getAgentPosition(index: number): Vector3;
  144877. /**
  144878. * Gets the agent position result in world space
  144879. * @param index agent index returned by addAgent
  144880. * @param result output world space position
  144881. */
  144882. getAgentPositionToRef(index: number, result: Vector3): void;
  144883. /**
  144884. * Gets the agent velocity in world space
  144885. * @param index agent index returned by addAgent
  144886. * @returns world space velocity
  144887. */
  144888. getAgentVelocity(index: number): Vector3;
  144889. /**
  144890. * Gets the agent velocity result in world space
  144891. * @param index agent index returned by addAgent
  144892. * @param result output world space velocity
  144893. */
  144894. getAgentVelocityToRef(index: number, result: Vector3): void;
  144895. /**
  144896. * remove a particular agent previously created
  144897. * @param index agent index returned by addAgent
  144898. */
  144899. removeAgent(index: number): void;
  144900. /**
  144901. * get the list of all agents attached to this crowd
  144902. * @returns list of agent indices
  144903. */
  144904. getAgents(): number[];
  144905. /**
  144906. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144907. * @param deltaTime in seconds
  144908. */
  144909. update(deltaTime: number): void;
  144910. /**
  144911. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144912. * @param index agent index returned by addAgent
  144913. * @param destination targeted world position
  144914. */
  144915. agentGoto(index: number, destination: Vector3): void;
  144916. /**
  144917. * Teleport the agent to a new position
  144918. * @param index agent index returned by addAgent
  144919. * @param destination targeted world position
  144920. */
  144921. agentTeleport(index: number, destination: Vector3): void;
  144922. /**
  144923. * Update agent parameters
  144924. * @param index agent index returned by addAgent
  144925. * @param parameters agent parameters
  144926. */
  144927. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144928. /**
  144929. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144930. * The queries will try to find a solution within those bounds
  144931. * default is (1,1,1)
  144932. * @param extent x,y,z value that define the extent around the queries point of reference
  144933. */
  144934. setDefaultQueryExtent(extent: Vector3): void;
  144935. /**
  144936. * Get the Bounding box extent specified by setDefaultQueryExtent
  144937. * @returns the box extent values
  144938. */
  144939. getDefaultQueryExtent(): Vector3;
  144940. /**
  144941. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144942. * @param result output the box extent values
  144943. */
  144944. getDefaultQueryExtentToRef(result: Vector3): void;
  144945. /**
  144946. * Release all resources
  144947. */
  144948. dispose(): void;
  144949. }
  144950. /**
  144951. * Configures an agent
  144952. */
  144953. export interface IAgentParameters {
  144954. /**
  144955. * Agent radius. [Limit: >= 0]
  144956. */
  144957. radius: number;
  144958. /**
  144959. * Agent height. [Limit: > 0]
  144960. */
  144961. height: number;
  144962. /**
  144963. * Maximum allowed acceleration. [Limit: >= 0]
  144964. */
  144965. maxAcceleration: number;
  144966. /**
  144967. * Maximum allowed speed. [Limit: >= 0]
  144968. */
  144969. maxSpeed: number;
  144970. /**
  144971. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144972. */
  144973. collisionQueryRange: number;
  144974. /**
  144975. * The path visibility optimization range. [Limit: > 0]
  144976. */
  144977. pathOptimizationRange: number;
  144978. /**
  144979. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144980. */
  144981. separationWeight: number;
  144982. }
  144983. /**
  144984. * Configures the navigation mesh creation
  144985. */
  144986. export interface INavMeshParameters {
  144987. /**
  144988. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144989. */
  144990. cs: number;
  144991. /**
  144992. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144993. */
  144994. ch: number;
  144995. /**
  144996. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144997. */
  144998. walkableSlopeAngle: number;
  144999. /**
  145000. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145001. * be considered walkable. [Limit: >= 3] [Units: vx]
  145002. */
  145003. walkableHeight: number;
  145004. /**
  145005. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145006. */
  145007. walkableClimb: number;
  145008. /**
  145009. * The distance to erode/shrink the walkable area of the heightfield away from
  145010. * obstructions. [Limit: >=0] [Units: vx]
  145011. */
  145012. walkableRadius: number;
  145013. /**
  145014. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145015. */
  145016. maxEdgeLen: number;
  145017. /**
  145018. * The maximum distance a simplfied contour's border edges should deviate
  145019. * the original raw contour. [Limit: >=0] [Units: vx]
  145020. */
  145021. maxSimplificationError: number;
  145022. /**
  145023. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145024. */
  145025. minRegionArea: number;
  145026. /**
  145027. * Any regions with a span count smaller than this value will, if possible,
  145028. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145029. */
  145030. mergeRegionArea: number;
  145031. /**
  145032. * The maximum number of vertices allowed for polygons generated during the
  145033. * contour to polygon conversion process. [Limit: >= 3]
  145034. */
  145035. maxVertsPerPoly: number;
  145036. /**
  145037. * Sets the sampling distance to use when generating the detail mesh.
  145038. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145039. */
  145040. detailSampleDist: number;
  145041. /**
  145042. * The maximum distance the detail mesh surface should deviate from heightfield
  145043. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145044. */
  145045. detailSampleMaxError: number;
  145046. }
  145047. }
  145048. declare module BABYLON {
  145049. /**
  145050. * RecastJS navigation plugin
  145051. */
  145052. export class RecastJSPlugin implements INavigationEnginePlugin {
  145053. /**
  145054. * Reference to the Recast library
  145055. */
  145056. bjsRECAST: any;
  145057. /**
  145058. * plugin name
  145059. */
  145060. name: string;
  145061. /**
  145062. * the first navmesh created. We might extend this to support multiple navmeshes
  145063. */
  145064. navMesh: any;
  145065. /**
  145066. * Initializes the recastJS plugin
  145067. * @param recastInjection can be used to inject your own recast reference
  145068. */
  145069. constructor(recastInjection?: any);
  145070. /**
  145071. * Creates a navigation mesh
  145072. * @param meshes array of all the geometry used to compute the navigatio mesh
  145073. * @param parameters bunch of parameters used to filter geometry
  145074. */
  145075. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145076. /**
  145077. * Create a navigation mesh debug mesh
  145078. * @param scene is where the mesh will be added
  145079. * @returns debug display mesh
  145080. */
  145081. createDebugNavMesh(scene: Scene): Mesh;
  145082. /**
  145083. * Get a navigation mesh constrained position, closest to the parameter position
  145084. * @param position world position
  145085. * @returns the closest point to position constrained by the navigation mesh
  145086. */
  145087. getClosestPoint(position: Vector3): Vector3;
  145088. /**
  145089. * Get a navigation mesh constrained position, closest to the parameter position
  145090. * @param position world position
  145091. * @param result output the closest point to position constrained by the navigation mesh
  145092. */
  145093. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145094. /**
  145095. * Get a navigation mesh constrained position, within a particular radius
  145096. * @param position world position
  145097. * @param maxRadius the maximum distance to the constrained world position
  145098. * @returns the closest point to position constrained by the navigation mesh
  145099. */
  145100. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145101. /**
  145102. * Get a navigation mesh constrained position, within a particular radius
  145103. * @param position world position
  145104. * @param maxRadius the maximum distance to the constrained world position
  145105. * @param result output the closest point to position constrained by the navigation mesh
  145106. */
  145107. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145108. /**
  145109. * Compute the final position from a segment made of destination-position
  145110. * @param position world position
  145111. * @param destination world position
  145112. * @returns the resulting point along the navmesh
  145113. */
  145114. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145115. /**
  145116. * Compute the final position from a segment made of destination-position
  145117. * @param position world position
  145118. * @param destination world position
  145119. * @param result output the resulting point along the navmesh
  145120. */
  145121. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145122. /**
  145123. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145124. * @param start world position
  145125. * @param end world position
  145126. * @returns array containing world position composing the path
  145127. */
  145128. computePath(start: Vector3, end: Vector3): Vector3[];
  145129. /**
  145130. * Create a new Crowd so you can add agents
  145131. * @param maxAgents the maximum agent count in the crowd
  145132. * @param maxAgentRadius the maximum radius an agent can have
  145133. * @param scene to attach the crowd to
  145134. * @returns the crowd you can add agents to
  145135. */
  145136. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145137. /**
  145138. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145139. * The queries will try to find a solution within those bounds
  145140. * default is (1,1,1)
  145141. * @param extent x,y,z value that define the extent around the queries point of reference
  145142. */
  145143. setDefaultQueryExtent(extent: Vector3): void;
  145144. /**
  145145. * Get the Bounding box extent specified by setDefaultQueryExtent
  145146. * @returns the box extent values
  145147. */
  145148. getDefaultQueryExtent(): Vector3;
  145149. /**
  145150. * build the navmesh from a previously saved state using getNavmeshData
  145151. * @param data the Uint8Array returned by getNavmeshData
  145152. */
  145153. buildFromNavmeshData(data: Uint8Array): void;
  145154. /**
  145155. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145156. * @returns data the Uint8Array that can be saved and reused
  145157. */
  145158. getNavmeshData(): Uint8Array;
  145159. /**
  145160. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145161. * @param result output the box extent values
  145162. */
  145163. getDefaultQueryExtentToRef(result: Vector3): void;
  145164. /**
  145165. * Disposes
  145166. */
  145167. dispose(): void;
  145168. /**
  145169. * If this plugin is supported
  145170. * @returns true if plugin is supported
  145171. */
  145172. isSupported(): boolean;
  145173. }
  145174. /**
  145175. * Recast detour crowd implementation
  145176. */
  145177. export class RecastJSCrowd implements ICrowd {
  145178. /**
  145179. * Recast/detour plugin
  145180. */
  145181. bjsRECASTPlugin: RecastJSPlugin;
  145182. /**
  145183. * Link to the detour crowd
  145184. */
  145185. recastCrowd: any;
  145186. /**
  145187. * One transform per agent
  145188. */
  145189. transforms: TransformNode[];
  145190. /**
  145191. * All agents created
  145192. */
  145193. agents: number[];
  145194. /**
  145195. * Link to the scene is kept to unregister the crowd from the scene
  145196. */
  145197. private _scene;
  145198. /**
  145199. * Observer for crowd updates
  145200. */
  145201. private _onBeforeAnimationsObserver;
  145202. /**
  145203. * Constructor
  145204. * @param plugin recastJS plugin
  145205. * @param maxAgents the maximum agent count in the crowd
  145206. * @param maxAgentRadius the maximum radius an agent can have
  145207. * @param scene to attach the crowd to
  145208. * @returns the crowd you can add agents to
  145209. */
  145210. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145211. /**
  145212. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145213. * You can attach anything to that node. The node position is updated in the scene update tick.
  145214. * @param pos world position that will be constrained by the navigation mesh
  145215. * @param parameters agent parameters
  145216. * @param transform hooked to the agent that will be update by the scene
  145217. * @returns agent index
  145218. */
  145219. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145220. /**
  145221. * Returns the agent position in world space
  145222. * @param index agent index returned by addAgent
  145223. * @returns world space position
  145224. */
  145225. getAgentPosition(index: number): Vector3;
  145226. /**
  145227. * Returns the agent position result in world space
  145228. * @param index agent index returned by addAgent
  145229. * @param result output world space position
  145230. */
  145231. getAgentPositionToRef(index: number, result: Vector3): void;
  145232. /**
  145233. * Returns the agent velocity in world space
  145234. * @param index agent index returned by addAgent
  145235. * @returns world space velocity
  145236. */
  145237. getAgentVelocity(index: number): Vector3;
  145238. /**
  145239. * Returns the agent velocity result in world space
  145240. * @param index agent index returned by addAgent
  145241. * @param result output world space velocity
  145242. */
  145243. getAgentVelocityToRef(index: number, result: Vector3): void;
  145244. /**
  145245. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145246. * @param index agent index returned by addAgent
  145247. * @param destination targeted world position
  145248. */
  145249. agentGoto(index: number, destination: Vector3): void;
  145250. /**
  145251. * Teleport the agent to a new position
  145252. * @param index agent index returned by addAgent
  145253. * @param destination targeted world position
  145254. */
  145255. agentTeleport(index: number, destination: Vector3): void;
  145256. /**
  145257. * Update agent parameters
  145258. * @param index agent index returned by addAgent
  145259. * @param parameters agent parameters
  145260. */
  145261. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145262. /**
  145263. * remove a particular agent previously created
  145264. * @param index agent index returned by addAgent
  145265. */
  145266. removeAgent(index: number): void;
  145267. /**
  145268. * get the list of all agents attached to this crowd
  145269. * @returns list of agent indices
  145270. */
  145271. getAgents(): number[];
  145272. /**
  145273. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145274. * @param deltaTime in seconds
  145275. */
  145276. update(deltaTime: number): void;
  145277. /**
  145278. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145279. * The queries will try to find a solution within those bounds
  145280. * default is (1,1,1)
  145281. * @param extent x,y,z value that define the extent around the queries point of reference
  145282. */
  145283. setDefaultQueryExtent(extent: Vector3): void;
  145284. /**
  145285. * Get the Bounding box extent specified by setDefaultQueryExtent
  145286. * @returns the box extent values
  145287. */
  145288. getDefaultQueryExtent(): Vector3;
  145289. /**
  145290. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145291. * @param result output the box extent values
  145292. */
  145293. getDefaultQueryExtentToRef(result: Vector3): void;
  145294. /**
  145295. * Release all resources
  145296. */
  145297. dispose(): void;
  145298. }
  145299. }
  145300. declare module BABYLON {
  145301. /**
  145302. * Class used to enable access to IndexedDB
  145303. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  145304. */
  145305. export class Database implements IOfflineProvider {
  145306. private _callbackManifestChecked;
  145307. private _currentSceneUrl;
  145308. private _db;
  145309. private _enableSceneOffline;
  145310. private _enableTexturesOffline;
  145311. private _manifestVersionFound;
  145312. private _mustUpdateRessources;
  145313. private _hasReachedQuota;
  145314. private _isSupported;
  145315. private _idbFactory;
  145316. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  145317. private static IsUASupportingBlobStorage;
  145318. /**
  145319. * Gets a boolean indicating if Database storate is enabled (off by default)
  145320. */
  145321. static IDBStorageEnabled: boolean;
  145322. /**
  145323. * Gets a boolean indicating if scene must be saved in the database
  145324. */
  145325. get enableSceneOffline(): boolean;
  145326. /**
  145327. * Gets a boolean indicating if textures must be saved in the database
  145328. */
  145329. get enableTexturesOffline(): boolean;
  145330. /**
  145331. * Creates a new Database
  145332. * @param urlToScene defines the url to load the scene
  145333. * @param callbackManifestChecked defines the callback to use when manifest is checked
  145334. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  145335. */
  145336. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  145337. private static _ParseURL;
  145338. private static _ReturnFullUrlLocation;
  145339. private _checkManifestFile;
  145340. /**
  145341. * Open the database and make it available
  145342. * @param successCallback defines the callback to call on success
  145343. * @param errorCallback defines the callback to call on error
  145344. */
  145345. open(successCallback: () => void, errorCallback: () => void): void;
  145346. /**
  145347. * Loads an image from the database
  145348. * @param url defines the url to load from
  145349. * @param image defines the target DOM image
  145350. */
  145351. loadImage(url: string, image: HTMLImageElement): void;
  145352. private _loadImageFromDBAsync;
  145353. private _saveImageIntoDBAsync;
  145354. private _checkVersionFromDB;
  145355. private _loadVersionFromDBAsync;
  145356. private _saveVersionIntoDBAsync;
  145357. /**
  145358. * Loads a file from database
  145359. * @param url defines the URL to load from
  145360. * @param sceneLoaded defines a callback to call on success
  145361. * @param progressCallBack defines a callback to call when progress changed
  145362. * @param errorCallback defines a callback to call on error
  145363. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  145364. */
  145365. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  145366. private _loadFileAsync;
  145367. private _saveFileAsync;
  145368. /**
  145369. * Validates if xhr data is correct
  145370. * @param xhr defines the request to validate
  145371. * @param dataType defines the expected data type
  145372. * @returns true if data is correct
  145373. */
  145374. private static _ValidateXHRData;
  145375. }
  145376. }
  145377. declare module BABYLON {
  145378. /** @hidden */
  145379. export var gpuUpdateParticlesPixelShader: {
  145380. name: string;
  145381. shader: string;
  145382. };
  145383. }
  145384. declare module BABYLON {
  145385. /** @hidden */
  145386. export var gpuUpdateParticlesVertexShader: {
  145387. name: string;
  145388. shader: string;
  145389. };
  145390. }
  145391. declare module BABYLON {
  145392. /** @hidden */
  145393. export var clipPlaneFragmentDeclaration2: {
  145394. name: string;
  145395. shader: string;
  145396. };
  145397. }
  145398. declare module BABYLON {
  145399. /** @hidden */
  145400. export var gpuRenderParticlesPixelShader: {
  145401. name: string;
  145402. shader: string;
  145403. };
  145404. }
  145405. declare module BABYLON {
  145406. /** @hidden */
  145407. export var clipPlaneVertexDeclaration2: {
  145408. name: string;
  145409. shader: string;
  145410. };
  145411. }
  145412. declare module BABYLON {
  145413. /** @hidden */
  145414. export var gpuRenderParticlesVertexShader: {
  145415. name: string;
  145416. shader: string;
  145417. };
  145418. }
  145419. declare module BABYLON {
  145420. /**
  145421. * This represents a GPU particle system in Babylon
  145422. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  145423. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  145424. */
  145425. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  145426. /**
  145427. * The layer mask we are rendering the particles through.
  145428. */
  145429. layerMask: number;
  145430. private _capacity;
  145431. private _activeCount;
  145432. private _currentActiveCount;
  145433. private _accumulatedCount;
  145434. private _renderEffect;
  145435. private _updateEffect;
  145436. private _buffer0;
  145437. private _buffer1;
  145438. private _spriteBuffer;
  145439. private _updateVAO;
  145440. private _renderVAO;
  145441. private _targetIndex;
  145442. private _sourceBuffer;
  145443. private _targetBuffer;
  145444. private _engine;
  145445. private _currentRenderId;
  145446. private _started;
  145447. private _stopped;
  145448. private _timeDelta;
  145449. private _randomTexture;
  145450. private _randomTexture2;
  145451. private _attributesStrideSize;
  145452. private _updateEffectOptions;
  145453. private _randomTextureSize;
  145454. private _actualFrame;
  145455. private _customEffect;
  145456. private readonly _rawTextureWidth;
  145457. /**
  145458. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  145459. */
  145460. static get IsSupported(): boolean;
  145461. /**
  145462. * An event triggered when the system is disposed.
  145463. */
  145464. onDisposeObservable: Observable<IParticleSystem>;
  145465. /**
  145466. * Gets the maximum number of particles active at the same time.
  145467. * @returns The max number of active particles.
  145468. */
  145469. getCapacity(): number;
  145470. /**
  145471. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  145472. * to override the particles.
  145473. */
  145474. forceDepthWrite: boolean;
  145475. /**
  145476. * Gets or set the number of active particles
  145477. */
  145478. get activeParticleCount(): number;
  145479. set activeParticleCount(value: number);
  145480. private _preWarmDone;
  145481. /**
  145482. * Specifies if the particles are updated in emitter local space or world space.
  145483. */
  145484. isLocal: boolean;
  145485. /**
  145486. * Is this system ready to be used/rendered
  145487. * @return true if the system is ready
  145488. */
  145489. isReady(): boolean;
  145490. /**
  145491. * Gets if the system has been started. (Note: this will still be true after stop is called)
  145492. * @returns True if it has been started, otherwise false.
  145493. */
  145494. isStarted(): boolean;
  145495. /**
  145496. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  145497. * @returns True if it has been stopped, otherwise false.
  145498. */
  145499. isStopped(): boolean;
  145500. /**
  145501. * Gets a boolean indicating that the system is stopping
  145502. * @returns true if the system is currently stopping
  145503. */
  145504. isStopping(): boolean;
  145505. /**
  145506. * Gets the number of particles active at the same time.
  145507. * @returns The number of active particles.
  145508. */
  145509. getActiveCount(): number;
  145510. /**
  145511. * Starts the particle system and begins to emit
  145512. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  145513. */
  145514. start(delay?: number): void;
  145515. /**
  145516. * Stops the particle system.
  145517. */
  145518. stop(): void;
  145519. /**
  145520. * Remove all active particles
  145521. */
  145522. reset(): void;
  145523. /**
  145524. * Returns the string "GPUParticleSystem"
  145525. * @returns a string containing the class name
  145526. */
  145527. getClassName(): string;
  145528. /**
  145529. * Gets the custom effect used to render the particles
  145530. * @param blendMode Blend mode for which the effect should be retrieved
  145531. * @returns The effect
  145532. */
  145533. getCustomEffect(blendMode?: number): Nullable<Effect>;
  145534. /**
  145535. * Sets the custom effect used to render the particles
  145536. * @param effect The effect to set
  145537. * @param blendMode Blend mode for which the effect should be set
  145538. */
  145539. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  145540. /** @hidden */
  145541. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  145542. /**
  145543. * Observable that will be called just before the particles are drawn
  145544. */
  145545. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  145546. /**
  145547. * Gets the name of the particle vertex shader
  145548. */
  145549. get vertexShaderName(): string;
  145550. private _colorGradientsTexture;
  145551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  145552. /**
  145553. * Adds a new color gradient
  145554. * @param gradient defines the gradient to use (between 0 and 1)
  145555. * @param color1 defines the color to affect to the specified gradient
  145556. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  145557. * @returns the current particle system
  145558. */
  145559. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  145560. private _refreshColorGradient;
  145561. /** Force the system to rebuild all gradients that need to be resync */
  145562. forceRefreshGradients(): void;
  145563. /**
  145564. * Remove a specific color gradient
  145565. * @param gradient defines the gradient to remove
  145566. * @returns the current particle system
  145567. */
  145568. removeColorGradient(gradient: number): GPUParticleSystem;
  145569. private _angularSpeedGradientsTexture;
  145570. private _sizeGradientsTexture;
  145571. private _velocityGradientsTexture;
  145572. private _limitVelocityGradientsTexture;
  145573. private _dragGradientsTexture;
  145574. private _addFactorGradient;
  145575. /**
  145576. * Adds a new size gradient
  145577. * @param gradient defines the gradient to use (between 0 and 1)
  145578. * @param factor defines the size factor to affect to the specified gradient
  145579. * @returns the current particle system
  145580. */
  145581. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  145582. /**
  145583. * Remove a specific size gradient
  145584. * @param gradient defines the gradient to remove
  145585. * @returns the current particle system
  145586. */
  145587. removeSizeGradient(gradient: number): GPUParticleSystem;
  145588. private _refreshFactorGradient;
  145589. /**
  145590. * Adds a new angular speed gradient
  145591. * @param gradient defines the gradient to use (between 0 and 1)
  145592. * @param factor defines the angular speed to affect to the specified gradient
  145593. * @returns the current particle system
  145594. */
  145595. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  145596. /**
  145597. * Remove a specific angular speed gradient
  145598. * @param gradient defines the gradient to remove
  145599. * @returns the current particle system
  145600. */
  145601. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  145602. /**
  145603. * Adds a new velocity gradient
  145604. * @param gradient defines the gradient to use (between 0 and 1)
  145605. * @param factor defines the velocity to affect to the specified gradient
  145606. * @returns the current particle system
  145607. */
  145608. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145609. /**
  145610. * Remove a specific velocity gradient
  145611. * @param gradient defines the gradient to remove
  145612. * @returns the current particle system
  145613. */
  145614. removeVelocityGradient(gradient: number): GPUParticleSystem;
  145615. /**
  145616. * Adds a new limit velocity gradient
  145617. * @param gradient defines the gradient to use (between 0 and 1)
  145618. * @param factor defines the limit velocity value to affect to the specified gradient
  145619. * @returns the current particle system
  145620. */
  145621. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145622. /**
  145623. * Remove a specific limit velocity gradient
  145624. * @param gradient defines the gradient to remove
  145625. * @returns the current particle system
  145626. */
  145627. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  145628. /**
  145629. * Adds a new drag gradient
  145630. * @param gradient defines the gradient to use (between 0 and 1)
  145631. * @param factor defines the drag value to affect to the specified gradient
  145632. * @returns the current particle system
  145633. */
  145634. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  145635. /**
  145636. * Remove a specific drag gradient
  145637. * @param gradient defines the gradient to remove
  145638. * @returns the current particle system
  145639. */
  145640. removeDragGradient(gradient: number): GPUParticleSystem;
  145641. /**
  145642. * Not supported by GPUParticleSystem
  145643. * @param gradient defines the gradient to use (between 0 and 1)
  145644. * @param factor defines the emit rate value to affect to the specified gradient
  145645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145646. * @returns the current particle system
  145647. */
  145648. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145649. /**
  145650. * Not supported by GPUParticleSystem
  145651. * @param gradient defines the gradient to remove
  145652. * @returns the current particle system
  145653. */
  145654. removeEmitRateGradient(gradient: number): IParticleSystem;
  145655. /**
  145656. * Not supported by GPUParticleSystem
  145657. * @param gradient defines the gradient to use (between 0 and 1)
  145658. * @param factor defines the start size value to affect to the specified gradient
  145659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145660. * @returns the current particle system
  145661. */
  145662. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145663. /**
  145664. * Not supported by GPUParticleSystem
  145665. * @param gradient defines the gradient to remove
  145666. * @returns the current particle system
  145667. */
  145668. removeStartSizeGradient(gradient: number): IParticleSystem;
  145669. /**
  145670. * Not supported by GPUParticleSystem
  145671. * @param gradient defines the gradient to use (between 0 and 1)
  145672. * @param min defines the color remap minimal range
  145673. * @param max defines the color remap maximal range
  145674. * @returns the current particle system
  145675. */
  145676. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145677. /**
  145678. * Not supported by GPUParticleSystem
  145679. * @param gradient defines the gradient to remove
  145680. * @returns the current particle system
  145681. */
  145682. removeColorRemapGradient(): IParticleSystem;
  145683. /**
  145684. * Not supported by GPUParticleSystem
  145685. * @param gradient defines the gradient to use (between 0 and 1)
  145686. * @param min defines the alpha remap minimal range
  145687. * @param max defines the alpha remap maximal range
  145688. * @returns the current particle system
  145689. */
  145690. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145691. /**
  145692. * Not supported by GPUParticleSystem
  145693. * @param gradient defines the gradient to remove
  145694. * @returns the current particle system
  145695. */
  145696. removeAlphaRemapGradient(): IParticleSystem;
  145697. /**
  145698. * Not supported by GPUParticleSystem
  145699. * @param gradient defines the gradient to use (between 0 and 1)
  145700. * @param color defines the color to affect to the specified gradient
  145701. * @returns the current particle system
  145702. */
  145703. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  145704. /**
  145705. * Not supported by GPUParticleSystem
  145706. * @param gradient defines the gradient to remove
  145707. * @returns the current particle system
  145708. */
  145709. removeRampGradient(): IParticleSystem;
  145710. /**
  145711. * Not supported by GPUParticleSystem
  145712. * @returns the list of ramp gradients
  145713. */
  145714. getRampGradients(): Nullable<Array<Color3Gradient>>;
  145715. /**
  145716. * Not supported by GPUParticleSystem
  145717. * Gets or sets a boolean indicating that ramp gradients must be used
  145718. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  145719. */
  145720. get useRampGradients(): boolean;
  145721. set useRampGradients(value: boolean);
  145722. /**
  145723. * Not supported by GPUParticleSystem
  145724. * @param gradient defines the gradient to use (between 0 and 1)
  145725. * @param factor defines the life time factor to affect to the specified gradient
  145726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145727. * @returns the current particle system
  145728. */
  145729. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145730. /**
  145731. * Not supported by GPUParticleSystem
  145732. * @param gradient defines the gradient to remove
  145733. * @returns the current particle system
  145734. */
  145735. removeLifeTimeGradient(gradient: number): IParticleSystem;
  145736. /**
  145737. * Instantiates a GPU particle system.
  145738. * 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.
  145739. * @param name The name of the particle system
  145740. * @param options The options used to create the system
  145741. * @param scene The scene the particle system belongs to
  145742. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  145743. * @param customEffect a custom effect used to change the way particles are rendered by default
  145744. */
  145745. constructor(name: string, options: Partial<{
  145746. capacity: number;
  145747. randomTextureSize: number;
  145748. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  145749. protected _reset(): void;
  145750. private _createUpdateVAO;
  145751. private _createRenderVAO;
  145752. private _initialize;
  145753. /** @hidden */
  145754. _recreateUpdateEffect(): void;
  145755. private _getEffect;
  145756. /**
  145757. * Fill the defines array according to the current settings of the particle system
  145758. * @param defines Array to be updated
  145759. * @param blendMode blend mode to take into account when updating the array
  145760. */
  145761. fillDefines(defines: Array<string>, blendMode?: number): void;
  145762. /**
  145763. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  145764. * @param uniforms Uniforms array to fill
  145765. * @param attributes Attributes array to fill
  145766. * @param samplers Samplers array to fill
  145767. */
  145768. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  145769. /** @hidden */
  145770. _recreateRenderEffect(): Effect;
  145771. /**
  145772. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  145773. * @param preWarm defines if we are in the pre-warmimg phase
  145774. */
  145775. animate(preWarm?: boolean): void;
  145776. private _createFactorGradientTexture;
  145777. private _createSizeGradientTexture;
  145778. private _createAngularSpeedGradientTexture;
  145779. private _createVelocityGradientTexture;
  145780. private _createLimitVelocityGradientTexture;
  145781. private _createDragGradientTexture;
  145782. private _createColorGradientTexture;
  145783. /**
  145784. * Renders the particle system in its current state
  145785. * @param preWarm defines if the system should only update the particles but not render them
  145786. * @returns the current number of particles
  145787. */
  145788. render(preWarm?: boolean): number;
  145789. /**
  145790. * Rebuilds the particle system
  145791. */
  145792. rebuild(): void;
  145793. private _releaseBuffers;
  145794. private _releaseVAOs;
  145795. /**
  145796. * Disposes the particle system and free the associated resources
  145797. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145798. */
  145799. dispose(disposeTexture?: boolean): void;
  145800. /**
  145801. * Clones the particle system.
  145802. * @param name The name of the cloned object
  145803. * @param newEmitter The new emitter to use
  145804. * @returns the cloned particle system
  145805. */
  145806. clone(name: string, newEmitter: any): GPUParticleSystem;
  145807. /**
  145808. * Serializes the particle system to a JSON object
  145809. * @param serializeTexture defines if the texture must be serialized as well
  145810. * @returns the JSON object
  145811. */
  145812. serialize(serializeTexture?: boolean): any;
  145813. /**
  145814. * Parses a JSON object to create a GPU particle system.
  145815. * @param parsedParticleSystem The JSON object to parse
  145816. * @param scene The scene to create the particle system in
  145817. * @param rootUrl The root url to use to load external dependencies like texture
  145818. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145819. * @returns the parsed GPU particle system
  145820. */
  145821. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145822. }
  145823. }
  145824. declare module BABYLON {
  145825. /**
  145826. * Represents a set of particle systems working together to create a specific effect
  145827. */
  145828. export class ParticleSystemSet implements IDisposable {
  145829. /**
  145830. * Gets or sets base Assets URL
  145831. */
  145832. static BaseAssetsUrl: string;
  145833. private _emitterCreationOptions;
  145834. private _emitterNode;
  145835. /**
  145836. * Gets the particle system list
  145837. */
  145838. systems: IParticleSystem[];
  145839. /**
  145840. * Gets the emitter node used with this set
  145841. */
  145842. get emitterNode(): Nullable<TransformNode>;
  145843. /**
  145844. * Creates a new emitter mesh as a sphere
  145845. * @param options defines the options used to create the sphere
  145846. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145847. * @param scene defines the hosting scene
  145848. */
  145849. setEmitterAsSphere(options: {
  145850. diameter: number;
  145851. segments: number;
  145852. color: Color3;
  145853. }, renderingGroupId: number, scene: Scene): void;
  145854. /**
  145855. * Starts all particle systems of the set
  145856. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145857. */
  145858. start(emitter?: AbstractMesh): void;
  145859. /**
  145860. * Release all associated resources
  145861. */
  145862. dispose(): void;
  145863. /**
  145864. * Serialize the set into a JSON compatible object
  145865. * @param serializeTexture defines if the texture must be serialized as well
  145866. * @returns a JSON compatible representation of the set
  145867. */
  145868. serialize(serializeTexture?: boolean): any;
  145869. /**
  145870. * Parse a new ParticleSystemSet from a serialized source
  145871. * @param data defines a JSON compatible representation of the set
  145872. * @param scene defines the hosting scene
  145873. * @param gpu defines if we want GPU particles or CPU particles
  145874. * @returns a new ParticleSystemSet
  145875. */
  145876. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145877. }
  145878. }
  145879. declare module BABYLON {
  145880. /**
  145881. * This class is made for on one-liner static method to help creating particle system set.
  145882. */
  145883. export class ParticleHelper {
  145884. /**
  145885. * Gets or sets base Assets URL
  145886. */
  145887. static BaseAssetsUrl: string;
  145888. /** Define the Url to load snippets */
  145889. static SnippetUrl: string;
  145890. /**
  145891. * Create a default particle system that you can tweak
  145892. * @param emitter defines the emitter to use
  145893. * @param capacity defines the system capacity (default is 500 particles)
  145894. * @param scene defines the hosting scene
  145895. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145896. * @returns the new Particle system
  145897. */
  145898. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145899. /**
  145900. * This is the main static method (one-liner) of this helper to create different particle systems
  145901. * @param type This string represents the type to the particle system to create
  145902. * @param scene The scene where the particle system should live
  145903. * @param gpu If the system will use gpu
  145904. * @returns the ParticleSystemSet created
  145905. */
  145906. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145907. /**
  145908. * Static function used to export a particle system to a ParticleSystemSet variable.
  145909. * Please note that the emitter shape is not exported
  145910. * @param systems defines the particle systems to export
  145911. * @returns the created particle system set
  145912. */
  145913. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145914. /**
  145915. * Creates a particle system from a snippet saved in a remote file
  145916. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145917. * @param url defines the url to load from
  145918. * @param scene defines the hosting scene
  145919. * @param gpu If the system will use gpu
  145920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145921. * @returns a promise that will resolve to the new particle system
  145922. */
  145923. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145924. /**
  145925. * Creates a particle system from a snippet saved by the particle system editor
  145926. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  145927. * @param scene defines the hosting scene
  145928. * @param gpu If the system will use gpu
  145929. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145930. * @returns a promise that will resolve to the new particle system
  145931. */
  145932. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145933. }
  145934. }
  145935. declare module BABYLON {
  145936. interface Engine {
  145937. /**
  145938. * Create an effect to use with particle systems.
  145939. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145940. * the particle system for which you want to create a custom effect in the last parameter
  145941. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145942. * @param uniformsNames defines a list of attribute names
  145943. * @param samplers defines an array of string used to represent textures
  145944. * @param defines defines the string containing the defines to use to compile the shaders
  145945. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145946. * @param onCompiled defines a function to call when the effect creation is successful
  145947. * @param onError defines a function to call when the effect creation has failed
  145948. * @param particleSystem the particle system you want to create the effect for
  145949. * @returns the new Effect
  145950. */
  145951. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145952. }
  145953. interface Mesh {
  145954. /**
  145955. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145956. * @returns an array of IParticleSystem
  145957. */
  145958. getEmittedParticleSystems(): IParticleSystem[];
  145959. /**
  145960. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145961. * @returns an array of IParticleSystem
  145962. */
  145963. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145964. }
  145965. }
  145966. declare module BABYLON {
  145967. /** Defines the 4 color options */
  145968. export enum PointColor {
  145969. /** color value */
  145970. Color = 2,
  145971. /** uv value */
  145972. UV = 1,
  145973. /** random value */
  145974. Random = 0,
  145975. /** stated value */
  145976. Stated = 3
  145977. }
  145978. /**
  145979. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145980. * 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.
  145981. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145982. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145983. *
  145984. * Full documentation here : TO BE ENTERED
  145985. */
  145986. export class PointsCloudSystem implements IDisposable {
  145987. /**
  145988. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145989. * Example : var p = SPS.particles[i];
  145990. */
  145991. particles: CloudPoint[];
  145992. /**
  145993. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145994. */
  145995. nbParticles: number;
  145996. /**
  145997. * This a counter for your own usage. It's not set by any SPS functions.
  145998. */
  145999. counter: number;
  146000. /**
  146001. * The PCS name. This name is also given to the underlying mesh.
  146002. */
  146003. name: string;
  146004. /**
  146005. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146006. */
  146007. mesh: Mesh;
  146008. /**
  146009. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146010. * Please read :
  146011. */
  146012. vars: any;
  146013. /**
  146014. * @hidden
  146015. */
  146016. _size: number;
  146017. private _scene;
  146018. private _promises;
  146019. private _positions;
  146020. private _indices;
  146021. private _normals;
  146022. private _colors;
  146023. private _uvs;
  146024. private _indices32;
  146025. private _positions32;
  146026. private _colors32;
  146027. private _uvs32;
  146028. private _updatable;
  146029. private _isVisibilityBoxLocked;
  146030. private _alwaysVisible;
  146031. private _groups;
  146032. private _groupCounter;
  146033. private _computeParticleColor;
  146034. private _computeParticleTexture;
  146035. private _computeParticleRotation;
  146036. private _computeBoundingBox;
  146037. private _isReady;
  146038. /**
  146039. * Creates a PCS (Points Cloud System) object
  146040. * @param name (String) is the PCS name, this will be the underlying mesh name
  146041. * @param pointSize (number) is the size for each point
  146042. * @param scene (Scene) is the scene in which the PCS is added
  146043. * @param options defines the options of the PCS e.g.
  146044. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146045. */
  146046. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146047. updatable?: boolean;
  146048. });
  146049. /**
  146050. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146051. * If no points were added to the PCS, the returned mesh is just a single point.
  146052. * @returns a promise for the created mesh
  146053. */
  146054. buildMeshAsync(): Promise<Mesh>;
  146055. /**
  146056. * @hidden
  146057. */
  146058. private _buildMesh;
  146059. private _addParticle;
  146060. private _randomUnitVector;
  146061. private _getColorIndicesForCoord;
  146062. private _setPointsColorOrUV;
  146063. private _colorFromTexture;
  146064. private _calculateDensity;
  146065. /**
  146066. * Adds points to the PCS in random positions within a unit sphere
  146067. * @param nb (positive integer) the number of particles to be created from this model
  146068. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146069. * @returns the number of groups in the system
  146070. */
  146071. addPoints(nb: number, pointFunction?: any): number;
  146072. /**
  146073. * Adds points to the PCS from the surface of the model shape
  146074. * @param mesh is any Mesh object that will be used as a surface model for the points
  146075. * @param nb (positive integer) the number of particles to be created from this model
  146076. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146077. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146078. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146079. * @returns the number of groups in the system
  146080. */
  146081. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146082. /**
  146083. * Adds points to the PCS inside the model shape
  146084. * @param mesh is any Mesh object that will be used as a surface model for the points
  146085. * @param nb (positive integer) the number of particles to be created from this model
  146086. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146087. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146088. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146089. * @returns the number of groups in the system
  146090. */
  146091. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146092. /**
  146093. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146094. * This method calls `updateParticle()` for each particle of the SPS.
  146095. * For an animated SPS, it is usually called within the render loop.
  146096. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146097. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146098. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146099. * @returns the PCS.
  146100. */
  146101. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146102. /**
  146103. * Disposes the PCS.
  146104. */
  146105. dispose(): void;
  146106. /**
  146107. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146108. * doc :
  146109. * @returns the PCS.
  146110. */
  146111. refreshVisibleSize(): PointsCloudSystem;
  146112. /**
  146113. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146114. * @param size the size (float) of the visibility box
  146115. * note : this doesn't lock the PCS mesh bounding box.
  146116. * doc :
  146117. */
  146118. setVisibilityBox(size: number): void;
  146119. /**
  146120. * Gets whether the PCS is always visible or not
  146121. * doc :
  146122. */
  146123. get isAlwaysVisible(): boolean;
  146124. /**
  146125. * Sets the PCS as always visible or not
  146126. * doc :
  146127. */
  146128. set isAlwaysVisible(val: boolean);
  146129. /**
  146130. * Tells to `setParticles()` to compute the particle rotations or not
  146131. * Default value : false. The PCS is faster when it's set to false
  146132. * Note : particle rotations are only applied to parent particles
  146133. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146134. */
  146135. set computeParticleRotation(val: boolean);
  146136. /**
  146137. * Tells to `setParticles()` to compute the particle colors or not.
  146138. * Default value : true. The PCS is faster when it's set to false.
  146139. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146140. */
  146141. set computeParticleColor(val: boolean);
  146142. set computeParticleTexture(val: boolean);
  146143. /**
  146144. * Gets if `setParticles()` computes the particle colors or not.
  146145. * Default value : false. The PCS is faster when it's set to false.
  146146. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146147. */
  146148. get computeParticleColor(): boolean;
  146149. /**
  146150. * Gets if `setParticles()` computes the particle textures or not.
  146151. * Default value : false. The PCS is faster when it's set to false.
  146152. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146153. */
  146154. get computeParticleTexture(): boolean;
  146155. /**
  146156. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146157. */
  146158. set computeBoundingBox(val: boolean);
  146159. /**
  146160. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146161. */
  146162. get computeBoundingBox(): boolean;
  146163. /**
  146164. * This function does nothing. It may be overwritten to set all the particle first values.
  146165. * The PCS doesn't call this function, you may have to call it by your own.
  146166. * doc :
  146167. */
  146168. initParticles(): void;
  146169. /**
  146170. * This function does nothing. It may be overwritten to recycle a particle
  146171. * The PCS doesn't call this function, you can to call it
  146172. * doc :
  146173. * @param particle The particle to recycle
  146174. * @returns the recycled particle
  146175. */
  146176. recycleParticle(particle: CloudPoint): CloudPoint;
  146177. /**
  146178. * Updates a particle : this function should be overwritten by the user.
  146179. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146180. * doc :
  146181. * @example : just set a particle position or velocity and recycle conditions
  146182. * @param particle The particle to update
  146183. * @returns the updated particle
  146184. */
  146185. updateParticle(particle: CloudPoint): CloudPoint;
  146186. /**
  146187. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146188. * This does nothing and may be overwritten by the user.
  146189. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146191. * @param update the boolean update value actually passed to setParticles()
  146192. */
  146193. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146194. /**
  146195. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146196. * This will be passed three parameters.
  146197. * This does nothing and may be overwritten by the user.
  146198. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146199. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146200. * @param update the boolean update value actually passed to setParticles()
  146201. */
  146202. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146203. }
  146204. }
  146205. declare module BABYLON {
  146206. /**
  146207. * Represents one particle of a points cloud system.
  146208. */
  146209. export class CloudPoint {
  146210. /**
  146211. * particle global index
  146212. */
  146213. idx: number;
  146214. /**
  146215. * The color of the particle
  146216. */
  146217. color: Nullable<Color4>;
  146218. /**
  146219. * The world space position of the particle.
  146220. */
  146221. position: Vector3;
  146222. /**
  146223. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146224. */
  146225. rotation: Vector3;
  146226. /**
  146227. * The world space rotation quaternion of the particle.
  146228. */
  146229. rotationQuaternion: Nullable<Quaternion>;
  146230. /**
  146231. * The uv of the particle.
  146232. */
  146233. uv: Nullable<Vector2>;
  146234. /**
  146235. * The current speed of the particle.
  146236. */
  146237. velocity: Vector3;
  146238. /**
  146239. * The pivot point in the particle local space.
  146240. */
  146241. pivot: Vector3;
  146242. /**
  146243. * Must the particle be translated from its pivot point in its local space ?
  146244. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146245. * Default : false
  146246. */
  146247. translateFromPivot: boolean;
  146248. /**
  146249. * Index of this particle in the global "positions" array (Internal use)
  146250. * @hidden
  146251. */
  146252. _pos: number;
  146253. /**
  146254. * @hidden Index of this particle in the global "indices" array (Internal use)
  146255. */
  146256. _ind: number;
  146257. /**
  146258. * Group this particle belongs to
  146259. */
  146260. _group: PointsGroup;
  146261. /**
  146262. * Group id of this particle
  146263. */
  146264. groupId: number;
  146265. /**
  146266. * Index of the particle in its group id (Internal use)
  146267. */
  146268. idxInGroup: number;
  146269. /**
  146270. * @hidden Particle BoundingInfo object (Internal use)
  146271. */
  146272. _boundingInfo: BoundingInfo;
  146273. /**
  146274. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146275. */
  146276. _pcs: PointsCloudSystem;
  146277. /**
  146278. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146279. */
  146280. _stillInvisible: boolean;
  146281. /**
  146282. * @hidden Last computed particle rotation matrix
  146283. */
  146284. _rotationMatrix: number[];
  146285. /**
  146286. * Parent particle Id, if any.
  146287. * Default null.
  146288. */
  146289. parentId: Nullable<number>;
  146290. /**
  146291. * @hidden Internal global position in the PCS.
  146292. */
  146293. _globalPosition: Vector3;
  146294. /**
  146295. * Creates a Point Cloud object.
  146296. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  146297. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  146298. * @param group (PointsGroup) is the group the particle belongs to
  146299. * @param groupId (integer) is the group identifier in the PCS.
  146300. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  146301. * @param pcs defines the PCS it is associated to
  146302. */
  146303. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  146304. /**
  146305. * get point size
  146306. */
  146307. get size(): Vector3;
  146308. /**
  146309. * Set point size
  146310. */
  146311. set size(scale: Vector3);
  146312. /**
  146313. * Legacy support, changed quaternion to rotationQuaternion
  146314. */
  146315. get quaternion(): Nullable<Quaternion>;
  146316. /**
  146317. * Legacy support, changed quaternion to rotationQuaternion
  146318. */
  146319. set quaternion(q: Nullable<Quaternion>);
  146320. /**
  146321. * Returns a boolean. True if the particle intersects a mesh, else false
  146322. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  146323. * @param target is the object (point or mesh) what the intersection is computed against
  146324. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  146325. * @returns true if it intersects
  146326. */
  146327. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  146328. /**
  146329. * get the rotation matrix of the particle
  146330. * @hidden
  146331. */
  146332. getRotationMatrix(m: Matrix): void;
  146333. }
  146334. /**
  146335. * Represents a group of points in a points cloud system
  146336. * * PCS internal tool, don't use it manually.
  146337. */
  146338. export class PointsGroup {
  146339. /**
  146340. * The group id
  146341. * @hidden
  146342. */
  146343. groupID: number;
  146344. /**
  146345. * image data for group (internal use)
  146346. * @hidden
  146347. */
  146348. _groupImageData: Nullable<ArrayBufferView>;
  146349. /**
  146350. * Image Width (internal use)
  146351. * @hidden
  146352. */
  146353. _groupImgWidth: number;
  146354. /**
  146355. * Image Height (internal use)
  146356. * @hidden
  146357. */
  146358. _groupImgHeight: number;
  146359. /**
  146360. * Custom position function (internal use)
  146361. * @hidden
  146362. */
  146363. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  146364. /**
  146365. * density per facet for surface points
  146366. * @hidden
  146367. */
  146368. _groupDensity: number[];
  146369. /**
  146370. * Only when points are colored by texture carries pointer to texture list array
  146371. * @hidden
  146372. */
  146373. _textureNb: number;
  146374. /**
  146375. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  146376. * PCS internal tool, don't use it manually.
  146377. * @hidden
  146378. */
  146379. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  146380. }
  146381. }
  146382. declare module BABYLON {
  146383. interface Scene {
  146384. /** @hidden (Backing field) */
  146385. _physicsEngine: Nullable<IPhysicsEngine>;
  146386. /** @hidden */
  146387. _physicsTimeAccumulator: number;
  146388. /**
  146389. * Gets the current physics engine
  146390. * @returns a IPhysicsEngine or null if none attached
  146391. */
  146392. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  146393. /**
  146394. * Enables physics to the current scene
  146395. * @param gravity defines the scene's gravity for the physics engine
  146396. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  146397. * @return a boolean indicating if the physics engine was initialized
  146398. */
  146399. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  146400. /**
  146401. * Disables and disposes the physics engine associated with the scene
  146402. */
  146403. disablePhysicsEngine(): void;
  146404. /**
  146405. * Gets a boolean indicating if there is an active physics engine
  146406. * @returns a boolean indicating if there is an active physics engine
  146407. */
  146408. isPhysicsEnabled(): boolean;
  146409. /**
  146410. * Deletes a physics compound impostor
  146411. * @param compound defines the compound to delete
  146412. */
  146413. deleteCompoundImpostor(compound: any): void;
  146414. /**
  146415. * An event triggered when physic simulation is about to be run
  146416. */
  146417. onBeforePhysicsObservable: Observable<Scene>;
  146418. /**
  146419. * An event triggered when physic simulation has been done
  146420. */
  146421. onAfterPhysicsObservable: Observable<Scene>;
  146422. }
  146423. interface AbstractMesh {
  146424. /** @hidden */
  146425. _physicsImpostor: Nullable<PhysicsImpostor>;
  146426. /**
  146427. * Gets or sets impostor used for physic simulation
  146428. * @see https://doc.babylonjs.com/features/physics_engine
  146429. */
  146430. physicsImpostor: Nullable<PhysicsImpostor>;
  146431. /**
  146432. * Gets the current physics impostor
  146433. * @see https://doc.babylonjs.com/features/physics_engine
  146434. * @returns a physics impostor or null
  146435. */
  146436. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  146437. /** Apply a physic impulse to the mesh
  146438. * @param force defines the force to apply
  146439. * @param contactPoint defines where to apply the force
  146440. * @returns the current mesh
  146441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  146442. */
  146443. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  146444. /**
  146445. * Creates a physic joint between two meshes
  146446. * @param otherMesh defines the other mesh to use
  146447. * @param pivot1 defines the pivot to use on this mesh
  146448. * @param pivot2 defines the pivot to use on the other mesh
  146449. * @param options defines additional options (can be plugin dependent)
  146450. * @returns the current mesh
  146451. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  146452. */
  146453. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  146454. /** @hidden */
  146455. _disposePhysicsObserver: Nullable<Observer<Node>>;
  146456. }
  146457. /**
  146458. * Defines the physics engine scene component responsible to manage a physics engine
  146459. */
  146460. export class PhysicsEngineSceneComponent implements ISceneComponent {
  146461. /**
  146462. * The component name helpful to identify the component in the list of scene components.
  146463. */
  146464. readonly name: string;
  146465. /**
  146466. * The scene the component belongs to.
  146467. */
  146468. scene: Scene;
  146469. /**
  146470. * Creates a new instance of the component for the given scene
  146471. * @param scene Defines the scene to register the component in
  146472. */
  146473. constructor(scene: Scene);
  146474. /**
  146475. * Registers the component in a given scene
  146476. */
  146477. register(): void;
  146478. /**
  146479. * Rebuilds the elements related to this component in case of
  146480. * context lost for instance.
  146481. */
  146482. rebuild(): void;
  146483. /**
  146484. * Disposes the component and the associated ressources
  146485. */
  146486. dispose(): void;
  146487. }
  146488. }
  146489. declare module BABYLON {
  146490. /**
  146491. * A helper for physics simulations
  146492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146493. */
  146494. export class PhysicsHelper {
  146495. private _scene;
  146496. private _physicsEngine;
  146497. /**
  146498. * Initializes the Physics helper
  146499. * @param scene Babylon.js scene
  146500. */
  146501. constructor(scene: Scene);
  146502. /**
  146503. * Applies a radial explosion impulse
  146504. * @param origin the origin of the explosion
  146505. * @param radiusOrEventOptions the radius or the options of radial explosion
  146506. * @param strength the explosion strength
  146507. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146508. * @returns A physics radial explosion event, or null
  146509. */
  146510. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146511. /**
  146512. * Applies a radial explosion force
  146513. * @param origin the origin of the explosion
  146514. * @param radiusOrEventOptions the radius or the options of radial explosion
  146515. * @param strength the explosion strength
  146516. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146517. * @returns A physics radial explosion event, or null
  146518. */
  146519. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146520. /**
  146521. * Creates a gravitational field
  146522. * @param origin the origin of the explosion
  146523. * @param radiusOrEventOptions the radius or the options of radial explosion
  146524. * @param strength the explosion strength
  146525. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146526. * @returns A physics gravitational field event, or null
  146527. */
  146528. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  146529. /**
  146530. * Creates a physics updraft event
  146531. * @param origin the origin of the updraft
  146532. * @param radiusOrEventOptions the radius or the options of the updraft
  146533. * @param strength the strength of the updraft
  146534. * @param height the height of the updraft
  146535. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  146536. * @returns A physics updraft event, or null
  146537. */
  146538. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  146539. /**
  146540. * Creates a physics vortex event
  146541. * @param origin the of the vortex
  146542. * @param radiusOrEventOptions the radius or the options of the vortex
  146543. * @param strength the strength of the vortex
  146544. * @param height the height of the vortex
  146545. * @returns a Physics vortex event, or null
  146546. * A physics vortex event or null
  146547. */
  146548. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  146549. }
  146550. /**
  146551. * Represents a physics radial explosion event
  146552. */
  146553. class PhysicsRadialExplosionEvent {
  146554. private _scene;
  146555. private _options;
  146556. private _sphere;
  146557. private _dataFetched;
  146558. /**
  146559. * Initializes a radial explosioin event
  146560. * @param _scene BabylonJS scene
  146561. * @param _options The options for the vortex event
  146562. */
  146563. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  146564. /**
  146565. * Returns the data related to the radial explosion event (sphere).
  146566. * @returns The radial explosion event data
  146567. */
  146568. getData(): PhysicsRadialExplosionEventData;
  146569. /**
  146570. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  146571. * @param impostor A physics imposter
  146572. * @param origin the origin of the explosion
  146573. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  146574. */
  146575. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  146576. /**
  146577. * Triggers affecterd impostors callbacks
  146578. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  146579. */
  146580. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  146581. /**
  146582. * Disposes the sphere.
  146583. * @param force Specifies if the sphere should be disposed by force
  146584. */
  146585. dispose(force?: boolean): void;
  146586. /*** Helpers ***/
  146587. private _prepareSphere;
  146588. private _intersectsWithSphere;
  146589. }
  146590. /**
  146591. * Represents a gravitational field event
  146592. */
  146593. class PhysicsGravitationalFieldEvent {
  146594. private _physicsHelper;
  146595. private _scene;
  146596. private _origin;
  146597. private _options;
  146598. private _tickCallback;
  146599. private _sphere;
  146600. private _dataFetched;
  146601. /**
  146602. * Initializes the physics gravitational field event
  146603. * @param _physicsHelper A physics helper
  146604. * @param _scene BabylonJS scene
  146605. * @param _origin The origin position of the gravitational field event
  146606. * @param _options The options for the vortex event
  146607. */
  146608. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  146609. /**
  146610. * Returns the data related to the gravitational field event (sphere).
  146611. * @returns A gravitational field event
  146612. */
  146613. getData(): PhysicsGravitationalFieldEventData;
  146614. /**
  146615. * Enables the gravitational field.
  146616. */
  146617. enable(): void;
  146618. /**
  146619. * Disables the gravitational field.
  146620. */
  146621. disable(): void;
  146622. /**
  146623. * Disposes the sphere.
  146624. * @param force The force to dispose from the gravitational field event
  146625. */
  146626. dispose(force?: boolean): void;
  146627. private _tick;
  146628. }
  146629. /**
  146630. * Represents a physics updraft event
  146631. */
  146632. class PhysicsUpdraftEvent {
  146633. private _scene;
  146634. private _origin;
  146635. private _options;
  146636. private _physicsEngine;
  146637. private _originTop;
  146638. private _originDirection;
  146639. private _tickCallback;
  146640. private _cylinder;
  146641. private _cylinderPosition;
  146642. private _dataFetched;
  146643. /**
  146644. * Initializes the physics updraft event
  146645. * @param _scene BabylonJS scene
  146646. * @param _origin The origin position of the updraft
  146647. * @param _options The options for the updraft event
  146648. */
  146649. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  146650. /**
  146651. * Returns the data related to the updraft event (cylinder).
  146652. * @returns A physics updraft event
  146653. */
  146654. getData(): PhysicsUpdraftEventData;
  146655. /**
  146656. * Enables the updraft.
  146657. */
  146658. enable(): void;
  146659. /**
  146660. * Disables the updraft.
  146661. */
  146662. disable(): void;
  146663. /**
  146664. * Disposes the cylinder.
  146665. * @param force Specifies if the updraft should be disposed by force
  146666. */
  146667. dispose(force?: boolean): void;
  146668. private getImpostorHitData;
  146669. private _tick;
  146670. /*** Helpers ***/
  146671. private _prepareCylinder;
  146672. private _intersectsWithCylinder;
  146673. }
  146674. /**
  146675. * Represents a physics vortex event
  146676. */
  146677. class PhysicsVortexEvent {
  146678. private _scene;
  146679. private _origin;
  146680. private _options;
  146681. private _physicsEngine;
  146682. private _originTop;
  146683. private _tickCallback;
  146684. private _cylinder;
  146685. private _cylinderPosition;
  146686. private _dataFetched;
  146687. /**
  146688. * Initializes the physics vortex event
  146689. * @param _scene The BabylonJS scene
  146690. * @param _origin The origin position of the vortex
  146691. * @param _options The options for the vortex event
  146692. */
  146693. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  146694. /**
  146695. * Returns the data related to the vortex event (cylinder).
  146696. * @returns The physics vortex event data
  146697. */
  146698. getData(): PhysicsVortexEventData;
  146699. /**
  146700. * Enables the vortex.
  146701. */
  146702. enable(): void;
  146703. /**
  146704. * Disables the cortex.
  146705. */
  146706. disable(): void;
  146707. /**
  146708. * Disposes the sphere.
  146709. * @param force
  146710. */
  146711. dispose(force?: boolean): void;
  146712. private getImpostorHitData;
  146713. private _tick;
  146714. /*** Helpers ***/
  146715. private _prepareCylinder;
  146716. private _intersectsWithCylinder;
  146717. }
  146718. /**
  146719. * Options fot the radial explosion event
  146720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146721. */
  146722. export class PhysicsRadialExplosionEventOptions {
  146723. /**
  146724. * The radius of the sphere for the radial explosion.
  146725. */
  146726. radius: number;
  146727. /**
  146728. * The strenth of the explosion.
  146729. */
  146730. strength: number;
  146731. /**
  146732. * The strenght of the force in correspondence to the distance of the affected object
  146733. */
  146734. falloff: PhysicsRadialImpulseFalloff;
  146735. /**
  146736. * Sphere options for the radial explosion.
  146737. */
  146738. sphere: {
  146739. segments: number;
  146740. diameter: number;
  146741. };
  146742. /**
  146743. * Sphere options for the radial explosion.
  146744. */
  146745. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  146746. }
  146747. /**
  146748. * Options fot the updraft event
  146749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146750. */
  146751. export class PhysicsUpdraftEventOptions {
  146752. /**
  146753. * The radius of the cylinder for the vortex
  146754. */
  146755. radius: number;
  146756. /**
  146757. * The strenth of the updraft.
  146758. */
  146759. strength: number;
  146760. /**
  146761. * The height of the cylinder for the updraft.
  146762. */
  146763. height: number;
  146764. /**
  146765. * The mode for the the updraft.
  146766. */
  146767. updraftMode: PhysicsUpdraftMode;
  146768. }
  146769. /**
  146770. * Options fot the vortex event
  146771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146772. */
  146773. export class PhysicsVortexEventOptions {
  146774. /**
  146775. * The radius of the cylinder for the vortex
  146776. */
  146777. radius: number;
  146778. /**
  146779. * The strenth of the vortex.
  146780. */
  146781. strength: number;
  146782. /**
  146783. * The height of the cylinder for the vortex.
  146784. */
  146785. height: number;
  146786. /**
  146787. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146788. */
  146789. centripetalForceThreshold: number;
  146790. /**
  146791. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146792. */
  146793. centripetalForceMultiplier: number;
  146794. /**
  146795. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146796. */
  146797. centrifugalForceMultiplier: number;
  146798. /**
  146799. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146800. */
  146801. updraftForceMultiplier: number;
  146802. }
  146803. /**
  146804. * The strenght of the force in correspondence to the distance of the affected object
  146805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146806. */
  146807. export enum PhysicsRadialImpulseFalloff {
  146808. /** Defines that impulse is constant in strength across it's whole radius */
  146809. Constant = 0,
  146810. /** Defines that impulse gets weaker if it's further from the origin */
  146811. Linear = 1
  146812. }
  146813. /**
  146814. * The strength of the force in correspondence to the distance of the affected object
  146815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146816. */
  146817. export enum PhysicsUpdraftMode {
  146818. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146819. Center = 0,
  146820. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146821. Perpendicular = 1
  146822. }
  146823. /**
  146824. * Interface for a physics hit data
  146825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146826. */
  146827. export interface PhysicsHitData {
  146828. /**
  146829. * The force applied at the contact point
  146830. */
  146831. force: Vector3;
  146832. /**
  146833. * The contact point
  146834. */
  146835. contactPoint: Vector3;
  146836. /**
  146837. * The distance from the origin to the contact point
  146838. */
  146839. distanceFromOrigin: number;
  146840. }
  146841. /**
  146842. * Interface for radial explosion event data
  146843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146844. */
  146845. export interface PhysicsRadialExplosionEventData {
  146846. /**
  146847. * A sphere used for the radial explosion event
  146848. */
  146849. sphere: Mesh;
  146850. }
  146851. /**
  146852. * Interface for gravitational field event data
  146853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146854. */
  146855. export interface PhysicsGravitationalFieldEventData {
  146856. /**
  146857. * A sphere mesh used for the gravitational field event
  146858. */
  146859. sphere: Mesh;
  146860. }
  146861. /**
  146862. * Interface for updraft event data
  146863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146864. */
  146865. export interface PhysicsUpdraftEventData {
  146866. /**
  146867. * A cylinder used for the updraft event
  146868. */
  146869. cylinder: Mesh;
  146870. }
  146871. /**
  146872. * Interface for vortex event data
  146873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146874. */
  146875. export interface PhysicsVortexEventData {
  146876. /**
  146877. * A cylinder used for the vortex event
  146878. */
  146879. cylinder: Mesh;
  146880. }
  146881. /**
  146882. * Interface for an affected physics impostor
  146883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146884. */
  146885. export interface PhysicsAffectedImpostorWithData {
  146886. /**
  146887. * The impostor affected by the effect
  146888. */
  146889. impostor: PhysicsImpostor;
  146890. /**
  146891. * The data about the hit/horce from the explosion
  146892. */
  146893. hitData: PhysicsHitData;
  146894. }
  146895. }
  146896. declare module BABYLON {
  146897. /** @hidden */
  146898. export var blackAndWhitePixelShader: {
  146899. name: string;
  146900. shader: string;
  146901. };
  146902. }
  146903. declare module BABYLON {
  146904. /**
  146905. * Post process used to render in black and white
  146906. */
  146907. export class BlackAndWhitePostProcess extends PostProcess {
  146908. /**
  146909. * Linear about to convert he result to black and white (default: 1)
  146910. */
  146911. degree: number;
  146912. /**
  146913. * Creates a black and white post process
  146914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146915. * @param name The name of the effect.
  146916. * @param options The required width/height ratio to downsize to before computing the render pass.
  146917. * @param camera The camera to apply the render pass to.
  146918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146919. * @param engine The engine which the post process will be applied. (default: current engine)
  146920. * @param reusable If the post process can be reused on the same frame. (default: false)
  146921. */
  146922. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146923. }
  146924. }
  146925. declare module BABYLON {
  146926. /**
  146927. * This represents a set of one or more post processes in Babylon.
  146928. * A post process can be used to apply a shader to a texture after it is rendered.
  146929. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146930. */
  146931. export class PostProcessRenderEffect {
  146932. private _postProcesses;
  146933. private _getPostProcesses;
  146934. private _singleInstance;
  146935. private _cameras;
  146936. private _indicesForCamera;
  146937. /**
  146938. * Name of the effect
  146939. * @hidden
  146940. */
  146941. _name: string;
  146942. /**
  146943. * Instantiates a post process render effect.
  146944. * A post process can be used to apply a shader to a texture after it is rendered.
  146945. * @param engine The engine the effect is tied to
  146946. * @param name The name of the effect
  146947. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146948. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146949. */
  146950. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146951. /**
  146952. * Checks if all the post processes in the effect are supported.
  146953. */
  146954. get isSupported(): boolean;
  146955. /**
  146956. * Updates the current state of the effect
  146957. * @hidden
  146958. */
  146959. _update(): void;
  146960. /**
  146961. * Attaches the effect on cameras
  146962. * @param cameras The camera to attach to.
  146963. * @hidden
  146964. */
  146965. _attachCameras(cameras: Camera): void;
  146966. /**
  146967. * Attaches the effect on cameras
  146968. * @param cameras The camera to attach to.
  146969. * @hidden
  146970. */
  146971. _attachCameras(cameras: Camera[]): void;
  146972. /**
  146973. * Detaches the effect on cameras
  146974. * @param cameras The camera to detatch from.
  146975. * @hidden
  146976. */
  146977. _detachCameras(cameras: Camera): void;
  146978. /**
  146979. * Detatches the effect on cameras
  146980. * @param cameras The camera to detatch from.
  146981. * @hidden
  146982. */
  146983. _detachCameras(cameras: Camera[]): void;
  146984. /**
  146985. * Enables the effect on given cameras
  146986. * @param cameras The camera to enable.
  146987. * @hidden
  146988. */
  146989. _enable(cameras: Camera): void;
  146990. /**
  146991. * Enables the effect on given cameras
  146992. * @param cameras The camera to enable.
  146993. * @hidden
  146994. */
  146995. _enable(cameras: Nullable<Camera[]>): void;
  146996. /**
  146997. * Disables the effect on the given cameras
  146998. * @param cameras The camera to disable.
  146999. * @hidden
  147000. */
  147001. _disable(cameras: Camera): void;
  147002. /**
  147003. * Disables the effect on the given cameras
  147004. * @param cameras The camera to disable.
  147005. * @hidden
  147006. */
  147007. _disable(cameras: Nullable<Camera[]>): void;
  147008. /**
  147009. * Gets a list of the post processes contained in the effect.
  147010. * @param camera The camera to get the post processes on.
  147011. * @returns The list of the post processes in the effect.
  147012. */
  147013. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147014. }
  147015. }
  147016. declare module BABYLON {
  147017. /** @hidden */
  147018. export var extractHighlightsPixelShader: {
  147019. name: string;
  147020. shader: string;
  147021. };
  147022. }
  147023. declare module BABYLON {
  147024. /**
  147025. * 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.
  147026. */
  147027. export class ExtractHighlightsPostProcess extends PostProcess {
  147028. /**
  147029. * The luminance threshold, pixels below this value will be set to black.
  147030. */
  147031. threshold: number;
  147032. /** @hidden */
  147033. _exposure: number;
  147034. /**
  147035. * Post process which has the input texture to be used when performing highlight extraction
  147036. * @hidden
  147037. */
  147038. _inputPostProcess: Nullable<PostProcess>;
  147039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147040. }
  147041. }
  147042. declare module BABYLON {
  147043. /** @hidden */
  147044. export var bloomMergePixelShader: {
  147045. name: string;
  147046. shader: string;
  147047. };
  147048. }
  147049. declare module BABYLON {
  147050. /**
  147051. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147052. */
  147053. export class BloomMergePostProcess extends PostProcess {
  147054. /** Weight of the bloom to be added to the original input. */
  147055. weight: number;
  147056. /**
  147057. * Creates a new instance of @see BloomMergePostProcess
  147058. * @param name The name of the effect.
  147059. * @param originalFromInput Post process which's input will be used for the merge.
  147060. * @param blurred Blurred highlights post process which's output will be used.
  147061. * @param weight Weight of the bloom to be added to the original input.
  147062. * @param options The required width/height ratio to downsize to before computing the render pass.
  147063. * @param camera The camera to apply the render pass to.
  147064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147065. * @param engine The engine which the post process will be applied. (default: current engine)
  147066. * @param reusable If the post process can be reused on the same frame. (default: false)
  147067. * @param textureType Type of textures used when performing the post process. (default: 0)
  147068. * @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)
  147069. */
  147070. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147071. /** Weight of the bloom to be added to the original input. */
  147072. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147073. }
  147074. }
  147075. declare module BABYLON {
  147076. /**
  147077. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147078. */
  147079. export class BloomEffect extends PostProcessRenderEffect {
  147080. private bloomScale;
  147081. /**
  147082. * @hidden Internal
  147083. */
  147084. _effects: Array<PostProcess>;
  147085. /**
  147086. * @hidden Internal
  147087. */
  147088. _downscale: ExtractHighlightsPostProcess;
  147089. private _blurX;
  147090. private _blurY;
  147091. private _merge;
  147092. /**
  147093. * The luminance threshold to find bright areas of the image to bloom.
  147094. */
  147095. get threshold(): number;
  147096. set threshold(value: number);
  147097. /**
  147098. * The strength of the bloom.
  147099. */
  147100. get weight(): number;
  147101. set weight(value: number);
  147102. /**
  147103. * Specifies the size of the bloom blur kernel, relative to the final output size
  147104. */
  147105. get kernel(): number;
  147106. set kernel(value: number);
  147107. /**
  147108. * Creates a new instance of @see BloomEffect
  147109. * @param scene The scene the effect belongs to.
  147110. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147111. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147112. * @param bloomWeight The the strength of bloom.
  147113. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147114. * @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)
  147115. */
  147116. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147117. /**
  147118. * Disposes each of the internal effects for a given camera.
  147119. * @param camera The camera to dispose the effect on.
  147120. */
  147121. disposeEffects(camera: Camera): void;
  147122. /**
  147123. * @hidden Internal
  147124. */
  147125. _updateEffects(): void;
  147126. /**
  147127. * Internal
  147128. * @returns if all the contained post processes are ready.
  147129. * @hidden
  147130. */
  147131. _isReady(): boolean;
  147132. }
  147133. }
  147134. declare module BABYLON {
  147135. /** @hidden */
  147136. export var chromaticAberrationPixelShader: {
  147137. name: string;
  147138. shader: string;
  147139. };
  147140. }
  147141. declare module BABYLON {
  147142. /**
  147143. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147144. */
  147145. export class ChromaticAberrationPostProcess extends PostProcess {
  147146. /**
  147147. * The amount of seperation of rgb channels (default: 30)
  147148. */
  147149. aberrationAmount: number;
  147150. /**
  147151. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147152. */
  147153. radialIntensity: number;
  147154. /**
  147155. * 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))
  147156. */
  147157. direction: Vector2;
  147158. /**
  147159. * 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))
  147160. */
  147161. centerPosition: Vector2;
  147162. /**
  147163. * Creates a new instance ChromaticAberrationPostProcess
  147164. * @param name The name of the effect.
  147165. * @param screenWidth The width of the screen to apply the effect on.
  147166. * @param screenHeight The height of the screen to apply the effect on.
  147167. * @param options The required width/height ratio to downsize to before computing the render pass.
  147168. * @param camera The camera to apply the render pass to.
  147169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147170. * @param engine The engine which the post process will be applied. (default: current engine)
  147171. * @param reusable If the post process can be reused on the same frame. (default: false)
  147172. * @param textureType Type of textures used when performing the post process. (default: 0)
  147173. * @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)
  147174. */
  147175. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147176. }
  147177. }
  147178. declare module BABYLON {
  147179. /** @hidden */
  147180. export var circleOfConfusionPixelShader: {
  147181. name: string;
  147182. shader: string;
  147183. };
  147184. }
  147185. declare module BABYLON {
  147186. /**
  147187. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147188. */
  147189. export class CircleOfConfusionPostProcess extends PostProcess {
  147190. /**
  147191. * 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.
  147192. */
  147193. lensSize: number;
  147194. /**
  147195. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147196. */
  147197. fStop: number;
  147198. /**
  147199. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147200. */
  147201. focusDistance: number;
  147202. /**
  147203. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147204. */
  147205. focalLength: number;
  147206. private _depthTexture;
  147207. /**
  147208. * Creates a new instance CircleOfConfusionPostProcess
  147209. * @param name The name of the effect.
  147210. * @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.
  147211. * @param options The required width/height ratio to downsize to before computing the render pass.
  147212. * @param camera The camera to apply the render pass to.
  147213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147214. * @param engine The engine which the post process will be applied. (default: current engine)
  147215. * @param reusable If the post process can be reused on the same frame. (default: false)
  147216. * @param textureType Type of textures used when performing the post process. (default: 0)
  147217. * @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)
  147218. */
  147219. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147220. /**
  147221. * 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.
  147222. */
  147223. set depthTexture(value: RenderTargetTexture);
  147224. }
  147225. }
  147226. declare module BABYLON {
  147227. /** @hidden */
  147228. export var colorCorrectionPixelShader: {
  147229. name: string;
  147230. shader: string;
  147231. };
  147232. }
  147233. declare module BABYLON {
  147234. /**
  147235. *
  147236. * This post-process allows the modification of rendered colors by using
  147237. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147238. *
  147239. * The object needs to be provided an url to a texture containing the color
  147240. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147241. * Use an image editing software to tweak the LUT to match your needs.
  147242. *
  147243. * For an example of a color LUT, see here:
  147244. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147245. * For explanations on color grading, see here:
  147246. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147247. *
  147248. */
  147249. export class ColorCorrectionPostProcess extends PostProcess {
  147250. private _colorTableTexture;
  147251. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147252. }
  147253. }
  147254. declare module BABYLON {
  147255. /** @hidden */
  147256. export var convolutionPixelShader: {
  147257. name: string;
  147258. shader: string;
  147259. };
  147260. }
  147261. declare module BABYLON {
  147262. /**
  147263. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147264. * input texture to perform effects such as edge detection or sharpening
  147265. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147266. */
  147267. export class ConvolutionPostProcess extends PostProcess {
  147268. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147269. kernel: number[];
  147270. /**
  147271. * Creates a new instance ConvolutionPostProcess
  147272. * @param name The name of the effect.
  147273. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147274. * @param options The required width/height ratio to downsize to before computing the render pass.
  147275. * @param camera The camera to apply the render pass to.
  147276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147277. * @param engine The engine which the post process will be applied. (default: current engine)
  147278. * @param reusable If the post process can be reused on the same frame. (default: false)
  147279. * @param textureType Type of textures used when performing the post process. (default: 0)
  147280. */
  147281. constructor(name: string,
  147282. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147283. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147284. /**
  147285. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147286. */
  147287. static EdgeDetect0Kernel: number[];
  147288. /**
  147289. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147290. */
  147291. static EdgeDetect1Kernel: number[];
  147292. /**
  147293. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147294. */
  147295. static EdgeDetect2Kernel: number[];
  147296. /**
  147297. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147298. */
  147299. static SharpenKernel: number[];
  147300. /**
  147301. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147302. */
  147303. static EmbossKernel: number[];
  147304. /**
  147305. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147306. */
  147307. static GaussianKernel: number[];
  147308. }
  147309. }
  147310. declare module BABYLON {
  147311. /**
  147312. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  147313. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  147314. * based on samples that have a large difference in distance than the center pixel.
  147315. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  147316. */
  147317. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  147318. direction: Vector2;
  147319. /**
  147320. * Creates a new instance CircleOfConfusionPostProcess
  147321. * @param name The name of the effect.
  147322. * @param scene The scene the effect belongs to.
  147323. * @param direction The direction the blur should be applied.
  147324. * @param kernel The size of the kernel used to blur.
  147325. * @param options The required width/height ratio to downsize to before computing the render pass.
  147326. * @param camera The camera to apply the render pass to.
  147327. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  147328. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  147329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147330. * @param engine The engine which the post process will be applied. (default: current engine)
  147331. * @param reusable If the post process can be reused on the same frame. (default: false)
  147332. * @param textureType Type of textures used when performing the post process. (default: 0)
  147333. * @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)
  147334. */
  147335. 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);
  147336. }
  147337. }
  147338. declare module BABYLON {
  147339. /** @hidden */
  147340. export var depthOfFieldMergePixelShader: {
  147341. name: string;
  147342. shader: string;
  147343. };
  147344. }
  147345. declare module BABYLON {
  147346. /**
  147347. * Options to be set when merging outputs from the default pipeline.
  147348. */
  147349. export class DepthOfFieldMergePostProcessOptions {
  147350. /**
  147351. * The original image to merge on top of
  147352. */
  147353. originalFromInput: PostProcess;
  147354. /**
  147355. * Parameters to perform the merge of the depth of field effect
  147356. */
  147357. depthOfField?: {
  147358. circleOfConfusion: PostProcess;
  147359. blurSteps: Array<PostProcess>;
  147360. };
  147361. /**
  147362. * Parameters to perform the merge of bloom effect
  147363. */
  147364. bloom?: {
  147365. blurred: PostProcess;
  147366. weight: number;
  147367. };
  147368. }
  147369. /**
  147370. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147371. */
  147372. export class DepthOfFieldMergePostProcess extends PostProcess {
  147373. private blurSteps;
  147374. /**
  147375. * Creates a new instance of DepthOfFieldMergePostProcess
  147376. * @param name The name of the effect.
  147377. * @param originalFromInput Post process which's input will be used for the merge.
  147378. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  147379. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  147380. * @param options The required width/height ratio to downsize to before computing the render pass.
  147381. * @param camera The camera to apply the render pass to.
  147382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147383. * @param engine The engine which the post process will be applied. (default: current engine)
  147384. * @param reusable If the post process can be reused on the same frame. (default: false)
  147385. * @param textureType Type of textures used when performing the post process. (default: 0)
  147386. * @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)
  147387. */
  147388. 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);
  147389. /**
  147390. * Updates the effect with the current post process compile time values and recompiles the shader.
  147391. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  147392. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  147393. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  147394. * @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
  147395. * @param onCompiled Called when the shader has been compiled.
  147396. * @param onError Called if there is an error when compiling a shader.
  147397. */
  147398. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  147399. }
  147400. }
  147401. declare module BABYLON {
  147402. /**
  147403. * Specifies the level of max blur that should be applied when using the depth of field effect
  147404. */
  147405. export enum DepthOfFieldEffectBlurLevel {
  147406. /**
  147407. * Subtle blur
  147408. */
  147409. Low = 0,
  147410. /**
  147411. * Medium blur
  147412. */
  147413. Medium = 1,
  147414. /**
  147415. * Large blur
  147416. */
  147417. High = 2
  147418. }
  147419. /**
  147420. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  147421. */
  147422. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  147423. private _circleOfConfusion;
  147424. /**
  147425. * @hidden Internal, blurs from high to low
  147426. */
  147427. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  147428. private _depthOfFieldBlurY;
  147429. private _dofMerge;
  147430. /**
  147431. * @hidden Internal post processes in depth of field effect
  147432. */
  147433. _effects: Array<PostProcess>;
  147434. /**
  147435. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  147436. */
  147437. set focalLength(value: number);
  147438. get focalLength(): number;
  147439. /**
  147440. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147441. */
  147442. set fStop(value: number);
  147443. get fStop(): number;
  147444. /**
  147445. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147446. */
  147447. set focusDistance(value: number);
  147448. get focusDistance(): number;
  147449. /**
  147450. * 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.
  147451. */
  147452. set lensSize(value: number);
  147453. get lensSize(): number;
  147454. /**
  147455. * Creates a new instance DepthOfFieldEffect
  147456. * @param scene The scene the effect belongs to.
  147457. * @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.
  147458. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147459. * @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)
  147460. */
  147461. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  147462. /**
  147463. * Get the current class name of the current effet
  147464. * @returns "DepthOfFieldEffect"
  147465. */
  147466. getClassName(): string;
  147467. /**
  147468. * 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.
  147469. */
  147470. set depthTexture(value: RenderTargetTexture);
  147471. /**
  147472. * Disposes each of the internal effects for a given camera.
  147473. * @param camera The camera to dispose the effect on.
  147474. */
  147475. disposeEffects(camera: Camera): void;
  147476. /**
  147477. * @hidden Internal
  147478. */
  147479. _updateEffects(): void;
  147480. /**
  147481. * Internal
  147482. * @returns if all the contained post processes are ready.
  147483. * @hidden
  147484. */
  147485. _isReady(): boolean;
  147486. }
  147487. }
  147488. declare module BABYLON {
  147489. /** @hidden */
  147490. export var displayPassPixelShader: {
  147491. name: string;
  147492. shader: string;
  147493. };
  147494. }
  147495. declare module BABYLON {
  147496. /**
  147497. * DisplayPassPostProcess which produces an output the same as it's input
  147498. */
  147499. export class DisplayPassPostProcess extends PostProcess {
  147500. /**
  147501. * Creates the DisplayPassPostProcess
  147502. * @param name The name of the effect.
  147503. * @param options The required width/height ratio to downsize to before computing the render pass.
  147504. * @param camera The camera to apply the render pass to.
  147505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147506. * @param engine The engine which the post process will be applied. (default: current engine)
  147507. * @param reusable If the post process can be reused on the same frame. (default: false)
  147508. */
  147509. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147510. }
  147511. }
  147512. declare module BABYLON {
  147513. /** @hidden */
  147514. export var filterPixelShader: {
  147515. name: string;
  147516. shader: string;
  147517. };
  147518. }
  147519. declare module BABYLON {
  147520. /**
  147521. * Applies a kernel filter to the image
  147522. */
  147523. export class FilterPostProcess extends PostProcess {
  147524. /** The matrix to be applied to the image */
  147525. kernelMatrix: Matrix;
  147526. /**
  147527. *
  147528. * @param name The name of the effect.
  147529. * @param kernelMatrix The matrix to be applied to the image
  147530. * @param options The required width/height ratio to downsize to before computing the render pass.
  147531. * @param camera The camera to apply the render pass to.
  147532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147533. * @param engine The engine which the post process will be applied. (default: current engine)
  147534. * @param reusable If the post process can be reused on the same frame. (default: false)
  147535. */
  147536. constructor(name: string,
  147537. /** The matrix to be applied to the image */
  147538. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147539. }
  147540. }
  147541. declare module BABYLON {
  147542. /** @hidden */
  147543. export var fxaaPixelShader: {
  147544. name: string;
  147545. shader: string;
  147546. };
  147547. }
  147548. declare module BABYLON {
  147549. /** @hidden */
  147550. export var fxaaVertexShader: {
  147551. name: string;
  147552. shader: string;
  147553. };
  147554. }
  147555. declare module BABYLON {
  147556. /**
  147557. * Fxaa post process
  147558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  147559. */
  147560. export class FxaaPostProcess extends PostProcess {
  147561. /** @hidden */
  147562. texelWidth: number;
  147563. /** @hidden */
  147564. texelHeight: number;
  147565. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147566. private _getDefines;
  147567. }
  147568. }
  147569. declare module BABYLON {
  147570. /** @hidden */
  147571. export var grainPixelShader: {
  147572. name: string;
  147573. shader: string;
  147574. };
  147575. }
  147576. declare module BABYLON {
  147577. /**
  147578. * The GrainPostProcess adds noise to the image at mid luminance levels
  147579. */
  147580. export class GrainPostProcess extends PostProcess {
  147581. /**
  147582. * The intensity of the grain added (default: 30)
  147583. */
  147584. intensity: number;
  147585. /**
  147586. * If the grain should be randomized on every frame
  147587. */
  147588. animated: boolean;
  147589. /**
  147590. * Creates a new instance of @see GrainPostProcess
  147591. * @param name The name of the effect.
  147592. * @param options The required width/height ratio to downsize to before computing the render pass.
  147593. * @param camera The camera to apply the render pass to.
  147594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147595. * @param engine The engine which the post process will be applied. (default: current engine)
  147596. * @param reusable If the post process can be reused on the same frame. (default: false)
  147597. * @param textureType Type of textures used when performing the post process. (default: 0)
  147598. * @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)
  147599. */
  147600. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147601. }
  147602. }
  147603. declare module BABYLON {
  147604. /** @hidden */
  147605. export var highlightsPixelShader: {
  147606. name: string;
  147607. shader: string;
  147608. };
  147609. }
  147610. declare module BABYLON {
  147611. /**
  147612. * Extracts highlights from the image
  147613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147614. */
  147615. export class HighlightsPostProcess extends PostProcess {
  147616. /**
  147617. * Extracts highlights from the image
  147618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147619. * @param name The name of the effect.
  147620. * @param options The required width/height ratio to downsize to before computing the render pass.
  147621. * @param camera The camera to apply the render pass to.
  147622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147623. * @param engine The engine which the post process will be applied. (default: current engine)
  147624. * @param reusable If the post process can be reused on the same frame. (default: false)
  147625. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  147626. */
  147627. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147628. }
  147629. }
  147630. declare module BABYLON {
  147631. /** @hidden */
  147632. export var mrtFragmentDeclaration: {
  147633. name: string;
  147634. shader: string;
  147635. };
  147636. }
  147637. declare module BABYLON {
  147638. /** @hidden */
  147639. export var geometryPixelShader: {
  147640. name: string;
  147641. shader: string;
  147642. };
  147643. }
  147644. declare module BABYLON {
  147645. /** @hidden */
  147646. export var geometryVertexShader: {
  147647. name: string;
  147648. shader: string;
  147649. };
  147650. }
  147651. declare module BABYLON {
  147652. /** @hidden */
  147653. interface ISavedTransformationMatrix {
  147654. world: Matrix;
  147655. viewProjection: Matrix;
  147656. }
  147657. /**
  147658. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  147659. */
  147660. export class GeometryBufferRenderer {
  147661. /**
  147662. * Constant used to retrieve the position texture index in the G-Buffer textures array
  147663. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  147664. */
  147665. static readonly POSITION_TEXTURE_TYPE: number;
  147666. /**
  147667. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  147668. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  147669. */
  147670. static readonly VELOCITY_TEXTURE_TYPE: number;
  147671. /**
  147672. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  147673. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  147674. */
  147675. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  147676. /**
  147677. * Dictionary used to store the previous transformation matrices of each rendered mesh
  147678. * in order to compute objects velocities when enableVelocity is set to "true"
  147679. * @hidden
  147680. */
  147681. _previousTransformationMatrices: {
  147682. [index: number]: ISavedTransformationMatrix;
  147683. };
  147684. /**
  147685. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  147686. * in order to compute objects velocities when enableVelocity is set to "true"
  147687. * @hidden
  147688. */
  147689. _previousBonesTransformationMatrices: {
  147690. [index: number]: Float32Array;
  147691. };
  147692. /**
  147693. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  147694. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  147695. */
  147696. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  147697. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  147698. renderTransparentMeshes: boolean;
  147699. private _scene;
  147700. private _resizeObserver;
  147701. private _multiRenderTarget;
  147702. private _ratio;
  147703. private _enablePosition;
  147704. private _enableVelocity;
  147705. private _enableReflectivity;
  147706. private _positionIndex;
  147707. private _velocityIndex;
  147708. private _reflectivityIndex;
  147709. protected _effect: Effect;
  147710. protected _cachedDefines: string;
  147711. /**
  147712. * Set the render list (meshes to be rendered) used in the G buffer.
  147713. */
  147714. set renderList(meshes: Mesh[]);
  147715. /**
  147716. * Gets wether or not G buffer are supported by the running hardware.
  147717. * This requires draw buffer supports
  147718. */
  147719. get isSupported(): boolean;
  147720. /**
  147721. * Returns the index of the given texture type in the G-Buffer textures array
  147722. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  147723. * @returns the index of the given texture type in the G-Buffer textures array
  147724. */
  147725. getTextureIndex(textureType: number): number;
  147726. /**
  147727. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  147728. */
  147729. get enablePosition(): boolean;
  147730. /**
  147731. * Sets whether or not objects positions are enabled for the G buffer.
  147732. */
  147733. set enablePosition(enable: boolean);
  147734. /**
  147735. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  147736. */
  147737. get enableVelocity(): boolean;
  147738. /**
  147739. * Sets wether or not objects velocities are enabled for the G buffer.
  147740. */
  147741. set enableVelocity(enable: boolean);
  147742. /**
  147743. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  147744. */
  147745. get enableReflectivity(): boolean;
  147746. /**
  147747. * Sets wether or not objects roughness are enabled for the G buffer.
  147748. */
  147749. set enableReflectivity(enable: boolean);
  147750. /**
  147751. * Gets the scene associated with the buffer.
  147752. */
  147753. get scene(): Scene;
  147754. /**
  147755. * Gets the ratio used by the buffer during its creation.
  147756. * How big is the buffer related to the main canvas.
  147757. */
  147758. get ratio(): number;
  147759. /** @hidden */
  147760. static _SceneComponentInitialization: (scene: Scene) => void;
  147761. /**
  147762. * Creates a new G Buffer for the scene
  147763. * @param scene The scene the buffer belongs to
  147764. * @param ratio How big is the buffer related to the main canvas.
  147765. */
  147766. constructor(scene: Scene, ratio?: number);
  147767. /**
  147768. * Checks wether everything is ready to render a submesh to the G buffer.
  147769. * @param subMesh the submesh to check readiness for
  147770. * @param useInstances is the mesh drawn using instance or not
  147771. * @returns true if ready otherwise false
  147772. */
  147773. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147774. /**
  147775. * Gets the current underlying G Buffer.
  147776. * @returns the buffer
  147777. */
  147778. getGBuffer(): MultiRenderTarget;
  147779. /**
  147780. * Gets the number of samples used to render the buffer (anti aliasing).
  147781. */
  147782. get samples(): number;
  147783. /**
  147784. * Sets the number of samples used to render the buffer (anti aliasing).
  147785. */
  147786. set samples(value: number);
  147787. /**
  147788. * Disposes the renderer and frees up associated resources.
  147789. */
  147790. dispose(): void;
  147791. protected _createRenderTargets(): void;
  147792. private _copyBonesTransformationMatrices;
  147793. }
  147794. }
  147795. declare module BABYLON {
  147796. interface Scene {
  147797. /** @hidden (Backing field) */
  147798. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147799. /**
  147800. * Gets or Sets the current geometry buffer associated to the scene.
  147801. */
  147802. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147803. /**
  147804. * Enables a GeometryBufferRender and associates it with the scene
  147805. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147806. * @returns the GeometryBufferRenderer
  147807. */
  147808. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147809. /**
  147810. * Disables the GeometryBufferRender associated with the scene
  147811. */
  147812. disableGeometryBufferRenderer(): void;
  147813. }
  147814. /**
  147815. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147816. * in several rendering techniques.
  147817. */
  147818. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147819. /**
  147820. * The component name helpful to identify the component in the list of scene components.
  147821. */
  147822. readonly name: string;
  147823. /**
  147824. * The scene the component belongs to.
  147825. */
  147826. scene: Scene;
  147827. /**
  147828. * Creates a new instance of the component for the given scene
  147829. * @param scene Defines the scene to register the component in
  147830. */
  147831. constructor(scene: Scene);
  147832. /**
  147833. * Registers the component in a given scene
  147834. */
  147835. register(): void;
  147836. /**
  147837. * Rebuilds the elements related to this component in case of
  147838. * context lost for instance.
  147839. */
  147840. rebuild(): void;
  147841. /**
  147842. * Disposes the component and the associated ressources
  147843. */
  147844. dispose(): void;
  147845. private _gatherRenderTargets;
  147846. }
  147847. }
  147848. declare module BABYLON {
  147849. /** @hidden */
  147850. export var motionBlurPixelShader: {
  147851. name: string;
  147852. shader: string;
  147853. };
  147854. }
  147855. declare module BABYLON {
  147856. /**
  147857. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147858. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147859. * As an example, all you have to do is to create the post-process:
  147860. * var mb = new BABYLON.MotionBlurPostProcess(
  147861. * 'mb', // The name of the effect.
  147862. * scene, // The scene containing the objects to blur according to their velocity.
  147863. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147864. * camera // The camera to apply the render pass to.
  147865. * );
  147866. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147867. */
  147868. export class MotionBlurPostProcess extends PostProcess {
  147869. /**
  147870. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147871. */
  147872. motionStrength: number;
  147873. /**
  147874. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147875. */
  147876. get motionBlurSamples(): number;
  147877. /**
  147878. * Sets the number of iterations to be used for motion blur quality
  147879. */
  147880. set motionBlurSamples(samples: number);
  147881. private _motionBlurSamples;
  147882. private _geometryBufferRenderer;
  147883. /**
  147884. * Creates a new instance MotionBlurPostProcess
  147885. * @param name The name of the effect.
  147886. * @param scene The scene containing the objects to blur according to their velocity.
  147887. * @param options The required width/height ratio to downsize to before computing the render pass.
  147888. * @param camera The camera to apply the render pass to.
  147889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147890. * @param engine The engine which the post process will be applied. (default: current engine)
  147891. * @param reusable If the post process can be reused on the same frame. (default: false)
  147892. * @param textureType Type of textures used when performing the post process. (default: 0)
  147893. * @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)
  147894. */
  147895. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147896. /**
  147897. * Excludes the given skinned mesh from computing bones velocities.
  147898. * 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.
  147899. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147900. */
  147901. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147902. /**
  147903. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147904. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147905. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147906. */
  147907. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147908. /**
  147909. * Disposes the post process.
  147910. * @param camera The camera to dispose the post process on.
  147911. */
  147912. dispose(camera?: Camera): void;
  147913. }
  147914. }
  147915. declare module BABYLON {
  147916. /** @hidden */
  147917. export var refractionPixelShader: {
  147918. name: string;
  147919. shader: string;
  147920. };
  147921. }
  147922. declare module BABYLON {
  147923. /**
  147924. * Post process which applies a refractin texture
  147925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147926. */
  147927. export class RefractionPostProcess extends PostProcess {
  147928. /** the base color of the refraction (used to taint the rendering) */
  147929. color: Color3;
  147930. /** simulated refraction depth */
  147931. depth: number;
  147932. /** the coefficient of the base color (0 to remove base color tainting) */
  147933. colorLevel: number;
  147934. private _refTexture;
  147935. private _ownRefractionTexture;
  147936. /**
  147937. * Gets or sets the refraction texture
  147938. * Please note that you are responsible for disposing the texture if you set it manually
  147939. */
  147940. get refractionTexture(): Texture;
  147941. set refractionTexture(value: Texture);
  147942. /**
  147943. * Initializes the RefractionPostProcess
  147944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147945. * @param name The name of the effect.
  147946. * @param refractionTextureUrl Url of the refraction texture to use
  147947. * @param color the base color of the refraction (used to taint the rendering)
  147948. * @param depth simulated refraction depth
  147949. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147950. * @param camera The camera to apply the render pass to.
  147951. * @param options The required width/height ratio to downsize to before computing the render pass.
  147952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147953. * @param engine The engine which the post process will be applied. (default: current engine)
  147954. * @param reusable If the post process can be reused on the same frame. (default: false)
  147955. */
  147956. constructor(name: string, refractionTextureUrl: string,
  147957. /** the base color of the refraction (used to taint the rendering) */
  147958. color: Color3,
  147959. /** simulated refraction depth */
  147960. depth: number,
  147961. /** the coefficient of the base color (0 to remove base color tainting) */
  147962. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147963. /**
  147964. * Disposes of the post process
  147965. * @param camera Camera to dispose post process on
  147966. */
  147967. dispose(camera: Camera): void;
  147968. }
  147969. }
  147970. declare module BABYLON {
  147971. /** @hidden */
  147972. export var sharpenPixelShader: {
  147973. name: string;
  147974. shader: string;
  147975. };
  147976. }
  147977. declare module BABYLON {
  147978. /**
  147979. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147980. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147981. */
  147982. export class SharpenPostProcess extends PostProcess {
  147983. /**
  147984. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147985. */
  147986. colorAmount: number;
  147987. /**
  147988. * How much sharpness should be applied (default: 0.3)
  147989. */
  147990. edgeAmount: number;
  147991. /**
  147992. * Creates a new instance ConvolutionPostProcess
  147993. * @param name The name of the effect.
  147994. * @param options The required width/height ratio to downsize to before computing the render pass.
  147995. * @param camera The camera to apply the render pass to.
  147996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147997. * @param engine The engine which the post process will be applied. (default: current engine)
  147998. * @param reusable If the post process can be reused on the same frame. (default: false)
  147999. * @param textureType Type of textures used when performing the post process. (default: 0)
  148000. * @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)
  148001. */
  148002. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148003. }
  148004. }
  148005. declare module BABYLON {
  148006. /**
  148007. * PostProcessRenderPipeline
  148008. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148009. */
  148010. export class PostProcessRenderPipeline {
  148011. private engine;
  148012. private _renderEffects;
  148013. private _renderEffectsForIsolatedPass;
  148014. /**
  148015. * List of inspectable custom properties (used by the Inspector)
  148016. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148017. */
  148018. inspectableCustomProperties: IInspectable[];
  148019. /**
  148020. * @hidden
  148021. */
  148022. protected _cameras: Camera[];
  148023. /** @hidden */
  148024. _name: string;
  148025. /**
  148026. * Gets pipeline name
  148027. */
  148028. get name(): string;
  148029. /** Gets the list of attached cameras */
  148030. get cameras(): Camera[];
  148031. /**
  148032. * Initializes a PostProcessRenderPipeline
  148033. * @param engine engine to add the pipeline to
  148034. * @param name name of the pipeline
  148035. */
  148036. constructor(engine: Engine, name: string);
  148037. /**
  148038. * Gets the class name
  148039. * @returns "PostProcessRenderPipeline"
  148040. */
  148041. getClassName(): string;
  148042. /**
  148043. * If all the render effects in the pipeline are supported
  148044. */
  148045. get isSupported(): boolean;
  148046. /**
  148047. * Adds an effect to the pipeline
  148048. * @param renderEffect the effect to add
  148049. */
  148050. addEffect(renderEffect: PostProcessRenderEffect): void;
  148051. /** @hidden */
  148052. _rebuild(): void;
  148053. /** @hidden */
  148054. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148055. /** @hidden */
  148056. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148057. /** @hidden */
  148058. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148059. /** @hidden */
  148060. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148061. /** @hidden */
  148062. _attachCameras(cameras: Camera, unique: boolean): void;
  148063. /** @hidden */
  148064. _attachCameras(cameras: Camera[], unique: boolean): void;
  148065. /** @hidden */
  148066. _detachCameras(cameras: Camera): void;
  148067. /** @hidden */
  148068. _detachCameras(cameras: Nullable<Camera[]>): void;
  148069. /** @hidden */
  148070. _update(): void;
  148071. /** @hidden */
  148072. _reset(): void;
  148073. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148074. /**
  148075. * Sets the required values to the prepass renderer.
  148076. * @param prePassRenderer defines the prepass renderer to setup.
  148077. * @returns true if the pre pass is needed.
  148078. */
  148079. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148080. /**
  148081. * Disposes of the pipeline
  148082. */
  148083. dispose(): void;
  148084. }
  148085. }
  148086. declare module BABYLON {
  148087. /**
  148088. * PostProcessRenderPipelineManager class
  148089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148090. */
  148091. export class PostProcessRenderPipelineManager {
  148092. private _renderPipelines;
  148093. /**
  148094. * Initializes a PostProcessRenderPipelineManager
  148095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148096. */
  148097. constructor();
  148098. /**
  148099. * Gets the list of supported render pipelines
  148100. */
  148101. get supportedPipelines(): PostProcessRenderPipeline[];
  148102. /**
  148103. * Adds a pipeline to the manager
  148104. * @param renderPipeline The pipeline to add
  148105. */
  148106. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148107. /**
  148108. * Attaches a camera to the pipeline
  148109. * @param renderPipelineName The name of the pipeline to attach to
  148110. * @param cameras the camera to attach
  148111. * @param unique if the camera can be attached multiple times to the pipeline
  148112. */
  148113. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148114. /**
  148115. * Detaches a camera from the pipeline
  148116. * @param renderPipelineName The name of the pipeline to detach from
  148117. * @param cameras the camera to detach
  148118. */
  148119. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148120. /**
  148121. * Enables an effect by name on a pipeline
  148122. * @param renderPipelineName the name of the pipeline to enable the effect in
  148123. * @param renderEffectName the name of the effect to enable
  148124. * @param cameras the cameras that the effect should be enabled on
  148125. */
  148126. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148127. /**
  148128. * Disables an effect by name on a pipeline
  148129. * @param renderPipelineName the name of the pipeline to disable the effect in
  148130. * @param renderEffectName the name of the effect to disable
  148131. * @param cameras the cameras that the effect should be disabled on
  148132. */
  148133. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148134. /**
  148135. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148136. */
  148137. update(): void;
  148138. /** @hidden */
  148139. _rebuild(): void;
  148140. /**
  148141. * Disposes of the manager and pipelines
  148142. */
  148143. dispose(): void;
  148144. }
  148145. }
  148146. declare module BABYLON {
  148147. interface Scene {
  148148. /** @hidden (Backing field) */
  148149. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148150. /**
  148151. * Gets the postprocess render pipeline manager
  148152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148153. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148154. */
  148155. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148156. }
  148157. /**
  148158. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148159. */
  148160. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148161. /**
  148162. * The component name helpfull to identify the component in the list of scene components.
  148163. */
  148164. readonly name: string;
  148165. /**
  148166. * The scene the component belongs to.
  148167. */
  148168. scene: Scene;
  148169. /**
  148170. * Creates a new instance of the component for the given scene
  148171. * @param scene Defines the scene to register the component in
  148172. */
  148173. constructor(scene: Scene);
  148174. /**
  148175. * Registers the component in a given scene
  148176. */
  148177. register(): void;
  148178. /**
  148179. * Rebuilds the elements related to this component in case of
  148180. * context lost for instance.
  148181. */
  148182. rebuild(): void;
  148183. /**
  148184. * Disposes the component and the associated ressources
  148185. */
  148186. dispose(): void;
  148187. private _gatherRenderTargets;
  148188. }
  148189. }
  148190. declare module BABYLON {
  148191. /**
  148192. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148193. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148194. */
  148195. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148196. private _scene;
  148197. private _camerasToBeAttached;
  148198. /**
  148199. * ID of the sharpen post process,
  148200. */
  148201. private readonly SharpenPostProcessId;
  148202. /**
  148203. * @ignore
  148204. * ID of the image processing post process;
  148205. */
  148206. readonly ImageProcessingPostProcessId: string;
  148207. /**
  148208. * @ignore
  148209. * ID of the Fast Approximate Anti-Aliasing post process;
  148210. */
  148211. readonly FxaaPostProcessId: string;
  148212. /**
  148213. * ID of the chromatic aberration post process,
  148214. */
  148215. private readonly ChromaticAberrationPostProcessId;
  148216. /**
  148217. * ID of the grain post process
  148218. */
  148219. private readonly GrainPostProcessId;
  148220. /**
  148221. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148222. */
  148223. sharpen: SharpenPostProcess;
  148224. private _sharpenEffect;
  148225. private bloom;
  148226. /**
  148227. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148228. */
  148229. depthOfField: DepthOfFieldEffect;
  148230. /**
  148231. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148232. */
  148233. fxaa: FxaaPostProcess;
  148234. /**
  148235. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148236. */
  148237. imageProcessing: ImageProcessingPostProcess;
  148238. /**
  148239. * Chromatic aberration post process which will shift rgb colors in the image
  148240. */
  148241. chromaticAberration: ChromaticAberrationPostProcess;
  148242. private _chromaticAberrationEffect;
  148243. /**
  148244. * Grain post process which add noise to the image
  148245. */
  148246. grain: GrainPostProcess;
  148247. private _grainEffect;
  148248. /**
  148249. * Glow post process which adds a glow to emissive areas of the image
  148250. */
  148251. private _glowLayer;
  148252. /**
  148253. * Animations which can be used to tweak settings over a period of time
  148254. */
  148255. animations: Animation[];
  148256. private _imageProcessingConfigurationObserver;
  148257. private _sharpenEnabled;
  148258. private _bloomEnabled;
  148259. private _depthOfFieldEnabled;
  148260. private _depthOfFieldBlurLevel;
  148261. private _fxaaEnabled;
  148262. private _imageProcessingEnabled;
  148263. private _defaultPipelineTextureType;
  148264. private _bloomScale;
  148265. private _chromaticAberrationEnabled;
  148266. private _grainEnabled;
  148267. private _buildAllowed;
  148268. /**
  148269. * Gets active scene
  148270. */
  148271. get scene(): Scene;
  148272. /**
  148273. * Enable or disable the sharpen process from the pipeline
  148274. */
  148275. set sharpenEnabled(enabled: boolean);
  148276. get sharpenEnabled(): boolean;
  148277. private _resizeObserver;
  148278. private _hardwareScaleLevel;
  148279. private _bloomKernel;
  148280. /**
  148281. * Specifies the size of the bloom blur kernel, relative to the final output size
  148282. */
  148283. get bloomKernel(): number;
  148284. set bloomKernel(value: number);
  148285. /**
  148286. * Specifies the weight of the bloom in the final rendering
  148287. */
  148288. private _bloomWeight;
  148289. /**
  148290. * Specifies the luma threshold for the area that will be blurred by the bloom
  148291. */
  148292. private _bloomThreshold;
  148293. private _hdr;
  148294. /**
  148295. * The strength of the bloom.
  148296. */
  148297. set bloomWeight(value: number);
  148298. get bloomWeight(): number;
  148299. /**
  148300. * The strength of the bloom.
  148301. */
  148302. set bloomThreshold(value: number);
  148303. get bloomThreshold(): number;
  148304. /**
  148305. * The scale of the bloom, lower value will provide better performance.
  148306. */
  148307. set bloomScale(value: number);
  148308. get bloomScale(): number;
  148309. /**
  148310. * Enable or disable the bloom from the pipeline
  148311. */
  148312. set bloomEnabled(enabled: boolean);
  148313. get bloomEnabled(): boolean;
  148314. private _rebuildBloom;
  148315. /**
  148316. * If the depth of field is enabled.
  148317. */
  148318. get depthOfFieldEnabled(): boolean;
  148319. set depthOfFieldEnabled(enabled: boolean);
  148320. /**
  148321. * Blur level of the depth of field effect. (Higher blur will effect performance)
  148322. */
  148323. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  148324. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  148325. /**
  148326. * If the anti aliasing is enabled.
  148327. */
  148328. set fxaaEnabled(enabled: boolean);
  148329. get fxaaEnabled(): boolean;
  148330. private _samples;
  148331. /**
  148332. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148333. */
  148334. set samples(sampleCount: number);
  148335. get samples(): number;
  148336. /**
  148337. * If image processing is enabled.
  148338. */
  148339. set imageProcessingEnabled(enabled: boolean);
  148340. get imageProcessingEnabled(): boolean;
  148341. /**
  148342. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  148343. */
  148344. set glowLayerEnabled(enabled: boolean);
  148345. get glowLayerEnabled(): boolean;
  148346. /**
  148347. * Gets the glow layer (or null if not defined)
  148348. */
  148349. get glowLayer(): Nullable<GlowLayer>;
  148350. /**
  148351. * Enable or disable the chromaticAberration process from the pipeline
  148352. */
  148353. set chromaticAberrationEnabled(enabled: boolean);
  148354. get chromaticAberrationEnabled(): boolean;
  148355. /**
  148356. * Enable or disable the grain process from the pipeline
  148357. */
  148358. set grainEnabled(enabled: boolean);
  148359. get grainEnabled(): boolean;
  148360. /**
  148361. * @constructor
  148362. * @param name - The rendering pipeline name (default: "")
  148363. * @param hdr - If high dynamic range textures should be used (default: true)
  148364. * @param scene - The scene linked to this pipeline (default: the last created scene)
  148365. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  148366. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  148367. */
  148368. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  148369. /**
  148370. * Get the class name
  148371. * @returns "DefaultRenderingPipeline"
  148372. */
  148373. getClassName(): string;
  148374. /**
  148375. * Force the compilation of the entire pipeline.
  148376. */
  148377. prepare(): void;
  148378. private _hasCleared;
  148379. private _prevPostProcess;
  148380. private _prevPrevPostProcess;
  148381. private _setAutoClearAndTextureSharing;
  148382. private _depthOfFieldSceneObserver;
  148383. private _buildPipeline;
  148384. private _disposePostProcesses;
  148385. /**
  148386. * Adds a camera to the pipeline
  148387. * @param camera the camera to be added
  148388. */
  148389. addCamera(camera: Camera): void;
  148390. /**
  148391. * Removes a camera from the pipeline
  148392. * @param camera the camera to remove
  148393. */
  148394. removeCamera(camera: Camera): void;
  148395. /**
  148396. * Dispose of the pipeline and stop all post processes
  148397. */
  148398. dispose(): void;
  148399. /**
  148400. * Serialize the rendering pipeline (Used when exporting)
  148401. * @returns the serialized object
  148402. */
  148403. serialize(): any;
  148404. /**
  148405. * Parse the serialized pipeline
  148406. * @param source Source pipeline.
  148407. * @param scene The scene to load the pipeline to.
  148408. * @param rootUrl The URL of the serialized pipeline.
  148409. * @returns An instantiated pipeline from the serialized object.
  148410. */
  148411. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  148412. }
  148413. }
  148414. declare module BABYLON {
  148415. /** @hidden */
  148416. export var lensHighlightsPixelShader: {
  148417. name: string;
  148418. shader: string;
  148419. };
  148420. }
  148421. declare module BABYLON {
  148422. /** @hidden */
  148423. export var depthOfFieldPixelShader: {
  148424. name: string;
  148425. shader: string;
  148426. };
  148427. }
  148428. declare module BABYLON {
  148429. /**
  148430. * BABYLON.JS Chromatic Aberration GLSL Shader
  148431. * Author: Olivier Guyot
  148432. * Separates very slightly R, G and B colors on the edges of the screen
  148433. * Inspired by Francois Tarlier & Martins Upitis
  148434. */
  148435. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  148436. /**
  148437. * @ignore
  148438. * The chromatic aberration PostProcess id in the pipeline
  148439. */
  148440. LensChromaticAberrationEffect: string;
  148441. /**
  148442. * @ignore
  148443. * The highlights enhancing PostProcess id in the pipeline
  148444. */
  148445. HighlightsEnhancingEffect: string;
  148446. /**
  148447. * @ignore
  148448. * The depth-of-field PostProcess id in the pipeline
  148449. */
  148450. LensDepthOfFieldEffect: string;
  148451. private _scene;
  148452. private _depthTexture;
  148453. private _grainTexture;
  148454. private _chromaticAberrationPostProcess;
  148455. private _highlightsPostProcess;
  148456. private _depthOfFieldPostProcess;
  148457. private _edgeBlur;
  148458. private _grainAmount;
  148459. private _chromaticAberration;
  148460. private _distortion;
  148461. private _highlightsGain;
  148462. private _highlightsThreshold;
  148463. private _dofDistance;
  148464. private _dofAperture;
  148465. private _dofDarken;
  148466. private _dofPentagon;
  148467. private _blurNoise;
  148468. /**
  148469. * @constructor
  148470. *
  148471. * Effect parameters are as follow:
  148472. * {
  148473. * chromatic_aberration: number; // from 0 to x (1 for realism)
  148474. * edge_blur: number; // from 0 to x (1 for realism)
  148475. * distortion: number; // from 0 to x (1 for realism)
  148476. * grain_amount: number; // from 0 to 1
  148477. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  148478. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  148479. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  148480. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  148481. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  148482. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  148483. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  148484. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  148485. * }
  148486. * Note: if an effect parameter is unset, effect is disabled
  148487. *
  148488. * @param name The rendering pipeline name
  148489. * @param parameters - An object containing all parameters (see above)
  148490. * @param scene The scene linked to this pipeline
  148491. * @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)
  148492. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148493. */
  148494. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  148495. /**
  148496. * Get the class name
  148497. * @returns "LensRenderingPipeline"
  148498. */
  148499. getClassName(): string;
  148500. /**
  148501. * Gets associated scene
  148502. */
  148503. get scene(): Scene;
  148504. /**
  148505. * Gets or sets the edge blur
  148506. */
  148507. get edgeBlur(): number;
  148508. set edgeBlur(value: number);
  148509. /**
  148510. * Gets or sets the grain amount
  148511. */
  148512. get grainAmount(): number;
  148513. set grainAmount(value: number);
  148514. /**
  148515. * Gets or sets the chromatic aberration amount
  148516. */
  148517. get chromaticAberration(): number;
  148518. set chromaticAberration(value: number);
  148519. /**
  148520. * Gets or sets the depth of field aperture
  148521. */
  148522. get dofAperture(): number;
  148523. set dofAperture(value: number);
  148524. /**
  148525. * Gets or sets the edge distortion
  148526. */
  148527. get edgeDistortion(): number;
  148528. set edgeDistortion(value: number);
  148529. /**
  148530. * Gets or sets the depth of field distortion
  148531. */
  148532. get dofDistortion(): number;
  148533. set dofDistortion(value: number);
  148534. /**
  148535. * Gets or sets the darken out of focus amount
  148536. */
  148537. get darkenOutOfFocus(): number;
  148538. set darkenOutOfFocus(value: number);
  148539. /**
  148540. * Gets or sets a boolean indicating if blur noise is enabled
  148541. */
  148542. get blurNoise(): boolean;
  148543. set blurNoise(value: boolean);
  148544. /**
  148545. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  148546. */
  148547. get pentagonBokeh(): boolean;
  148548. set pentagonBokeh(value: boolean);
  148549. /**
  148550. * Gets or sets the highlight grain amount
  148551. */
  148552. get highlightsGain(): number;
  148553. set highlightsGain(value: number);
  148554. /**
  148555. * Gets or sets the highlight threshold
  148556. */
  148557. get highlightsThreshold(): number;
  148558. set highlightsThreshold(value: number);
  148559. /**
  148560. * Sets the amount of blur at the edges
  148561. * @param amount blur amount
  148562. */
  148563. setEdgeBlur(amount: number): void;
  148564. /**
  148565. * Sets edge blur to 0
  148566. */
  148567. disableEdgeBlur(): void;
  148568. /**
  148569. * Sets the amout of grain
  148570. * @param amount Amount of grain
  148571. */
  148572. setGrainAmount(amount: number): void;
  148573. /**
  148574. * Set grain amount to 0
  148575. */
  148576. disableGrain(): void;
  148577. /**
  148578. * Sets the chromatic aberration amount
  148579. * @param amount amount of chromatic aberration
  148580. */
  148581. setChromaticAberration(amount: number): void;
  148582. /**
  148583. * Sets chromatic aberration amount to 0
  148584. */
  148585. disableChromaticAberration(): void;
  148586. /**
  148587. * Sets the EdgeDistortion amount
  148588. * @param amount amount of EdgeDistortion
  148589. */
  148590. setEdgeDistortion(amount: number): void;
  148591. /**
  148592. * Sets edge distortion to 0
  148593. */
  148594. disableEdgeDistortion(): void;
  148595. /**
  148596. * Sets the FocusDistance amount
  148597. * @param amount amount of FocusDistance
  148598. */
  148599. setFocusDistance(amount: number): void;
  148600. /**
  148601. * Disables depth of field
  148602. */
  148603. disableDepthOfField(): void;
  148604. /**
  148605. * Sets the Aperture amount
  148606. * @param amount amount of Aperture
  148607. */
  148608. setAperture(amount: number): void;
  148609. /**
  148610. * Sets the DarkenOutOfFocus amount
  148611. * @param amount amount of DarkenOutOfFocus
  148612. */
  148613. setDarkenOutOfFocus(amount: number): void;
  148614. private _pentagonBokehIsEnabled;
  148615. /**
  148616. * Creates a pentagon bokeh effect
  148617. */
  148618. enablePentagonBokeh(): void;
  148619. /**
  148620. * Disables the pentagon bokeh effect
  148621. */
  148622. disablePentagonBokeh(): void;
  148623. /**
  148624. * Enables noise blur
  148625. */
  148626. enableNoiseBlur(): void;
  148627. /**
  148628. * Disables noise blur
  148629. */
  148630. disableNoiseBlur(): void;
  148631. /**
  148632. * Sets the HighlightsGain amount
  148633. * @param amount amount of HighlightsGain
  148634. */
  148635. setHighlightsGain(amount: number): void;
  148636. /**
  148637. * Sets the HighlightsThreshold amount
  148638. * @param amount amount of HighlightsThreshold
  148639. */
  148640. setHighlightsThreshold(amount: number): void;
  148641. /**
  148642. * Disables highlights
  148643. */
  148644. disableHighlights(): void;
  148645. /**
  148646. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  148647. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  148648. */
  148649. dispose(disableDepthRender?: boolean): void;
  148650. private _createChromaticAberrationPostProcess;
  148651. private _createHighlightsPostProcess;
  148652. private _createDepthOfFieldPostProcess;
  148653. private _createGrainTexture;
  148654. }
  148655. }
  148656. declare module BABYLON {
  148657. /** @hidden */
  148658. export var ssao2PixelShader: {
  148659. name: string;
  148660. shader: string;
  148661. };
  148662. }
  148663. declare module BABYLON {
  148664. /** @hidden */
  148665. export var ssaoCombinePixelShader: {
  148666. name: string;
  148667. shader: string;
  148668. };
  148669. }
  148670. declare module BABYLON {
  148671. /**
  148672. * Render pipeline to produce ssao effect
  148673. */
  148674. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  148675. /**
  148676. * @ignore
  148677. * The PassPostProcess id in the pipeline that contains the original scene color
  148678. */
  148679. SSAOOriginalSceneColorEffect: string;
  148680. /**
  148681. * @ignore
  148682. * The SSAO PostProcess id in the pipeline
  148683. */
  148684. SSAORenderEffect: string;
  148685. /**
  148686. * @ignore
  148687. * The horizontal blur PostProcess id in the pipeline
  148688. */
  148689. SSAOBlurHRenderEffect: string;
  148690. /**
  148691. * @ignore
  148692. * The vertical blur PostProcess id in the pipeline
  148693. */
  148694. SSAOBlurVRenderEffect: string;
  148695. /**
  148696. * @ignore
  148697. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148698. */
  148699. SSAOCombineRenderEffect: string;
  148700. /**
  148701. * The output strength of the SSAO post-process. Default value is 1.0.
  148702. */
  148703. totalStrength: number;
  148704. /**
  148705. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  148706. */
  148707. maxZ: number;
  148708. /**
  148709. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  148710. */
  148711. minZAspect: number;
  148712. private _samples;
  148713. /**
  148714. * Number of samples used for the SSAO calculations. Default value is 8
  148715. */
  148716. set samples(n: number);
  148717. get samples(): number;
  148718. private _textureSamples;
  148719. /**
  148720. * Number of samples to use for antialiasing
  148721. */
  148722. set textureSamples(n: number);
  148723. get textureSamples(): number;
  148724. /**
  148725. * Force rendering the geometry through geometry buffer
  148726. */
  148727. private _forceGeometryBuffer;
  148728. /**
  148729. * Ratio object used for SSAO ratio and blur ratio
  148730. */
  148731. private _ratio;
  148732. /**
  148733. * Dynamically generated sphere sampler.
  148734. */
  148735. private _sampleSphere;
  148736. /**
  148737. * Blur filter offsets
  148738. */
  148739. private _samplerOffsets;
  148740. private _expensiveBlur;
  148741. /**
  148742. * If bilateral blur should be used
  148743. */
  148744. set expensiveBlur(b: boolean);
  148745. get expensiveBlur(): boolean;
  148746. /**
  148747. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  148748. */
  148749. radius: number;
  148750. /**
  148751. * The base color of the SSAO post-process
  148752. * The final result is "base + ssao" between [0, 1]
  148753. */
  148754. base: number;
  148755. /**
  148756. * Support test.
  148757. */
  148758. static get IsSupported(): boolean;
  148759. private _scene;
  148760. private _randomTexture;
  148761. private _originalColorPostProcess;
  148762. private _ssaoPostProcess;
  148763. private _blurHPostProcess;
  148764. private _blurVPostProcess;
  148765. private _ssaoCombinePostProcess;
  148766. private _prePassRenderer;
  148767. /**
  148768. * Gets active scene
  148769. */
  148770. get scene(): Scene;
  148771. /**
  148772. * @constructor
  148773. * @param name The rendering pipeline name
  148774. * @param scene The scene linked to this pipeline
  148775. * @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 }
  148776. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148777. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  148778. */
  148779. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  148780. /**
  148781. * Get the class name
  148782. * @returns "SSAO2RenderingPipeline"
  148783. */
  148784. getClassName(): string;
  148785. /**
  148786. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148787. */
  148788. dispose(disableGeometryBufferRenderer?: boolean): void;
  148789. private _createBlurPostProcess;
  148790. /** @hidden */
  148791. _rebuild(): void;
  148792. private _bits;
  148793. private _radicalInverse_VdC;
  148794. private _hammersley;
  148795. private _hemisphereSample_uniform;
  148796. private _generateHemisphere;
  148797. private _getDefinesForSSAO;
  148798. private _createSSAOPostProcess;
  148799. private _createSSAOCombinePostProcess;
  148800. private _createRandomTexture;
  148801. /**
  148802. * Serialize the rendering pipeline (Used when exporting)
  148803. * @returns the serialized object
  148804. */
  148805. serialize(): any;
  148806. /**
  148807. * Parse the serialized pipeline
  148808. * @param source Source pipeline.
  148809. * @param scene The scene to load the pipeline to.
  148810. * @param rootUrl The URL of the serialized pipeline.
  148811. * @returns An instantiated pipeline from the serialized object.
  148812. */
  148813. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148814. /**
  148815. * Sets the required values to the prepass renderer.
  148816. * @param prePassRenderer defines the prepass renderer to setup
  148817. * @returns true if the pre pass is needed.
  148818. */
  148819. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148820. }
  148821. }
  148822. declare module BABYLON {
  148823. /** @hidden */
  148824. export var ssaoPixelShader: {
  148825. name: string;
  148826. shader: string;
  148827. };
  148828. }
  148829. declare module BABYLON {
  148830. /**
  148831. * Render pipeline to produce ssao effect
  148832. */
  148833. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148834. /**
  148835. * @ignore
  148836. * The PassPostProcess id in the pipeline that contains the original scene color
  148837. */
  148838. SSAOOriginalSceneColorEffect: string;
  148839. /**
  148840. * @ignore
  148841. * The SSAO PostProcess id in the pipeline
  148842. */
  148843. SSAORenderEffect: string;
  148844. /**
  148845. * @ignore
  148846. * The horizontal blur PostProcess id in the pipeline
  148847. */
  148848. SSAOBlurHRenderEffect: string;
  148849. /**
  148850. * @ignore
  148851. * The vertical blur PostProcess id in the pipeline
  148852. */
  148853. SSAOBlurVRenderEffect: string;
  148854. /**
  148855. * @ignore
  148856. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148857. */
  148858. SSAOCombineRenderEffect: string;
  148859. /**
  148860. * The output strength of the SSAO post-process. Default value is 1.0.
  148861. */
  148862. totalStrength: number;
  148863. /**
  148864. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148865. */
  148866. radius: number;
  148867. /**
  148868. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148869. * Must not be equal to fallOff and superior to fallOff.
  148870. * Default value is 0.0075
  148871. */
  148872. area: number;
  148873. /**
  148874. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148875. * Must not be equal to area and inferior to area.
  148876. * Default value is 0.000001
  148877. */
  148878. fallOff: number;
  148879. /**
  148880. * The base color of the SSAO post-process
  148881. * The final result is "base + ssao" between [0, 1]
  148882. */
  148883. base: number;
  148884. private _scene;
  148885. private _depthTexture;
  148886. private _randomTexture;
  148887. private _originalColorPostProcess;
  148888. private _ssaoPostProcess;
  148889. private _blurHPostProcess;
  148890. private _blurVPostProcess;
  148891. private _ssaoCombinePostProcess;
  148892. private _firstUpdate;
  148893. /**
  148894. * Gets active scene
  148895. */
  148896. get scene(): Scene;
  148897. /**
  148898. * @constructor
  148899. * @param name - The rendering pipeline name
  148900. * @param scene - The scene linked to this pipeline
  148901. * @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 }
  148902. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148903. */
  148904. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148905. /**
  148906. * Get the class name
  148907. * @returns "SSAORenderingPipeline"
  148908. */
  148909. getClassName(): string;
  148910. /**
  148911. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148912. */
  148913. dispose(disableDepthRender?: boolean): void;
  148914. private _createBlurPostProcess;
  148915. /** @hidden */
  148916. _rebuild(): void;
  148917. private _createSSAOPostProcess;
  148918. private _createSSAOCombinePostProcess;
  148919. private _createRandomTexture;
  148920. }
  148921. }
  148922. declare module BABYLON {
  148923. /** @hidden */
  148924. export var screenSpaceReflectionPixelShader: {
  148925. name: string;
  148926. shader: string;
  148927. };
  148928. }
  148929. declare module BABYLON {
  148930. /**
  148931. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148932. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148933. */
  148934. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148935. /**
  148936. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148937. */
  148938. threshold: number;
  148939. /**
  148940. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148941. */
  148942. strength: number;
  148943. /**
  148944. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148945. */
  148946. reflectionSpecularFalloffExponent: number;
  148947. /**
  148948. * 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]
  148949. */
  148950. step: number;
  148951. /**
  148952. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148953. */
  148954. roughnessFactor: number;
  148955. private _geometryBufferRenderer;
  148956. private _enableSmoothReflections;
  148957. private _reflectionSamples;
  148958. private _smoothSteps;
  148959. /**
  148960. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148961. * @param name The name of the effect.
  148962. * @param scene The scene containing the objects to calculate reflections.
  148963. * @param options The required width/height ratio to downsize to before computing the render pass.
  148964. * @param camera The camera to apply the render pass to.
  148965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148966. * @param engine The engine which the post process will be applied. (default: current engine)
  148967. * @param reusable If the post process can be reused on the same frame. (default: false)
  148968. * @param textureType Type of textures used when performing the post process. (default: 0)
  148969. * @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)
  148970. */
  148971. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148972. /**
  148973. * Gets wether or not smoothing reflections is enabled.
  148974. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148975. */
  148976. get enableSmoothReflections(): boolean;
  148977. /**
  148978. * Sets wether or not smoothing reflections is enabled.
  148979. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148980. */
  148981. set enableSmoothReflections(enabled: boolean);
  148982. /**
  148983. * Gets the number of samples taken while computing reflections. More samples count is high,
  148984. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148985. */
  148986. get reflectionSamples(): number;
  148987. /**
  148988. * Sets the number of samples taken while computing reflections. More samples count is high,
  148989. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148990. */
  148991. set reflectionSamples(samples: number);
  148992. /**
  148993. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148994. * more the post-process will require GPU power and can generate a drop in FPS.
  148995. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148996. */
  148997. get smoothSteps(): number;
  148998. set smoothSteps(steps: number);
  148999. private _updateEffectDefines;
  149000. }
  149001. }
  149002. declare module BABYLON {
  149003. /** @hidden */
  149004. export var standardPixelShader: {
  149005. name: string;
  149006. shader: string;
  149007. };
  149008. }
  149009. declare module BABYLON {
  149010. /**
  149011. * Standard rendering pipeline
  149012. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149013. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149014. */
  149015. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149016. /**
  149017. * Public members
  149018. */
  149019. /**
  149020. * Post-process which contains the original scene color before the pipeline applies all the effects
  149021. */
  149022. originalPostProcess: Nullable<PostProcess>;
  149023. /**
  149024. * Post-process used to down scale an image x4
  149025. */
  149026. downSampleX4PostProcess: Nullable<PostProcess>;
  149027. /**
  149028. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149029. */
  149030. brightPassPostProcess: Nullable<PostProcess>;
  149031. /**
  149032. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149033. */
  149034. blurHPostProcesses: PostProcess[];
  149035. /**
  149036. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149037. */
  149038. blurVPostProcesses: PostProcess[];
  149039. /**
  149040. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149041. */
  149042. textureAdderPostProcess: Nullable<PostProcess>;
  149043. /**
  149044. * Post-process used to create volumetric lighting effect
  149045. */
  149046. volumetricLightPostProcess: Nullable<PostProcess>;
  149047. /**
  149048. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149049. */
  149050. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149051. /**
  149052. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149053. */
  149054. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149055. /**
  149056. * Post-process used to merge the volumetric light effect and the real scene color
  149057. */
  149058. volumetricLightMergePostProces: Nullable<PostProcess>;
  149059. /**
  149060. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149061. */
  149062. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149063. /**
  149064. * Base post-process used to calculate the average luminance of the final image for HDR
  149065. */
  149066. luminancePostProcess: Nullable<PostProcess>;
  149067. /**
  149068. * Post-processes used to create down sample post-processes in order to get
  149069. * the average luminance of the final image for HDR
  149070. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149071. */
  149072. luminanceDownSamplePostProcesses: PostProcess[];
  149073. /**
  149074. * Post-process used to create a HDR effect (light adaptation)
  149075. */
  149076. hdrPostProcess: Nullable<PostProcess>;
  149077. /**
  149078. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149079. */
  149080. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149081. /**
  149082. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149083. */
  149084. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149085. /**
  149086. * Post-process used to merge the final HDR post-process and the real scene color
  149087. */
  149088. hdrFinalPostProcess: Nullable<PostProcess>;
  149089. /**
  149090. * Post-process used to create a lens flare effect
  149091. */
  149092. lensFlarePostProcess: Nullable<PostProcess>;
  149093. /**
  149094. * Post-process that merges the result of the lens flare post-process and the real scene color
  149095. */
  149096. lensFlareComposePostProcess: Nullable<PostProcess>;
  149097. /**
  149098. * Post-process used to create a motion blur effect
  149099. */
  149100. motionBlurPostProcess: Nullable<PostProcess>;
  149101. /**
  149102. * Post-process used to create a depth of field effect
  149103. */
  149104. depthOfFieldPostProcess: Nullable<PostProcess>;
  149105. /**
  149106. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149107. */
  149108. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149109. /**
  149110. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149111. */
  149112. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149113. /**
  149114. * Represents the brightness threshold in order to configure the illuminated surfaces
  149115. */
  149116. brightThreshold: number;
  149117. /**
  149118. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149119. */
  149120. blurWidth: number;
  149121. /**
  149122. * Sets if the blur for highlighted surfaces must be only horizontal
  149123. */
  149124. horizontalBlur: boolean;
  149125. /**
  149126. * Gets the overall exposure used by the pipeline
  149127. */
  149128. get exposure(): number;
  149129. /**
  149130. * Sets the overall exposure used by the pipeline
  149131. */
  149132. set exposure(value: number);
  149133. /**
  149134. * Texture used typically to simulate "dirty" on camera lens
  149135. */
  149136. lensTexture: Nullable<Texture>;
  149137. /**
  149138. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149139. */
  149140. volumetricLightCoefficient: number;
  149141. /**
  149142. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149143. */
  149144. volumetricLightPower: number;
  149145. /**
  149146. * Used the set the blur intensity to smooth the volumetric lights
  149147. */
  149148. volumetricLightBlurScale: number;
  149149. /**
  149150. * Light (spot or directional) used to generate the volumetric lights rays
  149151. * The source light must have a shadow generate so the pipeline can get its
  149152. * depth map
  149153. */
  149154. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149155. /**
  149156. * For eye adaptation, represents the minimum luminance the eye can see
  149157. */
  149158. hdrMinimumLuminance: number;
  149159. /**
  149160. * For eye adaptation, represents the decrease luminance speed
  149161. */
  149162. hdrDecreaseRate: number;
  149163. /**
  149164. * For eye adaptation, represents the increase luminance speed
  149165. */
  149166. hdrIncreaseRate: number;
  149167. /**
  149168. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149169. */
  149170. get hdrAutoExposure(): boolean;
  149171. /**
  149172. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149173. */
  149174. set hdrAutoExposure(value: boolean);
  149175. /**
  149176. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149177. */
  149178. lensColorTexture: Nullable<Texture>;
  149179. /**
  149180. * The overall strengh for the lens flare effect
  149181. */
  149182. lensFlareStrength: number;
  149183. /**
  149184. * Dispersion coefficient for lens flare ghosts
  149185. */
  149186. lensFlareGhostDispersal: number;
  149187. /**
  149188. * Main lens flare halo width
  149189. */
  149190. lensFlareHaloWidth: number;
  149191. /**
  149192. * Based on the lens distortion effect, defines how much the lens flare result
  149193. * is distorted
  149194. */
  149195. lensFlareDistortionStrength: number;
  149196. /**
  149197. * Configures the blur intensity used for for lens flare (halo)
  149198. */
  149199. lensFlareBlurWidth: number;
  149200. /**
  149201. * Lens star texture must be used to simulate rays on the flares and is available
  149202. * in the documentation
  149203. */
  149204. lensStarTexture: Nullable<Texture>;
  149205. /**
  149206. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149207. * flare effect by taking account of the dirt texture
  149208. */
  149209. lensFlareDirtTexture: Nullable<Texture>;
  149210. /**
  149211. * Represents the focal length for the depth of field effect
  149212. */
  149213. depthOfFieldDistance: number;
  149214. /**
  149215. * Represents the blur intensity for the blurred part of the depth of field effect
  149216. */
  149217. depthOfFieldBlurWidth: number;
  149218. /**
  149219. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149220. */
  149221. get motionStrength(): number;
  149222. /**
  149223. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149224. */
  149225. set motionStrength(strength: number);
  149226. /**
  149227. * Gets wether or not the motion blur post-process is object based or screen based.
  149228. */
  149229. get objectBasedMotionBlur(): boolean;
  149230. /**
  149231. * Sets wether or not the motion blur post-process should be object based or screen based
  149232. */
  149233. set objectBasedMotionBlur(value: boolean);
  149234. /**
  149235. * List of animations for the pipeline (IAnimatable implementation)
  149236. */
  149237. animations: Animation[];
  149238. /**
  149239. * Private members
  149240. */
  149241. private _scene;
  149242. private _currentDepthOfFieldSource;
  149243. private _basePostProcess;
  149244. private _fixedExposure;
  149245. private _currentExposure;
  149246. private _hdrAutoExposure;
  149247. private _hdrCurrentLuminance;
  149248. private _motionStrength;
  149249. private _isObjectBasedMotionBlur;
  149250. private _floatTextureType;
  149251. private _camerasToBeAttached;
  149252. private _ratio;
  149253. private _bloomEnabled;
  149254. private _depthOfFieldEnabled;
  149255. private _vlsEnabled;
  149256. private _lensFlareEnabled;
  149257. private _hdrEnabled;
  149258. private _motionBlurEnabled;
  149259. private _fxaaEnabled;
  149260. private _screenSpaceReflectionsEnabled;
  149261. private _motionBlurSamples;
  149262. private _volumetricLightStepsCount;
  149263. private _samples;
  149264. /**
  149265. * @ignore
  149266. * Specifies if the bloom pipeline is enabled
  149267. */
  149268. get BloomEnabled(): boolean;
  149269. set BloomEnabled(enabled: boolean);
  149270. /**
  149271. * @ignore
  149272. * Specifies if the depth of field pipeline is enabed
  149273. */
  149274. get DepthOfFieldEnabled(): boolean;
  149275. set DepthOfFieldEnabled(enabled: boolean);
  149276. /**
  149277. * @ignore
  149278. * Specifies if the lens flare pipeline is enabed
  149279. */
  149280. get LensFlareEnabled(): boolean;
  149281. set LensFlareEnabled(enabled: boolean);
  149282. /**
  149283. * @ignore
  149284. * Specifies if the HDR pipeline is enabled
  149285. */
  149286. get HDREnabled(): boolean;
  149287. set HDREnabled(enabled: boolean);
  149288. /**
  149289. * @ignore
  149290. * Specifies if the volumetric lights scattering effect is enabled
  149291. */
  149292. get VLSEnabled(): boolean;
  149293. set VLSEnabled(enabled: boolean);
  149294. /**
  149295. * @ignore
  149296. * Specifies if the motion blur effect is enabled
  149297. */
  149298. get MotionBlurEnabled(): boolean;
  149299. set MotionBlurEnabled(enabled: boolean);
  149300. /**
  149301. * Specifies if anti-aliasing is enabled
  149302. */
  149303. get fxaaEnabled(): boolean;
  149304. set fxaaEnabled(enabled: boolean);
  149305. /**
  149306. * Specifies if screen space reflections are enabled.
  149307. */
  149308. get screenSpaceReflectionsEnabled(): boolean;
  149309. set screenSpaceReflectionsEnabled(enabled: boolean);
  149310. /**
  149311. * Specifies the number of steps used to calculate the volumetric lights
  149312. * Typically in interval [50, 200]
  149313. */
  149314. get volumetricLightStepsCount(): number;
  149315. set volumetricLightStepsCount(count: number);
  149316. /**
  149317. * Specifies the number of samples used for the motion blur effect
  149318. * Typically in interval [16, 64]
  149319. */
  149320. get motionBlurSamples(): number;
  149321. set motionBlurSamples(samples: number);
  149322. /**
  149323. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149324. */
  149325. get samples(): number;
  149326. set samples(sampleCount: number);
  149327. /**
  149328. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149329. * @constructor
  149330. * @param name The rendering pipeline name
  149331. * @param scene The scene linked to this pipeline
  149332. * @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)
  149333. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149334. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149335. */
  149336. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149337. private _buildPipeline;
  149338. private _createDownSampleX4PostProcess;
  149339. private _createBrightPassPostProcess;
  149340. private _createBlurPostProcesses;
  149341. private _createTextureAdderPostProcess;
  149342. private _createVolumetricLightPostProcess;
  149343. private _createLuminancePostProcesses;
  149344. private _createHdrPostProcess;
  149345. private _createLensFlarePostProcess;
  149346. private _createDepthOfFieldPostProcess;
  149347. private _createMotionBlurPostProcess;
  149348. private _getDepthTexture;
  149349. private _disposePostProcesses;
  149350. /**
  149351. * Dispose of the pipeline and stop all post processes
  149352. */
  149353. dispose(): void;
  149354. /**
  149355. * Serialize the rendering pipeline (Used when exporting)
  149356. * @returns the serialized object
  149357. */
  149358. serialize(): any;
  149359. /**
  149360. * Parse the serialized pipeline
  149361. * @param source Source pipeline.
  149362. * @param scene The scene to load the pipeline to.
  149363. * @param rootUrl The URL of the serialized pipeline.
  149364. * @returns An instantiated pipeline from the serialized object.
  149365. */
  149366. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149367. /**
  149368. * Luminance steps
  149369. */
  149370. static LuminanceSteps: number;
  149371. }
  149372. }
  149373. declare module BABYLON {
  149374. /** @hidden */
  149375. export var stereoscopicInterlacePixelShader: {
  149376. name: string;
  149377. shader: string;
  149378. };
  149379. }
  149380. declare module BABYLON {
  149381. /**
  149382. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149383. */
  149384. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149385. private _stepSize;
  149386. private _passedProcess;
  149387. /**
  149388. * Initializes a StereoscopicInterlacePostProcessI
  149389. * @param name The name of the effect.
  149390. * @param rigCameras The rig cameras to be appled to the post process
  149391. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149392. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149394. * @param engine The engine which the post process will be applied. (default: current engine)
  149395. * @param reusable If the post process can be reused on the same frame. (default: false)
  149396. */
  149397. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149398. }
  149399. /**
  149400. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149401. */
  149402. export class StereoscopicInterlacePostProcess extends PostProcess {
  149403. private _stepSize;
  149404. private _passedProcess;
  149405. /**
  149406. * Initializes a StereoscopicInterlacePostProcess
  149407. * @param name The name of the effect.
  149408. * @param rigCameras The rig cameras to be appled to the post process
  149409. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149411. * @param engine The engine which the post process will be applied. (default: current engine)
  149412. * @param reusable If the post process can be reused on the same frame. (default: false)
  149413. */
  149414. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149415. }
  149416. }
  149417. declare module BABYLON {
  149418. /** @hidden */
  149419. export var tonemapPixelShader: {
  149420. name: string;
  149421. shader: string;
  149422. };
  149423. }
  149424. declare module BABYLON {
  149425. /** Defines operator used for tonemapping */
  149426. export enum TonemappingOperator {
  149427. /** Hable */
  149428. Hable = 0,
  149429. /** Reinhard */
  149430. Reinhard = 1,
  149431. /** HejiDawson */
  149432. HejiDawson = 2,
  149433. /** Photographic */
  149434. Photographic = 3
  149435. }
  149436. /**
  149437. * Defines a post process to apply tone mapping
  149438. */
  149439. export class TonemapPostProcess extends PostProcess {
  149440. private _operator;
  149441. /** Defines the required exposure adjustement */
  149442. exposureAdjustment: number;
  149443. /**
  149444. * Creates a new TonemapPostProcess
  149445. * @param name defines the name of the postprocess
  149446. * @param _operator defines the operator to use
  149447. * @param exposureAdjustment defines the required exposure adjustement
  149448. * @param camera defines the camera to use (can be null)
  149449. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149450. * @param engine defines the hosting engine (can be ignore if camera is set)
  149451. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149452. */
  149453. constructor(name: string, _operator: TonemappingOperator,
  149454. /** Defines the required exposure adjustement */
  149455. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149456. }
  149457. }
  149458. declare module BABYLON {
  149459. /** @hidden */
  149460. export var volumetricLightScatteringPixelShader: {
  149461. name: string;
  149462. shader: string;
  149463. };
  149464. }
  149465. declare module BABYLON {
  149466. /** @hidden */
  149467. export var volumetricLightScatteringPassVertexShader: {
  149468. name: string;
  149469. shader: string;
  149470. };
  149471. }
  149472. declare module BABYLON {
  149473. /** @hidden */
  149474. export var volumetricLightScatteringPassPixelShader: {
  149475. name: string;
  149476. shader: string;
  149477. };
  149478. }
  149479. declare module BABYLON {
  149480. /**
  149481. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149482. */
  149483. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149484. private _volumetricLightScatteringPass;
  149485. private _volumetricLightScatteringRTT;
  149486. private _viewPort;
  149487. private _screenCoordinates;
  149488. private _cachedDefines;
  149489. /**
  149490. * If not undefined, the mesh position is computed from the attached node position
  149491. */
  149492. attachedNode: {
  149493. position: Vector3;
  149494. };
  149495. /**
  149496. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149497. */
  149498. customMeshPosition: Vector3;
  149499. /**
  149500. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149501. */
  149502. useCustomMeshPosition: boolean;
  149503. /**
  149504. * If the post-process should inverse the light scattering direction
  149505. */
  149506. invert: boolean;
  149507. /**
  149508. * The internal mesh used by the post-process
  149509. */
  149510. mesh: Mesh;
  149511. /**
  149512. * @hidden
  149513. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149514. */
  149515. get useDiffuseColor(): boolean;
  149516. set useDiffuseColor(useDiffuseColor: boolean);
  149517. /**
  149518. * Array containing the excluded meshes not rendered in the internal pass
  149519. */
  149520. excludedMeshes: AbstractMesh[];
  149521. /**
  149522. * Controls the overall intensity of the post-process
  149523. */
  149524. exposure: number;
  149525. /**
  149526. * Dissipates each sample's contribution in range [0, 1]
  149527. */
  149528. decay: number;
  149529. /**
  149530. * Controls the overall intensity of each sample
  149531. */
  149532. weight: number;
  149533. /**
  149534. * Controls the density of each sample
  149535. */
  149536. density: number;
  149537. /**
  149538. * @constructor
  149539. * @param name The post-process name
  149540. * @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)
  149541. * @param camera The camera that the post-process will be attached to
  149542. * @param mesh The mesh used to create the light scattering
  149543. * @param samples The post-process quality, default 100
  149544. * @param samplingModeThe post-process filtering mode
  149545. * @param engine The babylon engine
  149546. * @param reusable If the post-process is reusable
  149547. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  149548. */
  149549. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  149550. /**
  149551. * Returns the string "VolumetricLightScatteringPostProcess"
  149552. * @returns "VolumetricLightScatteringPostProcess"
  149553. */
  149554. getClassName(): string;
  149555. private _isReady;
  149556. /**
  149557. * Sets the new light position for light scattering effect
  149558. * @param position The new custom light position
  149559. */
  149560. setCustomMeshPosition(position: Vector3): void;
  149561. /**
  149562. * Returns the light position for light scattering effect
  149563. * @return Vector3 The custom light position
  149564. */
  149565. getCustomMeshPosition(): Vector3;
  149566. /**
  149567. * Disposes the internal assets and detaches the post-process from the camera
  149568. */
  149569. dispose(camera: Camera): void;
  149570. /**
  149571. * Returns the render target texture used by the post-process
  149572. * @return the render target texture used by the post-process
  149573. */
  149574. getPass(): RenderTargetTexture;
  149575. private _meshExcluded;
  149576. private _createPass;
  149577. private _updateMeshScreenCoordinates;
  149578. /**
  149579. * Creates a default mesh for the Volumeric Light Scattering post-process
  149580. * @param name The mesh name
  149581. * @param scene The scene where to create the mesh
  149582. * @return the default mesh
  149583. */
  149584. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  149585. }
  149586. }
  149587. declare module BABYLON {
  149588. /** @hidden */
  149589. export var screenSpaceCurvaturePixelShader: {
  149590. name: string;
  149591. shader: string;
  149592. };
  149593. }
  149594. declare module BABYLON {
  149595. /**
  149596. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  149597. */
  149598. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  149599. /**
  149600. * Defines how much ridge the curvature effect displays.
  149601. */
  149602. ridge: number;
  149603. /**
  149604. * Defines how much valley the curvature effect displays.
  149605. */
  149606. valley: number;
  149607. private _geometryBufferRenderer;
  149608. /**
  149609. * Creates a new instance ScreenSpaceCurvaturePostProcess
  149610. * @param name The name of the effect.
  149611. * @param scene The scene containing the objects to blur according to their velocity.
  149612. * @param options The required width/height ratio to downsize to before computing the render pass.
  149613. * @param camera The camera to apply the render pass to.
  149614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149615. * @param engine The engine which the post process will be applied. (default: current engine)
  149616. * @param reusable If the post process can be reused on the same frame. (default: false)
  149617. * @param textureType Type of textures used when performing the post process. (default: 0)
  149618. * @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)
  149619. */
  149620. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149621. /**
  149622. * Support test.
  149623. */
  149624. static get IsSupported(): boolean;
  149625. }
  149626. }
  149627. declare module BABYLON {
  149628. interface Scene {
  149629. /** @hidden (Backing field) */
  149630. _boundingBoxRenderer: BoundingBoxRenderer;
  149631. /** @hidden (Backing field) */
  149632. _forceShowBoundingBoxes: boolean;
  149633. /**
  149634. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  149635. */
  149636. forceShowBoundingBoxes: boolean;
  149637. /**
  149638. * Gets the bounding box renderer associated with the scene
  149639. * @returns a BoundingBoxRenderer
  149640. */
  149641. getBoundingBoxRenderer(): BoundingBoxRenderer;
  149642. }
  149643. interface AbstractMesh {
  149644. /** @hidden (Backing field) */
  149645. _showBoundingBox: boolean;
  149646. /**
  149647. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  149648. */
  149649. showBoundingBox: boolean;
  149650. }
  149651. /**
  149652. * Component responsible of rendering the bounding box of the meshes in a scene.
  149653. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  149654. */
  149655. export class BoundingBoxRenderer implements ISceneComponent {
  149656. /**
  149657. * The component name helpfull to identify the component in the list of scene components.
  149658. */
  149659. readonly name: string;
  149660. /**
  149661. * The scene the component belongs to.
  149662. */
  149663. scene: Scene;
  149664. /**
  149665. * Color of the bounding box lines placed in front of an object
  149666. */
  149667. frontColor: Color3;
  149668. /**
  149669. * Color of the bounding box lines placed behind an object
  149670. */
  149671. backColor: Color3;
  149672. /**
  149673. * Defines if the renderer should show the back lines or not
  149674. */
  149675. showBackLines: boolean;
  149676. /**
  149677. * Observable raised before rendering a bounding box
  149678. */
  149679. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  149680. /**
  149681. * Observable raised after rendering a bounding box
  149682. */
  149683. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  149684. /**
  149685. * @hidden
  149686. */
  149687. renderList: SmartArray<BoundingBox>;
  149688. private _colorShader;
  149689. private _vertexBuffers;
  149690. private _indexBuffer;
  149691. private _fillIndexBuffer;
  149692. private _fillIndexData;
  149693. /**
  149694. * Instantiates a new bounding box renderer in a scene.
  149695. * @param scene the scene the renderer renders in
  149696. */
  149697. constructor(scene: Scene);
  149698. /**
  149699. * Registers the component in a given scene
  149700. */
  149701. register(): void;
  149702. private _evaluateSubMesh;
  149703. private _activeMesh;
  149704. private _prepareRessources;
  149705. private _createIndexBuffer;
  149706. /**
  149707. * Rebuilds the elements related to this component in case of
  149708. * context lost for instance.
  149709. */
  149710. rebuild(): void;
  149711. /**
  149712. * @hidden
  149713. */
  149714. reset(): void;
  149715. /**
  149716. * Render the bounding boxes of a specific rendering group
  149717. * @param renderingGroupId defines the rendering group to render
  149718. */
  149719. render(renderingGroupId: number): void;
  149720. /**
  149721. * In case of occlusion queries, we can render the occlusion bounding box through this method
  149722. * @param mesh Define the mesh to render the occlusion bounding box for
  149723. */
  149724. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  149725. /**
  149726. * Dispose and release the resources attached to this renderer.
  149727. */
  149728. dispose(): void;
  149729. }
  149730. }
  149731. declare module BABYLON {
  149732. interface Scene {
  149733. /** @hidden (Backing field) */
  149734. _depthRenderer: {
  149735. [id: string]: DepthRenderer;
  149736. };
  149737. /**
  149738. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  149739. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  149740. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  149741. * @returns the created depth renderer
  149742. */
  149743. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  149744. /**
  149745. * Disables a depth renderer for a given camera
  149746. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  149747. */
  149748. disableDepthRenderer(camera?: Nullable<Camera>): void;
  149749. }
  149750. /**
  149751. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  149752. * in several rendering techniques.
  149753. */
  149754. export class DepthRendererSceneComponent implements ISceneComponent {
  149755. /**
  149756. * The component name helpfull to identify the component in the list of scene components.
  149757. */
  149758. readonly name: string;
  149759. /**
  149760. * The scene the component belongs to.
  149761. */
  149762. scene: Scene;
  149763. /**
  149764. * Creates a new instance of the component for the given scene
  149765. * @param scene Defines the scene to register the component in
  149766. */
  149767. constructor(scene: Scene);
  149768. /**
  149769. * Registers the component in a given scene
  149770. */
  149771. register(): void;
  149772. /**
  149773. * Rebuilds the elements related to this component in case of
  149774. * context lost for instance.
  149775. */
  149776. rebuild(): void;
  149777. /**
  149778. * Disposes the component and the associated ressources
  149779. */
  149780. dispose(): void;
  149781. private _gatherRenderTargets;
  149782. private _gatherActiveCameraRenderTargets;
  149783. }
  149784. }
  149785. declare module BABYLON {
  149786. interface AbstractScene {
  149787. /** @hidden (Backing field) */
  149788. _prePassRenderer: Nullable<PrePassRenderer>;
  149789. /**
  149790. * Gets or Sets the current prepass renderer associated to the scene.
  149791. */
  149792. prePassRenderer: Nullable<PrePassRenderer>;
  149793. /**
  149794. * Enables the prepass and associates it with the scene
  149795. * @returns the PrePassRenderer
  149796. */
  149797. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149798. /**
  149799. * Disables the prepass associated with the scene
  149800. */
  149801. disablePrePassRenderer(): void;
  149802. }
  149803. /**
  149804. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149805. * in several rendering techniques.
  149806. */
  149807. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149808. /**
  149809. * The component name helpful to identify the component in the list of scene components.
  149810. */
  149811. readonly name: string;
  149812. /**
  149813. * The scene the component belongs to.
  149814. */
  149815. scene: Scene;
  149816. /**
  149817. * Creates a new instance of the component for the given scene
  149818. * @param scene Defines the scene to register the component in
  149819. */
  149820. constructor(scene: Scene);
  149821. /**
  149822. * Registers the component in a given scene
  149823. */
  149824. register(): void;
  149825. private _beforeCameraDraw;
  149826. private _afterCameraDraw;
  149827. private _beforeClearStage;
  149828. /**
  149829. * Serializes the component data to the specified json object
  149830. * @param serializationObject The object to serialize to
  149831. */
  149832. serialize(serializationObject: any): void;
  149833. /**
  149834. * Adds all the elements from the container to the scene
  149835. * @param container the container holding the elements
  149836. */
  149837. addFromContainer(container: AbstractScene): void;
  149838. /**
  149839. * Removes all the elements in the container from the scene
  149840. * @param container contains the elements to remove
  149841. * @param dispose if the removed element should be disposed (default: false)
  149842. */
  149843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149844. /**
  149845. * Rebuilds the elements related to this component in case of
  149846. * context lost for instance.
  149847. */
  149848. rebuild(): void;
  149849. /**
  149850. * Disposes the component and the associated ressources
  149851. */
  149852. dispose(): void;
  149853. }
  149854. }
  149855. declare module BABYLON {
  149856. /** @hidden */
  149857. export var outlinePixelShader: {
  149858. name: string;
  149859. shader: string;
  149860. };
  149861. }
  149862. declare module BABYLON {
  149863. /** @hidden */
  149864. export var outlineVertexShader: {
  149865. name: string;
  149866. shader: string;
  149867. };
  149868. }
  149869. declare module BABYLON {
  149870. interface Scene {
  149871. /** @hidden */
  149872. _outlineRenderer: OutlineRenderer;
  149873. /**
  149874. * Gets the outline renderer associated with the scene
  149875. * @returns a OutlineRenderer
  149876. */
  149877. getOutlineRenderer(): OutlineRenderer;
  149878. }
  149879. interface AbstractMesh {
  149880. /** @hidden (Backing field) */
  149881. _renderOutline: boolean;
  149882. /**
  149883. * Gets or sets a boolean indicating if the outline must be rendered as well
  149884. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149885. */
  149886. renderOutline: boolean;
  149887. /** @hidden (Backing field) */
  149888. _renderOverlay: boolean;
  149889. /**
  149890. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149891. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149892. */
  149893. renderOverlay: boolean;
  149894. }
  149895. /**
  149896. * This class is responsible to draw bothe outline/overlay of meshes.
  149897. * It should not be used directly but through the available method on mesh.
  149898. */
  149899. export class OutlineRenderer implements ISceneComponent {
  149900. /**
  149901. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149902. */
  149903. private static _StencilReference;
  149904. /**
  149905. * The name of the component. Each component must have a unique name.
  149906. */
  149907. name: string;
  149908. /**
  149909. * The scene the component belongs to.
  149910. */
  149911. scene: Scene;
  149912. /**
  149913. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149914. */
  149915. zOffset: number;
  149916. private _engine;
  149917. private _effect;
  149918. private _cachedDefines;
  149919. private _savedDepthWrite;
  149920. /**
  149921. * Instantiates a new outline renderer. (There could be only one per scene).
  149922. * @param scene Defines the scene it belongs to
  149923. */
  149924. constructor(scene: Scene);
  149925. /**
  149926. * Register the component to one instance of a scene.
  149927. */
  149928. register(): void;
  149929. /**
  149930. * Rebuilds the elements related to this component in case of
  149931. * context lost for instance.
  149932. */
  149933. rebuild(): void;
  149934. /**
  149935. * Disposes the component and the associated ressources.
  149936. */
  149937. dispose(): void;
  149938. /**
  149939. * Renders the outline in the canvas.
  149940. * @param subMesh Defines the sumesh to render
  149941. * @param batch Defines the batch of meshes in case of instances
  149942. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149943. */
  149944. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149945. /**
  149946. * Returns whether or not the outline renderer is ready for a given submesh.
  149947. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149948. * @param subMesh Defines the submesh to check readyness for
  149949. * @param useInstances Defines wheter wee are trying to render instances or not
  149950. * @returns true if ready otherwise false
  149951. */
  149952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149953. private _beforeRenderingMesh;
  149954. private _afterRenderingMesh;
  149955. }
  149956. }
  149957. declare module BABYLON {
  149958. /**
  149959. * Defines the basic options interface of a Sprite Frame Source Size.
  149960. */
  149961. export interface ISpriteJSONSpriteSourceSize {
  149962. /**
  149963. * number of the original width of the Frame
  149964. */
  149965. w: number;
  149966. /**
  149967. * number of the original height of the Frame
  149968. */
  149969. h: number;
  149970. }
  149971. /**
  149972. * Defines the basic options interface of a Sprite Frame Data.
  149973. */
  149974. export interface ISpriteJSONSpriteFrameData {
  149975. /**
  149976. * number of the x offset of the Frame
  149977. */
  149978. x: number;
  149979. /**
  149980. * number of the y offset of the Frame
  149981. */
  149982. y: number;
  149983. /**
  149984. * number of the width of the Frame
  149985. */
  149986. w: number;
  149987. /**
  149988. * number of the height of the Frame
  149989. */
  149990. h: number;
  149991. }
  149992. /**
  149993. * Defines the basic options interface of a JSON Sprite.
  149994. */
  149995. export interface ISpriteJSONSprite {
  149996. /**
  149997. * string name of the Frame
  149998. */
  149999. filename: string;
  150000. /**
  150001. * ISpriteJSONSpriteFrame basic object of the frame data
  150002. */
  150003. frame: ISpriteJSONSpriteFrameData;
  150004. /**
  150005. * boolean to flag is the frame was rotated.
  150006. */
  150007. rotated: boolean;
  150008. /**
  150009. * boolean to flag is the frame was trimmed.
  150010. */
  150011. trimmed: boolean;
  150012. /**
  150013. * ISpriteJSONSpriteFrame basic object of the source data
  150014. */
  150015. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150016. /**
  150017. * ISpriteJSONSpriteFrame basic object of the source data
  150018. */
  150019. sourceSize: ISpriteJSONSpriteSourceSize;
  150020. }
  150021. /**
  150022. * Defines the basic options interface of a JSON atlas.
  150023. */
  150024. export interface ISpriteJSONAtlas {
  150025. /**
  150026. * Array of objects that contain the frame data.
  150027. */
  150028. frames: Array<ISpriteJSONSprite>;
  150029. /**
  150030. * object basic object containing the sprite meta data.
  150031. */
  150032. meta?: object;
  150033. }
  150034. }
  150035. declare module BABYLON {
  150036. /** @hidden */
  150037. export var spriteMapPixelShader: {
  150038. name: string;
  150039. shader: string;
  150040. };
  150041. }
  150042. declare module BABYLON {
  150043. /** @hidden */
  150044. export var spriteMapVertexShader: {
  150045. name: string;
  150046. shader: string;
  150047. };
  150048. }
  150049. declare module BABYLON {
  150050. /**
  150051. * Defines the basic options interface of a SpriteMap
  150052. */
  150053. export interface ISpriteMapOptions {
  150054. /**
  150055. * Vector2 of the number of cells in the grid.
  150056. */
  150057. stageSize?: Vector2;
  150058. /**
  150059. * Vector2 of the size of the output plane in World Units.
  150060. */
  150061. outputSize?: Vector2;
  150062. /**
  150063. * Vector3 of the position of the output plane in World Units.
  150064. */
  150065. outputPosition?: Vector3;
  150066. /**
  150067. * Vector3 of the rotation of the output plane.
  150068. */
  150069. outputRotation?: Vector3;
  150070. /**
  150071. * number of layers that the system will reserve in resources.
  150072. */
  150073. layerCount?: number;
  150074. /**
  150075. * number of max animation frames a single cell will reserve in resources.
  150076. */
  150077. maxAnimationFrames?: number;
  150078. /**
  150079. * number cell index of the base tile when the system compiles.
  150080. */
  150081. baseTile?: number;
  150082. /**
  150083. * boolean flip the sprite after its been repositioned by the framing data.
  150084. */
  150085. flipU?: boolean;
  150086. /**
  150087. * Vector3 scalar of the global RGB values of the SpriteMap.
  150088. */
  150089. colorMultiply?: Vector3;
  150090. }
  150091. /**
  150092. * Defines the IDisposable interface in order to be cleanable from resources.
  150093. */
  150094. export interface ISpriteMap extends IDisposable {
  150095. /**
  150096. * String name of the SpriteMap.
  150097. */
  150098. name: string;
  150099. /**
  150100. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150101. */
  150102. atlasJSON: ISpriteJSONAtlas;
  150103. /**
  150104. * Texture of the SpriteMap.
  150105. */
  150106. spriteSheet: Texture;
  150107. /**
  150108. * The parameters to initialize the SpriteMap with.
  150109. */
  150110. options: ISpriteMapOptions;
  150111. }
  150112. /**
  150113. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150114. */
  150115. export class SpriteMap implements ISpriteMap {
  150116. /** The Name of the spriteMap */
  150117. name: string;
  150118. /** The JSON file with the frame and meta data */
  150119. atlasJSON: ISpriteJSONAtlas;
  150120. /** The systems Sprite Sheet Texture */
  150121. spriteSheet: Texture;
  150122. /** Arguments passed with the Constructor */
  150123. options: ISpriteMapOptions;
  150124. /** Public Sprite Storage array, parsed from atlasJSON */
  150125. sprites: Array<ISpriteJSONSprite>;
  150126. /** Returns the Number of Sprites in the System */
  150127. get spriteCount(): number;
  150128. /** Returns the Position of Output Plane*/
  150129. get position(): Vector3;
  150130. /** Returns the Position of Output Plane*/
  150131. set position(v: Vector3);
  150132. /** Returns the Rotation of Output Plane*/
  150133. get rotation(): Vector3;
  150134. /** Returns the Rotation of Output Plane*/
  150135. set rotation(v: Vector3);
  150136. /** Sets the AnimationMap*/
  150137. get animationMap(): RawTexture;
  150138. /** Sets the AnimationMap*/
  150139. set animationMap(v: RawTexture);
  150140. /** Scene that the SpriteMap was created in */
  150141. private _scene;
  150142. /** Texture Buffer of Float32 that holds tile frame data*/
  150143. private _frameMap;
  150144. /** Texture Buffers of Float32 that holds tileMap data*/
  150145. private _tileMaps;
  150146. /** Texture Buffer of Float32 that holds Animation Data*/
  150147. private _animationMap;
  150148. /** Custom ShaderMaterial Central to the System*/
  150149. private _material;
  150150. /** Custom ShaderMaterial Central to the System*/
  150151. private _output;
  150152. /** Systems Time Ticker*/
  150153. private _time;
  150154. /**
  150155. * Creates a new SpriteMap
  150156. * @param name defines the SpriteMaps Name
  150157. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150158. * @param spriteSheet is the Texture that the Sprites are on.
  150159. * @param options a basic deployment configuration
  150160. * @param scene The Scene that the map is deployed on
  150161. */
  150162. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150163. /**
  150164. * Returns tileID location
  150165. * @returns Vector2 the cell position ID
  150166. */
  150167. getTileID(): Vector2;
  150168. /**
  150169. * Gets the UV location of the mouse over the SpriteMap.
  150170. * @returns Vector2 the UV position of the mouse interaction
  150171. */
  150172. getMousePosition(): Vector2;
  150173. /**
  150174. * Creates the "frame" texture Buffer
  150175. * -------------------------------------
  150176. * Structure of frames
  150177. * "filename": "Falling-Water-2.png",
  150178. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150179. * "rotated": true,
  150180. * "trimmed": true,
  150181. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150182. * "sourceSize": {"w":32,"h":32}
  150183. * @returns RawTexture of the frameMap
  150184. */
  150185. private _createFrameBuffer;
  150186. /**
  150187. * Creates the tileMap texture Buffer
  150188. * @param buffer normally and array of numbers, or a false to generate from scratch
  150189. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150190. * @returns RawTexture of the tileMap
  150191. */
  150192. private _createTileBuffer;
  150193. /**
  150194. * Modifies the data of the tileMaps
  150195. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150196. * @param pos is the iVector2 Coordinates of the Tile
  150197. * @param tile The SpriteIndex of the new Tile
  150198. */
  150199. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150200. /**
  150201. * Creates the animationMap texture Buffer
  150202. * @param buffer normally and array of numbers, or a false to generate from scratch
  150203. * @returns RawTexture of the animationMap
  150204. */
  150205. private _createTileAnimationBuffer;
  150206. /**
  150207. * Modifies the data of the animationMap
  150208. * @param cellID is the Index of the Sprite
  150209. * @param _frame is the target Animation frame
  150210. * @param toCell is the Target Index of the next frame of the animation
  150211. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150212. * @param speed is a global scalar of the time variable on the map.
  150213. */
  150214. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150215. /**
  150216. * Exports the .tilemaps file
  150217. */
  150218. saveTileMaps(): void;
  150219. /**
  150220. * Imports the .tilemaps file
  150221. * @param url of the .tilemaps file
  150222. */
  150223. loadTileMaps(url: string): void;
  150224. /**
  150225. * Release associated resources
  150226. */
  150227. dispose(): void;
  150228. }
  150229. }
  150230. declare module BABYLON {
  150231. /**
  150232. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150233. * @see https://doc.babylonjs.com/babylon101/sprites
  150234. */
  150235. export class SpritePackedManager extends SpriteManager {
  150236. /** defines the packed manager's name */
  150237. name: string;
  150238. /**
  150239. * Creates a new sprite manager from a packed sprite sheet
  150240. * @param name defines the manager's name
  150241. * @param imgUrl defines the sprite sheet url
  150242. * @param capacity defines the maximum allowed number of sprites
  150243. * @param scene defines the hosting scene
  150244. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150245. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150246. * @param samplingMode defines the smapling mode to use with spritesheet
  150247. * @param fromPacked set to true; do not alter
  150248. */
  150249. constructor(
  150250. /** defines the packed manager's name */
  150251. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150252. }
  150253. }
  150254. declare module BABYLON {
  150255. /**
  150256. * Defines the list of states available for a task inside a AssetsManager
  150257. */
  150258. export enum AssetTaskState {
  150259. /**
  150260. * Initialization
  150261. */
  150262. INIT = 0,
  150263. /**
  150264. * Running
  150265. */
  150266. RUNNING = 1,
  150267. /**
  150268. * Done
  150269. */
  150270. DONE = 2,
  150271. /**
  150272. * Error
  150273. */
  150274. ERROR = 3
  150275. }
  150276. /**
  150277. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150278. */
  150279. export abstract class AbstractAssetTask {
  150280. /**
  150281. * Task name
  150282. */ name: string;
  150283. /**
  150284. * Callback called when the task is successful
  150285. */
  150286. onSuccess: (task: any) => void;
  150287. /**
  150288. * Callback called when the task is not successful
  150289. */
  150290. onError: (task: any, message?: string, exception?: any) => void;
  150291. /**
  150292. * Creates a new AssetsManager
  150293. * @param name defines the name of the task
  150294. */
  150295. constructor(
  150296. /**
  150297. * Task name
  150298. */ name: string);
  150299. private _isCompleted;
  150300. private _taskState;
  150301. private _errorObject;
  150302. /**
  150303. * Get if the task is completed
  150304. */
  150305. get isCompleted(): boolean;
  150306. /**
  150307. * Gets the current state of the task
  150308. */
  150309. get taskState(): AssetTaskState;
  150310. /**
  150311. * Gets the current error object (if task is in error)
  150312. */
  150313. get errorObject(): {
  150314. message?: string;
  150315. exception?: any;
  150316. };
  150317. /**
  150318. * Internal only
  150319. * @hidden
  150320. */
  150321. _setErrorObject(message?: string, exception?: any): void;
  150322. /**
  150323. * Execute the current task
  150324. * @param scene defines the scene where you want your assets to be loaded
  150325. * @param onSuccess is a callback called when the task is successfully executed
  150326. * @param onError is a callback called if an error occurs
  150327. */
  150328. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150329. /**
  150330. * Execute the current task
  150331. * @param scene defines the scene where you want your assets to be loaded
  150332. * @param onSuccess is a callback called when the task is successfully executed
  150333. * @param onError is a callback called if an error occurs
  150334. */
  150335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150336. /**
  150337. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150338. * This can be used with failed tasks that have the reason for failure fixed.
  150339. */
  150340. reset(): void;
  150341. private onErrorCallback;
  150342. private onDoneCallback;
  150343. }
  150344. /**
  150345. * Define the interface used by progress events raised during assets loading
  150346. */
  150347. export interface IAssetsProgressEvent {
  150348. /**
  150349. * Defines the number of remaining tasks to process
  150350. */
  150351. remainingCount: number;
  150352. /**
  150353. * Defines the total number of tasks
  150354. */
  150355. totalCount: number;
  150356. /**
  150357. * Defines the task that was just processed
  150358. */
  150359. task: AbstractAssetTask;
  150360. }
  150361. /**
  150362. * Class used to share progress information about assets loading
  150363. */
  150364. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150365. /**
  150366. * Defines the number of remaining tasks to process
  150367. */
  150368. remainingCount: number;
  150369. /**
  150370. * Defines the total number of tasks
  150371. */
  150372. totalCount: number;
  150373. /**
  150374. * Defines the task that was just processed
  150375. */
  150376. task: AbstractAssetTask;
  150377. /**
  150378. * Creates a AssetsProgressEvent
  150379. * @param remainingCount defines the number of remaining tasks to process
  150380. * @param totalCount defines the total number of tasks
  150381. * @param task defines the task that was just processed
  150382. */
  150383. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150384. }
  150385. /**
  150386. * Define a task used by AssetsManager to load meshes
  150387. */
  150388. export class MeshAssetTask extends AbstractAssetTask {
  150389. /**
  150390. * Defines the name of the task
  150391. */
  150392. name: string;
  150393. /**
  150394. * Defines the list of mesh's names you want to load
  150395. */
  150396. meshesNames: any;
  150397. /**
  150398. * Defines the root url to use as a base to load your meshes and associated resources
  150399. */
  150400. rootUrl: string;
  150401. /**
  150402. * Defines the filename or File of the scene to load from
  150403. */
  150404. sceneFilename: string | File;
  150405. /**
  150406. * Gets the list of loaded meshes
  150407. */
  150408. loadedMeshes: Array<AbstractMesh>;
  150409. /**
  150410. * Gets the list of loaded particle systems
  150411. */
  150412. loadedParticleSystems: Array<IParticleSystem>;
  150413. /**
  150414. * Gets the list of loaded skeletons
  150415. */
  150416. loadedSkeletons: Array<Skeleton>;
  150417. /**
  150418. * Gets the list of loaded animation groups
  150419. */
  150420. loadedAnimationGroups: Array<AnimationGroup>;
  150421. /**
  150422. * Callback called when the task is successful
  150423. */
  150424. onSuccess: (task: MeshAssetTask) => void;
  150425. /**
  150426. * Callback called when the task is successful
  150427. */
  150428. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150429. /**
  150430. * Creates a new MeshAssetTask
  150431. * @param name defines the name of the task
  150432. * @param meshesNames defines the list of mesh's names you want to load
  150433. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150434. * @param sceneFilename defines the filename or File of the scene to load from
  150435. */
  150436. constructor(
  150437. /**
  150438. * Defines the name of the task
  150439. */
  150440. name: string,
  150441. /**
  150442. * Defines the list of mesh's names you want to load
  150443. */
  150444. meshesNames: any,
  150445. /**
  150446. * Defines the root url to use as a base to load your meshes and associated resources
  150447. */
  150448. rootUrl: string,
  150449. /**
  150450. * Defines the filename or File of the scene to load from
  150451. */
  150452. sceneFilename: string | File);
  150453. /**
  150454. * Execute the current task
  150455. * @param scene defines the scene where you want your assets to be loaded
  150456. * @param onSuccess is a callback called when the task is successfully executed
  150457. * @param onError is a callback called if an error occurs
  150458. */
  150459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150460. }
  150461. /**
  150462. * Define a task used by AssetsManager to load text content
  150463. */
  150464. export class TextFileAssetTask extends AbstractAssetTask {
  150465. /**
  150466. * Defines the name of the task
  150467. */
  150468. name: string;
  150469. /**
  150470. * Defines the location of the file to load
  150471. */
  150472. url: string;
  150473. /**
  150474. * Gets the loaded text string
  150475. */
  150476. text: string;
  150477. /**
  150478. * Callback called when the task is successful
  150479. */
  150480. onSuccess: (task: TextFileAssetTask) => void;
  150481. /**
  150482. * Callback called when the task is successful
  150483. */
  150484. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  150485. /**
  150486. * Creates a new TextFileAssetTask object
  150487. * @param name defines the name of the task
  150488. * @param url defines the location of the file to load
  150489. */
  150490. constructor(
  150491. /**
  150492. * Defines the name of the task
  150493. */
  150494. name: string,
  150495. /**
  150496. * Defines the location of the file to load
  150497. */
  150498. url: string);
  150499. /**
  150500. * Execute the current task
  150501. * @param scene defines the scene where you want your assets to be loaded
  150502. * @param onSuccess is a callback called when the task is successfully executed
  150503. * @param onError is a callback called if an error occurs
  150504. */
  150505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150506. }
  150507. /**
  150508. * Define a task used by AssetsManager to load binary data
  150509. */
  150510. export class BinaryFileAssetTask extends AbstractAssetTask {
  150511. /**
  150512. * Defines the name of the task
  150513. */
  150514. name: string;
  150515. /**
  150516. * Defines the location of the file to load
  150517. */
  150518. url: string;
  150519. /**
  150520. * Gets the lodaded data (as an array buffer)
  150521. */
  150522. data: ArrayBuffer;
  150523. /**
  150524. * Callback called when the task is successful
  150525. */
  150526. onSuccess: (task: BinaryFileAssetTask) => void;
  150527. /**
  150528. * Callback called when the task is successful
  150529. */
  150530. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  150531. /**
  150532. * Creates a new BinaryFileAssetTask object
  150533. * @param name defines the name of the new task
  150534. * @param url defines the location of the file to load
  150535. */
  150536. constructor(
  150537. /**
  150538. * Defines the name of the task
  150539. */
  150540. name: string,
  150541. /**
  150542. * Defines the location of the file to load
  150543. */
  150544. url: string);
  150545. /**
  150546. * Execute the current task
  150547. * @param scene defines the scene where you want your assets to be loaded
  150548. * @param onSuccess is a callback called when the task is successfully executed
  150549. * @param onError is a callback called if an error occurs
  150550. */
  150551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150552. }
  150553. /**
  150554. * Define a task used by AssetsManager to load images
  150555. */
  150556. export class ImageAssetTask extends AbstractAssetTask {
  150557. /**
  150558. * Defines the name of the task
  150559. */
  150560. name: string;
  150561. /**
  150562. * Defines the location of the image to load
  150563. */
  150564. url: string;
  150565. /**
  150566. * Gets the loaded images
  150567. */
  150568. image: HTMLImageElement;
  150569. /**
  150570. * Callback called when the task is successful
  150571. */
  150572. onSuccess: (task: ImageAssetTask) => void;
  150573. /**
  150574. * Callback called when the task is successful
  150575. */
  150576. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  150577. /**
  150578. * Creates a new ImageAssetTask
  150579. * @param name defines the name of the task
  150580. * @param url defines the location of the image to load
  150581. */
  150582. constructor(
  150583. /**
  150584. * Defines the name of the task
  150585. */
  150586. name: string,
  150587. /**
  150588. * Defines the location of the image to load
  150589. */
  150590. url: string);
  150591. /**
  150592. * Execute the current task
  150593. * @param scene defines the scene where you want your assets to be loaded
  150594. * @param onSuccess is a callback called when the task is successfully executed
  150595. * @param onError is a callback called if an error occurs
  150596. */
  150597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150598. }
  150599. /**
  150600. * Defines the interface used by texture loading tasks
  150601. */
  150602. export interface ITextureAssetTask<TEX extends BaseTexture> {
  150603. /**
  150604. * Gets the loaded texture
  150605. */
  150606. texture: TEX;
  150607. }
  150608. /**
  150609. * Define a task used by AssetsManager to load 2D textures
  150610. */
  150611. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  150612. /**
  150613. * Defines the name of the task
  150614. */
  150615. name: string;
  150616. /**
  150617. * Defines the location of the file to load
  150618. */
  150619. url: string;
  150620. /**
  150621. * Defines if mipmap should not be generated (default is false)
  150622. */
  150623. noMipmap?: boolean | undefined;
  150624. /**
  150625. * Defines if texture must be inverted on Y axis (default is true)
  150626. */
  150627. invertY: boolean;
  150628. /**
  150629. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150630. */
  150631. samplingMode: number;
  150632. /**
  150633. * Gets the loaded texture
  150634. */
  150635. texture: Texture;
  150636. /**
  150637. * Callback called when the task is successful
  150638. */
  150639. onSuccess: (task: TextureAssetTask) => void;
  150640. /**
  150641. * Callback called when the task is successful
  150642. */
  150643. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150644. /**
  150645. * Creates a new TextureAssetTask object
  150646. * @param name defines the name of the task
  150647. * @param url defines the location of the file to load
  150648. * @param noMipmap defines if mipmap should not be generated (default is false)
  150649. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150650. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150651. */
  150652. constructor(
  150653. /**
  150654. * Defines the name of the task
  150655. */
  150656. name: string,
  150657. /**
  150658. * Defines the location of the file to load
  150659. */
  150660. url: string,
  150661. /**
  150662. * Defines if mipmap should not be generated (default is false)
  150663. */
  150664. noMipmap?: boolean | undefined,
  150665. /**
  150666. * Defines if texture must be inverted on Y axis (default is true)
  150667. */
  150668. invertY?: boolean,
  150669. /**
  150670. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150671. */
  150672. samplingMode?: number);
  150673. /**
  150674. * Execute the current task
  150675. * @param scene defines the scene where you want your assets to be loaded
  150676. * @param onSuccess is a callback called when the task is successfully executed
  150677. * @param onError is a callback called if an error occurs
  150678. */
  150679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150680. }
  150681. /**
  150682. * Define a task used by AssetsManager to load cube textures
  150683. */
  150684. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150685. /**
  150686. * Defines the name of the task
  150687. */
  150688. name: string;
  150689. /**
  150690. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150691. */
  150692. url: string;
  150693. /**
  150694. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150695. */
  150696. extensions?: string[] | undefined;
  150697. /**
  150698. * Defines if mipmaps should not be generated (default is false)
  150699. */
  150700. noMipmap?: boolean | undefined;
  150701. /**
  150702. * Defines the explicit list of files (undefined by default)
  150703. */
  150704. files?: string[] | undefined;
  150705. /**
  150706. * Gets the loaded texture
  150707. */
  150708. texture: CubeTexture;
  150709. /**
  150710. * Callback called when the task is successful
  150711. */
  150712. onSuccess: (task: CubeTextureAssetTask) => void;
  150713. /**
  150714. * Callback called when the task is successful
  150715. */
  150716. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150717. /**
  150718. * Creates a new CubeTextureAssetTask
  150719. * @param name defines the name of the task
  150720. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150721. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150722. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150723. * @param files defines the explicit list of files (undefined by default)
  150724. */
  150725. constructor(
  150726. /**
  150727. * Defines the name of the task
  150728. */
  150729. name: string,
  150730. /**
  150731. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150732. */
  150733. url: string,
  150734. /**
  150735. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150736. */
  150737. extensions?: string[] | undefined,
  150738. /**
  150739. * Defines if mipmaps should not be generated (default is false)
  150740. */
  150741. noMipmap?: boolean | undefined,
  150742. /**
  150743. * Defines the explicit list of files (undefined by default)
  150744. */
  150745. files?: string[] | undefined);
  150746. /**
  150747. * Execute the current task
  150748. * @param scene defines the scene where you want your assets to be loaded
  150749. * @param onSuccess is a callback called when the task is successfully executed
  150750. * @param onError is a callback called if an error occurs
  150751. */
  150752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150753. }
  150754. /**
  150755. * Define a task used by AssetsManager to load HDR cube textures
  150756. */
  150757. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150758. /**
  150759. * Defines the name of the task
  150760. */
  150761. name: string;
  150762. /**
  150763. * Defines the location of the file to load
  150764. */
  150765. url: string;
  150766. /**
  150767. * Defines the desired size (the more it increases the longer the generation will be)
  150768. */
  150769. size: number;
  150770. /**
  150771. * Defines if mipmaps should not be generated (default is false)
  150772. */
  150773. noMipmap: boolean;
  150774. /**
  150775. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150776. */
  150777. generateHarmonics: boolean;
  150778. /**
  150779. * 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)
  150780. */
  150781. gammaSpace: boolean;
  150782. /**
  150783. * Internal Use Only
  150784. */
  150785. reserved: boolean;
  150786. /**
  150787. * Gets the loaded texture
  150788. */
  150789. texture: HDRCubeTexture;
  150790. /**
  150791. * Callback called when the task is successful
  150792. */
  150793. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150794. /**
  150795. * Callback called when the task is successful
  150796. */
  150797. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150798. /**
  150799. * Creates a new HDRCubeTextureAssetTask object
  150800. * @param name defines the name of the task
  150801. * @param url defines the location of the file to load
  150802. * @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.
  150803. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150804. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150805. * @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)
  150806. * @param reserved Internal use only
  150807. */
  150808. constructor(
  150809. /**
  150810. * Defines the name of the task
  150811. */
  150812. name: string,
  150813. /**
  150814. * Defines the location of the file to load
  150815. */
  150816. url: string,
  150817. /**
  150818. * Defines the desired size (the more it increases the longer the generation will be)
  150819. */
  150820. size: number,
  150821. /**
  150822. * Defines if mipmaps should not be generated (default is false)
  150823. */
  150824. noMipmap?: boolean,
  150825. /**
  150826. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150827. */
  150828. generateHarmonics?: boolean,
  150829. /**
  150830. * 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)
  150831. */
  150832. gammaSpace?: boolean,
  150833. /**
  150834. * Internal Use Only
  150835. */
  150836. reserved?: boolean);
  150837. /**
  150838. * Execute the current task
  150839. * @param scene defines the scene where you want your assets to be loaded
  150840. * @param onSuccess is a callback called when the task is successfully executed
  150841. * @param onError is a callback called if an error occurs
  150842. */
  150843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150844. }
  150845. /**
  150846. * Define a task used by AssetsManager to load Equirectangular cube textures
  150847. */
  150848. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150849. /**
  150850. * Defines the name of the task
  150851. */
  150852. name: string;
  150853. /**
  150854. * Defines the location of the file to load
  150855. */
  150856. url: string;
  150857. /**
  150858. * Defines the desired size (the more it increases the longer the generation will be)
  150859. */
  150860. size: number;
  150861. /**
  150862. * Defines if mipmaps should not be generated (default is false)
  150863. */
  150864. noMipmap: boolean;
  150865. /**
  150866. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150867. * but the standard material would require them in Gamma space) (default is true)
  150868. */
  150869. gammaSpace: boolean;
  150870. /**
  150871. * Gets the loaded texture
  150872. */
  150873. texture: EquiRectangularCubeTexture;
  150874. /**
  150875. * Callback called when the task is successful
  150876. */
  150877. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150878. /**
  150879. * Callback called when the task is successful
  150880. */
  150881. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150882. /**
  150883. * Creates a new EquiRectangularCubeTextureAssetTask object
  150884. * @param name defines the name of the task
  150885. * @param url defines the location of the file to load
  150886. * @param size defines the desired size (the more it increases the longer the generation will be)
  150887. * If the size is omitted this implies you are using a preprocessed cubemap.
  150888. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150889. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150890. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150891. * (default is true)
  150892. */
  150893. constructor(
  150894. /**
  150895. * Defines the name of the task
  150896. */
  150897. name: string,
  150898. /**
  150899. * Defines the location of the file to load
  150900. */
  150901. url: string,
  150902. /**
  150903. * Defines the desired size (the more it increases the longer the generation will be)
  150904. */
  150905. size: number,
  150906. /**
  150907. * Defines if mipmaps should not be generated (default is false)
  150908. */
  150909. noMipmap?: boolean,
  150910. /**
  150911. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150912. * but the standard material would require them in Gamma space) (default is true)
  150913. */
  150914. gammaSpace?: boolean);
  150915. /**
  150916. * Execute the current task
  150917. * @param scene defines the scene where you want your assets to be loaded
  150918. * @param onSuccess is a callback called when the task is successfully executed
  150919. * @param onError is a callback called if an error occurs
  150920. */
  150921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150922. }
  150923. /**
  150924. * This class can be used to easily import assets into a scene
  150925. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150926. */
  150927. export class AssetsManager {
  150928. private _scene;
  150929. private _isLoading;
  150930. protected _tasks: AbstractAssetTask[];
  150931. protected _waitingTasksCount: number;
  150932. protected _totalTasksCount: number;
  150933. /**
  150934. * Callback called when all tasks are processed
  150935. */
  150936. onFinish: (tasks: AbstractAssetTask[]) => void;
  150937. /**
  150938. * Callback called when a task is successful
  150939. */
  150940. onTaskSuccess: (task: AbstractAssetTask) => void;
  150941. /**
  150942. * Callback called when a task had an error
  150943. */
  150944. onTaskError: (task: AbstractAssetTask) => void;
  150945. /**
  150946. * Callback called when a task is done (whatever the result is)
  150947. */
  150948. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150949. /**
  150950. * Observable called when all tasks are processed
  150951. */
  150952. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150953. /**
  150954. * Observable called when a task had an error
  150955. */
  150956. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150957. /**
  150958. * Observable called when all tasks were executed
  150959. */
  150960. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150961. /**
  150962. * Observable called when a task is done (whatever the result is)
  150963. */
  150964. onProgressObservable: Observable<IAssetsProgressEvent>;
  150965. /**
  150966. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150967. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150968. */
  150969. useDefaultLoadingScreen: boolean;
  150970. /**
  150971. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150972. * when all assets have been downloaded.
  150973. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150974. */
  150975. autoHideLoadingUI: boolean;
  150976. /**
  150977. * Creates a new AssetsManager
  150978. * @param scene defines the scene to work on
  150979. */
  150980. constructor(scene: Scene);
  150981. /**
  150982. * Add a MeshAssetTask to the list of active tasks
  150983. * @param taskName defines the name of the new task
  150984. * @param meshesNames defines the name of meshes to load
  150985. * @param rootUrl defines the root url to use to locate files
  150986. * @param sceneFilename defines the filename of the scene file
  150987. * @returns a new MeshAssetTask object
  150988. */
  150989. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150990. /**
  150991. * Add a TextFileAssetTask to the list of active tasks
  150992. * @param taskName defines the name of the new task
  150993. * @param url defines the url of the file to load
  150994. * @returns a new TextFileAssetTask object
  150995. */
  150996. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150997. /**
  150998. * Add a BinaryFileAssetTask to the list of active tasks
  150999. * @param taskName defines the name of the new task
  151000. * @param url defines the url of the file to load
  151001. * @returns a new BinaryFileAssetTask object
  151002. */
  151003. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151004. /**
  151005. * Add a ImageAssetTask to the list of active tasks
  151006. * @param taskName defines the name of the new task
  151007. * @param url defines the url of the file to load
  151008. * @returns a new ImageAssetTask object
  151009. */
  151010. addImageTask(taskName: string, url: string): ImageAssetTask;
  151011. /**
  151012. * Add a TextureAssetTask to the list of active tasks
  151013. * @param taskName defines the name of the new task
  151014. * @param url defines the url of the file to load
  151015. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151016. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151017. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151018. * @returns a new TextureAssetTask object
  151019. */
  151020. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151021. /**
  151022. * Add a CubeTextureAssetTask to the list of active tasks
  151023. * @param taskName defines the name of the new task
  151024. * @param url defines the url of the file to load
  151025. * @param extensions defines the extension to use to load the cube map (can be null)
  151026. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151027. * @param files defines the list of files to load (can be null)
  151028. * @returns a new CubeTextureAssetTask object
  151029. */
  151030. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151031. /**
  151032. *
  151033. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151034. * @param taskName defines the name of the new task
  151035. * @param url defines the url of the file to load
  151036. * @param size defines the size you want for the cubemap (can be null)
  151037. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151038. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151039. * @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)
  151040. * @param reserved Internal use only
  151041. * @returns a new HDRCubeTextureAssetTask object
  151042. */
  151043. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151044. /**
  151045. *
  151046. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151047. * @param taskName defines the name of the new task
  151048. * @param url defines the url of the file to load
  151049. * @param size defines the size you want for the cubemap (can be null)
  151050. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151051. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151052. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151053. * @returns a new EquiRectangularCubeTextureAssetTask object
  151054. */
  151055. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151056. /**
  151057. * Remove a task from the assets manager.
  151058. * @param task the task to remove
  151059. */
  151060. removeTask(task: AbstractAssetTask): void;
  151061. private _decreaseWaitingTasksCount;
  151062. private _runTask;
  151063. /**
  151064. * Reset the AssetsManager and remove all tasks
  151065. * @return the current instance of the AssetsManager
  151066. */
  151067. reset(): AssetsManager;
  151068. /**
  151069. * Start the loading process
  151070. * @return the current instance of the AssetsManager
  151071. */
  151072. load(): AssetsManager;
  151073. /**
  151074. * Start the loading process as an async operation
  151075. * @return a promise returning the list of failed tasks
  151076. */
  151077. loadAsync(): Promise<void>;
  151078. }
  151079. }
  151080. declare module BABYLON {
  151081. /**
  151082. * Wrapper class for promise with external resolve and reject.
  151083. */
  151084. export class Deferred<T> {
  151085. /**
  151086. * The promise associated with this deferred object.
  151087. */
  151088. readonly promise: Promise<T>;
  151089. private _resolve;
  151090. private _reject;
  151091. /**
  151092. * The resolve method of the promise associated with this deferred object.
  151093. */
  151094. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151095. /**
  151096. * The reject method of the promise associated with this deferred object.
  151097. */
  151098. get reject(): (reason?: any) => void;
  151099. /**
  151100. * Constructor for this deferred object.
  151101. */
  151102. constructor();
  151103. }
  151104. }
  151105. declare module BABYLON {
  151106. /**
  151107. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151108. */
  151109. export class MeshExploder {
  151110. private _centerMesh;
  151111. private _meshes;
  151112. private _meshesOrigins;
  151113. private _toCenterVectors;
  151114. private _scaledDirection;
  151115. private _newPosition;
  151116. private _centerPosition;
  151117. /**
  151118. * Explodes meshes from a center mesh.
  151119. * @param meshes The meshes to explode.
  151120. * @param centerMesh The mesh to be center of explosion.
  151121. */
  151122. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151123. private _setCenterMesh;
  151124. /**
  151125. * Get class name
  151126. * @returns "MeshExploder"
  151127. */
  151128. getClassName(): string;
  151129. /**
  151130. * "Exploded meshes"
  151131. * @returns Array of meshes with the centerMesh at index 0.
  151132. */
  151133. getMeshes(): Array<Mesh>;
  151134. /**
  151135. * Explodes meshes giving a specific direction
  151136. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151137. */
  151138. explode(direction?: number): void;
  151139. }
  151140. }
  151141. declare module BABYLON {
  151142. /**
  151143. * Class used to help managing file picking and drag'n'drop
  151144. */
  151145. export class FilesInput {
  151146. /**
  151147. * List of files ready to be loaded
  151148. */
  151149. static get FilesToLoad(): {
  151150. [key: string]: File;
  151151. };
  151152. /**
  151153. * Callback called when a file is processed
  151154. */
  151155. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151156. private _engine;
  151157. private _currentScene;
  151158. private _sceneLoadedCallback;
  151159. private _progressCallback;
  151160. private _additionalRenderLoopLogicCallback;
  151161. private _textureLoadingCallback;
  151162. private _startingProcessingFilesCallback;
  151163. private _onReloadCallback;
  151164. private _errorCallback;
  151165. private _elementToMonitor;
  151166. private _sceneFileToLoad;
  151167. private _filesToLoad;
  151168. /**
  151169. * Creates a new FilesInput
  151170. * @param engine defines the rendering engine
  151171. * @param scene defines the hosting scene
  151172. * @param sceneLoadedCallback callback called when scene is loaded
  151173. * @param progressCallback callback called to track progress
  151174. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151175. * @param textureLoadingCallback callback called when a texture is loading
  151176. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151177. * @param onReloadCallback callback called when a reload is requested
  151178. * @param errorCallback callback call if an error occurs
  151179. */
  151180. 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>);
  151181. private _dragEnterHandler;
  151182. private _dragOverHandler;
  151183. private _dropHandler;
  151184. /**
  151185. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151186. * @param elementToMonitor defines the DOM element to track
  151187. */
  151188. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151189. /** Gets the current list of files to load */
  151190. get filesToLoad(): File[];
  151191. /**
  151192. * Release all associated resources
  151193. */
  151194. dispose(): void;
  151195. private renderFunction;
  151196. private drag;
  151197. private drop;
  151198. private _traverseFolder;
  151199. private _processFiles;
  151200. /**
  151201. * Load files from a drop event
  151202. * @param event defines the drop event to use as source
  151203. */
  151204. loadFiles(event: any): void;
  151205. private _processReload;
  151206. /**
  151207. * Reload the current scene from the loaded files
  151208. */
  151209. reload(): void;
  151210. }
  151211. }
  151212. declare module BABYLON {
  151213. /**
  151214. * Defines the root class used to create scene optimization to use with SceneOptimizer
  151215. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151216. */
  151217. export class SceneOptimization {
  151218. /**
  151219. * Defines the priority of this optimization (0 by default which means first in the list)
  151220. */
  151221. priority: number;
  151222. /**
  151223. * Gets a string describing the action executed by the current optimization
  151224. * @returns description string
  151225. */
  151226. getDescription(): string;
  151227. /**
  151228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151229. * @param scene defines the current scene where to apply this optimization
  151230. * @param optimizer defines the current optimizer
  151231. * @returns true if everything that can be done was applied
  151232. */
  151233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151234. /**
  151235. * Creates the SceneOptimization object
  151236. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151237. * @param desc defines the description associated with the optimization
  151238. */
  151239. constructor(
  151240. /**
  151241. * Defines the priority of this optimization (0 by default which means first in the list)
  151242. */
  151243. priority?: number);
  151244. }
  151245. /**
  151246. * Defines an optimization used to reduce the size of render target textures
  151247. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151248. */
  151249. export class TextureOptimization extends SceneOptimization {
  151250. /**
  151251. * Defines the priority of this optimization (0 by default which means first in the list)
  151252. */
  151253. priority: number;
  151254. /**
  151255. * 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
  151256. */
  151257. maximumSize: number;
  151258. /**
  151259. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151260. */
  151261. step: number;
  151262. /**
  151263. * Gets a string describing the action executed by the current optimization
  151264. * @returns description string
  151265. */
  151266. getDescription(): string;
  151267. /**
  151268. * Creates the TextureOptimization object
  151269. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151270. * @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
  151271. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151272. */
  151273. constructor(
  151274. /**
  151275. * Defines the priority of this optimization (0 by default which means first in the list)
  151276. */
  151277. priority?: number,
  151278. /**
  151279. * 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
  151280. */
  151281. maximumSize?: number,
  151282. /**
  151283. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151284. */
  151285. step?: number);
  151286. /**
  151287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151288. * @param scene defines the current scene where to apply this optimization
  151289. * @param optimizer defines the current optimizer
  151290. * @returns true if everything that can be done was applied
  151291. */
  151292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151293. }
  151294. /**
  151295. * Defines an optimization used to increase or decrease the rendering resolution
  151296. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151297. */
  151298. export class HardwareScalingOptimization extends SceneOptimization {
  151299. /**
  151300. * Defines the priority of this optimization (0 by default which means first in the list)
  151301. */
  151302. priority: number;
  151303. /**
  151304. * Defines the maximum scale to use (2 by default)
  151305. */
  151306. maximumScale: number;
  151307. /**
  151308. * Defines the step to use between two passes (0.5 by default)
  151309. */
  151310. step: number;
  151311. private _currentScale;
  151312. private _directionOffset;
  151313. /**
  151314. * Gets a string describing the action executed by the current optimization
  151315. * @return description string
  151316. */
  151317. getDescription(): string;
  151318. /**
  151319. * Creates the HardwareScalingOptimization object
  151320. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151321. * @param maximumScale defines the maximum scale to use (2 by default)
  151322. * @param step defines the step to use between two passes (0.5 by default)
  151323. */
  151324. constructor(
  151325. /**
  151326. * Defines the priority of this optimization (0 by default which means first in the list)
  151327. */
  151328. priority?: number,
  151329. /**
  151330. * Defines the maximum scale to use (2 by default)
  151331. */
  151332. maximumScale?: number,
  151333. /**
  151334. * Defines the step to use between two passes (0.5 by default)
  151335. */
  151336. step?: number);
  151337. /**
  151338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151339. * @param scene defines the current scene where to apply this optimization
  151340. * @param optimizer defines the current optimizer
  151341. * @returns true if everything that can be done was applied
  151342. */
  151343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151344. }
  151345. /**
  151346. * Defines an optimization used to remove shadows
  151347. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151348. */
  151349. export class ShadowsOptimization extends SceneOptimization {
  151350. /**
  151351. * Gets a string describing the action executed by the current optimization
  151352. * @return description string
  151353. */
  151354. getDescription(): string;
  151355. /**
  151356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151357. * @param scene defines the current scene where to apply this optimization
  151358. * @param optimizer defines the current optimizer
  151359. * @returns true if everything that can be done was applied
  151360. */
  151361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151362. }
  151363. /**
  151364. * Defines an optimization used to turn post-processes off
  151365. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151366. */
  151367. export class PostProcessesOptimization extends SceneOptimization {
  151368. /**
  151369. * Gets a string describing the action executed by the current optimization
  151370. * @return description string
  151371. */
  151372. getDescription(): string;
  151373. /**
  151374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151375. * @param scene defines the current scene where to apply this optimization
  151376. * @param optimizer defines the current optimizer
  151377. * @returns true if everything that can be done was applied
  151378. */
  151379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151380. }
  151381. /**
  151382. * Defines an optimization used to turn lens flares off
  151383. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151384. */
  151385. export class LensFlaresOptimization extends SceneOptimization {
  151386. /**
  151387. * Gets a string describing the action executed by the current optimization
  151388. * @return description string
  151389. */
  151390. getDescription(): string;
  151391. /**
  151392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151393. * @param scene defines the current scene where to apply this optimization
  151394. * @param optimizer defines the current optimizer
  151395. * @returns true if everything that can be done was applied
  151396. */
  151397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151398. }
  151399. /**
  151400. * Defines an optimization based on user defined callback.
  151401. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151402. */
  151403. export class CustomOptimization extends SceneOptimization {
  151404. /**
  151405. * Callback called to apply the custom optimization.
  151406. */
  151407. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151408. /**
  151409. * Callback called to get custom description
  151410. */
  151411. onGetDescription: () => string;
  151412. /**
  151413. * Gets a string describing the action executed by the current optimization
  151414. * @returns description string
  151415. */
  151416. getDescription(): string;
  151417. /**
  151418. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151419. * @param scene defines the current scene where to apply this optimization
  151420. * @param optimizer defines the current optimizer
  151421. * @returns true if everything that can be done was applied
  151422. */
  151423. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151424. }
  151425. /**
  151426. * Defines an optimization used to turn particles off
  151427. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151428. */
  151429. export class ParticlesOptimization extends SceneOptimization {
  151430. /**
  151431. * Gets a string describing the action executed by the current optimization
  151432. * @return description string
  151433. */
  151434. getDescription(): string;
  151435. /**
  151436. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151437. * @param scene defines the current scene where to apply this optimization
  151438. * @param optimizer defines the current optimizer
  151439. * @returns true if everything that can be done was applied
  151440. */
  151441. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151442. }
  151443. /**
  151444. * Defines an optimization used to turn render targets off
  151445. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151446. */
  151447. export class RenderTargetsOptimization extends SceneOptimization {
  151448. /**
  151449. * Gets a string describing the action executed by the current optimization
  151450. * @return description string
  151451. */
  151452. getDescription(): string;
  151453. /**
  151454. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151455. * @param scene defines the current scene where to apply this optimization
  151456. * @param optimizer defines the current optimizer
  151457. * @returns true if everything that can be done was applied
  151458. */
  151459. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151460. }
  151461. /**
  151462. * Defines an optimization used to merge meshes with compatible materials
  151463. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151464. */
  151465. export class MergeMeshesOptimization extends SceneOptimization {
  151466. private static _UpdateSelectionTree;
  151467. /**
  151468. * Gets or sets a boolean which defines if optimization octree has to be updated
  151469. */
  151470. static get UpdateSelectionTree(): boolean;
  151471. /**
  151472. * Gets or sets a boolean which defines if optimization octree has to be updated
  151473. */
  151474. static set UpdateSelectionTree(value: boolean);
  151475. /**
  151476. * Gets a string describing the action executed by the current optimization
  151477. * @return description string
  151478. */
  151479. getDescription(): string;
  151480. private _canBeMerged;
  151481. /**
  151482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151483. * @param scene defines the current scene where to apply this optimization
  151484. * @param optimizer defines the current optimizer
  151485. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  151486. * @returns true if everything that can be done was applied
  151487. */
  151488. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  151489. }
  151490. /**
  151491. * Defines a list of options used by SceneOptimizer
  151492. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151493. */
  151494. export class SceneOptimizerOptions {
  151495. /**
  151496. * Defines the target frame rate to reach (60 by default)
  151497. */
  151498. targetFrameRate: number;
  151499. /**
  151500. * Defines the interval between two checkes (2000ms by default)
  151501. */
  151502. trackerDuration: number;
  151503. /**
  151504. * Gets the list of optimizations to apply
  151505. */
  151506. optimizations: SceneOptimization[];
  151507. /**
  151508. * Creates a new list of options used by SceneOptimizer
  151509. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  151510. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  151511. */
  151512. constructor(
  151513. /**
  151514. * Defines the target frame rate to reach (60 by default)
  151515. */
  151516. targetFrameRate?: number,
  151517. /**
  151518. * Defines the interval between two checkes (2000ms by default)
  151519. */
  151520. trackerDuration?: number);
  151521. /**
  151522. * Add a new optimization
  151523. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  151524. * @returns the current SceneOptimizerOptions
  151525. */
  151526. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  151527. /**
  151528. * Add a new custom optimization
  151529. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  151530. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  151531. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151532. * @returns the current SceneOptimizerOptions
  151533. */
  151534. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  151535. /**
  151536. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  151537. * @param targetFrameRate defines the target frame rate (60 by default)
  151538. * @returns a SceneOptimizerOptions object
  151539. */
  151540. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151541. /**
  151542. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  151543. * @param targetFrameRate defines the target frame rate (60 by default)
  151544. * @returns a SceneOptimizerOptions object
  151545. */
  151546. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151547. /**
  151548. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  151549. * @param targetFrameRate defines the target frame rate (60 by default)
  151550. * @returns a SceneOptimizerOptions object
  151551. */
  151552. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151553. }
  151554. /**
  151555. * Class used to run optimizations in order to reach a target frame rate
  151556. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151557. */
  151558. export class SceneOptimizer implements IDisposable {
  151559. private _isRunning;
  151560. private _options;
  151561. private _scene;
  151562. private _currentPriorityLevel;
  151563. private _targetFrameRate;
  151564. private _trackerDuration;
  151565. private _currentFrameRate;
  151566. private _sceneDisposeObserver;
  151567. private _improvementMode;
  151568. /**
  151569. * Defines an observable called when the optimizer reaches the target frame rate
  151570. */
  151571. onSuccessObservable: Observable<SceneOptimizer>;
  151572. /**
  151573. * Defines an observable called when the optimizer enables an optimization
  151574. */
  151575. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  151576. /**
  151577. * Defines an observable called when the optimizer is not able to reach the target frame rate
  151578. */
  151579. onFailureObservable: Observable<SceneOptimizer>;
  151580. /**
  151581. * Gets a boolean indicating if the optimizer is in improvement mode
  151582. */
  151583. get isInImprovementMode(): boolean;
  151584. /**
  151585. * Gets the current priority level (0 at start)
  151586. */
  151587. get currentPriorityLevel(): number;
  151588. /**
  151589. * Gets the current frame rate checked by the SceneOptimizer
  151590. */
  151591. get currentFrameRate(): number;
  151592. /**
  151593. * Gets or sets the current target frame rate (60 by default)
  151594. */
  151595. get targetFrameRate(): number;
  151596. /**
  151597. * Gets or sets the current target frame rate (60 by default)
  151598. */
  151599. set targetFrameRate(value: number);
  151600. /**
  151601. * Gets or sets the current interval between two checks (every 2000ms by default)
  151602. */
  151603. get trackerDuration(): number;
  151604. /**
  151605. * Gets or sets the current interval between two checks (every 2000ms by default)
  151606. */
  151607. set trackerDuration(value: number);
  151608. /**
  151609. * Gets the list of active optimizations
  151610. */
  151611. get optimizations(): SceneOptimization[];
  151612. /**
  151613. * Creates a new SceneOptimizer
  151614. * @param scene defines the scene to work on
  151615. * @param options defines the options to use with the SceneOptimizer
  151616. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  151617. * @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)
  151618. */
  151619. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  151620. /**
  151621. * Stops the current optimizer
  151622. */
  151623. stop(): void;
  151624. /**
  151625. * Reset the optimizer to initial step (current priority level = 0)
  151626. */
  151627. reset(): void;
  151628. /**
  151629. * Start the optimizer. By default it will try to reach a specific framerate
  151630. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  151631. */
  151632. start(): void;
  151633. private _checkCurrentState;
  151634. /**
  151635. * Release all resources
  151636. */
  151637. dispose(): void;
  151638. /**
  151639. * Helper function to create a SceneOptimizer with one single line of code
  151640. * @param scene defines the scene to work on
  151641. * @param options defines the options to use with the SceneOptimizer
  151642. * @param onSuccess defines a callback to call on success
  151643. * @param onFailure defines a callback to call on failure
  151644. * @returns the new SceneOptimizer object
  151645. */
  151646. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151647. }
  151648. }
  151649. declare module BABYLON {
  151650. /**
  151651. * Class used to serialize a scene into a string
  151652. */
  151653. export class SceneSerializer {
  151654. /**
  151655. * Clear cache used by a previous serialization
  151656. */
  151657. static ClearCache(): void;
  151658. /**
  151659. * Serialize a scene into a JSON compatible object
  151660. * @param scene defines the scene to serialize
  151661. * @returns a JSON compatible object
  151662. */
  151663. static Serialize(scene: Scene): any;
  151664. /**
  151665. * Serialize a mesh into a JSON compatible object
  151666. * @param toSerialize defines the mesh to serialize
  151667. * @param withParents defines if parents must be serialized as well
  151668. * @param withChildren defines if children must be serialized as well
  151669. * @returns a JSON compatible object
  151670. */
  151671. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151672. }
  151673. }
  151674. declare module BABYLON {
  151675. /**
  151676. * Class used to host texture specific utilities
  151677. */
  151678. export class TextureTools {
  151679. /**
  151680. * Uses the GPU to create a copy texture rescaled at a given size
  151681. * @param texture Texture to copy from
  151682. * @param width defines the desired width
  151683. * @param height defines the desired height
  151684. * @param useBilinearMode defines if bilinear mode has to be used
  151685. * @return the generated texture
  151686. */
  151687. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151688. }
  151689. }
  151690. declare module BABYLON {
  151691. /**
  151692. * This represents the different options available for the video capture.
  151693. */
  151694. export interface VideoRecorderOptions {
  151695. /** Defines the mime type of the video. */
  151696. mimeType: string;
  151697. /** Defines the FPS the video should be recorded at. */
  151698. fps: number;
  151699. /** Defines the chunk size for the recording data. */
  151700. recordChunckSize: number;
  151701. /** The audio tracks to attach to the recording. */
  151702. audioTracks?: MediaStreamTrack[];
  151703. }
  151704. /**
  151705. * This can help with recording videos from BabylonJS.
  151706. * This is based on the available WebRTC functionalities of the browser.
  151707. *
  151708. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151709. */
  151710. export class VideoRecorder {
  151711. private static readonly _defaultOptions;
  151712. /**
  151713. * Returns whether or not the VideoRecorder is available in your browser.
  151714. * @param engine Defines the Babylon Engine.
  151715. * @returns true if supported otherwise false.
  151716. */
  151717. static IsSupported(engine: Engine): boolean;
  151718. private readonly _options;
  151719. private _canvas;
  151720. private _mediaRecorder;
  151721. private _recordedChunks;
  151722. private _fileName;
  151723. private _resolve;
  151724. private _reject;
  151725. /**
  151726. * True when a recording is already in progress.
  151727. */
  151728. get isRecording(): boolean;
  151729. /**
  151730. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151731. * @param engine Defines the BabylonJS Engine you wish to record.
  151732. * @param options Defines options that can be used to customize the capture.
  151733. */
  151734. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151735. /**
  151736. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151737. */
  151738. stopRecording(): void;
  151739. /**
  151740. * Starts recording the canvas for a max duration specified in parameters.
  151741. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151742. * If null no automatic download will start and you can rely on the promise to get the data back.
  151743. * @param maxDuration Defines the maximum recording time in seconds.
  151744. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151745. * @return A promise callback at the end of the recording with the video data in Blob.
  151746. */
  151747. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151748. /**
  151749. * Releases internal resources used during the recording.
  151750. */
  151751. dispose(): void;
  151752. private _handleDataAvailable;
  151753. private _handleError;
  151754. private _handleStop;
  151755. }
  151756. }
  151757. declare module BABYLON {
  151758. /**
  151759. * Class containing a set of static utilities functions for screenshots
  151760. */
  151761. export class ScreenshotTools {
  151762. /**
  151763. * Captures a screenshot of the current rendering
  151764. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151765. * @param engine defines the rendering engine
  151766. * @param camera defines the source camera
  151767. * @param size This parameter can be set to a single number or to an object with the
  151768. * following (optional) properties: precision, width, height. If a single number is passed,
  151769. * it will be used for both width and height. If an object is passed, the screenshot size
  151770. * will be derived from the parameters. The precision property is a multiplier allowing
  151771. * rendering at a higher or lower resolution
  151772. * @param successCallback defines the callback receives a single parameter which contains the
  151773. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151774. * src parameter of an <img> to display it
  151775. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151776. * Check your browser for supported MIME types
  151777. */
  151778. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151779. /**
  151780. * Captures a screenshot of the current rendering
  151781. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151782. * @param engine defines the rendering engine
  151783. * @param camera defines the source camera
  151784. * @param size This parameter can be set to a single number or to an object with the
  151785. * following (optional) properties: precision, width, height. If a single number is passed,
  151786. * it will be used for both width and height. If an object is passed, the screenshot size
  151787. * will be derived from the parameters. The precision property is a multiplier allowing
  151788. * rendering at a higher or lower resolution
  151789. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151790. * Check your browser for supported MIME types
  151791. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151792. * to the src parameter of an <img> to display it
  151793. */
  151794. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151795. /**
  151796. * Generates an image screenshot from the specified camera.
  151797. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151798. * @param engine The engine to use for rendering
  151799. * @param camera The camera to use for rendering
  151800. * @param size This parameter can be set to a single number or to an object with the
  151801. * following (optional) properties: precision, width, height. If a single number is passed,
  151802. * it will be used for both width and height. If an object is passed, the screenshot size
  151803. * will be derived from the parameters. The precision property is a multiplier allowing
  151804. * rendering at a higher or lower resolution
  151805. * @param successCallback The callback receives a single parameter which contains the
  151806. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151807. * src parameter of an <img> to display it
  151808. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151809. * Check your browser for supported MIME types
  151810. * @param samples Texture samples (default: 1)
  151811. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151812. * @param fileName A name for for the downloaded file.
  151813. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151814. */
  151815. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151816. /**
  151817. * Generates an image screenshot from the specified camera.
  151818. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151819. * @param engine The engine to use for rendering
  151820. * @param camera The camera to use for rendering
  151821. * @param size This parameter can be set to a single number or to an object with the
  151822. * following (optional) properties: precision, width, height. If a single number is passed,
  151823. * it will be used for both width and height. If an object is passed, the screenshot size
  151824. * will be derived from the parameters. The precision property is a multiplier allowing
  151825. * rendering at a higher or lower resolution
  151826. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151827. * Check your browser for supported MIME types
  151828. * @param samples Texture samples (default: 1)
  151829. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151830. * @param fileName A name for for the downloaded file.
  151831. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151832. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151833. * to the src parameter of an <img> to display it
  151834. */
  151835. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151836. /**
  151837. * Gets height and width for screenshot size
  151838. * @private
  151839. */
  151840. private static _getScreenshotSize;
  151841. }
  151842. }
  151843. declare module BABYLON {
  151844. /**
  151845. * Interface for a data buffer
  151846. */
  151847. export interface IDataBuffer {
  151848. /**
  151849. * Reads bytes from the data buffer.
  151850. * @param byteOffset The byte offset to read
  151851. * @param byteLength The byte length to read
  151852. * @returns A promise that resolves when the bytes are read
  151853. */
  151854. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151855. /**
  151856. * The byte length of the buffer.
  151857. */
  151858. readonly byteLength: number;
  151859. }
  151860. /**
  151861. * Utility class for reading from a data buffer
  151862. */
  151863. export class DataReader {
  151864. /**
  151865. * The data buffer associated with this data reader.
  151866. */
  151867. readonly buffer: IDataBuffer;
  151868. /**
  151869. * The current byte offset from the beginning of the data buffer.
  151870. */
  151871. byteOffset: number;
  151872. private _dataView;
  151873. private _dataByteOffset;
  151874. /**
  151875. * Constructor
  151876. * @param buffer The buffer to read
  151877. */
  151878. constructor(buffer: IDataBuffer);
  151879. /**
  151880. * Loads the given byte length.
  151881. * @param byteLength The byte length to load
  151882. * @returns A promise that resolves when the load is complete
  151883. */
  151884. loadAsync(byteLength: number): Promise<void>;
  151885. /**
  151886. * Read a unsigned 32-bit integer from the currently loaded data range.
  151887. * @returns The 32-bit integer read
  151888. */
  151889. readUint32(): number;
  151890. /**
  151891. * Read a byte array from the currently loaded data range.
  151892. * @param byteLength The byte length to read
  151893. * @returns The byte array read
  151894. */
  151895. readUint8Array(byteLength: number): Uint8Array;
  151896. /**
  151897. * Read a string from the currently loaded data range.
  151898. * @param byteLength The byte length to read
  151899. * @returns The string read
  151900. */
  151901. readString(byteLength: number): string;
  151902. /**
  151903. * Skips the given byte length the currently loaded data range.
  151904. * @param byteLength The byte length to skip
  151905. */
  151906. skipBytes(byteLength: number): void;
  151907. }
  151908. }
  151909. declare module BABYLON {
  151910. /**
  151911. * Class for storing data to local storage if available or in-memory storage otherwise
  151912. */
  151913. export class DataStorage {
  151914. private static _Storage;
  151915. private static _GetStorage;
  151916. /**
  151917. * Reads a string from the data storage
  151918. * @param key The key to read
  151919. * @param defaultValue The value if the key doesn't exist
  151920. * @returns The string value
  151921. */
  151922. static ReadString(key: string, defaultValue: string): string;
  151923. /**
  151924. * Writes a string to the data storage
  151925. * @param key The key to write
  151926. * @param value The value to write
  151927. */
  151928. static WriteString(key: string, value: string): void;
  151929. /**
  151930. * Reads a boolean from the data storage
  151931. * @param key The key to read
  151932. * @param defaultValue The value if the key doesn't exist
  151933. * @returns The boolean value
  151934. */
  151935. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151936. /**
  151937. * Writes a boolean to the data storage
  151938. * @param key The key to write
  151939. * @param value The value to write
  151940. */
  151941. static WriteBoolean(key: string, value: boolean): void;
  151942. /**
  151943. * Reads a number from the data storage
  151944. * @param key The key to read
  151945. * @param defaultValue The value if the key doesn't exist
  151946. * @returns The number value
  151947. */
  151948. static ReadNumber(key: string, defaultValue: number): number;
  151949. /**
  151950. * Writes a number to the data storage
  151951. * @param key The key to write
  151952. * @param value The value to write
  151953. */
  151954. static WriteNumber(key: string, value: number): void;
  151955. }
  151956. }
  151957. declare module BABYLON {
  151958. /**
  151959. * An interface for all Hit test features
  151960. */
  151961. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151962. /**
  151963. * Triggered when new babylon (transformed) hit test results are available
  151964. */
  151965. onHitTestResultObservable: Observable<T[]>;
  151966. }
  151967. /**
  151968. * Options used for hit testing
  151969. */
  151970. export interface IWebXRLegacyHitTestOptions {
  151971. /**
  151972. * Only test when user interacted with the scene. Default - hit test every frame
  151973. */
  151974. testOnPointerDownOnly?: boolean;
  151975. /**
  151976. * The node to use to transform the local results to world coordinates
  151977. */
  151978. worldParentNode?: TransformNode;
  151979. }
  151980. /**
  151981. * Interface defining the babylon result of raycasting/hit-test
  151982. */
  151983. export interface IWebXRLegacyHitResult {
  151984. /**
  151985. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151986. */
  151987. transformationMatrix: Matrix;
  151988. /**
  151989. * The native hit test result
  151990. */
  151991. xrHitResult: XRHitResult | XRHitTestResult;
  151992. }
  151993. /**
  151994. * The currently-working hit-test module.
  151995. * Hit test (or Ray-casting) is used to interact with the real world.
  151996. * For further information read here - https://github.com/immersive-web/hit-test
  151997. */
  151998. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151999. /**
  152000. * options to use when constructing this feature
  152001. */
  152002. readonly options: IWebXRLegacyHitTestOptions;
  152003. private _direction;
  152004. private _mat;
  152005. private _onSelectEnabled;
  152006. private _origin;
  152007. /**
  152008. * The module's name
  152009. */
  152010. static readonly Name: string;
  152011. /**
  152012. * The (Babylon) version of this module.
  152013. * This is an integer representing the implementation version.
  152014. * This number does not correspond to the WebXR specs version
  152015. */
  152016. static readonly Version: number;
  152017. /**
  152018. * Populated with the last native XR Hit Results
  152019. */
  152020. lastNativeXRHitResults: XRHitResult[];
  152021. /**
  152022. * Triggered when new babylon (transformed) hit test results are available
  152023. */
  152024. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152025. /**
  152026. * Creates a new instance of the (legacy version) hit test feature
  152027. * @param _xrSessionManager an instance of WebXRSessionManager
  152028. * @param options options to use when constructing this feature
  152029. */
  152030. constructor(_xrSessionManager: WebXRSessionManager,
  152031. /**
  152032. * options to use when constructing this feature
  152033. */
  152034. options?: IWebXRLegacyHitTestOptions);
  152035. /**
  152036. * execute a hit test with an XR Ray
  152037. *
  152038. * @param xrSession a native xrSession that will execute this hit test
  152039. * @param xrRay the ray (position and direction) to use for ray-casting
  152040. * @param referenceSpace native XR reference space to use for the hit-test
  152041. * @param filter filter function that will filter the results
  152042. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152043. */
  152044. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152045. /**
  152046. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152047. * @param event the (select) event to use to select with
  152048. * @param referenceSpace the reference space to use for this hit test
  152049. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152050. */
  152051. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152052. /**
  152053. * attach this feature
  152054. * Will usually be called by the features manager
  152055. *
  152056. * @returns true if successful.
  152057. */
  152058. attach(): boolean;
  152059. /**
  152060. * detach this feature.
  152061. * Will usually be called by the features manager
  152062. *
  152063. * @returns true if successful.
  152064. */
  152065. detach(): boolean;
  152066. /**
  152067. * Dispose this feature and all of the resources attached
  152068. */
  152069. dispose(): void;
  152070. protected _onXRFrame(frame: XRFrame): void;
  152071. private _onHitTestResults;
  152072. private _onSelect;
  152073. }
  152074. }
  152075. declare module BABYLON {
  152076. /**
  152077. * Options used for hit testing (version 2)
  152078. */
  152079. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152080. /**
  152081. * Do not create a permanent hit test. Will usually be used when only
  152082. * transient inputs are needed.
  152083. */
  152084. disablePermanentHitTest?: boolean;
  152085. /**
  152086. * Enable transient (for example touch-based) hit test inspections
  152087. */
  152088. enableTransientHitTest?: boolean;
  152089. /**
  152090. * Offset ray for the permanent hit test
  152091. */
  152092. offsetRay?: Vector3;
  152093. /**
  152094. * Offset ray for the transient hit test
  152095. */
  152096. transientOffsetRay?: Vector3;
  152097. /**
  152098. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152099. */
  152100. useReferenceSpace?: boolean;
  152101. }
  152102. /**
  152103. * Interface defining the babylon result of hit-test
  152104. */
  152105. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152106. /**
  152107. * The input source that generated this hit test (if transient)
  152108. */
  152109. inputSource?: XRInputSource;
  152110. /**
  152111. * Is this a transient hit test
  152112. */
  152113. isTransient?: boolean;
  152114. /**
  152115. * Position of the hit test result
  152116. */
  152117. position: Vector3;
  152118. /**
  152119. * Rotation of the hit test result
  152120. */
  152121. rotationQuaternion: Quaternion;
  152122. /**
  152123. * The native hit test result
  152124. */
  152125. xrHitResult: XRHitTestResult;
  152126. }
  152127. /**
  152128. * The currently-working hit-test module.
  152129. * Hit test (or Ray-casting) is used to interact with the real world.
  152130. * For further information read here - https://github.com/immersive-web/hit-test
  152131. *
  152132. * Tested on chrome (mobile) 80.
  152133. */
  152134. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152135. /**
  152136. * options to use when constructing this feature
  152137. */
  152138. readonly options: IWebXRHitTestOptions;
  152139. private _tmpMat;
  152140. private _tmpPos;
  152141. private _tmpQuat;
  152142. private _transientXrHitTestSource;
  152143. private _xrHitTestSource;
  152144. private initHitTestSource;
  152145. /**
  152146. * The module's name
  152147. */
  152148. static readonly Name: string;
  152149. /**
  152150. * The (Babylon) version of this module.
  152151. * This is an integer representing the implementation version.
  152152. * This number does not correspond to the WebXR specs version
  152153. */
  152154. static readonly Version: number;
  152155. /**
  152156. * When set to true, each hit test will have its own position/rotation objects
  152157. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152158. * the developers will clone them or copy them as they see fit.
  152159. */
  152160. autoCloneTransformation: boolean;
  152161. /**
  152162. * Triggered when new babylon (transformed) hit test results are available
  152163. */
  152164. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152165. /**
  152166. * Use this to temporarily pause hit test checks.
  152167. */
  152168. paused: boolean;
  152169. /**
  152170. * Creates a new instance of the hit test feature
  152171. * @param _xrSessionManager an instance of WebXRSessionManager
  152172. * @param options options to use when constructing this feature
  152173. */
  152174. constructor(_xrSessionManager: WebXRSessionManager,
  152175. /**
  152176. * options to use when constructing this feature
  152177. */
  152178. options?: IWebXRHitTestOptions);
  152179. /**
  152180. * attach this feature
  152181. * Will usually be called by the features manager
  152182. *
  152183. * @returns true if successful.
  152184. */
  152185. attach(): boolean;
  152186. /**
  152187. * detach this feature.
  152188. * Will usually be called by the features manager
  152189. *
  152190. * @returns true if successful.
  152191. */
  152192. detach(): boolean;
  152193. /**
  152194. * Dispose this feature and all of the resources attached
  152195. */
  152196. dispose(): void;
  152197. protected _onXRFrame(frame: XRFrame): void;
  152198. private _processWebXRHitTestResult;
  152199. }
  152200. }
  152201. declare module BABYLON {
  152202. /**
  152203. * Configuration options of the anchor system
  152204. */
  152205. export interface IWebXRAnchorSystemOptions {
  152206. /**
  152207. * a node that will be used to convert local to world coordinates
  152208. */
  152209. worldParentNode?: TransformNode;
  152210. /**
  152211. * If set to true a reference of the created anchors will be kept until the next session starts
  152212. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  152213. */
  152214. doNotRemoveAnchorsOnSessionEnded?: boolean;
  152215. }
  152216. /**
  152217. * A babylon container for an XR Anchor
  152218. */
  152219. export interface IWebXRAnchor {
  152220. /**
  152221. * A babylon-assigned ID for this anchor
  152222. */
  152223. id: number;
  152224. /**
  152225. * Transformation matrix to apply to an object attached to this anchor
  152226. */
  152227. transformationMatrix: Matrix;
  152228. /**
  152229. * The native anchor object
  152230. */
  152231. xrAnchor: XRAnchor;
  152232. /**
  152233. * if defined, this object will be constantly updated by the anchor's position and rotation
  152234. */
  152235. attachedNode?: TransformNode;
  152236. }
  152237. /**
  152238. * An implementation of the anchor system for WebXR.
  152239. * For further information see https://github.com/immersive-web/anchors/
  152240. */
  152241. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  152242. private _options;
  152243. private _lastFrameDetected;
  152244. private _trackedAnchors;
  152245. private _referenceSpaceForFrameAnchors;
  152246. private _futureAnchors;
  152247. /**
  152248. * The module's name
  152249. */
  152250. static readonly Name: string;
  152251. /**
  152252. * The (Babylon) version of this module.
  152253. * This is an integer representing the implementation version.
  152254. * This number does not correspond to the WebXR specs version
  152255. */
  152256. static readonly Version: number;
  152257. /**
  152258. * Observers registered here will be executed when a new anchor was added to the session
  152259. */
  152260. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152261. /**
  152262. * Observers registered here will be executed when an anchor was removed from the session
  152263. */
  152264. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152265. /**
  152266. * Observers registered here will be executed when an existing anchor updates
  152267. * This can execute N times every frame
  152268. */
  152269. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152270. /**
  152271. * Set the reference space to use for anchor creation, when not using a hit test.
  152272. * Will default to the session's reference space if not defined
  152273. */
  152274. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152275. /**
  152276. * constructs a new anchor system
  152277. * @param _xrSessionManager an instance of WebXRSessionManager
  152278. * @param _options configuration object for this feature
  152279. */
  152280. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152281. private _tmpVector;
  152282. private _tmpQuaternion;
  152283. private _populateTmpTransformation;
  152284. /**
  152285. * Create a new anchor point using a hit test result at a specific point in the scene
  152286. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152287. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152288. *
  152289. * @param hitTestResult The hit test result to use for this anchor creation
  152290. * @param position an optional position offset for this anchor
  152291. * @param rotationQuaternion an optional rotation offset for this anchor
  152292. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152293. */
  152294. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  152295. /**
  152296. * Add a new anchor at a specific position and rotation
  152297. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  152298. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  152299. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152300. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152301. *
  152302. * @param position the position in which to add an anchor
  152303. * @param rotationQuaternion an optional rotation for the anchor transformation
  152304. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  152305. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152306. */
  152307. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  152308. /**
  152309. * detach this feature.
  152310. * Will usually be called by the features manager
  152311. *
  152312. * @returns true if successful.
  152313. */
  152314. detach(): boolean;
  152315. /**
  152316. * Dispose this feature and all of the resources attached
  152317. */
  152318. dispose(): void;
  152319. protected _onXRFrame(frame: XRFrame): void;
  152320. /**
  152321. * avoiding using Array.find for global support.
  152322. * @param xrAnchor the plane to find in the array
  152323. */
  152324. private _findIndexInAnchorArray;
  152325. private _updateAnchorWithXRFrame;
  152326. private _createAnchorAtTransformation;
  152327. }
  152328. }
  152329. declare module BABYLON {
  152330. /**
  152331. * Options used in the plane detector module
  152332. */
  152333. export interface IWebXRPlaneDetectorOptions {
  152334. /**
  152335. * The node to use to transform the local results to world coordinates
  152336. */
  152337. worldParentNode?: TransformNode;
  152338. /**
  152339. * If set to true a reference of the created planes will be kept until the next session starts
  152340. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  152341. */
  152342. doNotRemovePlanesOnSessionEnded?: boolean;
  152343. }
  152344. /**
  152345. * A babylon interface for a WebXR plane.
  152346. * A Plane is actually a polygon, built from N points in space
  152347. *
  152348. * Supported in chrome 79, not supported in canary 81 ATM
  152349. */
  152350. export interface IWebXRPlane {
  152351. /**
  152352. * a babylon-assigned ID for this polygon
  152353. */
  152354. id: number;
  152355. /**
  152356. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  152357. */
  152358. polygonDefinition: Array<Vector3>;
  152359. /**
  152360. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  152361. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  152362. */
  152363. transformationMatrix: Matrix;
  152364. /**
  152365. * the native xr-plane object
  152366. */
  152367. xrPlane: XRPlane;
  152368. }
  152369. /**
  152370. * The plane detector is used to detect planes in the real world when in AR
  152371. * For more information see https://github.com/immersive-web/real-world-geometry/
  152372. */
  152373. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  152374. private _options;
  152375. private _detectedPlanes;
  152376. private _enabled;
  152377. private _lastFrameDetected;
  152378. /**
  152379. * The module's name
  152380. */
  152381. static readonly Name: string;
  152382. /**
  152383. * The (Babylon) version of this module.
  152384. * This is an integer representing the implementation version.
  152385. * This number does not correspond to the WebXR specs version
  152386. */
  152387. static readonly Version: number;
  152388. /**
  152389. * Observers registered here will be executed when a new plane was added to the session
  152390. */
  152391. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152392. /**
  152393. * Observers registered here will be executed when a plane is no longer detected in the session
  152394. */
  152395. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  152396. /**
  152397. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  152398. * This can execute N times every frame
  152399. */
  152400. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  152401. /**
  152402. * construct a new Plane Detector
  152403. * @param _xrSessionManager an instance of xr Session manager
  152404. * @param _options configuration to use when constructing this feature
  152405. */
  152406. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  152407. /**
  152408. * detach this feature.
  152409. * Will usually be called by the features manager
  152410. *
  152411. * @returns true if successful.
  152412. */
  152413. detach(): boolean;
  152414. /**
  152415. * Dispose this feature and all of the resources attached
  152416. */
  152417. dispose(): void;
  152418. protected _onXRFrame(frame: XRFrame): void;
  152419. private _init;
  152420. private _updatePlaneWithXRPlane;
  152421. /**
  152422. * avoiding using Array.find for global support.
  152423. * @param xrPlane the plane to find in the array
  152424. */
  152425. private findIndexInPlaneArray;
  152426. }
  152427. }
  152428. declare module BABYLON {
  152429. /**
  152430. * Options interface for the background remover plugin
  152431. */
  152432. export interface IWebXRBackgroundRemoverOptions {
  152433. /**
  152434. * Further background meshes to disable when entering AR
  152435. */
  152436. backgroundMeshes?: AbstractMesh[];
  152437. /**
  152438. * flags to configure the removal of the environment helper.
  152439. * If not set, the entire background will be removed. If set, flags should be set as well.
  152440. */
  152441. environmentHelperRemovalFlags?: {
  152442. /**
  152443. * Should the skybox be removed (default false)
  152444. */
  152445. skyBox?: boolean;
  152446. /**
  152447. * Should the ground be removed (default false)
  152448. */
  152449. ground?: boolean;
  152450. };
  152451. /**
  152452. * don't disable the environment helper
  152453. */
  152454. ignoreEnvironmentHelper?: boolean;
  152455. }
  152456. /**
  152457. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  152458. */
  152459. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  152460. /**
  152461. * read-only options to be used in this module
  152462. */
  152463. readonly options: IWebXRBackgroundRemoverOptions;
  152464. /**
  152465. * The module's name
  152466. */
  152467. static readonly Name: string;
  152468. /**
  152469. * The (Babylon) version of this module.
  152470. * This is an integer representing the implementation version.
  152471. * This number does not correspond to the WebXR specs version
  152472. */
  152473. static readonly Version: number;
  152474. /**
  152475. * registered observers will be triggered when the background state changes
  152476. */
  152477. onBackgroundStateChangedObservable: Observable<boolean>;
  152478. /**
  152479. * constructs a new background remover module
  152480. * @param _xrSessionManager the session manager for this module
  152481. * @param options read-only options to be used in this module
  152482. */
  152483. constructor(_xrSessionManager: WebXRSessionManager,
  152484. /**
  152485. * read-only options to be used in this module
  152486. */
  152487. options?: IWebXRBackgroundRemoverOptions);
  152488. /**
  152489. * attach this feature
  152490. * Will usually be called by the features manager
  152491. *
  152492. * @returns true if successful.
  152493. */
  152494. attach(): boolean;
  152495. /**
  152496. * detach this feature.
  152497. * Will usually be called by the features manager
  152498. *
  152499. * @returns true if successful.
  152500. */
  152501. detach(): boolean;
  152502. /**
  152503. * Dispose this feature and all of the resources attached
  152504. */
  152505. dispose(): void;
  152506. protected _onXRFrame(_xrFrame: XRFrame): void;
  152507. private _setBackgroundState;
  152508. }
  152509. }
  152510. declare module BABYLON {
  152511. /**
  152512. * Options for the controller physics feature
  152513. */
  152514. export class IWebXRControllerPhysicsOptions {
  152515. /**
  152516. * Should the headset get its own impostor
  152517. */
  152518. enableHeadsetImpostor?: boolean;
  152519. /**
  152520. * Optional parameters for the headset impostor
  152521. */
  152522. headsetImpostorParams?: {
  152523. /**
  152524. * The type of impostor to create. Default is sphere
  152525. */
  152526. impostorType: number;
  152527. /**
  152528. * the size of the impostor. Defaults to 10cm
  152529. */
  152530. impostorSize?: number | {
  152531. width: number;
  152532. height: number;
  152533. depth: number;
  152534. };
  152535. /**
  152536. * Friction definitions
  152537. */
  152538. friction?: number;
  152539. /**
  152540. * Restitution
  152541. */
  152542. restitution?: number;
  152543. };
  152544. /**
  152545. * The physics properties of the future impostors
  152546. */
  152547. physicsProperties?: {
  152548. /**
  152549. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  152550. * Note that this requires a physics engine that supports mesh impostors!
  152551. */
  152552. useControllerMesh?: boolean;
  152553. /**
  152554. * The type of impostor to create. Default is sphere
  152555. */
  152556. impostorType?: number;
  152557. /**
  152558. * the size of the impostor. Defaults to 10cm
  152559. */
  152560. impostorSize?: number | {
  152561. width: number;
  152562. height: number;
  152563. depth: number;
  152564. };
  152565. /**
  152566. * Friction definitions
  152567. */
  152568. friction?: number;
  152569. /**
  152570. * Restitution
  152571. */
  152572. restitution?: number;
  152573. };
  152574. /**
  152575. * the xr input to use with this pointer selection
  152576. */
  152577. xrInput: WebXRInput;
  152578. }
  152579. /**
  152580. * Add physics impostor to your webxr controllers,
  152581. * including naive calculation of their linear and angular velocity
  152582. */
  152583. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  152584. private readonly _options;
  152585. private _attachController;
  152586. private _controllers;
  152587. private _debugMode;
  152588. private _delta;
  152589. private _headsetImpostor?;
  152590. private _headsetMesh?;
  152591. private _lastTimestamp;
  152592. private _tmpQuaternion;
  152593. private _tmpVector;
  152594. /**
  152595. * The module's name
  152596. */
  152597. static readonly Name: string;
  152598. /**
  152599. * The (Babylon) version of this module.
  152600. * This is an integer representing the implementation version.
  152601. * This number does not correspond to the webxr specs version
  152602. */
  152603. static readonly Version: number;
  152604. /**
  152605. * Construct a new Controller Physics Feature
  152606. * @param _xrSessionManager the corresponding xr session manager
  152607. * @param _options options to create this feature with
  152608. */
  152609. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  152610. /**
  152611. * @hidden
  152612. * enable debugging - will show console outputs and the impostor mesh
  152613. */
  152614. _enablePhysicsDebug(): void;
  152615. /**
  152616. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  152617. * @param xrController the controller to add
  152618. */
  152619. addController(xrController: WebXRInputSource): void;
  152620. /**
  152621. * attach this feature
  152622. * Will usually be called by the features manager
  152623. *
  152624. * @returns true if successful.
  152625. */
  152626. attach(): boolean;
  152627. /**
  152628. * detach this feature.
  152629. * Will usually be called by the features manager
  152630. *
  152631. * @returns true if successful.
  152632. */
  152633. detach(): boolean;
  152634. /**
  152635. * Get the headset impostor, if enabled
  152636. * @returns the impostor
  152637. */
  152638. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152639. /**
  152640. * Get the physics impostor of a specific controller.
  152641. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152642. * @param controller the controller or the controller id of which to get the impostor
  152643. * @returns the impostor or null
  152644. */
  152645. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152646. /**
  152647. * Update the physics properties provided in the constructor
  152648. * @param newProperties the new properties object
  152649. */
  152650. setPhysicsProperties(newProperties: {
  152651. impostorType?: number;
  152652. impostorSize?: number | {
  152653. width: number;
  152654. height: number;
  152655. depth: number;
  152656. };
  152657. friction?: number;
  152658. restitution?: number;
  152659. }): void;
  152660. protected _onXRFrame(_xrFrame: any): void;
  152661. private _detachController;
  152662. }
  152663. }
  152664. declare module BABYLON {
  152665. /**
  152666. * The motion controller class for all microsoft mixed reality controllers
  152667. */
  152668. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152669. protected readonly _mapping: {
  152670. defaultButton: {
  152671. valueNodeName: string;
  152672. unpressedNodeName: string;
  152673. pressedNodeName: string;
  152674. };
  152675. defaultAxis: {
  152676. valueNodeName: string;
  152677. minNodeName: string;
  152678. maxNodeName: string;
  152679. };
  152680. buttons: {
  152681. "xr-standard-trigger": {
  152682. rootNodeName: string;
  152683. componentProperty: string;
  152684. states: string[];
  152685. };
  152686. "xr-standard-squeeze": {
  152687. rootNodeName: string;
  152688. componentProperty: string;
  152689. states: string[];
  152690. };
  152691. "xr-standard-touchpad": {
  152692. rootNodeName: string;
  152693. labelAnchorNodeName: string;
  152694. touchPointNodeName: string;
  152695. };
  152696. "xr-standard-thumbstick": {
  152697. rootNodeName: string;
  152698. componentProperty: string;
  152699. states: string[];
  152700. };
  152701. };
  152702. axes: {
  152703. "xr-standard-touchpad": {
  152704. "x-axis": {
  152705. rootNodeName: string;
  152706. };
  152707. "y-axis": {
  152708. rootNodeName: string;
  152709. };
  152710. };
  152711. "xr-standard-thumbstick": {
  152712. "x-axis": {
  152713. rootNodeName: string;
  152714. };
  152715. "y-axis": {
  152716. rootNodeName: string;
  152717. };
  152718. };
  152719. };
  152720. };
  152721. /**
  152722. * The base url used to load the left and right controller models
  152723. */
  152724. static MODEL_BASE_URL: string;
  152725. /**
  152726. * The name of the left controller model file
  152727. */
  152728. static MODEL_LEFT_FILENAME: string;
  152729. /**
  152730. * The name of the right controller model file
  152731. */
  152732. static MODEL_RIGHT_FILENAME: string;
  152733. profileId: string;
  152734. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152735. protected _getFilenameAndPath(): {
  152736. filename: string;
  152737. path: string;
  152738. };
  152739. protected _getModelLoadingConstraints(): boolean;
  152740. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152741. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152742. protected _updateModel(): void;
  152743. }
  152744. }
  152745. declare module BABYLON {
  152746. /**
  152747. * The motion controller class for oculus touch (quest, rift).
  152748. * This class supports legacy mapping as well the standard xr mapping
  152749. */
  152750. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152751. private _forceLegacyControllers;
  152752. private _modelRootNode;
  152753. /**
  152754. * The base url used to load the left and right controller models
  152755. */
  152756. static MODEL_BASE_URL: string;
  152757. /**
  152758. * The name of the left controller model file
  152759. */
  152760. static MODEL_LEFT_FILENAME: string;
  152761. /**
  152762. * The name of the right controller model file
  152763. */
  152764. static MODEL_RIGHT_FILENAME: string;
  152765. /**
  152766. * Base Url for the Quest controller model.
  152767. */
  152768. static QUEST_MODEL_BASE_URL: string;
  152769. profileId: string;
  152770. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152771. protected _getFilenameAndPath(): {
  152772. filename: string;
  152773. path: string;
  152774. };
  152775. protected _getModelLoadingConstraints(): boolean;
  152776. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152777. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152778. protected _updateModel(): void;
  152779. /**
  152780. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152781. * between the touch and touch 2.
  152782. */
  152783. private _isQuest;
  152784. }
  152785. }
  152786. declare module BABYLON {
  152787. /**
  152788. * The motion controller class for the standard HTC-Vive controllers
  152789. */
  152790. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152791. private _modelRootNode;
  152792. /**
  152793. * The base url used to load the left and right controller models
  152794. */
  152795. static MODEL_BASE_URL: string;
  152796. /**
  152797. * File name for the controller model.
  152798. */
  152799. static MODEL_FILENAME: string;
  152800. profileId: string;
  152801. /**
  152802. * Create a new Vive motion controller object
  152803. * @param scene the scene to use to create this controller
  152804. * @param gamepadObject the corresponding gamepad object
  152805. * @param handedness the handedness of the controller
  152806. */
  152807. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152808. protected _getFilenameAndPath(): {
  152809. filename: string;
  152810. path: string;
  152811. };
  152812. protected _getModelLoadingConstraints(): boolean;
  152813. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152814. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152815. protected _updateModel(): void;
  152816. }
  152817. }
  152818. declare module BABYLON {
  152819. /**
  152820. * A cursor which tracks a point on a path
  152821. */
  152822. export class PathCursor {
  152823. private path;
  152824. /**
  152825. * Stores path cursor callbacks for when an onchange event is triggered
  152826. */
  152827. private _onchange;
  152828. /**
  152829. * The value of the path cursor
  152830. */
  152831. value: number;
  152832. /**
  152833. * The animation array of the path cursor
  152834. */
  152835. animations: Animation[];
  152836. /**
  152837. * Initializes the path cursor
  152838. * @param path The path to track
  152839. */
  152840. constructor(path: Path2);
  152841. /**
  152842. * Gets the cursor point on the path
  152843. * @returns A point on the path cursor at the cursor location
  152844. */
  152845. getPoint(): Vector3;
  152846. /**
  152847. * Moves the cursor ahead by the step amount
  152848. * @param step The amount to move the cursor forward
  152849. * @returns This path cursor
  152850. */
  152851. moveAhead(step?: number): PathCursor;
  152852. /**
  152853. * Moves the cursor behind by the step amount
  152854. * @param step The amount to move the cursor back
  152855. * @returns This path cursor
  152856. */
  152857. moveBack(step?: number): PathCursor;
  152858. /**
  152859. * Moves the cursor by the step amount
  152860. * If the step amount is greater than one, an exception is thrown
  152861. * @param step The amount to move the cursor
  152862. * @returns This path cursor
  152863. */
  152864. move(step: number): PathCursor;
  152865. /**
  152866. * Ensures that the value is limited between zero and one
  152867. * @returns This path cursor
  152868. */
  152869. private ensureLimits;
  152870. /**
  152871. * Runs onchange callbacks on change (used by the animation engine)
  152872. * @returns This path cursor
  152873. */
  152874. private raiseOnChange;
  152875. /**
  152876. * Executes a function on change
  152877. * @param f A path cursor onchange callback
  152878. * @returns This path cursor
  152879. */
  152880. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152881. }
  152882. }
  152883. declare module BABYLON {
  152884. /** @hidden */
  152885. export var blurPixelShader: {
  152886. name: string;
  152887. shader: string;
  152888. };
  152889. }
  152890. declare module BABYLON {
  152891. /** @hidden */
  152892. export var pointCloudVertexDeclaration: {
  152893. name: string;
  152894. shader: string;
  152895. };
  152896. }
  152897. // Mixins
  152898. interface Window {
  152899. mozIndexedDB: IDBFactory;
  152900. webkitIndexedDB: IDBFactory;
  152901. msIndexedDB: IDBFactory;
  152902. webkitURL: typeof URL;
  152903. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152904. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152905. WebGLRenderingContext: WebGLRenderingContext;
  152906. MSGesture: MSGesture;
  152907. CANNON: any;
  152908. AudioContext: AudioContext;
  152909. webkitAudioContext: AudioContext;
  152910. PointerEvent: any;
  152911. Math: Math;
  152912. Uint8Array: Uint8ArrayConstructor;
  152913. Float32Array: Float32ArrayConstructor;
  152914. mozURL: typeof URL;
  152915. msURL: typeof URL;
  152916. VRFrameData: any; // WebVR, from specs 1.1
  152917. DracoDecoderModule: any;
  152918. setImmediate(handler: (...args: any[]) => void): number;
  152919. }
  152920. interface HTMLCanvasElement {
  152921. requestPointerLock(): void;
  152922. msRequestPointerLock?(): void;
  152923. mozRequestPointerLock?(): void;
  152924. webkitRequestPointerLock?(): void;
  152925. /** Track wether a record is in progress */
  152926. isRecording: boolean;
  152927. /** Capture Stream method defined by some browsers */
  152928. captureStream(fps?: number): MediaStream;
  152929. }
  152930. interface CanvasRenderingContext2D {
  152931. msImageSmoothingEnabled: boolean;
  152932. }
  152933. interface MouseEvent {
  152934. mozMovementX: number;
  152935. mozMovementY: number;
  152936. webkitMovementX: number;
  152937. webkitMovementY: number;
  152938. msMovementX: number;
  152939. msMovementY: number;
  152940. }
  152941. interface Navigator {
  152942. mozGetVRDevices: (any: any) => any;
  152943. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152944. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152945. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152946. webkitGetGamepads(): Gamepad[];
  152947. msGetGamepads(): Gamepad[];
  152948. webkitGamepads(): Gamepad[];
  152949. }
  152950. interface HTMLVideoElement {
  152951. mozSrcObject: any;
  152952. }
  152953. interface Math {
  152954. fround(x: number): number;
  152955. imul(a: number, b: number): number;
  152956. }
  152957. interface WebGLRenderingContext {
  152958. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152959. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152960. vertexAttribDivisor(index: number, divisor: number): void;
  152961. createVertexArray(): any;
  152962. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152963. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152964. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152965. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152966. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152967. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152968. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152969. // Queries
  152970. createQuery(): WebGLQuery;
  152971. deleteQuery(query: WebGLQuery): void;
  152972. beginQuery(target: number, query: WebGLQuery): void;
  152973. endQuery(target: number): void;
  152974. getQueryParameter(query: WebGLQuery, pname: number): any;
  152975. getQuery(target: number, pname: number): any;
  152976. MAX_SAMPLES: number;
  152977. RGBA8: number;
  152978. READ_FRAMEBUFFER: number;
  152979. DRAW_FRAMEBUFFER: number;
  152980. UNIFORM_BUFFER: number;
  152981. HALF_FLOAT_OES: number;
  152982. RGBA16F: number;
  152983. RGBA32F: number;
  152984. R32F: number;
  152985. RG32F: number;
  152986. RGB32F: number;
  152987. R16F: number;
  152988. RG16F: number;
  152989. RGB16F: number;
  152990. RED: number;
  152991. RG: number;
  152992. R8: number;
  152993. RG8: number;
  152994. UNSIGNED_INT_24_8: number;
  152995. DEPTH24_STENCIL8: number;
  152996. MIN: number;
  152997. MAX: number;
  152998. /* Multiple Render Targets */
  152999. drawBuffers(buffers: number[]): void;
  153000. readBuffer(src: number): void;
  153001. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153002. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153003. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153004. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153005. // Occlusion Query
  153006. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153007. ANY_SAMPLES_PASSED: number;
  153008. QUERY_RESULT_AVAILABLE: number;
  153009. QUERY_RESULT: number;
  153010. }
  153011. interface WebGLProgram {
  153012. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153013. }
  153014. interface EXT_disjoint_timer_query {
  153015. QUERY_COUNTER_BITS_EXT: number;
  153016. TIME_ELAPSED_EXT: number;
  153017. TIMESTAMP_EXT: number;
  153018. GPU_DISJOINT_EXT: number;
  153019. QUERY_RESULT_EXT: number;
  153020. QUERY_RESULT_AVAILABLE_EXT: number;
  153021. queryCounterEXT(query: WebGLQuery, target: number): void;
  153022. createQueryEXT(): WebGLQuery;
  153023. beginQueryEXT(target: number, query: WebGLQuery): void;
  153024. endQueryEXT(target: number): void;
  153025. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153026. deleteQueryEXT(query: WebGLQuery): void;
  153027. }
  153028. interface WebGLUniformLocation {
  153029. _currentState: any;
  153030. }
  153031. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153032. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153033. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153034. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153035. interface WebGLRenderingContext {
  153036. readonly RASTERIZER_DISCARD: number;
  153037. readonly DEPTH_COMPONENT24: number;
  153038. readonly TEXTURE_3D: number;
  153039. readonly TEXTURE_2D_ARRAY: number;
  153040. readonly TEXTURE_COMPARE_FUNC: number;
  153041. readonly TEXTURE_COMPARE_MODE: number;
  153042. readonly COMPARE_REF_TO_TEXTURE: number;
  153043. readonly TEXTURE_WRAP_R: number;
  153044. readonly HALF_FLOAT: number;
  153045. readonly RGB8: number;
  153046. readonly RED_INTEGER: number;
  153047. readonly RG_INTEGER: number;
  153048. readonly RGB_INTEGER: number;
  153049. readonly RGBA_INTEGER: number;
  153050. readonly R8_SNORM: number;
  153051. readonly RG8_SNORM: number;
  153052. readonly RGB8_SNORM: number;
  153053. readonly RGBA8_SNORM: number;
  153054. readonly R8I: number;
  153055. readonly RG8I: number;
  153056. readonly RGB8I: number;
  153057. readonly RGBA8I: number;
  153058. readonly R8UI: number;
  153059. readonly RG8UI: number;
  153060. readonly RGB8UI: number;
  153061. readonly RGBA8UI: number;
  153062. readonly R16I: number;
  153063. readonly RG16I: number;
  153064. readonly RGB16I: number;
  153065. readonly RGBA16I: number;
  153066. readonly R16UI: number;
  153067. readonly RG16UI: number;
  153068. readonly RGB16UI: number;
  153069. readonly RGBA16UI: number;
  153070. readonly R32I: number;
  153071. readonly RG32I: number;
  153072. readonly RGB32I: number;
  153073. readonly RGBA32I: number;
  153074. readonly R32UI: number;
  153075. readonly RG32UI: number;
  153076. readonly RGB32UI: number;
  153077. readonly RGBA32UI: number;
  153078. readonly RGB10_A2UI: number;
  153079. readonly R11F_G11F_B10F: number;
  153080. readonly RGB9_E5: number;
  153081. readonly RGB10_A2: number;
  153082. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153083. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153084. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153085. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153086. readonly DEPTH_COMPONENT32F: number;
  153087. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153088. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153089. 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;
  153090. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153091. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153092. readonly TRANSFORM_FEEDBACK: number;
  153093. readonly INTERLEAVED_ATTRIBS: number;
  153094. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153095. createTransformFeedback(): WebGLTransformFeedback;
  153096. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153097. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153098. beginTransformFeedback(primitiveMode: number): void;
  153099. endTransformFeedback(): void;
  153100. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153101. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153102. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153103. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153104. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153105. }
  153106. interface ImageBitmap {
  153107. readonly width: number;
  153108. readonly height: number;
  153109. close(): void;
  153110. }
  153111. interface WebGLQuery extends WebGLObject {
  153112. }
  153113. declare var WebGLQuery: {
  153114. prototype: WebGLQuery;
  153115. new(): WebGLQuery;
  153116. };
  153117. interface WebGLSampler extends WebGLObject {
  153118. }
  153119. declare var WebGLSampler: {
  153120. prototype: WebGLSampler;
  153121. new(): WebGLSampler;
  153122. };
  153123. interface WebGLSync extends WebGLObject {
  153124. }
  153125. declare var WebGLSync: {
  153126. prototype: WebGLSync;
  153127. new(): WebGLSync;
  153128. };
  153129. interface WebGLTransformFeedback extends WebGLObject {
  153130. }
  153131. declare var WebGLTransformFeedback: {
  153132. prototype: WebGLTransformFeedback;
  153133. new(): WebGLTransformFeedback;
  153134. };
  153135. interface WebGLVertexArrayObject extends WebGLObject {
  153136. }
  153137. declare var WebGLVertexArrayObject: {
  153138. prototype: WebGLVertexArrayObject;
  153139. new(): WebGLVertexArrayObject;
  153140. };
  153141. // Type definitions for WebVR API
  153142. // Project: https://w3c.github.io/webvr/
  153143. // Definitions by: six a <https://github.com/lostfictions>
  153144. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153145. interface VRDisplay extends EventTarget {
  153146. /**
  153147. * Dictionary of capabilities describing the VRDisplay.
  153148. */
  153149. readonly capabilities: VRDisplayCapabilities;
  153150. /**
  153151. * z-depth defining the far plane of the eye view frustum
  153152. * enables mapping of values in the render target depth
  153153. * attachment to scene coordinates. Initially set to 10000.0.
  153154. */
  153155. depthFar: number;
  153156. /**
  153157. * z-depth defining the near plane of the eye view frustum
  153158. * enables mapping of values in the render target depth
  153159. * attachment to scene coordinates. Initially set to 0.01.
  153160. */
  153161. depthNear: number;
  153162. /**
  153163. * An identifier for this distinct VRDisplay. Used as an
  153164. * association point in the Gamepad API.
  153165. */
  153166. readonly displayId: number;
  153167. /**
  153168. * A display name, a user-readable name identifying it.
  153169. */
  153170. readonly displayName: string;
  153171. readonly isConnected: boolean;
  153172. readonly isPresenting: boolean;
  153173. /**
  153174. * If this VRDisplay supports room-scale experiences, the optional
  153175. * stage attribute contains details on the room-scale parameters.
  153176. */
  153177. readonly stageParameters: VRStageParameters | null;
  153178. /**
  153179. * Passing the value returned by `requestAnimationFrame` to
  153180. * `cancelAnimationFrame` will unregister the callback.
  153181. * @param handle Define the hanle of the request to cancel
  153182. */
  153183. cancelAnimationFrame(handle: number): void;
  153184. /**
  153185. * Stops presenting to the VRDisplay.
  153186. * @returns a promise to know when it stopped
  153187. */
  153188. exitPresent(): Promise<void>;
  153189. /**
  153190. * Return the current VREyeParameters for the given eye.
  153191. * @param whichEye Define the eye we want the parameter for
  153192. * @returns the eye parameters
  153193. */
  153194. getEyeParameters(whichEye: string): VREyeParameters;
  153195. /**
  153196. * Populates the passed VRFrameData with the information required to render
  153197. * the current frame.
  153198. * @param frameData Define the data structure to populate
  153199. * @returns true if ok otherwise false
  153200. */
  153201. getFrameData(frameData: VRFrameData): boolean;
  153202. /**
  153203. * Get the layers currently being presented.
  153204. * @returns the list of VR layers
  153205. */
  153206. getLayers(): VRLayer[];
  153207. /**
  153208. * Return a VRPose containing the future predicted pose of the VRDisplay
  153209. * when the current frame will be presented. The value returned will not
  153210. * change until JavaScript has returned control to the browser.
  153211. *
  153212. * The VRPose will contain the position, orientation, velocity,
  153213. * and acceleration of each of these properties.
  153214. * @returns the pose object
  153215. */
  153216. getPose(): VRPose;
  153217. /**
  153218. * Return the current instantaneous pose of the VRDisplay, with no
  153219. * prediction applied.
  153220. * @returns the current instantaneous pose
  153221. */
  153222. getImmediatePose(): VRPose;
  153223. /**
  153224. * The callback passed to `requestAnimationFrame` will be called
  153225. * any time a new frame should be rendered. When the VRDisplay is
  153226. * presenting the callback will be called at the native refresh
  153227. * rate of the HMD. When not presenting this function acts
  153228. * identically to how window.requestAnimationFrame acts. Content should
  153229. * make no assumptions of frame rate or vsync behavior as the HMD runs
  153230. * asynchronously from other displays and at differing refresh rates.
  153231. * @param callback Define the eaction to run next frame
  153232. * @returns the request handle it
  153233. */
  153234. requestAnimationFrame(callback: FrameRequestCallback): number;
  153235. /**
  153236. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  153237. * Repeat calls while already presenting will update the VRLayers being displayed.
  153238. * @param layers Define the list of layer to present
  153239. * @returns a promise to know when the request has been fulfilled
  153240. */
  153241. requestPresent(layers: VRLayer[]): Promise<void>;
  153242. /**
  153243. * Reset the pose for this display, treating its current position and
  153244. * orientation as the "origin/zero" values. VRPose.position,
  153245. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153246. * updated when calling resetPose(). This should be called in only
  153247. * sitting-space experiences.
  153248. */
  153249. resetPose(): void;
  153250. /**
  153251. * The VRLayer provided to the VRDisplay will be captured and presented
  153252. * in the HMD. Calling this function has the same effect on the source
  153253. * canvas as any other operation that uses its source image, and canvases
  153254. * created without preserveDrawingBuffer set to true will be cleared.
  153255. * @param pose Define the pose to submit
  153256. */
  153257. submitFrame(pose?: VRPose): void;
  153258. }
  153259. declare var VRDisplay: {
  153260. prototype: VRDisplay;
  153261. new(): VRDisplay;
  153262. };
  153263. interface VRLayer {
  153264. leftBounds?: number[] | Float32Array | null;
  153265. rightBounds?: number[] | Float32Array | null;
  153266. source?: HTMLCanvasElement | null;
  153267. }
  153268. interface VRDisplayCapabilities {
  153269. readonly canPresent: boolean;
  153270. readonly hasExternalDisplay: boolean;
  153271. readonly hasOrientation: boolean;
  153272. readonly hasPosition: boolean;
  153273. readonly maxLayers: number;
  153274. }
  153275. interface VREyeParameters {
  153276. /** @deprecated */
  153277. readonly fieldOfView: VRFieldOfView;
  153278. readonly offset: Float32Array;
  153279. readonly renderHeight: number;
  153280. readonly renderWidth: number;
  153281. }
  153282. interface VRFieldOfView {
  153283. readonly downDegrees: number;
  153284. readonly leftDegrees: number;
  153285. readonly rightDegrees: number;
  153286. readonly upDegrees: number;
  153287. }
  153288. interface VRFrameData {
  153289. readonly leftProjectionMatrix: Float32Array;
  153290. readonly leftViewMatrix: Float32Array;
  153291. readonly pose: VRPose;
  153292. readonly rightProjectionMatrix: Float32Array;
  153293. readonly rightViewMatrix: Float32Array;
  153294. readonly timestamp: number;
  153295. }
  153296. interface VRPose {
  153297. readonly angularAcceleration: Float32Array | null;
  153298. readonly angularVelocity: Float32Array | null;
  153299. readonly linearAcceleration: Float32Array | null;
  153300. readonly linearVelocity: Float32Array | null;
  153301. readonly orientation: Float32Array | null;
  153302. readonly position: Float32Array | null;
  153303. readonly timestamp: number;
  153304. }
  153305. interface VRStageParameters {
  153306. sittingToStandingTransform?: Float32Array;
  153307. sizeX?: number;
  153308. sizeY?: number;
  153309. }
  153310. interface Navigator {
  153311. getVRDisplays(): Promise<VRDisplay[]>;
  153312. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  153313. }
  153314. interface Window {
  153315. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  153316. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  153317. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  153318. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153319. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153320. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  153321. }
  153322. interface Gamepad {
  153323. readonly displayId: number;
  153324. }
  153325. type XRSessionMode =
  153326. | "inline"
  153327. | "immersive-vr"
  153328. | "immersive-ar";
  153329. type XRReferenceSpaceType =
  153330. | "viewer"
  153331. | "local"
  153332. | "local-floor"
  153333. | "bounded-floor"
  153334. | "unbounded";
  153335. type XREnvironmentBlendMode =
  153336. | "opaque"
  153337. | "additive"
  153338. | "alpha-blend";
  153339. type XRVisibilityState =
  153340. | "visible"
  153341. | "visible-blurred"
  153342. | "hidden";
  153343. type XRHandedness =
  153344. | "none"
  153345. | "left"
  153346. | "right";
  153347. type XRTargetRayMode =
  153348. | "gaze"
  153349. | "tracked-pointer"
  153350. | "screen";
  153351. type XREye =
  153352. | "none"
  153353. | "left"
  153354. | "right";
  153355. type XREventType =
  153356. | "devicechange"
  153357. | "visibilitychange"
  153358. | "end"
  153359. | "inputsourceschange"
  153360. | "select"
  153361. | "selectstart"
  153362. | "selectend"
  153363. | "squeeze"
  153364. | "squeezestart"
  153365. | "squeezeend"
  153366. | "reset";
  153367. interface XRSpace extends EventTarget {
  153368. }
  153369. interface XRRenderState {
  153370. depthNear?: number;
  153371. depthFar?: number;
  153372. inlineVerticalFieldOfView?: number;
  153373. baseLayer?: XRWebGLLayer;
  153374. }
  153375. interface XRInputSource {
  153376. handedness: XRHandedness;
  153377. targetRayMode: XRTargetRayMode;
  153378. targetRaySpace: XRSpace;
  153379. gripSpace: XRSpace | undefined;
  153380. gamepad: Gamepad | undefined;
  153381. profiles: Array<string>;
  153382. }
  153383. interface XRSessionInit {
  153384. optionalFeatures?: string[];
  153385. requiredFeatures?: string[];
  153386. }
  153387. interface XRSession {
  153388. addEventListener: Function;
  153389. removeEventListener: Function;
  153390. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153391. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153392. requestAnimationFrame: Function;
  153393. end(): Promise<void>;
  153394. renderState: XRRenderState;
  153395. inputSources: Array<XRInputSource>;
  153396. // hit test
  153397. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  153398. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  153399. // legacy AR hit test
  153400. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153401. // legacy plane detection
  153402. updateWorldTrackingState(options: {
  153403. planeDetectionState?: { enabled: boolean; }
  153404. }): void;
  153405. }
  153406. interface XRReferenceSpace extends XRSpace {
  153407. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  153408. onreset: any;
  153409. }
  153410. type XRPlaneSet = Set<XRPlane>;
  153411. type XRAnchorSet = Set<XRAnchor>;
  153412. interface XRFrame {
  153413. session: XRSession;
  153414. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  153415. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  153416. // AR
  153417. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  153418. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  153419. // Anchors
  153420. trackedAnchors?: XRAnchorSet;
  153421. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  153422. // Planes
  153423. worldInformation: {
  153424. detectedPlanes?: XRPlaneSet;
  153425. };
  153426. }
  153427. interface XRViewerPose extends XRPose {
  153428. views: Array<XRView>;
  153429. }
  153430. interface XRPose {
  153431. transform: XRRigidTransform;
  153432. emulatedPosition: boolean;
  153433. }
  153434. interface XRWebGLLayerOptions {
  153435. antialias?: boolean;
  153436. depth?: boolean;
  153437. stencil?: boolean;
  153438. alpha?: boolean;
  153439. multiview?: boolean;
  153440. framebufferScaleFactor?: number;
  153441. }
  153442. declare var XRWebGLLayer: {
  153443. prototype: XRWebGLLayer;
  153444. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  153445. };
  153446. interface XRWebGLLayer {
  153447. framebuffer: WebGLFramebuffer;
  153448. framebufferWidth: number;
  153449. framebufferHeight: number;
  153450. getViewport: Function;
  153451. }
  153452. declare class XRRigidTransform {
  153453. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  153454. position: DOMPointReadOnly;
  153455. orientation: DOMPointReadOnly;
  153456. matrix: Float32Array;
  153457. inverse: XRRigidTransform;
  153458. }
  153459. interface XRView {
  153460. eye: XREye;
  153461. projectionMatrix: Float32Array;
  153462. transform: XRRigidTransform;
  153463. }
  153464. interface XRInputSourceChangeEvent {
  153465. session: XRSession;
  153466. removed: Array<XRInputSource>;
  153467. added: Array<XRInputSource>;
  153468. }
  153469. interface XRInputSourceEvent extends Event {
  153470. readonly frame: XRFrame;
  153471. readonly inputSource: XRInputSource;
  153472. }
  153473. // Experimental(er) features
  153474. declare class XRRay {
  153475. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  153476. origin: DOMPointReadOnly;
  153477. direction: DOMPointReadOnly;
  153478. matrix: Float32Array;
  153479. }
  153480. declare enum XRHitTestTrackableType {
  153481. "point",
  153482. "plane"
  153483. }
  153484. interface XRHitResult {
  153485. hitMatrix: Float32Array;
  153486. }
  153487. interface XRTransientInputHitTestResult {
  153488. readonly inputSource: XRInputSource;
  153489. readonly results: Array<XRHitTestResult>;
  153490. }
  153491. interface XRHitTestResult {
  153492. getPose(baseSpace: XRSpace): XRPose | undefined;
  153493. // When anchor system is enabled
  153494. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  153495. }
  153496. interface XRHitTestSource {
  153497. cancel(): void;
  153498. }
  153499. interface XRTransientInputHitTestSource {
  153500. cancel(): void;
  153501. }
  153502. interface XRHitTestOptionsInit {
  153503. space: XRSpace;
  153504. entityTypes?: Array<XRHitTestTrackableType>;
  153505. offsetRay?: XRRay;
  153506. }
  153507. interface XRTransientInputHitTestOptionsInit {
  153508. profile: string;
  153509. entityTypes?: Array<XRHitTestTrackableType>;
  153510. offsetRay?: XRRay;
  153511. }
  153512. interface XRAnchor {
  153513. anchorSpace: XRSpace;
  153514. delete(): void;
  153515. }
  153516. interface XRPlane {
  153517. orientation: "Horizontal" | "Vertical";
  153518. planeSpace: XRSpace;
  153519. polygon: Array<DOMPointReadOnly>;
  153520. lastChangedTime: number;
  153521. }